Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jface.text/src/org')
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractHoverInformationControlManager.java485
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractInformationControlManager.java788
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/CursorLinePainter.java245
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultAutoIndentStrategy.java91
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultInformationControl.java378
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultTextDoubleClickStrategy.java218
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultUndoManager.java810
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/DocumentAdapter.java361
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/DocumentCommand.java450
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/IAutoEditStrategy.java33
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/IAutoIndentStrategy.java20
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/IDocumentAdapter.java37
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/IDocumentAdapterExtension.java39
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/IEventConsumer.java41
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/IFindReplaceTarget.java72
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/IFindReplaceTargetExtension.java89
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/IFindReplaceTargetExtension3.java53
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControl.java142
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControlCreator.java33
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControlCreatorExtension.java39
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControlExtension.java29
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControlExtension2.java31
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/IMarkRegionTarget.java32
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/IMarkSelection.java48
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/IPaintPositionManager.java40
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/IPainter.java94
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/IRewriteTarget.java55
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/ITextDoubleClickStrategy.java33
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/ITextHover.java52
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/ITextHoverExtension.java29
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/ITextInputListener.java40
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/ITextListener.java39
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/ITextOperationTarget.java101
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/ITextOperationTargetExtension.java32
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/ITextSelection.java84
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewer.java432
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension.java103
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension2.java108
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension3.java95
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension4.java30
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/IUndoManager.java94
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/IViewportListener.java30
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/IWidgetTokenKeeper.java34
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/IWidgetTokenKeeperExtension.java46
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/IWidgetTokenOwner.java45
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/IWidgetTokenOwnerExtension.java37
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/JFaceTextMessages.java32
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/JFaceTextMessages.properties37
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/MarginPainter.java171
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/MarkSelection.java69
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/PaintManager.java360
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/PropagatingFontFieldEditor.java132
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/TextAttribute.java121
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/TextEvent.java119
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/TextPresentation.java417
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/TextSelection.java188
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java4668
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewerHoverManager.java358
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AdditionalInfoController.java241
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposal.java135
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java815
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistSubjectAdapter.java406
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java1614
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformation.java96
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.java674
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationValidator.java80
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/Helper.java32
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposal.java87
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposalExtension.java67
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposalExtension2.java74
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposalExtension3.java34
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistListener.java35
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistProcessor.java86
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistProcessorExtension.java52
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistSubject.java297
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistant.java91
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistantExtension.java38
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformation.java63
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformationExtension.java29
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformationPresenter.java47
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformationPresenterExtension.java34
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformationValidator.java44
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformationValidatorExtension.java34
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/JFaceTextMessages.java32
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/PopupCloser.java100
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/package.html25
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContentFormatter.java809
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContentFormatter2.java1095
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContextBasedFormattingStrategy.java113
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/FormattingContext.java165
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/FormattingContextProperties.java78
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IContentFormatter.java55
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IContentFormatterExtension.java27
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IContentFormatterExtension2.java86
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IFormattingContext.java157
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IFormattingStrategy.java55
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IFormattingStrategyExtension.java61
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/package.html21
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/information/IInformationPresenter.java66
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/information/IInformationPresenterExtension.java27
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/information/IInformationProvider.java54
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/information/IInformationProviderExtension.java42
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/information/IInformationProviderExtension2.java31
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/information/InformationPresenter.java492
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/information/package.html22
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/package.html82
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/IPresentationDamager.java60
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/IPresentationReconciler.java76
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/IPresentationReconcilerExtension.java27
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/IPresentationRepairer.java56
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/PresentationReconciler.java557
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/package.html24
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/AbstractReconcileStep.java169
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/AbstractReconciler.java497
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/DirtyRegion.java97
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/DirtyRegionQueue.java104
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/DocumentAdapter.java42
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcilableModel.java21
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcileResult.java22
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcileStep.java100
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconciler.java62
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcilerExtension.java27
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcilingStrategy.java60
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcilingStrategyExtension.java45
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/MonoReconciler.java107
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/Reconciler.java219
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/package.html25
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/BufferedRuleBasedScanner.java133
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/DefaultDamagerRepairer.java213
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/DefaultPartitioner.java543
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/EndOfLineRule.java45
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/ICharacterScanner.java51
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IPartitionTokenScanner.java42
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IPredicateRule.java47
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IRule.java33
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IToken.java53
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/ITokenScanner.java58
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IWhitespaceDetector.java27
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IWordDetector.java38
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/MultiLineRule.java63
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/NumberRule.java72
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/PatternRule.java239
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedDamagerRepairer.java49
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedPartitionScanner.java106
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedPartitioner.java551
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedScanner.java196
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/SingleLineRule.java65
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/Token.java125
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/WhitespaceRule.java58
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/WordPatternRule.java108
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/WordRule.java145
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/package.html21
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/Annotation.java130
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationBarHoverManager.java266
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationColumn.java30
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationModel.java475
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationModelEvent.java44
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationPainter.java647
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationRulerColumn.java602
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/ChangeRulerColumn.java676
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/CompositeRuler.java774
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationAccess.java47
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationAccessExtension.java30
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationHover.java33
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationHoverExtension.java61
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModel.java124
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModelExtension.java48
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModelListener.java31
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModelListenerExtension.java30
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/IChangeRulerColumn.java63
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/ICharacterPairMatcher.java70
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/ILineDiffInfo.java70
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/ILineDiffer.java70
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/IOverviewRuler.java116
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/ISharedTextColors.java39
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/ISourceViewer.java162
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/ISourceViewerExtension.java37
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/ITagHandler.java92
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/ITagHandlerFactory.java49
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/ITranslator.java76
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/ITranslatorResultCollector.java21
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRuler.java75
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRulerColumn.java74
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRulerExtension.java41
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRulerInfo.java63
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRulerInfoExtension.java31
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/JFaceTextMessages.java66
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineChangeHover.java319
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberChangeRulerColumn.java414
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberRulerColumn.java826
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/MatchingCharacterPainter.java240
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRuler.java1086
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRulerHoverManager.java77
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java789
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewerConfiguration.java304
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/TagHandlerFactory.java64
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/VerticalRuler.java542
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/VisualAnnotationModel.java189
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/package.html26
199 files changed, 0 insertions, 37406 deletions
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractHoverInformationControlManager.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractHoverInformationControlManager.java
deleted file mode 100644
index bf000bd5e2c..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractHoverInformationControlManager.java
+++ /dev/null
@@ -1,485 +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 org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.ControlListener;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.MouseMoveListener;
-import org.eclipse.swt.events.MouseTrackAdapter;
-import org.eclipse.swt.events.MouseTrackListener;
-import org.eclipse.swt.events.ShellAdapter;
-import org.eclipse.swt.events.ShellEvent;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-
-
-/**
- * An information control manager that shows information on mouse hover events.
- * The mouse hover events are caught by registering a <code>MouseTrackListener</code>
- * on the manager's subject control. The manager has by default an information control closer
- * that closes the information control as soon as the mouse pointer leaves the subject area, the
- * user presses a key, or the subject control is resized, moved, or deactivated.<p>
- * When being activated by a mouse hover event, the manager disables itself, until the mouse
- * leaves the subject area. Thus, the manager is usually still disabled, when the information control
- * has already been closed by the closer.
- *
- * @see org.eclipse.swt.events.MouseTrackListener
- * @since 2.0
- */
-abstract public class AbstractHoverInformationControlManager extends AbstractInformationControlManager {
-
-
- /**
- * The information control closer for the hover information. Closes the information control as
- * soon as the mouse pointer leaves the subject area, a mouse button is pressed, the user presses a key,
- * or the subject control is resized or moved.
- */
- class Closer extends MouseTrackAdapter
- implements IInformationControlCloser, MouseListener, MouseMoveListener, ControlListener, KeyListener {
-
- /** The closer's subject control */
- private Control fSubjectControl;
- /** The subject area */
- private Rectangle fSubjectArea;
- /** Indicates whether this closer is active */
- private boolean fIsActive= false;
-
- /**
- * Creates a new information control closer.
- */
- public Closer() {
- }
-
- /*
- * @see IInformationControlCloser#setSubjectControl(Control)
- */
- public void setSubjectControl(Control control) {
- fSubjectControl= control;
- }
-
- /*
- * @see IInformationControlCloser#setHoverControl(IHoverControl)
- */
- public void setInformationControl(IInformationControl control) {
- }
-
- /*
- * @see IInformationControlCloser#start(Rectangle)
- */
- public void start(Rectangle subjectArea) {
-
- if (fIsActive) return;
- fIsActive= true;
-
- fSubjectArea= subjectArea;
-
- if (fSubjectControl != null && !fSubjectControl.isDisposed()) {
- fSubjectControl.addMouseListener(this);
- fSubjectControl.addMouseMoveListener(this);
- fSubjectControl.addMouseTrackListener(this);
- fSubjectControl.addControlListener(this);
- fSubjectControl.addKeyListener(this);
- }
- }
-
- /*
- * @see IInformationControlCloser#stop()
- */
- public void stop() {
- stop(false);
- }
-
- /**
- * Stops the information control and if <code>delayRestart</code> is set
- * allows restart only after a certain delay.
- *
- * @param delayRestart <code>true</code> if restart should be delayed
- */
- protected void stop(boolean delayRestart) {
-
- if (!fIsActive) return;
- fIsActive= false;
-
- hideInformationControl();
-
- if (fSubjectControl != null && !fSubjectControl.isDisposed()) {
- fSubjectControl.removeMouseListener(this);
- fSubjectControl.removeMouseMoveListener(this);
- fSubjectControl.removeMouseTrackListener(this);
- fSubjectControl.removeControlListener(this);
- fSubjectControl.removeKeyListener(this);
- }
- }
-
- /*
- * @see org.eclipse.swt.events.MouseMoveListener#mouseMove(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseMove(MouseEvent event) {
- if (!fSubjectArea.contains(event.x, event.y))
- stop();
- }
-
- /*
- * @see org.eclipse.swt.events.MouseListener#mouseUp(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseUp(MouseEvent event) {
- }
-
- /*
- * @see MouseListener#mouseDown(MouseEvent)
- */
- public void mouseDown(MouseEvent event) {
- stop();
- }
-
- /*
- * @see MouseListener#mouseDoubleClick(MouseEvent)
- */
- public void mouseDoubleClick(MouseEvent event) {
- stop();
- }
-
- /*
- * @see MouseTrackAdapter#mouseExit(MouseEvent)
- */
- public void mouseExit(MouseEvent event) {
- stop();
- }
-
- /*
- * @see ControlListener#controlResized(ControlEvent)
- */
- public void controlResized(ControlEvent event) {
- stop();
- }
-
- /*
- * @see ControlListener#controlMoved(ControlEvent)
- */
- public void controlMoved(ControlEvent event) {
- stop();
- }
-
- /*
- * @see KeyListener#keyReleased(KeyEvent)
- */
- public void keyReleased(KeyEvent event) {
- }
-
- /*
- * @see KeyListener#keyPressed(KeyEvent)
- */
- public void keyPressed(KeyEvent event) {
- stop(true);
- }
- }
-
-
- /**
- * To be installed on the manager's subject control. Serves two different purposes:
- * <ul>
- * <li> start function: initiates the computation of the information to be presented. This happens on
- * receipt of a mouse hover event and disables the information control manager,
- * <li> restart function: tracks mouse move and shell activation event to determine when the information
- * control manager needs to be reactivated.
- * </ul>
- */
- class MouseTracker extends ShellAdapter implements MouseTrackListener, MouseMoveListener {
-
- /** Margin around the original hover event location for coputing the hover area. */
- private final static int EPSILON= 3;
-
- /** The area in which the original hover event occurred. */
- private Rectangle fHoverArea;
- /** The area for which is computed information is valid. */
- private Rectangle fSubjectArea;
- /** The tracker's subject control. */
- private Control fSubjectControl;
-
- /** Indicates whether the tracker is in restart mode ignoring hover events. */
- private boolean fIsInRestartMode= false;
- /** Indicates whether the tracker is computing the information to be presented. */
- private boolean fIsComputing= false;
- /** Indicates whether the mouse has been lost. */
- private boolean fMouseLostWhileComputing= false;
- /** Indicates whether the subject control's shell has been deactivated. */
- private boolean fShellDeactivatedWhileComputing= false;
-
- /**
- * Creates a new mouse tracker.
- */
- public MouseTracker() {
- }
-
- /**
- * Sets this mouse tracker's subject area, the area to be tracked in order
- * to re-enable the information control manager.
- *
- * @param subjectArea the subject area
- */
- public void setSubjectArea(Rectangle subjectArea) {
- Assert.isNotNull(subjectArea);
- fSubjectArea= subjectArea;
- }
-
- /**
- * Starts this mouse tracker. The given control becomes this tracker's subject control.
- * Installs itself as mouse track listener on the subject control.
- *
- * @param subjectControl the subject control
- */
- public void start(Control subjectControl) {
- fSubjectControl= subjectControl;
- if (fSubjectControl != null && !fSubjectControl.isDisposed())
- fSubjectControl.addMouseTrackListener(this);
-
- fIsInRestartMode= false;
- fIsComputing= false;
- fMouseLostWhileComputing= false;
- fShellDeactivatedWhileComputing= false;
- }
-
- /**
- * Stops this mouse tracker. Removes itself as mouse track, mouse move, and
- * shell listener from the subject control.
- */
- public void stop() {
- if (fSubjectControl != null && !fSubjectControl.isDisposed()) {
- fSubjectControl.removeMouseTrackListener(this);
- fSubjectControl.removeMouseMoveListener(this);
- fSubjectControl.getShell().removeShellListener(this);
- }
- }
-
- /**
- * Initiates the computation of the information to be presented. Sets the initial hover area
- * to a small rectangle around the hover event location. Adds mouse move and shell activation listeners
- * to track whether the computed information is, after completion, useful for presentation and to
- * implement the restart function.
- *
- * @param event the mouse hover event
- */
- public void mouseHover(MouseEvent event) {
-
- if (fIsComputing || fIsInRestartMode) return;
-
- fIsInRestartMode= true;
- fIsComputing= true;
- fMouseLostWhileComputing= false;
- fShellDeactivatedWhileComputing= false;
-
- fHoverEventStateMask= event.stateMask;
- fHoverEvent= event;
- fHoverArea= new Rectangle(event.x - EPSILON, event.y - EPSILON, 2 * EPSILON, 2 * EPSILON );
- if (fHoverArea.x < 0) fHoverArea.x= 0;
- if (fHoverArea.y < 0) fHoverArea.y= 0;
- setSubjectArea(fHoverArea);
-
- if (fSubjectControl != null && !fSubjectControl.isDisposed()) {
- fSubjectControl.addMouseMoveListener(this);
- fSubjectControl.getShell().addShellListener(this);
- }
- doShowInformation();
- }
-
- /**
- * Deactivates this tracker's restart function and enables the information control
- * manager. Does not have any effect if the tracker is still executing the start function (i.e.
- * computing the information to be presented.
- */
- protected void deactivate() {
- if (fIsComputing) return;
- fIsInRestartMode= false;
- if (fSubjectControl != null && !fSubjectControl.isDisposed()) {
- fSubjectControl.removeMouseMoveListener(this);
- fSubjectControl.getShell().removeShellListener(this);
- }
- }
-
- /*
- * @see MouseTrackListener#mouseEnter(MouseEvent)
- */
- public void mouseEnter(MouseEvent e) {
- }
-
- /*
- * @see MouseTrackListener#mouseExit(MouseEvent)
- */
- public void mouseExit(MouseEvent e) {
- fMouseLostWhileComputing= true;
- deactivate();
- }
-
- /*
- * @see MouseMoveListener#mouseMove(MouseEvent)
- */
- public void mouseMove(MouseEvent event) {
- if (!fSubjectArea.contains(event.x, event.y))
- deactivate();
- }
-
- /*
- * @see ShellListener#shellDeactivated(ShellEvent)
- */
- public void shellDeactivated(ShellEvent e) {
- fShellDeactivatedWhileComputing= true;
- deactivate();
- }
-
- /*
- * @see ShellListener#shellIconified(ShellEvent)
- */
- public void shellIconified(ShellEvent e) {
- fShellDeactivatedWhileComputing= true;
- deactivate();
- }
-
- /**
- * Tells this tracker that the start function processing has been completed.
- */
- public void computationCompleted() {
- fIsComputing= false;
- fMouseLostWhileComputing= false;
- fShellDeactivatedWhileComputing= false;
- }
-
- /**
- * Determines whether the computed information is still useful for presentation.
- * This is not the case, if the shell of the subject control has been deactivated, the mouse
- * left the subject control, or the mouse moved on, so that it is no longer in the subject
- * area.
- *
- * @return <code>true</code> if information is still useful for presentation, <code>false</code> otherwise
- */
- public boolean isMouseLost() {
-
- if (fMouseLostWhileComputing || fShellDeactivatedWhileComputing)
- return true;
-
- if (fSubjectControl != null && !fSubjectControl.isDisposed()) {
- Display display= fSubjectControl.getDisplay();
- Point p= display.getCursorLocation();
- p= fSubjectControl.toControl(p);
- if (!fSubjectArea.contains(p) && !fHoverArea.contains(p))
- return true;
- }
-
- return false;
- }
- }
-
- /** The mouse tracker on the subject control */
- private MouseTracker fMouseTracker= new MouseTracker();
- /** The remembered hover event */
- private MouseEvent fHoverEvent= null;
- /** The remembered hover event sate mask of the keyboard modifiers */
- private int fHoverEventStateMask= 0;
-
- /**
- * Creates a new hover information control manager using the given information control creator.
- * By default a <code>Closer</code> instance is set as this manager's closer.
- *
- * @param creator the information control creator
- */
- protected AbstractHoverInformationControlManager(IInformationControlCreator creator) {
- super(creator);
- setCloser(new Closer());
- }
-
- /*
- * @see AbstractInformationControlManager#presentInformation()
- */
- protected void presentInformation() {
- if (fMouseTracker == null) {
- super.presentInformation();
- return;
- }
-
- Rectangle area= getSubjectArea();
- if (area != null)
- fMouseTracker.setSubjectArea(area);
-
- if (fMouseTracker.isMouseLost()) {
- fMouseTracker.computationCompleted();
- fMouseTracker.deactivate();
- } else {
- fMouseTracker.computationCompleted();
- super.presentInformation();
- }
- }
-
- /*
- * @see AbstractInformationControlManager#setEnabled(boolean)
- */
- public void setEnabled(boolean enabled) {
-
- boolean was= isEnabled();
- super.setEnabled(enabled);
- boolean is= isEnabled();
-
- if (was != is && fMouseTracker != null) {
- if (is)
- fMouseTracker.start(getSubjectControl());
- else
- fMouseTracker.stop();
- }
- }
-
- /**
- * Disposes this manager's information control.
- */
- public void dispose() {
- if (fMouseTracker != null) {
- fMouseTracker.stop();
- fMouseTracker.fSubjectControl= null;
- fMouseTracker= null;
- }
- super.dispose();
- }
-
- /**
- * Returns the location at which the most recent mouse hover event
- * has been issued.
- *
- * @return the location of the most recent mouse hover event
- */
- protected Point getHoverEventLocation() {
- return fHoverEvent != null ? new Point(fHoverEvent.x, fHoverEvent.y) : new Point(-1, -1);
- }
-
- /**
- * Returns the most recent mouse hover event.
- *
- * @return the most recent mouse hover event or <code>null</code>
- * @since 3.0
- */
- protected MouseEvent getHoverEvent() {
- return fHoverEvent;
- }
-
- /**
- * Returns the SWT event state of the most recent mouse hover event.
- *
- * @return the SWT event state of the most recent mouse hover event
- */
- protected int getHoverEventStateMask() {
- return fHoverEventStateMask;
- }
-
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractInformationControlManager.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractInformationControlManager.java
deleted file mode 100644
index 57bf7fd1f02..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractInformationControlManager.java
+++ /dev/null
@@ -1,788 +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 org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Control;
-
-
-/**
- * Manages the life cycle, visibility, layout, and contents of an <code>IInformationControl</code>.
- * This manager can be installed on and uninstalled from a control, refered to as the subject control, i.e.
- * the one from which the subject of the information to be shown is retrieved. Also a manager can
- * be enabled or disabled. An installed and enabled manager can be forced to show information in
- * its information control using <code>showInformation</code>. An information control
- * manager uses an <code>IInformationControlCloser</code> to define the behavior when
- * a presented information control must be closed. The disposal of the subject and the information
- * control are internally handled by the information control manager and are not the responsibility
- * of the information control closer.
- *
- * @see org.eclipse.jface.text.IInformationControl
- * @since 2.0
- */
-abstract public class AbstractInformationControlManager {
-
- /**
- * Interface of a information control closer. An information control closer
- * monitors its information control and its subject control and closes
- * the information control if necessary. <p>
- * Clients must implement this interface in order to equipe an information
- * control manager accordingly.
- */
- public static interface IInformationControlCloser {
-
- /**
- * Sets the closer's subject control. This is the control that parents
- * the information control and from which the subject of the information
- * to be shown is retrieved. <p>
- * Must be called before <code>start</code>. May again be called
- * between <code>start</code> and <code>stop</code>.
- *
- * @param subject the subject control
- */
- public void setSubjectControl(Control subject);
-
- /**
- * Sets the closer's information control, the one to close if necessary. <p>
- * Must be called before <code>start</code>. May again be called
- * between <code>start</code> and <code>stop</code>.
- *
- * @param control the information control
- */
- public void setInformationControl(IInformationControl control);
-
- /**
- * Tells this closer to start monitoring the subject and the information
- * control. The presented information is considered valid for the given
- * area of the subject control's display.
- *
- * @param subjectArea the area for which the presented information is valid
- */
- public void start(Rectangle subjectArea);
-
- /**
- * Tells this closer to stop monitoring the subject and the information control.
- */
- public void stop();
- }
-
-
-
- /**
- * Constitutes entities to enumerate anchors for the layout of the information control.
- */
- public static final class Anchor {
- private Anchor() {
- }
- }
-
- /** Internal anchor list. */
- private final static Anchor[] ANCHORS= { new Anchor(), new Anchor(), new Anchor(), new Anchor() };
-
- /** Anchor representing the top of the information area */
- public final static Anchor ANCHOR_TOP= ANCHORS[0];
- /** Anchor representing the bottom of the information area */
- public final static Anchor ANCHOR_BOTTOM= ANCHORS[1];
- /** Anchor representing the left side of the information area */
- public final static Anchor ANCHOR_LEFT= ANCHORS[2];
- /** Anchor representing the right side of the information area */
- public final static Anchor ANCHOR_RIGHT= ANCHORS[3];
- /**
- * Anchor representing the middle of the subject control
- * @since 2.1
- */
- public final static Anchor ANCHOR_GLOBAL= new Anchor();
-
-
- /** The subject control of the information control */
- private Control fSubjectControl;
-
- /** The display area for which the information to be presented is valid */
- private Rectangle fSubjectArea;
-
- /** The information to be presented */
- private Object fInformation;
-
- /** Indicates whether the information control takes focus when visible */
- private boolean fTakesFocusWhenVisible= false;
-
- /** The information control */
- protected IInformationControl fInformationControl;
-
- /** The information control creator */
- protected IInformationControlCreator fInformationControlCreator;
-
- /** The information control closer */
- protected IInformationControlCloser fInformationControlCloser;
-
- /** Indicates that the information control has been disposed */
- protected boolean fDisposed= false;
-
- /** Indicates the enable state of this manager */
- private boolean fEnabled= false;
-
- /** Cached, computed size constraints of the information control in points */
- private Point fSizeConstraints;
-
- /** The y margin when laying out the information control */
- private int fMarginY= 5;
-
- /** The x margin when laying out the information control */
- private int fMarginX= 5;
-
- /** The width contraint of the information control in characters */
- private int fWidthConstraint= 60;
-
- /** The height constraint of the information control in characters */
- private int fHeightConstraint= 6;
-
- /** Indicates wether the size constraints should be enforced as minimal control size */
- private boolean fEnforceAsMinimalSize= false;
-
- /** Indicates whether the size constraints should be enforced as maximal control size */
- private boolean fEnforceAsMaximalSize= false;
-
- /** The anchor for laying out the information control in relation to the subject control */
- private Anchor fAnchor= ANCHOR_BOTTOM;
-
- /**
- * A list of anchors used to layout the information control if the original anchor can not
- * be used because the information control would not fit in the display client area.
- */
- private Anchor[] fFallbackAnchors= ANCHORS;
-
- /**
- * The custom information control creator.
- * @since 3.0
- */
- private volatile IInformationControlCreator fCustomInformationControlCreator;
-
- /**
- * Tells whether a custom information control is in use.
- * @since 3.0
- */
- private boolean fIsCustomInformationControl= false;
-
-
-
- /**
- * Creates a new information control manager using the given information control creator.
- * By default the following configuration is given:
- * <ul>
- * <li> enabled == false
- * <li> x-margin == 5 points
- * <li> y-margin == 5 points
- * <li> width constraint == 60 characters
- * <li> height constraint == 6 characters
- * <li> enforce constraints as minimal size == false
- * <li> enforce constraints as maximal size == false
- * <li> layout anchor == ANCHOR_BOTTOM
- * <li> fallback anchors == { ANCHOR_TOP, ANCHOR_BOTTOM, ANCHOR_LEFT, ANCHOR_RIGHT, ANCHOR_GLOBAL }
- * <li> takes focus when visible == false
- * </ul>
- *
- * @param creator the information control creator
- */
- protected AbstractInformationControlManager(IInformationControlCreator creator) {
- Assert.isNotNull(creator);
- fInformationControlCreator= creator;
- }
-
- /**
- * Computes the information to be displayed and the area in which the computed
- * information is valid. Implementation of this method must finish their computation
- * by setting the computation results using <code>setInformation</code>.
- */
- abstract protected void computeInformation();
-
- /**
- * Sets the parameters of the information to be displayed. These are the information itself and
- * the area for which the given information is valid. This so called subject area is a graphical
- * region of the information control's subject control. This method calls <code>presentInformation()</code>
- * to trigger the presentation of the computed information.
- *
- * @param information the information
- * @param subjectArea the subject area
- */
- protected final void setInformation(String information, Rectangle subjectArea) {
- fInformation= information;
- fSubjectArea= subjectArea;
- presentInformation();
- }
-
- /**
- * Sets the parameters of the information to be displayed. These are the information itself and
- * the area for which the given information is valid. This so called subject area is a graphical
- * region of the information control's subject control. This method calls <code>presentInformation()</code>
- * to trigger the presentation of the computed information.
- *
- * @param information the information
- * @param subjectArea the subject area
- * @since 2.1
- */
- protected final void setInformation(Object information, Rectangle subjectArea) {
- fInformation= information;
- fSubjectArea= subjectArea;
- presentInformation();
- }
-
- /**
- * Sets the information control closer for this manager.
- *
- * @param closer the information control closer for this manager
- */
- protected void setCloser(IInformationControlCloser closer) {
- fInformationControlCloser= closer;
- }
-
- /**
- * Sets the x- and y- margin to be used when laying out the information control
- * relative to the subject control.
- *
- * @param xMargin the x-margin
- * @param yMargin the y-Margin
- */
- public void setMargins(int xMargin, int yMargin) {
- fMarginX= xMargin;
- fMarginY= yMargin;
- }
-
- /**
- * Sets the width- and height constraints of the information control.
- *
- * @param widthInChar the width constraint in number of characters
- * @param heightInChar the height constrain in number of characters
- * @param enforceAsMinimalSize indicates whether the constraints describe the minimal allowed size of the control
- * @param enforceAsMaximalSize indicates whether the constraints describe the maximal allowed size of the control
- */
- public void setSizeConstraints(int widthInChar, int heightInChar, boolean enforceAsMinimalSize, boolean enforceAsMaximalSize) {
- fSizeConstraints= null;
- fWidthConstraint= widthInChar;
- fHeightConstraint= heightInChar;
- fEnforceAsMinimalSize= enforceAsMinimalSize;
- fEnforceAsMaximalSize= enforceAsMaximalSize;
- }
-
- /**
- * Sets the anchor used for laying out the information control relative to the
- * subject control. E.g, using <code>ANCHOR_TOP</code> indicates that the
- * information control is position above the area for which the information to
- * be displayed is valid.
- *
- * @param anchor the layout anchor
- */
- public void setAnchor(Anchor anchor) {
- fAnchor= anchor;
- }
-
- /**
- * Sets the sequence of anchors along which the information control is tried to
- * be laid out until it is fully visible. This fallback is initiated when the information
- * control does not fit into the client area of the subject control's display.
- *
- * @param fallbackAnchors the list of anchors to be tried
- */
- public void setFallbackAnchors(Anchor[] fallbackAnchors) {
- fFallbackAnchors= fallbackAnchors;
- }
-
- /**
- * Sets the temporary custom control creator, overriding this manager's default information control creator.
- *
- * @param informationControlCreator
- * @since 3.0
- */
- protected void setCustomInformationControlCreator(IInformationControlCreator informationControlCreator) {
- if (fCustomInformationControlCreator instanceof IInformationControlCreatorExtension) {
- IInformationControlCreatorExtension extension= (IInformationControlCreatorExtension) fCustomInformationControlCreator;
- if (extension.canReplace(informationControlCreator))
- return;
- }
- fCustomInformationControlCreator= informationControlCreator;
- }
-
- /**
- * Tells the manager whether it should set the focus to the information control when made visible.
- *
- * @param takesFocus <code>true</code> if information control should take focus when made visible
- */
- public void takesFocusWhenVisible(boolean takesFocus) {
- fTakesFocusWhenVisible= takesFocus;
- }
-
- /**
- * Handles the disposal of the subject control. By default, the information control
- * is disposed by calling <code>disposeInformationControl</code>. Subclasses may extend
- * this method.
- */
- protected void handleSubjectControlDisposed() {
- disposeInformationControl();
- }
-
- /**
- * Installs this manager on the given control. The control is now taking the role of
- * the subject control. This implementation sets the control also as the information
- * control closer's subject control and automatically enables this manager.
- *
- * @param subjectControl the subject control
- */
- public void install(Control subjectControl) {
- fSubjectControl= subjectControl;
-
- if (fSubjectControl != null) {
- fSubjectControl.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- handleSubjectControlDisposed();
- }
- });
- }
-
- if (fInformationControlCloser != null)
- fInformationControlCloser.setSubjectControl(subjectControl);
-
- setEnabled(true);
- }
-
- /**
- * Returns the subject control of this manager/information control.
- *
- * @return the subject control
- */
- protected Control getSubjectControl() {
- return fSubjectControl;
- }
-
- /**
- * Returns the actual subject area.
- *
- * @return the actual subject area
- */
- protected Rectangle getSubjectArea() {
- return fSubjectArea;
- }
-
- /**
- * Sets the enable state of this manager.
- *
- * @param enabled the enable state
- * @deprecated visibility will be changed to protected
- */
- public void setEnabled(boolean enabled) {
- fEnabled= enabled;
- }
-
- /**
- * Returns whether this manager is enabled or not.
- *
- * @return <code>true</code> if this manager is enabled otherwise <code>false</code>
- */
- protected boolean isEnabled() {
- return fEnabled;
- }
-
- /**
- * Computes the size constraints of the information control in points based on the
- * default font of the given subject control as well as the size constraints in character
- * width.
- *
- * @param subjectControl the subject control
- * @param informationControl the information control whose size constraints are computed
- * @return the computed size constraints in points
- */
- protected Point computeSizeConstraints(Control subjectControl, IInformationControl informationControl) {
-
- if (fSizeConstraints == null) {
-
- if (subjectControl == null)
- return null;
-
- GC gc= new GC(subjectControl);
- gc.setFont(subjectControl.getFont());
- int width= gc.getFontMetrics().getAverageCharWidth();
- int height = gc.getFontMetrics().getHeight();
- gc.dispose();
-
- fSizeConstraints= new Point (fWidthConstraint * width, fHeightConstraint * height);
- }
-
- return fSizeConstraints;
- }
-
- /**
- * Handles the disposal of the information control. By default, the information
- * control closer is stopped.
- */
- protected void handleInformationControlDisposed() {
- fInformationControl= null;
- if (fInformationControlCloser != null) {
- fInformationControlCloser.setInformationControl(null);
- fInformationControlCloser.stop();
- }
- }
-
- /**
- * Returns the information control. If the information control has not been created yet,
- * it is automatically created.
- *
- * @return the information control
- */
- protected IInformationControl getInformationControl() {
-
- if (fDisposed)
- return fInformationControl;
-
- IInformationControlCreator creator= null;
-
- if (fCustomInformationControlCreator == null) {
- creator= fInformationControlCreator;
- if (fIsCustomInformationControl && fInformationControl != null) {
- fInformationControl.dispose();
- fInformationControl= null;
- }
- fIsCustomInformationControl= false;
-
- } else {
-
- creator= fCustomInformationControlCreator;
- if (creator instanceof IInformationControlCreatorExtension) {
- IInformationControlCreatorExtension extension= (IInformationControlCreatorExtension) creator;
- if (extension.canReuse(fInformationControl))
- return fInformationControl;
- }
- if (fInformationControl != null) {
- fInformationControl.dispose();
- fInformationControl= null;
- }
- fIsCustomInformationControl= true;
- }
-
- if (fInformationControl == null) {
- fInformationControl= creator.createInformationControl(fSubjectControl.getShell());
- fInformationControl.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- handleInformationControlDisposed();
- }
- });
-
- if (fInformationControlCloser != null)
- fInformationControlCloser.setInformationControl(fInformationControl);
- }
-
- return fInformationControl;
- }
-
- /**
- * Computes the display location of the information control. The location is computed
- * considering the given subject area, the anchor at the subject area, and the
- * size of the information control. This method does not care about whether the information
- * control would be completely visible when placed at the result location.
- *
- * @param subjectArea the subject area
- * @param controlSize the size of the information control
- * @param anchor the anchor at the subject area
- * @return the display location of the information control
- */
- protected Point computeLocation(Rectangle subjectArea, Point controlSize, Anchor anchor) {
-
- if (ANCHOR_GLOBAL == anchor) {
- Point subjectControlSize= fSubjectControl.getSize();
- Point location= new Point(subjectControlSize.x / 2, subjectControlSize.y / 2);
- location.x -= (controlSize.x / 2);
- location.y -= (controlSize.y / 2);
- return fSubjectControl.toDisplay(location);
- }
-
- int xShift= 0;
- int yShift= 0;
-
- if (ANCHOR_BOTTOM == anchor) {
- xShift= fMarginX;
- yShift= subjectArea.height + fMarginY;
- } else if (ANCHOR_RIGHT == anchor) {
- xShift= fMarginX + subjectArea.width;
- yShift= fMarginY;
- } else if (ANCHOR_TOP == anchor) {
- xShift= fMarginX;
- yShift= -controlSize.y - fMarginY;
- } else if (ANCHOR_LEFT == anchor) {
- xShift= -controlSize.x - fMarginX;
- yShift= fMarginY;
- }
-
- return fSubjectControl.toDisplay(new Point(subjectArea.x + xShift, subjectArea.y + yShift));
- }
-
- /**
- * Checks whether a control of the given size at the given location would be completely visible
- * in the given display area when laid out by using the given anchor. If not, this method tries
- * to shift the control orthogonal to the direction given by the anchor to make it visible. If possible
- * it updates the location.<p>
- * This method returns <code>true</code> if the potentially updated position results in a
- * completely visible control, or <code>false</code> otherwise.
- *
- *
- * @param location the location of the control
- * @param size the size of the control
- * @param displayArea the display area in which the control should be visible
- * @param anchor anchor for alying out the control
- * @return <code>true</code>if the updated location is useful
- */
- protected boolean updateLocation(Point location, Point size, Rectangle displayArea, Anchor anchor) {
-
- int displayLowerRightX= displayArea.x + displayArea.width;
- int displayLowerRightY= displayArea.y + displayArea.height;
- int lowerRightX= location.x + size.x;
- int lowerRightY= location.y + size.y;
-
- if (ANCHOR_BOTTOM == anchor || ANCHOR_TOP == anchor) {
-
- if (ANCHOR_BOTTOM == anchor) {
- if (lowerRightY > displayLowerRightY)
- return false;
- } else {
- if (location.y < displayArea.y)
- return false;
- }
-
- if (lowerRightX > displayLowerRightX)
- location.x= location.x - (lowerRightX - displayLowerRightX);
-
- return (location.x >= 0 && location.y >= 0);
-
- } else if (ANCHOR_RIGHT == anchor || ANCHOR_LEFT == anchor) {
-
- if (ANCHOR_RIGHT == anchor) {
- if (lowerRightX > displayLowerRightX)
- return false;
- } else {
- if (location.x < displayArea.x)
- return false;
- }
-
- if (lowerRightY > displayLowerRightY)
- location.y= location.y - (lowerRightY - displayLowerRightY);
-
- return (location.x >= 0 && location.y >= 0);
-
- } else if (ANCHOR_GLOBAL == anchor) {
-
- if (lowerRightX > displayLowerRightX)
- location.x= location.x - (lowerRightX - displayLowerRightX);
-
- if (lowerRightY > displayLowerRightY)
- location.y= location.y - (lowerRightY - displayLowerRightY);
-
- return (location.x >= 0 && location.y >= 0);
- }
-
- return false;
- }
-
- /**
- * Returns the next fallback anchor from this manager's list of fallback anchors.
- * If no more fallback anchor is available <code>null</code> is returned.
- *
- * @param anchor the current anchor
- * @return the next fallback anchor or <code>null</code> if no more anchor is available
- */
- protected Anchor getNextFallbackAnchor(Anchor anchor) {
-
- if (anchor == null || fFallbackAnchors == null)
- return null;
-
- for (int i= 0; i < fFallbackAnchors.length; i++) {
- if (fFallbackAnchors[i] == anchor)
- return fFallbackAnchors[i + 1 == fFallbackAnchors.length ? 0 : i + 1];
- }
-
- return null;
- }
-
- /**
- * Computes the location of the information control depending on the
- * subject area and the size of the information control. This method attempts
- * to find a location at which the information control lies completely in the display's
- * client area honoring the manager's default anchor. If this isn't possible using the
- * default anchor, the fallback anchors are tried out.
- *
- * @param subjectArea the information area
- * @param controlSize the size of the information control
- * @return the computed location of the information control
- */
- protected Point computeInformationControlLocation(Rectangle subjectArea, Point controlSize) {
-
- Rectangle displayBounds= fSubjectControl.getDisplay().getClientArea();
-
- Point upperLeft;
- Anchor testAnchor= fAnchor;
- do {
-
- upperLeft= computeLocation(subjectArea, controlSize, testAnchor);
- if (updateLocation(upperLeft, controlSize, displayBounds, testAnchor))
- break;
- testAnchor= getNextFallbackAnchor(testAnchor);
-
- } while (testAnchor != fAnchor && testAnchor != null);
-
- return upperLeft;
- }
-
- /**
- * Computes information to be displayed as well as the subject area
- * and initiates that this information is presented in the information control.
- * This happens only if this controller is enabled.
- */
- public void showInformation() {
- if (fEnabled)
- doShowInformation();
- }
-
- /**
- * Computes information to be displayed as well as the subject area
- * and initiates that this information is presented in the information control.
- */
- protected void doShowInformation() {
- fSubjectArea= null;
- fInformation= null;
- computeInformation();
- }
-
- /**
- * Presents the information in the information control or hides the information
- * control if no information should be presented. The information has previously
- * been set using <code>setInformation</code>.
- */
- protected void presentInformation() {
- boolean hasContents= false;
- if (fInformation instanceof String)
- hasContents= ((String)fInformation).trim().length() > 0;
- else
- hasContents= (fInformation != null);
-
- if (fSubjectArea != null && hasContents)
- internalShowInformationControl(fSubjectArea, fInformation);
- else
- hideInformationControl();
- }
-
- /**
- * Opens the information control with the given information and the specified
- * subject area. It also activates the information control closer.
- *
- * @param subjectArea the information area
- * @param information the information
- */
- private void internalShowInformationControl(Rectangle subjectArea, Object information) {
-
- IInformationControl informationControl= getInformationControl();
- if (informationControl != null) {
-
- Point sizeConstraints= computeSizeConstraints(fSubjectControl, informationControl);
- informationControl.setSizeConstraints(sizeConstraints.x, sizeConstraints.y);
-
- if (informationControl instanceof IInformationControlExtension2)
- ((IInformationControlExtension2)informationControl).setInput(information);
- else
- informationControl.setInformation(information.toString());
-
- if (informationControl instanceof IInformationControlExtension) {
- IInformationControlExtension extension= (IInformationControlExtension)informationControl;
- if (!extension.hasContents())
- return;
- }
-
- Point size= informationControl.computeSizeHint();
-
- if (fEnforceAsMinimalSize) {
- if (size.x < sizeConstraints.x)
- size.x= sizeConstraints.x;
- if (size.y < sizeConstraints.y)
- size.y= sizeConstraints.y;
- }
-
- if (fEnforceAsMaximalSize) {
- if (size.x > sizeConstraints.x)
- size.x= sizeConstraints.x;
- if (size.y > sizeConstraints.y)
- size.y= sizeConstraints.y;
- }
-
- informationControl.setSize(size.x, size.y);
-
- Point location= computeInformationControlLocation(subjectArea, size);
- informationControl.setLocation(location);
-
- showInformationControl(subjectArea);
- }
- }
-
- /**
- * Hides the information control and stops the information control closer.
- */
- protected void hideInformationControl() {
- if (fInformationControl != null) {
- fInformationControl.setVisible(false);
- if (fInformationControlCloser != null)
- fInformationControlCloser.stop();
- }
- }
-
- /**
- * Shows the information control and starts the information control closer.
- * This method may not be called by clients.
- *
- * @param subjectArea the information area
- */
- protected void showInformationControl(Rectangle subjectArea) {
- fInformationControl.setVisible(true);
-
- if (fTakesFocusWhenVisible)
- fInformationControl.setFocus();
-
- if (fInformationControlCloser != null)
- fInformationControlCloser.start(subjectArea);
- }
-
- /**
- * Disposes this manager's information control.
- */
- public void disposeInformationControl() {
- if (fInformationControl != null) {
- fInformationControl.dispose();
- handleInformationControlDisposed();
- }
- }
-
- /**
- * Disposes this manager and if necessary all dependent parts such as
- * the information control. For symmetry it first disables this manager.
- */
- public void dispose() {
- if (!fDisposed) {
-
- fDisposed= true;
-
- setEnabled(false);
- disposeInformationControl();
-
- fIsCustomInformationControl= false;
- fCustomInformationControlCreator= null;
- fInformationControlCreator= null;
- fInformationControlCloser= null;
- }
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/CursorLinePainter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/CursorLinePainter.java
deleted file mode 100644
index c7ef1bf7c0c..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/CursorLinePainter.java
+++ /dev/null
@@ -1,245 +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 org.eclipse.swt.custom.LineBackgroundEvent;
-import org.eclipse.swt.custom.LineBackgroundListener;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Point;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextViewerExtension3;
-import org.eclipse.jface.text.Position;
-
-
-/**
- * A painter the draws the background of the cursor line in a configured color.
- * Clients usually instantiate and configure object of this class.<p>
- * This class is not intended to be subclassed.
- *
- * @since 2.1
- */
-public class CursorLinePainter implements IPainter, LineBackgroundListener {
-
- /** The viewer the painter works on */
- private final ITextViewer fViewer;
- /** The cursor line back ground color */
- private Color fHighlightColor;
- /** The paint position manager for managing the line coordinates */
- private IPaintPositionManager fPositionManager;
-
- /** Keeps track of the line to be painted */
- private Position fCurrentLine= new Position(0, 0);
- /** Keeps track of the line to be cleared */
- private Position fLastLine= new Position(0, 0);
- /** Keeps track of the line number of the last painted line */
- private int fLastLineNumber= -1;
- /** Indicates whether this painter is active */
- private boolean fIsActive;
-
- /**
- * Creates a new painter for the given source viewer.
- *
- * @param textViewer the source viewer for which to create a painter
- */
- public CursorLinePainter(ITextViewer textViewer) {
- fViewer= textViewer;
- }
-
- /**
- * Sets the color in which to draw the background of the cursor line.
- *
- * @param highlightColor the color in which to draw the background of the cursor line
- */
- public void setHighlightColor(Color highlightColor) {
- fHighlightColor= highlightColor;
- }
-
- /*
- * @see LineBackgroundListener#lineGetBackground(LineBackgroundEvent)
- */
- public void lineGetBackground(LineBackgroundEvent event) {
- // don't use cached line information because of asynch painting
-
- StyledText textWidget= fViewer.getTextWidget();
- if (textWidget != null) {
-
- int caret= textWidget.getCaretOffset();
- int length= event.lineText.length();
-
- if (event.lineOffset <= caret && caret <= event.lineOffset + length)
- event.lineBackground= fHighlightColor;
- else
- event.lineBackground= textWidget.getBackground();
- }
- }
-
- /**
- * Updates all the cached information about the lines to be painted and to be cleared. Returns <code>true</code>
- * if the line number of the cursor line has changed.
- *
- * @return <code>true</code> if cursor line changed
- */
- private boolean updateHighlightLine() {
- try {
-
- IDocument document= fViewer.getDocument();
- int lineNumber= document.getLineOfOffset(getModelCaret());
-
- // redraw if the current line number is different from the last line number we painted
- // initially fLastLineNumber is -1
- if (lineNumber != fLastLineNumber) {
-
- fLastLine.offset= fCurrentLine.offset;
- fLastLine.length= fCurrentLine.length;
- fLastLine.isDeleted= fCurrentLine.isDeleted;
-
- fCurrentLine.isDeleted= false;
- fCurrentLine.offset= document.getLineOffset(lineNumber);
- if (lineNumber == document.getNumberOfLines() - 1)
- fCurrentLine.length= document.getLength() - fCurrentLine.offset;
- else
- fCurrentLine.length= document.getLineOffset(lineNumber + 1) - fCurrentLine.offset;
-
- fLastLineNumber= lineNumber;
- return true;
-
- }
-
- } catch (BadLocationException e) {
- }
-
- return false;
- }
-
- /**
- * Returns the location of the caret as offset in the source viewer's
- * input document.
- *
- * @return the caret location
- */
- private int getModelCaret() {
- int widgetCaret= fViewer.getTextWidget().getCaretOffset();
- if (fViewer instanceof ITextViewerExtension3) {
- ITextViewerExtension3 extension= (ITextViewerExtension3) fViewer;
- return extension.modelOffset2WidgetOffset(widgetCaret);
- } else {
- IRegion visible= fViewer.getVisibleRegion();
- return widgetCaret + visible.getOffset();
- }
- }
-
- /**
- * Assumes the given position to specify offset and length of a line to be painted.
- *
- * @param position the specification of the line to be painted
- */
- private void drawHighlightLine(Position position) {
-
- // if the position that is about to be drawn was deleted then we can't
- if (position.isDeleted())
- return;
-
- int widgetOffset= 0;
- if (fViewer instanceof ITextViewerExtension3) {
-
- ITextViewerExtension3 extension= (ITextViewerExtension3) fViewer;
- widgetOffset= extension.modelOffset2WidgetOffset(position.getOffset());
- if (widgetOffset == -1)
- return;
-
- } else {
-
- IRegion visible= fViewer.getVisibleRegion();
- widgetOffset= position.getOffset() - visible.getOffset();
- if (widgetOffset < 0 || visible.getLength() < widgetOffset )
- return;
- }
-
- StyledText textWidget= fViewer.getTextWidget();
- Point upperLeft= textWidget.getLocationAtOffset(widgetOffset);
- int width= textWidget.getClientArea().width + textWidget.getHorizontalPixel();
- int height= textWidget.getLineHeight();
- textWidget.redraw(0, upperLeft.y, width, height, false);
- }
-
- /*
- * @see IPainter#deactivate(boolean)
- */
- public void deactivate(boolean redraw) {
- if (fIsActive) {
- fIsActive= false;
-
- /* on turning off the feature one has to paint the currently
- * highlighted line with the standard background color
- */
- if (redraw)
- drawHighlightLine(fCurrentLine);
-
- fViewer.getTextWidget().removeLineBackgroundListener(this);
-
- if (fPositionManager != null)
- fPositionManager.unmanagePosition(fCurrentLine);
-
- fLastLineNumber= -1;
- }
- }
-
- /*
- * @see IPainter#dispose()
- */
- public void dispose() {
- }
-
- /*
- * @see IPainter#paint(int)
- */
- public void paint(int reason) {
- if (fViewer.getDocument() == null) {
- deactivate(false);
- return;
- }
-
- // check selection
- Point selection= fViewer.getTextWidget().getSelectionRange();
- if (selection.y > 0) {
- deactivate(true);
- return;
- }
-
- // initialization
- if (!fIsActive) {
- fViewer.getTextWidget().addLineBackgroundListener(this);
- fPositionManager.managePosition(fCurrentLine);
- fIsActive= true;
- }
-
- //redraw line highlight only if it hasn't been drawn yet on the respective line
- if (updateHighlightLine()) {
- // clear last line
- drawHighlightLine(fLastLine);
- // draw new line
- drawHighlightLine(fCurrentLine);
- }
- }
-
- /*
- * @see IPainter#setPositionManager(IPaintPositionManager)
- */
- public void setPositionManager(IPaintPositionManager manager) {
- fPositionManager = manager;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultAutoIndentStrategy.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultAutoIndentStrategy.java
deleted file mode 100644
index 742322bd2f8..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultAutoIndentStrategy.java
+++ /dev/null
@@ -1,91 +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;
-
-
-
-
-/**
- * Default implementation of <code>IAutoIndentStrategy</code>.
- * This strategy always copies the indentation of the previous line.
- */
-public class DefaultAutoIndentStrategy implements IAutoIndentStrategy {
-
- /**
- * Creates a new default auto indent strategy which can be installed on
- * text viewers.
- */
- public DefaultAutoIndentStrategy() {
- }
-
- /**
- * Returns the first offset greater than <code>offset</code> and smaller than
- * <code>end</code> whose character is not a space or tab character. If no such
- * offset is found, <code>end</code> is returned.
- *
- * @param document the document to search in
- * @param offset the offset at which searching start
- * @param end the offset at which searching stops
- * @return the offset in the specifed range whose character is not a space or tab
- * @exception BadLocationException if position is an invalid range in the given document
- */
- protected int findEndOfWhiteSpace(IDocument document, int offset, int end) throws BadLocationException {
- while (offset < end) {
- char c= document.getChar(offset);
- if (c != ' ' && c != '\t') {
- return offset;
- }
- offset++;
- }
- return end;
- }
-
- /**
- * Copies the indentation of the previous line.
- *
- * @param d the document to work on
- * @param c the command to deal with
- */
- private void autoIndentAfterNewLine(IDocument d, DocumentCommand c) {
-
- if (c.offset == -1 || d.getLength() == 0)
- return;
-
- try {
- // find start of line
- int p= (c.offset == d.getLength() ? c.offset - 1 : c.offset);
- IRegion info= d.getLineInformationOfOffset(p);
- int start= info.getOffset();
-
- // find white spaces
- int end= findEndOfWhiteSpace(d, start, c.offset);
-
- StringBuffer buf= new StringBuffer(c.text);
- if (end > start) {
- // append to input
- buf.append(d.get(start, end - start));
- }
-
- c.text= buf.toString();
-
- } catch (BadLocationException excp) {
- // stop work
- }
- }
-
- /*
- * @see IAutoIndentStrategy#customizeDocumentCommand
- */
- public void customizeDocumentCommand(IDocument d, DocumentCommand c) {
- if (c.length == 0 && c.text != null && TextUtilities.endsWith(d.getLegalLineDelimiters(), c.text) != -1)
- autoIndentAfterNewLine(d, c);
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultInformationControl.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultInformationControl.java
deleted file mode 100644
index 13073c75198..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultInformationControl.java
+++ /dev/null
@@ -1,378 +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 org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-
-
-/**
- * Text based implementation of <code>IInformationControl</code>.
- * Displays information in a styled text widget. Before displaying, the
- * information set to this information control is processed by an
- * <code>IInformationPresenter</code>.
- *
- * @since 2.0
- */
-public class DefaultInformationControl implements IInformationControl, IInformationControlExtension {
-
- /**
- * An information presenter determines the style presentation
- * of information displayed in the default information control.
- * The interface can be implemented by clients.
- */
- public static interface IInformationPresenter {
-
- /**
- * Updates the given presentation of the given information and
- * thereby may manipulate the information to be displayed. The manipulation
- * could be the extraction of textual encoded style information etc. Returns the
- * manipulated information.
- *
- * @param display the display of the information control
- * @param hoverInfo the information to be presented
- * @param presentation the presentation to be updated
- * @param maxWidth the maximal width in pixels
- * @param maxHeight the maximal height in pixels
- *
- * @return the manipulated information
- */
- String updatePresentation(Display display, String hoverInfo, TextPresentation presentation, int maxWidth, int maxHeight);
- }
-
- /** Border thickness in pixels. */
- private static final int BORDER= 1;
-
- /** The control's shell */
- private Shell fShell;
- /** The control's text widget */
- private StyledText fText;
- /** The information presenter */
- private IInformationPresenter fPresenter;
- /** A cached text presentation */
- private TextPresentation fPresentation= new TextPresentation();
- /** The control width constraint */
- private int fMaxWidth= -1;
- /** The control height constraint */
- private int fMaxHeight= -1;
- /**
- * The font of the optional status text label.
- *
- * @since 3.0
- */
- private Font fStatusTextFont;
-
- /**
- * Creates a default information control with the given shell as parent. The given
- * information presenter is used to process the information to be displayed. The given
- * styles are applied to the created styled text widget.
- *
- * @param parent the parent shell
- * @param shellStyle the additional styles for the shell
- * @param style the additional styles for the styled text widget
- * @param presenter the presenter to be used
- */
- public DefaultInformationControl(Shell parent, int shellStyle, int style, IInformationPresenter presenter) {
- this(parent, shellStyle, style, presenter, null);
- }
-
- /**
- * Creates a default information control with the given shell as parent. The given
- * information presenter is used to process the information to be displayed. The given
- * styles are applied to the created styled text widget.
- *
- * @param parent the parent shell
- * @param shellStyle the additional styles for the shell
- * @param style the additional styles for the styled text widget
- * @param presenter the presenter to be used
- * @param statusFieldText the text to be used in the optional status field
- * or <code>null</code> if the status field should be hidden
- * @since 3.0
- */
- public DefaultInformationControl(Shell parent, int shellStyle, int style, IInformationPresenter presenter, String statusFieldText) {
- GridLayout layout;
- GridData gd;
-
- fShell= new Shell(parent, SWT.NO_FOCUS | SWT.ON_TOP | shellStyle);
- Display display= fShell.getDisplay();
- fShell.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
-
- Composite composite= fShell;
- layout= new GridLayout(1, false);
- int border= ((shellStyle & SWT.NO_TRIM) == 0) ? 0 : BORDER;
- layout.marginHeight= border;
- layout.marginWidth= border;
- composite.setLayout(layout);
- gd= new GridData(GridData.FILL_BOTH);
- composite.setLayoutData(gd);
-
- if (statusFieldText != null) {
- composite= new Composite(composite, SWT.NONE);
- layout= new GridLayout(1, false);
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- composite.setLayout(layout);
- gd= new GridData(GridData.FILL_BOTH);
- composite.setLayoutData(gd);
- composite.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
- composite.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
- }
-
- // Text field
- fText= new StyledText(composite, SWT.MULTI | SWT.READ_ONLY | style);
- gd= new GridData(GridData.BEGINNING | GridData.FILL_BOTH);
- fText.setLayoutData(gd);
- fText.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
- fText.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
- fText.addKeyListener(new KeyListener() {
-
- public void keyPressed(KeyEvent e) {
- if (e.character == 0x1B) // ESC
- fShell.dispose();
- }
-
- public void keyReleased(KeyEvent e) {}
- });
-
- fPresenter= presenter;
-
- // Status field
- if (statusFieldText != null) {
-
- // Horizontal separator line
- Label separator= new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL | SWT.LINE_DOT);
- separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- // Status field label
- Label statusField= new Label(composite, SWT.RIGHT);
- statusField.setText(statusFieldText);
- Font font= statusField.getFont();
- FontData[] fontDatas= font.getFontData();
- for (int i= 0; i < fontDatas.length; i++)
- fontDatas[i].setHeight(fontDatas[i].getHeight() * 9 / 10);
- fStatusTextFont= new Font(statusField.getDisplay(), fontDatas);
- statusField.setFont(fStatusTextFont);
- gd= new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING);
- statusField.setLayoutData(gd);
-
- // Regarding the color see bug 41128
- statusField.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW));
-
- statusField.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
- }
- }
-
- /**
- * Creates a default information control with the given shell as parent. The given
- * information presenter is used to process the information to be displayed. The given
- * styles are applied to the created styled text widget.
- *
- * @param parent the parent shell
- * @param style the additional styles for the styled text widget
- * @param presenter the presenter to be used
- */
- public DefaultInformationControl(Shell parent,int style, IInformationPresenter presenter) {
- this(parent, SWT.NO_TRIM, style, presenter);
- }
-
- /**
- * Creates a default information control with the given shell as parent. The given
- * information presenter is used to process the information to be displayed. The given
- * styles are applied to the created styled text widget.
- *
- * @param parent the parent shell
- * @param style the additional styles for the styled text widget
- * @param presenter the presenter to be used
- * @param statusFieldText the text to be used in the optional status field
- * or <code>null</code> if the status field should be hidden
- * @since 3.0
- */
- public DefaultInformationControl(Shell parent,int style, IInformationPresenter presenter, String statusFieldText) {
- this(parent, SWT.NO_TRIM, style, presenter, statusFieldText);
- }
-
- /**
- * Creates a default information control with the given shell as parent.
- * No information presenter is used to process the information
- * to be displayed. No additional styles are applied to the styled text widget.
- *
- * @param parent the parent shell
- */
- public DefaultInformationControl(Shell parent) {
- this(parent, SWT.NONE, null);
- }
-
- /**
- * Creates a default information control with the given shell as parent. The given
- * information presenter is used to process the information to be displayed.
- * No additional styles are applied to the styled text widget.
- *
- * @param parent the parent shell
- * @param presenter the presenter to be used
- */
- public DefaultInformationControl(Shell parent, IInformationPresenter presenter) {
- this(parent, SWT.NONE, presenter);
- }
-
- /*
- * @see IInformationControl#setInformation(String)
- */
- public void setInformation(String content) {
- if (fPresenter == null) {
- fText.setText(content);
- } else {
- fPresentation.clear();
- content= fPresenter.updatePresentation(fShell.getDisplay(), content, fPresentation, fMaxWidth, fMaxHeight);
- if (content != null) {
- fText.setText(content);
- TextPresentation.applyTextPresentation(fPresentation, fText);
- } else {
- fText.setText(""); //$NON-NLS-1$
- }
- }
- }
-
- /*
- * @see IInformationControl#setVisible(boolean)
- */
- public void setVisible(boolean visible) {
- fShell.setVisible(visible);
- }
-
- /*
- * @see IInformationControl#dispose()
- */
- public void dispose() {
- if (fStatusTextFont != null && !fStatusTextFont.isDisposed())
- fStatusTextFont.dispose();
-
- if (fShell != null) {
- if (!fShell.isDisposed())
- fShell.dispose();
- fShell= null;
- fText= null;
- }
- }
-
- /*
- * @see IInformationControl#setSize(int, int)
- */
- public void setSize(int width, int height) {
- fShell.setSize(width, height);
- }
-
- /*
- * @see IInformationControl#setLocation(Point)
- */
- public void setLocation(Point location) {
- Rectangle trim= fShell.computeTrim(0, 0, 0, 0);
- Point textLocation= fText.getLocation();
- location.x += trim.x - textLocation.x;
- location.y += trim.y - textLocation.y;
- fShell.setLocation(location);
- }
-
- /*
- * @see IInformationControl#setSizeConstraints(int, int)
- */
- public void setSizeConstraints(int maxWidth, int maxHeight) {
- fMaxWidth= maxWidth;
- fMaxHeight= maxHeight;
- }
-
- /*
- * @see IInformationControl#computeSizeHint()
- */
- public Point computeSizeHint() {
- return fShell.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- }
-
- /*
- * @see IInformationControl#addDisposeListener(DisposeListener)
- */
- public void addDisposeListener(DisposeListener listener) {
- fShell.addDisposeListener(listener);
- }
-
- /*
- * @see IInformationControl#removeDisposeListener(DisposeListener)
- */
- public void removeDisposeListener(DisposeListener listener) {
- fShell.removeDisposeListener(listener);
- }
-
- /*
- * @see IInformationControl#setForegroundColor(Color)
- */
- public void setForegroundColor(Color foreground) {
- fText.setForeground(foreground);
- }
-
- /*
- * @see IInformationControl#setBackgroundColor(Color)
- */
- public void setBackgroundColor(Color background) {
- fText.setBackground(background);
- }
-
- /*
- * @see IInformationControl#isFocusControl()
- */
- public boolean isFocusControl() {
- return fText.isFocusControl();
- }
-
- /*
- * @see IInformationControl#setFocus()
- */
- public void setFocus() {
- fShell.forceFocus();
- fText.setFocus();
- }
-
- /*
- * @see IInformationControl#addFocusListener(FocusListener)
- */
- public void addFocusListener(FocusListener listener) {
- fText.addFocusListener(listener);
- }
-
- /*
- * @see IInformationControl#removeFocusListener(FocusListener)
- */
- public void removeFocusListener(FocusListener listener) {
- fText.removeFocusListener(listener);
- }
-
- /*
- * @see IInformationControlExtension#hasContents()
- */
- public boolean hasContents() {
- return fText.getCharCount() > 0;
- }
-}
-
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultTextDoubleClickStrategy.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultTextDoubleClickStrategy.java
deleted file mode 100644
index 282ebff3825..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultTextDoubleClickStrategy.java
+++ /dev/null
@@ -1,218 +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.text.BreakIterator;
-import java.text.CharacterIterator;
-
-
-/**
- * Standard implementation of <code>ITextDoubleClickStrategy</code>.
- * Selects words using <code>java.text.BreakIterator</code> for the
- * default locale. This class is not intended to be subclassed.
- *
- * @see java.text.BreakIterator
- */
-public class DefaultTextDoubleClickStrategy implements ITextDoubleClickStrategy {
-
-
- /**
- * Implements a character iterator that works directly on
- * instances of <code>IDocument</code>. Used to collaborate with
- * the break iterator.
- *
- * @see IDocument
- * @since 2.0
- */
- static class DocumentCharacterIterator implements CharacterIterator {
-
- /** Document to iterate over. */
- private IDocument fDocument;
- /** Start offset of iteration. */
- private int fOffset= -1;
- /** Endoffset of iteration. */
- private int fEndOffset= -1;
- /** Current offset of iteration. */
- private int fIndex= -1;
-
- /** Creates a new document iterator. */
- public DocumentCharacterIterator() {
- }
-
- /**
- * Configures this document iterator with the document section to be iteratored.
- *
- * @param document the document to be iterated
- * @param iteratorRange the range in the document to be iterated
- */
- public void setDocument(IDocument document, IRegion iteratorRange) {
- fDocument= document;
- fOffset= iteratorRange.getOffset();
- fEndOffset= fOffset + iteratorRange.getLength();
- }
-
- /*
- * @see CharacterIterator#first()
- */
- public char first() {
- fIndex= fOffset;
- return current();
- }
-
- /*
- * @see CharacterIterator#last()
- */
- public char last() {
- fIndex= fOffset < fEndOffset ? fEndOffset -1 : fEndOffset;
- return current();
- }
-
- /*
- * @see CharacterIterator#current()
- */
- public char current() {
- if (fOffset <= fIndex && fIndex < fEndOffset) {
- try {
- return fDocument.getChar(fIndex);
- } catch (BadLocationException x) {
- }
- }
- return DONE;
- }
-
- /*
- * @see CharacterIterator#next()
- */
- public char next() {
- if (fIndex == fEndOffset -1)
- return DONE;
-
- if (fIndex < fEndOffset)
- ++ fIndex;
-
- return current();
- }
-
- /*
- * @see CharacterIterator#previous()
- */
- public char previous() {
- if (fIndex == fOffset)
- return DONE;
-
- if (fIndex > fOffset)
- -- fIndex;
-
- return current();
- }
-
- /*
- * @see CharacterIterator#setIndex(int)
- */
- public char setIndex(int index) {
- fIndex= index;
- return current();
- }
-
- /*
- * @see CharacterIterator#getBeginIndex()
- */
- public int getBeginIndex() {
- return fOffset;
- }
-
- /*
- * @see CharacterIterator#getEndIndex()
- */
- public int getEndIndex() {
- return fEndOffset;
- }
-
- /*
- * @see CharacterIterator#getIndex()
- */
- public int getIndex() {
- return fIndex;
- }
-
- /*
- * @see CharacterIterator#clone()
- */
- public Object clone() {
- DocumentCharacterIterator i= new DocumentCharacterIterator();
- i.fDocument= fDocument;
- i.fIndex= fIndex;
- i.fOffset= fOffset;
- i.fEndOffset= fEndOffset;
- return i;
- }
- }
-
-
- /**
- * The document character iterator used by this strategy.
- * @since 2.0
- */
- private DocumentCharacterIterator fDocIter= new DocumentCharacterIterator();
-
-
- /**
- * Creates a new default text double click strategy.
- */
- public DefaultTextDoubleClickStrategy() {
- super();
- }
-
- /*
- * @see ITextDoubleClickStrategy#doubleClicked
- */
- public void doubleClicked(ITextViewer text) {
-
- int position= text.getSelectedRange().x;
-
- if (position < 0)
- return;
-
- try {
-
- IDocument document= text.getDocument();
- IRegion line= document.getLineInformationOfOffset(position);
- if (position == line.getOffset() + line.getLength())
- return;
-
- fDocIter.setDocument(document, line);
-
- BreakIterator breakIter= BreakIterator.getWordInstance();
- breakIter.setText(fDocIter);
-
- int start= breakIter.preceding(position);
- if (start == BreakIterator.DONE)
- start= line.getOffset();
-
- int end= breakIter.following(position);
- if (end == BreakIterator.DONE)
- end= line.getOffset() + line.getLength();
-
- if (breakIter.isBoundary(position)) {
- if (end - position > position- start)
- start= position;
- else
- end= position;
- }
-
- if (start != end)
- text.setSelectedRange(start, end - start);
-
- } catch (BadLocationException x) {
- }
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultUndoManager.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultUndoManager.java
deleted file mode 100644
index a49d54f6cd2..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultUndoManager.java
+++ /dev/null
@@ -1,810 +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.List;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-
-
-/**
- * Standard implementation of <code>IUndoManager</code>.
- * It registers with the connected text viewer as text listeners and logs all changes.
- * It also monitors mouse and keyboard activities in order to partition the stream of
- * text changes into undoable edit commands. <p>
- * This class is not intended to be subclassed.
- *
- * @see ITextViewer
- * @see ITextListener
- * @see MouseListener
- * @see KeyListener
- */
-public class DefaultUndoManager implements IUndoManager {
-
- /**
- * Represents an undoable edit command.
- */
- class TextCommand {
-
- /** The start index of the replaced text */
- protected int fStart= -1;
- /** The end index of the replaced text */
- protected int fEnd= -1;
- /** The newly inserted text */
- protected String fText;
- /** The replaced text */
- protected String fPreservedText;
-
- /**
- * Reinitializes this text command.
- */
- protected void reinitialize() {
- fStart= fEnd= -1;
- fText= fPreservedText= null;
- }
-
- /**
- * Sets the start and the end index of this command.
- *
- * @param start the start index
- * @param end the end index
- */
- protected void set(int start, int end) {
- fStart= start;
- fEnd= end;
- fText= null;
- fPreservedText= null;
- }
-
- /**
- * Undo the change described by this command.
- *
- * @param text the text widget to be modified
- * @since 2.0
- */
- protected void undoTextChange(StyledText text) {
- text.replaceTextRange(fStart, fText.length(), fPreservedText);
- }
-
- /**
- * Undo the change described by this command. Also selects and
- * reveals the change.
- *
- * @param text the text widget to be modified
- */
- protected void undo(StyledText text) {
- undoTextChange(text);
- IRegion modelRange= widgetRange2ModelRange(fStart, fPreservedText == null ? 0 : fPreservedText.length());
- fTextViewer.setSelectedRange(modelRange.getOffset(), modelRange.getLength());
- fTextViewer.revealRange(modelRange.getOffset(), modelRange.getLength());
- }
-
- /**
- * Redo the change described by this command.
- *
- * @param text the text widget to be modified
- * @since 2.0
- */
- protected void redoTextChange(StyledText text) {
- text.replaceTextRange(fStart, fEnd - fStart, fText);
- }
-
- /**
- * Redo the change described by this command that previously been
- * rolled back. Also selects and reveals the change.
- *
- * @param text the text widget to be modified
- */
- protected void redo(StyledText text) {
- redoTextChange(text);
- IRegion modelRange= widgetRange2ModelRange(fStart, fText == null ? 0 : fText.length());
- fTextViewer.setSelectedRange(modelRange.getOffset(), modelRange.getLength());
- fTextViewer.revealRange(modelRange.getOffset(), modelRange.getLength());
- }
-
- /**
- * Translates a given widget range into the corresponding range of the source viewer's input document.
- *
- * @param offset the offset of the widget range
- * @param length the length of the widget range
- * @return the corresponding model range
- * @since 2.1
- */
- protected IRegion widgetRange2ModelRange(int offset, int length) {
- if (fTextViewer instanceof ITextViewerExtension3) {
- ITextViewerExtension3 extension= (ITextViewerExtension3) fTextViewer;
- return extension.widgetRange2ModelRange(new Region(offset, length));
- }
-
- IRegion visible= fTextViewer.getVisibleRegion();
- return new Region(offset + visible.getOffset(), length);
- }
-
- /**
- * Updates the command stack in response to committing
- * the current change into this command.
- */
- protected void updateCommandStack() {
-
- int length= fCommandStack.size();
- for (int i= fCommandCounter + 1; i < length; i++)
- fCommandStack.remove(fCommandCounter + 1);
-
- fCommandStack.add(this);
-
- while (fCommandStack.size() > fUndoLevel)
- fCommandStack.remove(0);
-
- fCommandCounter= fCommandStack.size() - 1;
- }
-
- /**
- * Creates a new uncommitted text command depending on whether
- * a compound change is currently being executed.
- *
- * @return a new, uncommitted text command or a compound text command
- */
- protected TextCommand createCurrent() {
- return fFoldingIntoCompoundChange ? new CompoundTextCommand() : new TextCommand();
- }
-
- /**
- * Commits the current change into this command.
- */
- protected void commit() {
-
- if (fStart < 0) {
- reinitialize();
- } else {
-
- fText= fTextBuffer.toString();
- fTextBuffer.setLength(0);
- fPreservedText= fPreservedTextBuffer.toString();
- fPreservedTextBuffer.setLength(0);
-
- updateCommandStack();
- }
-
- fCurrent= createCurrent();
- }
- }
-
- /**
- * Represents an undoable edit command consisting of several
- * individual edit commands.
- */
- class CompoundTextCommand extends TextCommand {
-
- /** The list of individual commands */
- private List fCommands= new ArrayList();
-
- /**
- * Adds a new individual command to this compound command.
- *
- * @param command the command to be added
- */
- protected void add(TextCommand command) {
- fCommands.add(command);
- }
-
- /*
- * @see TextCommand#undo
- */
- protected void undo(StyledText text) {
- ITextViewerExtension extension= null;
- if (fTextViewer instanceof ITextViewerExtension)
- extension= (ITextViewerExtension) fTextViewer;
-
- if (extension != null)
- extension.setRedraw(false);
-
- try {
-
- int size= fCommands.size();
- if (size > 0) {
-
- TextCommand c;
-
- for (int i= size -1; i > 0; --i) {
- c= (TextCommand) fCommands.get(i);
- c.undoTextChange(text);
- }
-
- c= (TextCommand) fCommands.get(0);
- c.undo(text);
- }
-
- } finally {
- if (extension != null)
- extension.setRedraw(true);
- }
- }
-
- /*
- * @see TextCommand#redo
- */
- protected void redo(StyledText text) {
-
- ITextViewerExtension extension= null;
- if (fTextViewer instanceof ITextViewerExtension)
- extension= (ITextViewerExtension) fTextViewer;
-
- if (extension != null)
- extension.setRedraw(false);
-
- try {
-
- int size= fCommands.size();
- if (size > 0) {
-
- TextCommand c;
-
- for (int i= 0; i < size -1; ++i) {
- c= (TextCommand) fCommands.get(i);
- c.redoTextChange(text);
- }
-
- c= (TextCommand) fCommands.get(size -1);
- c.redo(text);
- }
-
- } finally {
- if (extension != null)
- extension.setRedraw(true);
- }
- }
-
- /*
- * @see TextCommand#updateCommandStack
- */
- protected void updateCommandStack() {
- TextCommand c= new TextCommand();
- c.fStart= fStart;
- c.fEnd= fEnd;
- c.fText= fText;
- c.fPreservedText= fPreservedText;
-
- add(c);
-
- if (!fFoldingIntoCompoundChange)
- super.updateCommandStack();
- }
-
- /*
- * @see TextCommand#createCurrent
- */
- protected TextCommand createCurrent() {
-
- if (!fFoldingIntoCompoundChange)
- return new TextCommand();
-
- reinitialize();
- return this;
- }
-
- /*
- * @see org.eclipse.jface.text.DefaultUndoManager.TextCommand#commit()
- */
- protected void commit() {
- if (fStart < 0) {
- if (fCommands.size() > 0 && !fFoldingIntoCompoundChange) {
- super.updateCommandStack();
- fCurrent= createCurrent();
- return;
- }
- }
- super.commit();
- }
- }
-
- /**
- * Represents pretended <code>UndoManager</code> state.
- */
- class PretendedUndoManagerState {
- /** The counter in the undo stack */
- protected int cmdCounter= -1;
- /** The size of the undo stack */
- protected int stackSize= -1;
- }
-
- /**
- * Internal listener to mouse and key events.
- */
- class KeyAndMouseListener implements MouseListener, KeyListener {
-
- /*
- * @see MouseListener#mouseDoubleClick
- */
- public void mouseDoubleClick(MouseEvent e) {
- }
-
- /*
- * If the right mouse button is pressed, the current editing command is closed
- * @see MouseListener#mouseDown
- */
- public void mouseDown(MouseEvent e) {
- if (e.button == 1)
- commit();
- }
-
- /*
- * @see MouseListener#mouseUp
- */
- public void mouseUp(MouseEvent e) {
- }
-
- /*
- * @see KeyListener#keyPressed
- */
- public void keyReleased(KeyEvent e) {
- }
-
- /*
- * On cursor keys, the current editing command is closed
- * @see KeyListener#keyPressed
- */
- public void keyPressed(KeyEvent e) {
- switch (e.keyCode) {
- case SWT.ARROW_UP:
- case SWT.ARROW_DOWN:
- case SWT.ARROW_LEFT:
- case SWT.ARROW_RIGHT:
- commit();
- break;
- }
- }
- }
-
- /**
- * Internal listener to text changes.
- */
- class TextListener implements ITextListener {
-
- /*
- * @see ITextListener#textChanged
- */
- public void textChanged(TextEvent e) {
- if (e.getDocumentEvent() != null)
- processTextEvent(e);
- }
- }
-
- /** Text buffer to collect text which is inserted into the viewer */
- private StringBuffer fTextBuffer= new StringBuffer();
- /** Text buffer to collect viewer content which has been replaced */
- private StringBuffer fPreservedTextBuffer= new StringBuffer();
- /** Pretended undo manager state */
- private PretendedUndoManagerState fPretendedState= new PretendedUndoManagerState();
-
- /** The internal text listener */
- private ITextListener fTextListener;
- /** The internal key and mouse event listener */
- private KeyAndMouseListener fKeyAndMouseListener;
-
-
- /** Indicates inserting state */
- private boolean fInserting= false;
- /** Indicates overwriting state */
- private boolean fOverwriting= false;
- /** Indicates whether the current change belongs to a compound change */
- private boolean fFoldingIntoCompoundChange= false;
-
- /** The text viewer the undo manager is connected to */
- private ITextViewer fTextViewer;
-
- /** Supported undo level */
- private int fUndoLevel;
- /** The list of undoable edit commands */
- private List fCommandStack;
- /** The currently constructed edit command */
- private TextCommand fCurrent;
- /** The last delete edit command */
- private TextCommand fPreviousDelete;
- /** Command counter into the edit command stack */
- private int fCommandCounter= -1;
-
-
- /**
- * Creates a new undo manager who remembers the specified number of edit commands.
- *
- * @param undoLevel the length of this manager's history
- */
- public DefaultUndoManager(int undoLevel) {
- setMaximalUndoLevel(undoLevel);
- }
-
- /*
- * @see IUndoManager#beginCompoundChange
- */
- public void beginCompoundChange() {
- fFoldingIntoCompoundChange= true;
- commit();
- }
-
- /*
- * @see IUndoManager#endCompoundChange
- */
- public void endCompoundChange() {
- fFoldingIntoCompoundChange= false;
- commit();
- }
-
- /**
- * Registers all necessary listeners with the text viewer.
- */
- private void addListeners() {
- StyledText text= fTextViewer.getTextWidget();
- if (text != null) {
- fKeyAndMouseListener= new KeyAndMouseListener();
- text.addMouseListener(fKeyAndMouseListener);
- text.addKeyListener(fKeyAndMouseListener);
- listenToTextChanges(true);
- }
- }
-
- /**
- * Deregister all previously installed listeners from the text viewer.
- */
- private void removeListeners() {
- StyledText text= fTextViewer.getTextWidget();
- if (text != null && fKeyAndMouseListener != null) {
- text.removeMouseListener(fKeyAndMouseListener);
- text.removeKeyListener(fKeyAndMouseListener);
- listenToTextChanges(false);
- }
- }
-
- /**
- * Switches the state of whether there is a text listener or not.
- *
- * @param listen the state which should be established
- */
- private void listenToTextChanges(boolean listen) {
- if (listen && fTextListener == null) {
- fTextListener= new TextListener();
- fTextViewer.addTextListener(fTextListener);
- } else if (!listen && fTextListener != null) {
- fTextViewer.removeTextListener(fTextListener);
- fTextListener= null;
- }
- }
-
- /**
- * Closes the current editing command and opens a new one.
- */
- private void commit() {
-
- fInserting= false;
- fOverwriting= false;
- fPreviousDelete.reinitialize();
-
- fCurrent.commit();
- }
-
- /**
- * Does redo the previously undone editing command.
- */
- private void internalRedo() {
- StyledText text= fTextViewer.getTextWidget();
- if (text != null) {
-
- ++fCommandCounter;
- TextCommand cmd= (TextCommand) fCommandStack.get(fCommandCounter);
-
- listenToTextChanges(false);
- cmd.redo(text);
- listenToTextChanges(true);
-
- fCurrent= new TextCommand();
- }
- }
-
- /**
- * Does undo the last editing command.
- */
- private void internalUndo() {
- StyledText text= fTextViewer.getTextWidget();
- if (text != null) {
-
- TextCommand cmd= (TextCommand) fCommandStack.get(fCommandCounter);
- -- fCommandCounter;
-
- listenToTextChanges(false);
- cmd.undo(text);
- listenToTextChanges(true);
-
- fCurrent= new TextCommand();
- }
- }
-
- /**
- * Checks whether the given text starts with a line delimiter and
- * subsequently contains a white space only.
- *
- * @param text the text to check
- */
- private boolean isWhitespaceText(String text) {
-
- if (text == null || text.length() == 0)
- return false;
-
- String[] delimiters= fTextViewer.getDocument().getLegalLineDelimiters();
- int index= TextUtilities.startsWith(delimiters, text);
- if (index > -1) {
- char c;
- int length= text.length();
- for (int i= delimiters[index].length(); i < length; i++) {
- c= text.charAt(i);
- if (c != ' ' && c != '\t')
- return false;
- }
- return true;
- }
-
- return false;
- }
-
- /**
- * Returns the state the would result if the current editing command would be closed.
- *
- * @return the pretended state after closing the current editing command
- */
- private PretendedUndoManagerState pretendCommit() {
- if (fCurrent.fStart < 0) {
- fPretendedState.stackSize= fCommandStack.size();
- fPretendedState.cmdCounter= fCommandCounter;
- } else {
- int sz= Math.max(fCommandCounter, 0) + 1;
- if (sz > fUndoLevel)
- sz -= fUndoLevel;
- fPretendedState.stackSize= sz;
- fPretendedState.cmdCounter= sz - 1;
- }
- return fPretendedState;
- }
-
- /**
- * Processes the given text event in order to determine editor command.
- *
- * @param e the text event
- */
- private void processTextEvent(TextEvent e) {
-
- int start= e.getOffset();
- int end= e.getOffset() + e.getLength();
- String newText= e.getText();
- String oldText= e.getReplacedText();
-
-
- if (newText == null)
- newText= ""; //$NON-NLS-1$
-
- if (oldText == null)
- oldText= ""; //$NON-NLS-1$
-
- int length= newText.length();
- int diff= end - start;
-
- // normalize verify command
- if (diff < 0) {
- int tmp= end;
- end= start;
- start= tmp;
- diff= -diff;
- }
-
- if (start == end) {
- // text will be inserted
- if ((length == 1) || isWhitespaceText(newText)) {
- // by typing or model manipulation
- if (!fInserting || (start != fCurrent.fStart + fTextBuffer.length())) {
- commit();
- fInserting= true;
- }
- if (fCurrent.fStart < 0)
- fCurrent.fStart= fCurrent.fEnd= start;
- if (length > 0)
- fTextBuffer.append(newText);
- } else if (length > 0) {
- // by pasting
- commit();
- fCurrent.fStart= fCurrent.fEnd= start;
- fTextBuffer.append(newText);
- commit();
- }
- } else {
- if (length == 0) {
- // text will be deleted by backspace or DEL key or empty clipboard
- length= oldText.length();
- String[] delimiters= fTextViewer.getDocument().getLegalLineDelimiters();
-
- if ((length == 1) || TextUtilities.equals(delimiters, oldText) > -1) {
-
- // whereby selection is empty
-
- if (fPreviousDelete.fStart == start && fPreviousDelete.fEnd == end) {
- // repeated DEL
-
- // correct wrong settings of fCurrent
- if (fCurrent.fStart == end && fCurrent.fEnd == start) {
- fCurrent.fStart= start;
- fCurrent.fEnd= end;
- }
- // append to buffer && extend command range
- fPreservedTextBuffer.append(oldText);
- ++fCurrent.fEnd;
-
- } else if (fPreviousDelete.fStart == end) {
- // repeated backspace
-
- // insert in buffer and extend command range
- fPreservedTextBuffer.insert(0, oldText);
- fCurrent.fStart= start;
-
- } else {
- // either DEL or backspace for the first time
-
- commit();
-
- // as we can not decide whether it was DEL or backspace we initialize for backspace
- fPreservedTextBuffer.append(oldText);
- fCurrent.fStart= start;
- fCurrent.fEnd= end;
- }
-
- fPreviousDelete.set(start, end);
-
- } else if (length > 0) {
- // whereby selection is not empty
- commit();
- fCurrent.fStart= start;
- fCurrent.fEnd= end;
- fPreservedTextBuffer.append(oldText);
- }
- } else {
- // text will be replaced
-
- if (length == 1) {
- length= oldText.length();
- String[] delimiters= fTextViewer.getDocument().getLegalLineDelimiters();
-
- if ((length == 1) || TextUtilities.equals(delimiters, oldText) > -1) {
- // because of overwrite mode or model manipulation
- if (!fOverwriting || (start != fCurrent.fStart + fTextBuffer.length())) {
- commit();
- fOverwriting= true;
- }
-
- if (fCurrent.fStart < 0)
- fCurrent.fStart= start;
-
- fCurrent.fEnd= end;
- fTextBuffer.append(newText);
- fPreservedTextBuffer.append(oldText);
- return;
- }
- }
- // because of typing or pasting whereby selection is not empty
- commit();
- fCurrent.fStart= start;
- fCurrent.fEnd= end;
- fTextBuffer.append(newText);
- fPreservedTextBuffer.append(oldText);
- }
- }
- }
-
- /*
- * @see IUndoManager#setMaximalUndoLevel
- */
- public void setMaximalUndoLevel(int undoLevel) {
- fUndoLevel= undoLevel;
- }
-
- /*
- * @see IUndoManager#connect
- */
- public void connect(ITextViewer textViewer) {
- if (fTextViewer == null) {
- fTextViewer= textViewer;
- fCommandStack= new ArrayList();
- fCurrent= new TextCommand();
- fPreviousDelete= new TextCommand();
- addListeners();
- }
- }
-
- /*
- * @see IUndoManager#disconnect
- */
- public void disconnect() {
- if (fTextViewer != null) {
-
- removeListeners();
-
- fCurrent= null;
- if (fCommandStack != null) {
- fCommandStack.clear();
- fCommandStack= null;
- }
- fTextBuffer= null;
- fPreservedTextBuffer= null;
- fTextViewer= null;
- }
- }
-
- /*
- * @see IUndoManager#reset
- */
- public void reset() {
- if (fCommandStack != null)
- fCommandStack.clear();
- fCommandCounter= -1;
- if (fCurrent != null)
- fCurrent.reinitialize();
- fFoldingIntoCompoundChange= false;
- fInserting= false;
- fOverwriting= false;
- fTextBuffer.setLength(0);
- fPreservedTextBuffer.setLength(0);
- }
-
- /*
- * @see IUndoManager#redoable
- */
- public boolean redoable() {
- if (fCommandStack != null) {
- PretendedUndoManagerState s= pretendCommit();
- return (0 <= s.cmdCounter + 1) && (s.cmdCounter + 1 < s.stackSize);
- }
- return false;
- }
-
- /*
- * @see IUndoManager#undoable
- */
- public boolean undoable() {
- if (fCommandStack != null) {
- PretendedUndoManagerState s= pretendCommit();
- return (0 <= s.cmdCounter) && (s.cmdCounter < s.stackSize);
- }
- return false;
- }
-
- /*
- * @see IUndoManager#redo
- */
- public void redo() {
- if (redoable()) {
- commit();
- internalRedo();
- }
- }
-
- /*
- * @see IUndoManager#undo
- */
- public void undo() {
- if (undoable()) {
- fFoldingIntoCompoundChange= false;
- commit();
- internalUndo();
- }
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/DocumentAdapter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/DocumentAdapter.java
deleted file mode 100644
index f3ff19f92c4..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/DocumentAdapter.java
+++ /dev/null
@@ -1,361 +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.Iterator;
-import java.util.List;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.TextChangeListener;
-import org.eclipse.swt.custom.TextChangedEvent;
-import org.eclipse.swt.custom.TextChangingEvent;
-
-
-/**
- * Adapts an <code>IDocument</code> to the <code>StyledTextContent</code> interface.
- */
-class DocumentAdapter implements IDocumentAdapter, IDocumentListener, IDocumentAdapterExtension {
-
- /** The adapted document. */
- private IDocument fDocument;
- /** The registered text change listeners */
- private List fTextChangeListeners= new ArrayList(1);
- /**
- * The remembered document event
- * @since 2.0
- */
- private DocumentEvent fEvent;
- /** The line delimiter */
- private String fLineDelimiter= null;
- /**
- * Indicates whether this adapter is forwarding document changes
- * @since 2.0
- */
- private boolean fIsForwarding= true;
- /**
- * Length of document at receipt of <code>documentAboutToBeChanged</code>
- * @since 2.1
- */
- private int fRememberedLengthOfDocument;
- /**
- * Length of first document line at receipt of <code>documentAboutToBeChanged</code>
- * @since 2.1
- */
- private int fRememberedLengthOfFirstLine;
- /**
- * The data of the event at receipt of <code>documentAboutToBeChanged</code>
- * @since 2.1
- */
- private DocumentEvent fOriginalEvent= new DocumentEvent();
-
-
- /**
- * Creates a new document adapter which is initiallly not connected to
- * any document.
- */
- public DocumentAdapter() {
- }
-
- /**
- * Sets the given document as the document to be adapted.
- *
- * @param document the document to be adapted or <code>null</code> if there is no document
- */
- public void setDocument(IDocument document) {
-
- if (fDocument != null)
- fDocument.removePrenotifiedDocumentListener(this);
-
- fDocument= document;
- fLineDelimiter= null;
-
- if (fDocument != null)
- fDocument.addPrenotifiedDocumentListener(this);
- }
-
- /*
- * @see StyledTextContent#addTextChangeListener(TextChangeListener)
- */
- public void addTextChangeListener(TextChangeListener listener) {
- Assert.isNotNull(listener);
- if (! fTextChangeListeners.contains(listener))
- fTextChangeListeners.add(listener);
- }
-
- /*
- * @see StyledTextContent#removeTextChangeListener(TextChangeListener)
- */
- public void removeTextChangeListener(TextChangeListener listener) {
- Assert.isNotNull(listener);
- fTextChangeListeners.remove(listener);
- }
-
- private void repairLineInformation() {
- if (fDocument instanceof IRepairableDocument) {
- IRepairableDocument repairable= (IRepairableDocument) fDocument;
- repairable.repairLineInformation();
- }
- }
-
- private String doGetLine(int line) throws BadLocationException {
- IRegion r= fDocument.getLineInformation(line);
- return fDocument.get(r.getOffset(), r.getLength());
- }
-
- /*
- * @see StyledTextContent#getLine(int)
- */
- public String getLine(int line) {
- try {
- return doGetLine(line);
- } catch (BadLocationException x) {
- repairLineInformation();
- try {
- return doGetLine(line);
- } catch (BadLocationException x2) {
- }
- }
-
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- return null;
- }
-
- /*
- * @see StyledTextContent#getLineAtOffset(int)
- */
- public int getLineAtOffset(int offset) {
- try {
- return fDocument.getLineOfOffset(offset);
- } catch (BadLocationException x) {
- repairLineInformation();
- try {
- return fDocument.getLineOfOffset(offset);
- } catch (BadLocationException x2) {
- }
- }
-
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- return -1;
- }
-
- /*
- * @see StyledTextContent#getLineCount()
- */
- public int getLineCount() {
- return fDocument.getNumberOfLines();
- }
-
- /*
- * @see StyledTextContent#getOffsetAtLine(int)
- */
- public int getOffsetAtLine(int line) {
- try {
- return fDocument.getLineOffset(line);
- } catch (BadLocationException x) {
- repairLineInformation();
- try {
- return fDocument.getLineOffset(line);
- } catch (BadLocationException x2) {
- }
- }
-
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- return -1;
- }
-
- /*
- * @see StyledTextContent#getTextRange(int, int)
- */
- public String getTextRange(int offset, int length) {
- try {
- return fDocument.get(offset, length);
- } catch (BadLocationException x) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- return null;
- }
- }
-
- /*
- * @see StyledTextContent#replaceTextRange(int, int, String)
- */
- public void replaceTextRange(int pos, int length, String text) {
- try {
- fDocument.replace(pos, length, text);
- } catch (BadLocationException x) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- }
-
- /*
- * @see StyledTextContent#setText(String)
- */
- public void setText(String text) {
- fDocument.set(text);
- }
-
- /*
- * @see StyledTextContent#getCharCount()
- */
- public int getCharCount() {
- return fDocument.getLength();
- }
-
- /*
- * @see StyledTextContent#getLineDelimiter()
- */
- public String getLineDelimiter() {
- if (fLineDelimiter == null)
- fLineDelimiter= TextUtilities.getDefaultLineDelimiter(fDocument);
- return fLineDelimiter;
- }
-
- /*
- * @see IDocumentListener#documentChanged(DocumentEvent)
- */
- public void documentChanged(DocumentEvent event) {
- // check whether the given event is the one which was remembered
- if (fEvent == null || event != fEvent)
- return;
-
- if (isPatchedEvent(event) || (event.getOffset() == 0 && event.getLength() == fRememberedLengthOfDocument)) {
- fLineDelimiter= null;
- fireTextSet();
- } else {
- if (event.getOffset() < fRememberedLengthOfFirstLine)
- fLineDelimiter= null;
- fireTextChanged();
- }
- }
-
- /*
- * @see IDocumentListener#documentAboutToBeChanged(DocumentEvent)
- */
- public void documentAboutToBeChanged(DocumentEvent event) {
-
- fRememberedLengthOfDocument= fDocument.getLength();
- try {
- fRememberedLengthOfFirstLine= fDocument.getLineLength(0);
- } catch (BadLocationException e) {
- fRememberedLengthOfFirstLine= -1;
- }
-
- fEvent= event;
- rememberEventData(fEvent);
- fireTextChanging();
- }
-
- /**
- * Checks whether this event has been changed between <code>documentAboutToBeChanged</code> and
- * <code>documentChanged</code>.
- *
- * @param event the event to be checked
- * @return <code>true</code> if the event has been changed, <code>false</code> otherwise
- */
- private boolean isPatchedEvent(DocumentEvent event) {
- return fOriginalEvent.fOffset != event.fOffset || fOriginalEvent.fLength != event.fLength || fOriginalEvent.fText != event.fText;
- }
-
- /**
- * Makes a copy of the given event and remembers it.
- *
- * @param event the event to be copied
- */
- private void rememberEventData(DocumentEvent event) {
- fOriginalEvent.fOffset= event.fOffset;
- fOriginalEvent.fLength= event.fLength;
- fOriginalEvent.fText= event.fText;
- }
-
- /**
- * Sends a text changed event to all registered listeners.
- */
- private void fireTextChanged() {
-
- if (!fIsForwarding)
- return;
-
- TextChangedEvent event= new TextChangedEvent(this);
-
- if (fTextChangeListeners != null && fTextChangeListeners.size() > 0) {
- Iterator e= new ArrayList(fTextChangeListeners).iterator();
- while (e.hasNext())
- ((TextChangeListener) e.next()).textChanged(event);
- }
- }
-
- /**
- * Sends a text set event to all registered listeners.
- */
- private void fireTextSet() {
-
- if (!fIsForwarding)
- return;
-
- TextChangedEvent event = new TextChangedEvent(this);
-
- if (fTextChangeListeners != null && fTextChangeListeners.size() > 0) {
- Iterator e= new ArrayList(fTextChangeListeners).iterator();
- while (e.hasNext())
- ((TextChangeListener) e.next()).textSet(event);
- }
- }
-
- /**
- * Sends the text changing event to all registered listeners.
- */
- private void fireTextChanging() {
-
- if (!fIsForwarding)
- return;
-
- try {
- IDocument document= fEvent.getDocument();
- if (document == null)
- return;
-
- TextChangingEvent event= new TextChangingEvent(this);
- event.start= fEvent.fOffset;
- event.replaceCharCount= fEvent.fLength;
- event.replaceLineCount= document.getNumberOfLines(fEvent.fOffset, fEvent.fLength) - 1;
- event.newText= fEvent.fText;
- event.newCharCount= (fEvent.fText == null ? 0 : fEvent.fText.length());
- event.newLineCount= (fEvent.fText == null ? 0 : document.computeNumberOfLines(fEvent.fText));
-
- if (fTextChangeListeners != null && fTextChangeListeners.size() > 0) {
- Iterator e= new ArrayList(fTextChangeListeners).iterator();
- while (e.hasNext())
- ((TextChangeListener) e.next()).textChanging(event);
- }
-
- } catch (BadLocationException e) {
- }
- }
-
- /*
- * @see IDocumentAdapterExtension#resumeForwardingDocumentChanges()
- * @since 2.0
- */
- public void resumeForwardingDocumentChanges() {
- fIsForwarding= true;
- fireTextSet();
- }
-
- /*
- * @see IDocumentAdapterExtension#stopForwardingDocumentChanges()
- * @since 2.0
- */
- public void stopForwardingDocumentChanges() {
- fIsForwarding= false;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/DocumentCommand.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/DocumentCommand.java
deleted file mode 100644
index 70162d6009c..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/DocumentCommand.java
+++ /dev/null
@@ -1,450 +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.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.NoSuchElementException;
-
-import org.eclipse.swt.events.VerifyEvent;
-
-
-/**
- * Represents a text modification as a document replace command. The text modification is given
- * as a <code>VerifyEvent</code> and translated into a document replace command relative
- * to a given offset. A document command can also be used to initialize a given <code>VerifyEvent</code>.<p>
- * A document command can also represent a list of related changes.
- */
-public class DocumentCommand {
-
- /**
- * A command which is added to document commands.
- * @since 2.1
- */
- private static class Command implements Comparable {
- /** The offset of the range to be replaced */
- private final int fOffset;
- /** The length of the range to be replaced. */
- private final int fLength;
- /** The replacement text */
- private final String fText;
- /** The listern who owns this command */
- private final IDocumentListener fOwner;
- /**
- * Indicates whether the caret should be shifted.
- * @since 3.0
- */
- private final boolean fShiftsCaret;
-
- /**
- * Creates a new command with the given specification.
- *
- * @param offset the offset of the replace command
- * @param length the length of the replace command
- * @param text the text to replace with, may be <code>null</code>
- * @param shiftsCaret <code>true</code> if caret should be shifted by this command
- * @param owner the document command owner, may be <code>null</code>
- * @since 3.0
- */
- public Command(int offset, int length, String text, boolean shiftsCaret, IDocumentListener owner) {
- if (offset < 0 || length < 0)
- throw new IllegalArgumentException();
- fOffset= offset;
- fLength= length;
- fText= text;
- fShiftsCaret= shiftsCaret;
- fOwner= owner;
- }
-
- /**
- * Returns the length delta for this command.
- *
- * @return the length delta for this command
- */
- public int getDeltaLength() {
- return (fText == null ? 0 : fText.length()) - fLength;
- }
-
- /**
- * Executes the document command on the specified document.
- *
- * @param document the document on which to execute the command.
- * @throws BadLocationException in case this commands cannot be executed
- */
- public void execute(IDocument document) throws BadLocationException {
-
- if (fLength == 0 && fText == null)
- return;
-
- if (fOwner != null)
- document.removeDocumentListener(fOwner);
-
- document.replace(fOffset, fLength, fText);
-
- if (fOwner != null)
- document.addDocumentListener(fOwner);
- }
-
- /*
- * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
- */
- public int compareTo(final Object object) {
- if (equals(object))
- return 0;
-
- final Command command= (Command) object;
-
- // diff middle points if not intersecting
- if (fOffset + fLength <= command.fOffset || command.fOffset + command.fLength <= fOffset) {
- int value= (2 * fOffset + fLength) - (2 * command.fOffset + command.fLength);
- if (value != 0)
- return value;
- }
- // the answer
- return 42;
- }
-
- /*
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object object) {
- if (object == this)
- return true;
- if (! (object instanceof Command))
- return false;
- final Command command= (Command) object;
- return command.fOffset == fOffset && command.fLength == fLength;
- }
- }
-
- /**
- * An iterator, which iterates in reverse over a list.
- */
- private static class ReverseListIterator implements Iterator {
-
- /** The list iterator. */
- private final ListIterator fListIterator;
-
- /**
- * Creates a reverse list iterator.
- */
- public ReverseListIterator(ListIterator listIterator) {
- if (listIterator == null)
- throw new IllegalArgumentException();
- fListIterator= listIterator;
- }
-
- /*
- * @see java.util.Iterator#hasNext()
- */
- public boolean hasNext() {
- return fListIterator.hasPrevious();
- }
-
- /*
- * @see java.util.Iterator#next()
- */
- public Object next() {
- return fListIterator.previous();
- }
-
- /*
- * @see java.util.Iterator#remove()
- */
- public void remove() {
- throw new UnsupportedOperationException();
- }
- }
-
- /**
- * A command iterator.
- */
- private static class CommandIterator implements Iterator {
-
- /** The command iterator. */
- private final Iterator fIterator;
-
- /** The original command. */
- private Command fCommand;
-
- /** A flag indicating the direction of iteration. */
- private boolean fForward;
-
- /**
- * Creates a command iterator.
- *
- * @param commands an ascending ordered list of commands
- * @param command the original command
- * @param forward the direction
- */
- public CommandIterator(final List commands, final Command command, final boolean forward) {
- if (commands == null || command == null)
- throw new IllegalArgumentException();
- fIterator= forward ? commands.iterator() : new ReverseListIterator(commands.listIterator(commands.size()));
- fCommand= command;
- fForward= forward;
- }
-
- /*
- * @see java.util.Iterator#hasNext()
- */
- public boolean hasNext() {
- return fCommand != null || fIterator.hasNext();
- }
-
- /*
- * @see java.util.Iterator#next()
- */
- public Object next() {
-
- if (! hasNext())
- throw new NoSuchElementException();
-
- if (fCommand == null)
- return fIterator.next();
-
- if (!fIterator.hasNext()) {
- final Command tempCommand= fCommand;
- fCommand= null;
- return tempCommand;
- }
-
- final Command command= (Command) fIterator.next();
- final int compareValue= command.compareTo(fCommand);
-
- if ((compareValue < 0) ^ ! fForward) {
- return command;
-
- } else if ((compareValue > 0) ^ ! fForward) {
- final Command tempCommand= fCommand;
- fCommand= command;
- return tempCommand;
-
- } else {
- throw new IllegalArgumentException();
- }
- }
-
- /*
- * @see java.util.Iterator#remove()
- */
- public void remove() {
- throw new UnsupportedOperationException();
- }
- }
-
- /** Must the command be updated */
- public boolean doit= false;
- /** The offset of the command. */
- public int offset;
- /** The length of the command */
- public int length;
- /** The text to be inserted */
- public String text;
- /**
- * The owner of the document command which will not be notified.
- * @since 2.1
- */
- public IDocumentListener owner;
- /**
- * The caret offset with respect to the document before the document command is executed.
- * @since 2.1
- */
- public int caretOffset;
- /**
- * Additional document commands.
- * @since 2.1
- */
- private final List fCommands= new ArrayList();
- /**
- * Indicates whether the caret should be shifted by this command.
- * @since 3.0
- */
- public boolean shiftsCaret;
-
-
- /**
- * Creates a new document command.
- */
- protected DocumentCommand() {
- }
-
- /**
- * Translates a verify event into a document replace command using the given offset.
- *
- * @param event the event to be translated
- * @param modelRange the event range as model range
- */
- void setEvent(VerifyEvent event, IRegion modelRange) {
-
- doit= true;
- text= event.text;
-
- offset= modelRange.getOffset();
- length= modelRange.getLength();
-
- owner= null;
- caretOffset= -1;
- shiftsCaret= true;
- fCommands.clear();
- }
-
- /**
- * Fills the given verify event with the replace text and the doit
- * flag of this document command. Returns whether the document command
- * covers the same range as the verify event considering the given offset.
- *
- * @param event the event to be changed
- * @param modelRange to be considered for range comparison
- * @return <code>true</code> if this command and the event cover the same range
- */
- boolean fillEvent(VerifyEvent event, IRegion modelRange) {
- event.text= text;
- event.doit= (offset == modelRange.getOffset() && length == modelRange.getLength() && doit && caretOffset == -1);
- return event.doit;
- }
-
- /**
- * Adds an additional replace command. The added replace command must not overlap
- * with existing ones. If the document command owner is not <code>null</code>, it will not
- * get document change notifications for the particular command.
- *
- * @param offset the offset of the region to replace
- * @param length the length of the region to replace
- * @param text the text to replace with, may be <code>null</code>
- * @param shiftsCaret <code>true</code> if the command shifts the caret
- * @param owner the command owner, may be <code>null</code>
- * @throws BadLocationException if the added command intersects with an existing one
- * @since 3.0
- */
- public void addCommand(int offset, int length, String text, boolean shiftsCaret, IDocumentListener owner) throws BadLocationException {
- final Command command= new Command(offset, length, text, shiftsCaret, owner);
-
- if (intersects(command))
- throw new BadLocationException();
-
- final int index= Collections.binarySearch(fCommands, command);
-
- // a command with exactly the same ranges exists already
- if (index >= 0)
- throw new BadLocationException();
-
- // binary search result is defined as (-(insertionIndex) - 1)
- final int insertionIndex= -(index + 1);
-
- // overlaps to the right?
- if (insertionIndex != fCommands.size() && intersects((Command) fCommands.get(insertionIndex), command))
- throw new BadLocationException();
-
- // overlaps to the left?
- if (insertionIndex != 0 && intersects((Command) fCommands.get(insertionIndex - 1), command))
- throw new BadLocationException();
-
- fCommands.add(insertionIndex, command);
- }
-
-
- /**
- * Adds an additional replace command. The added replace command must not overlap
- * with existing ones. If the document command owner is not <code>null</code>, it will not
- * get document change notifications for the particular command.
- *
- * @param offset the offset of the region to replace
- * @param length the length of the region to replace
- * @param text the text to replace with, may be <code>null</code>
- * @param owner the command owner, may be <code>null</code>
- * @throws BadLocationException if the added command intersects with an existing one
- * @since 2.1
- */
- public void addCommand(int offset, int length, String text, IDocumentListener owner) throws BadLocationException {
- addCommand(offset, length, text, true, owner);
- }
-
- /**
- * Returns an iterator over the commands in ascending position order.
- * The iterator includes the original document command.
- * Commands cannot be removed.
- *
- * @return returns the command iterator
- */
- public Iterator getCommandIterator() {
- Command command= new Command(offset, length, text, shiftsCaret, owner);
- return new CommandIterator(fCommands, command, true);
- }
-
- /**
- * Returns the number of commands including the original document command.
- *
- * @return returns the number of commands
- * @since 2.1
- */
- public int getCommandCount() {
- return 1 + fCommands.size();
- }
-
- /**
- * Returns whether the two given commands intersect.
- *
- * @param command0 the first command
- * @param command1 the second command
- * @return <code>true</code> if the commands intersect
- * @since 2.1
- */
- private boolean intersects(Command command0, Command command1) {
- // diff middle points if not intersecting
- if (command0.fOffset + command0.fLength <= command1.fOffset || command1.fOffset + command1.fLength <= command0.fOffset)
- return (2 * command0.fOffset + command0.fLength) - (2 * command1.fOffset + command1.fLength) == 0;
- else
- return true;
- }
-
- /**
- * Returns whether the given command intersects with this command.
- *
- * @param command the command
- * @return <code>true</code> if the command intersects with this command
- * @since 2.1
- */
- private boolean intersects(Command command) {
- // diff middle points if not intersecting
- if (offset + length <= command.fOffset || command.fOffset + command.fLength <= offset)
- return (2 * offset + length) - (2 * command.fOffset + command.fLength) == 0;
- else
- return true;
- }
-
- /**
- * Executes the document commands on a document.
- *
- * @param document the document on which to execute the commands
- * @since 2.1
- */
- void execute(IDocument document) throws BadLocationException {
-
- if (length == 0 && text == null && fCommands.size() == 0)
- return;
-
- final Command originalCommand= new Command(offset, length, text, shiftsCaret, owner);
-
- for (final Iterator iterator= new CommandIterator(fCommands, originalCommand, false); iterator.hasNext(); ) {
- final Command command= (Command) iterator.next();
- command.execute(document);
- if (caretOffset != -1 && command.fOffset + command.fLength <= caretOffset && command.fShiftsCaret)
- caretOffset += command.getDeltaLength();
- }
- }
-
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IAutoEditStrategy.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IAutoEditStrategy.java
deleted file mode 100644
index 05f40688981..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IAutoEditStrategy.java
+++ /dev/null
@@ -1,33 +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;
-
-
-/**
- * An auto edit strategy can adapt changes that will be applied to
- * a text viewer's document. The strategy is informed by the text viewer
- * about each upcoming change in form of a document command. By manipulating
- * this document command, the strategy can influence in which way the text
- * viewer's document is changed. Clients may implement this interface.
- *
- * @since 2.1
- */
-public interface IAutoEditStrategy {
-
- /**
- * Allows the strategy to manipulate the document command.
- *
- * @param document the document that will be changed
- * @param command the document command describing the change
- */
- void customizeDocumentCommand(IDocument document, DocumentCommand command);
-}
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
deleted file mode 100644
index 53cf935ba9e..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IAutoIndentStrategy.java
+++ /dev/null
@@ -1,20 +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;
-
-
-
-/**
- * Exists for backward compatibility.
- * Please use <code>IAutoEditStrategy</code> directly.
- */
-public interface IAutoIndentStrategy extends IAutoEditStrategy {
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IDocumentAdapter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IDocumentAdapter.java
deleted file mode 100644
index 2c91b6b2976..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IDocumentAdapter.java
+++ /dev/null
@@ -1,37 +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 org.eclipse.swt.custom.StyledTextContent;
-
-
-/**
- * Adapts an <code>IDocument</code> to the <code>StyledTextContent</code> interface.
- * The document adapter is used by <code>TextViewer</code> to translate document changes
- * into styled text content changes and vice versa.
- * Clients may implement this interface and override <code>TextViewer.createDocumentAdapter</code>
- * if they want to intercept the communication between the viewer's text widget and
- * the viewer's document.
- *
- * @see IDocument
- * @see StyledTextContent
- */
-public interface IDocumentAdapter extends StyledTextContent {
-
- /**
- * Sets the adapters document.
- *
- * @param document the document to be adapted
- */
- void setDocument(IDocument document);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IDocumentAdapterExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IDocumentAdapterExtension.java
deleted file mode 100644
index 96906c3c84e..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IDocumentAdapterExtension.java
+++ /dev/null
@@ -1,39 +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;
-
-/**
- * Extension interface for <code>IDocumentAdapter</code>. Introduces the concepts of
- * batching a series of document changes into one styled text content change. Batching start
- * when a client calls <code>stopForwardingDocumentChanges</code>. After that call this document
- * adapter does not send out any styled text content change until
- * <code>resumeForwardingDocumentChanges</code> is called. Then, it sends out one styled text
- * content change that covers all changes that have been applied to the document since calling
- * <code>stopForwardingDocumentChanges</code>.
- *
- * @since 2.0
- */
-public interface IDocumentAdapterExtension {
-
- /**
- * Stops forwarding document changes to the styled text.
- */
- void stopForwardingDocumentChanges();
-
- /**
- * Resumes forwarding document changes to the styled text.
- * Also forces the styled text to catch up with all the changes
- * that have been applied since <code>stopForwardingDocumentChanges</code>
- * has been called.
- */
- void resumeForwardingDocumentChanges();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IEventConsumer.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IEventConsumer.java
deleted file mode 100644
index b3985e4a481..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IEventConsumer.java
+++ /dev/null
@@ -1,41 +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 org.eclipse.swt.events.VerifyEvent;
-
-/**
- * Implementers can register with a text viewer and
- * receive <code>VerifyEvent</code>s before the text viewer
- * they are registered with. If the event consumer marks events
- * as processed by turning their <code>doit</code> field to
- * <code>false</code> the text viewer subsequently ignores them.
- * Clients may implement this interface.<p>
- *
- * <code>ITextViewerExtension2</code> allows clients to manage the
- * <code>VerifyListener</code>s of a <code>TextViewer</code>. This makes
- * <code>IEventConsumer</code> obsolete.
- *
- * @see ITextViewer
- * @see org.eclipse.swt.events.VerifyEvent
- */
-public interface IEventConsumer {
-
- /**
- * Processes the given event and marks it as done if it should
- * be ignored by subsequent receivers.
- *
- * @param event the verify event which will be investigated
- */
- public void processEvent(VerifyEvent event);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IFindReplaceTarget.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IFindReplaceTarget.java
deleted file mode 100644
index 94bf9785063..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IFindReplaceTarget.java
+++ /dev/null
@@ -1,72 +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 org.eclipse.swt.graphics.Point;
-
-
-/**
- * Defines the interface for finding and replacing strings.
- */
-public interface IFindReplaceTarget {
-
- /**
- * Returns whether a find operation can be performed.
- *
- * @return whether a find operation can be performed
- */
- boolean canPerformFind();
-
- /**
- * Searches for a string starting at the given offset and using the specified search
- * directives. If a string has been found it is selected and its start offset is
- * returned.
- *
- * @param offset the offset at which searching starts
- * @param findString the string which should be found
- * @param searchForward <code>true</code> searches forward, <code>false</code> backwards
- * @param caseSensitive <code>true</code> performes a case sensitve search, <code>false</code> an insensitive search
- * @param wholeWord if <code>true</code> only occurences are reported in which the findString stands as a word by itself
- * @return the position of the specified string, or -1 if the string has not been found
- */
- int findAndSelect(int offset, String findString, boolean searchForward, boolean caseSensitive, boolean wholeWord);
-
- /**
- * Returns the currently selected range of characters as a offset and length.
- *
- * @return the currently selected character range
- */
- Point getSelection();
-
- /**
- * Returns the currently selected characters as a string.
- *
- * @return the currently selected characters
- */
- String getSelectionText();
-
- /**
- * Returns whether this target can be modified.
- *
- * @return <code>true</code> if target can be modified
- */
- boolean isEditable();
-
- /**
- * Replaces the currently selected range of characters with the given text.
- * This target must be editable. Otherwise nothing happens.
- *
- * @param text the substitution text
- */
- void replaceSelection(String text);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IFindReplaceTargetExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IFindReplaceTargetExtension.java
deleted file mode 100644
index 50b24764a06..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IFindReplaceTargetExtension.java
+++ /dev/null
@@ -1,89 +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 org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Point;
-
-
-/**
- * Extension interface for <code>IFindReplaceTarget</code>. Extends the find replace target with
- * the concept of searching in a limiting scope and introduces a replace-all mode.
- *
- * @since 2.0
- */
-public interface IFindReplaceTargetExtension {
-
- /**
- * Indicates that a session with the target begins.
- * All calls except <code>beginSession()</code> and <code>endSession()</code> to
- * <code>IFindReplaceTarget</code> and
- * <code>IFindReplaceTargetExtension</code> must be embedded within calls to
- * <code>beginSession()</code> and <code>endSession()</code>.
- *
- * @see #endSession()
- */
- void beginSession();
-
- /**
- * Indicates that a session with the target ends.
- *
- * @see #beginSession()
- */
- void endSession();
-
- /**
- * Returns the find scope of the target, <code>null</code> for global scope.
- *
- * @return returns the find scope of the target, may be <code>null</code>
- */
- IRegion getScope();
-
- /**
- * Sets the find scope of the target to operate on. <code>null</code>
- * indicates that the global scope should be used.
- *
- * @param scope the find scope of the target, may be <code>null</code>
- */
- void setScope(IRegion scope);
-
- /**
- * Returns the currently selected range of lines as a offset and length.
- *
- * @return the currently selected line range
- */
- Point getLineSelection();
-
- /**
- * Sets a selection.
- *
- * @param offset the offset of the selection
- * @param length the length of the selection
- */
- void setSelection(int offset, int length);
-
- /**
- * Sets the scope highlight color
- *
- * @param color the color of the scope highlight
- */
- void setScopeHighlightColor(Color color);
-
-
- /**
- * Sets the target's replace-all mode.
- *
- * @param replaceAll <code>true</code> if this target should switch into replace-all mode,
- * <code>false</code> if it should leave the replace-all state
- */
- void setReplaceAllMode(boolean replaceAll);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IFindReplaceTargetExtension3.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IFindReplaceTargetExtension3.java
deleted file mode 100644
index aa282e9073e..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IFindReplaceTargetExtension3.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;
-
-/**
- * Extension interface for <code>IFindReplaceTarget</code>. Extends the find replace target's
- * findAndSelect method to allow regular expression find/replace.
- *
- * @since 3.0
- */
-public interface IFindReplaceTargetExtension3 {
-
- /**
- * Searches for a string starting at the given offset and using the specified search
- * directives. If a string has been found it is selected and its start offset is
- * returned. If regExSearch is <code>true</code> the findString is
- * interpreted as a regular expression for searching.
- *
- * @param offset the offset at which searching starts
- * @param findString the string which should be found
- * @param searchForward <code>true</code> searches forward, <code>false</code> backwards
- * @param caseSensitive <code>true</code> performes a case sensitve search, <code>false</code> an insensitive search
- * @param wholeWord if <code>true</code> only occurences are reported in which the findString stands as a word by itself.
- * Must not be used in combination with <code>regExSearch</code>.
- * @param regExSearch if <code>true</code> findString represents a regular expression
- * Must not be used in combination with <code>wholeWord</code>.
- * @return the position of the specified string, or -1 if the string has not been found
- * @throws PatternSyntaxException if regExSearch is <code>true</code> and findString is an invalid regular expression
- */
- int findAndSelect(int offset, String findString, boolean searchForward, boolean caseSensitive, boolean wholeWord, boolean regExSearch);
-
- /**
- * Replaces the currently selected range of characters with the given text.
- * If regExReplace is <code>true</code> the text is interpreted as a regular
- * expression for searching.
- * This target must be editable. Otherwise nothing happens.
- *
- * @param text the substitution text
- * @param regExReplace if <code>true</code> text represents a regular expression
- * @throws IllegalStateException if a REPLACE or REPLACE_FIND operation is not preceded by a successful FIND operation
- * @throws PatternSyntaxException if regExReplace is <code>true</code> and text is an invalid regular expression
- */
- void replaceSelection(String text, boolean regExReplace);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControl.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControl.java
deleted file mode 100644
index d9cc1b15da2..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControl.java
+++ /dev/null
@@ -1,142 +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 org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Point;
-
-
-/**
- * Interface of a control presenting information. The information is given
- * in textual form. It can be either the content itself or a description
- * of the content. This specification is left to the implementers of this interface.<p>
- * The information control may not grap focus when made visible using
- * <code>setVisible(true)</code>.
- *
- * @since 2.0
- */
-public interface IInformationControl {
-
- /**
- * Sets the information to be presented by this information control.
- *
- * @param information the information to be presented
- */
- void setInformation(String information);
-
- /**
- * Sets the information control's size constraints. A constraint value of
- * <code>-1</code> indicates no constraint. This method must be called before
- * <code>computeSizeHint</code> is called.
- *
- * @param maxWidth the maximal width of the control to present the information, or <code>-1</code> for not constraint
- * @param maxHeight the maximal height of the control to present the information, or <code>-1</code> for not constraint
- */
- void setSizeConstraints(int maxWidth, int maxHeight);
-
- /**
- * Computes and returns a proposal for the size of this information control depending
- * on the information to present. The method tries to honor known size constraints but might
- * returns a size that exceeds them.
- *
- * @return the computed size hint
- */
- Point computeSizeHint();
-
- /**
- * Controls the visibility of this information control.
- *
- * @param visible <code>true</code> if the control should be visible
- */
- void setVisible(boolean visible);
-
- /**
- * Sets the size of this information control.
- *
- * @param width the width of the control
- * @param height the height of the control
- */
- void setSize(int width, int height);
-
- /**
- * Sets the location of this information control.
- *
- * @param location the location
- */
- void setLocation(Point location);
-
- /**
- * Disposes this information control.
- */
- void dispose();
-
- /**
- * Adds the given listener to the list of dispose listeners.
- * If the listener is already registered it is not registered again.
- *
- * @param listener the listener to be added
- */
- void addDisposeListener(DisposeListener listener);
-
- /**
- * Removes the given listeners from the list of dispose listeners.
- * If the listener is not registered this call has no effect.
- *
- * @param listener the listener to be removed
- */
- void removeDisposeListener(DisposeListener listener);
-
- /**
- * Sets the foreground color of this information control.
- *
- * @param foreground the foreground color of this information control
- */
- void setForegroundColor(Color foreground);
-
- /**
- * Sets the background color of this information control.
- *
- * @param background the background color of this information control
- */
- void setBackgroundColor(Color background);
-
- /**
- * Returns whether this information control has the focus.
- *
- * @return <code>true</code> when the information control has the focus otherwise <code>false</code>
- */
- boolean isFocusControl();
-
- /**
- * Sets the keyboard focus to this information control.
- */
- void setFocus();
-
- /**
- * Adds the given listener to the list of focus listeners.
- * If the listener is already registered it is not registered again.
- *
- * @param listener the listener to be added
- */
- void addFocusListener(FocusListener listener);
-
- /**
- * Removes the given listeners from the list of focus listeners.
- * If the listener is not registered this call has no affect.
- *
- * @param listener the listener to be removed
- */
- void removeFocusListener(FocusListener listener);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControlCreator.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControlCreator.java
deleted file mode 100644
index 1af2737601f..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControlCreator.java
+++ /dev/null
@@ -1,33 +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 org.eclipse.swt.widgets.Shell;
-
-
-/**
- * Interface of a factory of information controls.
- *
- * @since 2.0
- */
-public interface IInformationControlCreator {
-
- /**
- * Creates a new information control with the given shell as the control's parent.
- *
- * @param parent the parent shell
- * @return the created information control
- */
- IInformationControl createInformationControl(Shell parent);
-}
-
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
deleted file mode 100644
index a68948e9e69..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControlCreatorExtension.java
+++ /dev/null
@@ -1,39 +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;
-
-/**
- * Extension to <code>IInformationControlCreator</code> which
- * tests if an existing information control can be reused.
- *
- * @see org.eclipse.jface.text.IInformationControlCreator
- * @see org.eclipse.jface.text.IInformationControl
- * @since 3.0
- */
-public interface IInformationControlCreatorExtension {
-
- /**
- * Tests if an existing information control can be reused.
- *
- * @param control the information control to test
- * @return <code>true</code> if the control can be reused
- */
- 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.
- *
- * @param creator the creator to be checked
- * @return <code>true</code> if the given creator can be replaced
- */
- boolean canReplace(IInformationControlCreator creator);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControlExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControlExtension.java
deleted file mode 100644
index 0720fb42340..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControlExtension.java
+++ /dev/null
@@ -1,29 +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;
-
-/**
- * Extension interface for <code>IInformationControl</code>. As it is the responsibility of
- * the implementer of <code>IInformationControl</code> to specify whether the information
- * set is the information itself or a description of the information, only the information control
- * can decide whether there is something that must be displayed.
- *
- * @since 2.0
- */
-public interface IInformationControlExtension {
-
- /**
- * Returns whether this information control has contents to be displayed.
- * @return <code>true</code> if there is contents to be displayed.
- */
- boolean hasContents();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControlExtension2.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControlExtension2.java
deleted file mode 100644
index bc2b4b57d38..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControlExtension2.java
+++ /dev/null
@@ -1,31 +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;
-
-
-/**
- * Extension interface for <code>IInformationControl</code>. Replaces the concept of
- * textual information to be displayed with the more general concept of an input of the
- * information control. Text to be displayed set with <code>setInformation(String)</code>
- * is ignored.
- *
- * @see org.eclipse.jface.text.IInformationControl
- * @since 2.1
- */
-public interface IInformationControlExtension2 {
-
- /**
- * Sets the input to be presented in this information control.
- *
- * @param input the object to be used as input for this control
- */
- void setInput(Object input);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IMarkRegionTarget.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IMarkRegionTarget.java
deleted file mode 100644
index 88e358b7528..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IMarkRegionTarget.java
+++ /dev/null
@@ -1,32 +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 mark region target to support marked regions as found in emacs.
- *
- * @since 2.0
- */
-public interface IMarkRegionTarget {
-
- /**
- * Sets or clears a mark at the current cursor position.
- *
- * @param set sets the mark if <code>true</code>, clears otherwise.
- */
- void setMarkAtCursor(boolean set);
-
- /**
- * Swaps the mark and cursor position if the mark is in the visible region.
- */
- void swapMarkAndCursor();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IMarkSelection.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IMarkSelection.java
deleted file mode 100644
index 3bc7aa147e5..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IMarkSelection.java
+++ /dev/null
@@ -1,48 +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 org.eclipse.jface.viewers.ISelection;
-
-
-/**
- * A mark selection. Can be returned by text viewers implementing the
- * <code>IMarkRegionTarget</code> interface.
- *
- * @since 2.0
- */
-public interface IMarkSelection extends ISelection {
-
- /**
- * Returns the marked document.
- *
- * @return the marked document
- */
- IDocument getDocument();
-
- /**
- * Returns the mark position. The offset may be <code>-1</code> if there's no marked region.
- *
- * @return the mark position or <code>-1</code> if there is no marked region
- */
- int getOffset();
-
- /**
- * Returns the length of the mark selection. The length may be negative, if the caret
- * is before the mark position. The length has no meaning if <code>getOffset()</code>
- * returns <code>-1</code>.
- *
- * @return the length of the mark selection. Result is undefined for <code>getOffset == -1</code>
- */
- int getLength();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IPaintPositionManager.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IPaintPositionManager.java
deleted file mode 100644
index 00b19771bcf..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IPaintPositionManager.java
+++ /dev/null
@@ -1,40 +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 org.eclipse.jface.text.Position;
-
-/**
- * Manager that manages and updates positions used by <code>IPainter</code>s.
- *
- * @see org.eclipse.jface.text.IPainter
- * @since 2.1
- */
-public interface IPaintPositionManager {
-
- /**
- * Starts managing the given position until <code>unmanagePosition</code> is called.
- *
- * @param position the position to manage
- * @see #unmanagePosition(Position)
- */
- void managePosition(Position position);
-
- /**
- * Stops managing the given position. If the position is not managed
- * by this managed, this call has no effect.
- *
- * @param position the position that should no longer be managed
- */
- void unmanagePosition(Position position);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IPainter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IPainter.java
deleted file mode 100644
index 26b51096ea2..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IPainter.java
+++ /dev/null
@@ -1,94 +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 painter is responsible for creating, managing, updating, and removing visual decorations of an <code>ITextViewer</code>. Examples are
- * the highlighting of the cursor line, the print marging, or the highlighting of matching peer characters such as pairs of brackets. Clients
- * may implement this interface. Painters should be registered with a <code>PaintManager</code>. The paint manager tracks several classes
- * of events issued by an <code>ITextViewer</code> and reacts by appropriately invoking the registered painters.<p>
- * Painters can be activated or deactivated. Usually, painters are initially deactivated and are activated by the first call to their <code>paint</code>
- * method. Painters can be deactivated by calling <code>deactivate</code>. Deactivated painter can be reactivated by calling <code>paint</code>
- * again.<p>
- * Painters usually have to manage state information. E.g., a painter painting a cursor line highlight must redraw the previous and the actual cursor
- * line in the advent of a change of the cursor position. This state information must usually be adapted to changes of the viewer's content. In order
- * to support this common scenario, the <code>PaintManager</code> gives a painter access to a <code>IPaintPositionUpdater</code>. The painter
- * can use this updater to manage its state information.<p>
- *
- * @see org.eclipse.jface.text.PaintManager
- * @since 2.1
- */
-public interface IPainter {
-
- /**
- * Constant describing the reason of a repaint request: selection changed.
- */
- int SELECTION= 0;
- /**
- * Constant describing the reason of a repaint request: text changed.
- */
- int TEXT_CHANGE= 1;
- /**
- * Constant describing the reason of a repaint request: key pressed.
- */
- int KEY_STROKE= 2;
- /**
- * Constant describing the reason of a repaint request: mouse button pressed.
- */
- int MOUSE_BUTTON= 4;
- /**
- * Constant describing the reason of a repaint request: paint manager internal change.
- */
- int INTERNAL= 8;
- /**
- * Constant describing the reason of a repaint request: paint manager or painter configuration changed.
- */
- int CONFIGURATION= 16;
-
-
- /**
- * Disposes this painter. Prior to disposing, a painter should be deactivated. A disposed
- * painter can not be reactivated.
- *
- * @see #deactivate(boolean)
- */
- void dispose();
-
- /**
- * Requests this painter to repaint because of the given reason. Based on the given reason
- * the painter can decide whether it will repaint or not. If it repaints and is not yet activated,
- * it wil activate itself.
- *
- * @param reason the repaint reason, value is one of the constants defined in this interface
- */
- void paint(int reason);
-
- /**
- * Deactivates this painter. If the painter has not been activated before, this call does not
- * have any effect. <code>redraw</code> indicates whether the painter should remove
- * any decoration it previously applied. A deactivated painter can be reactivated by calling
- * <code>paint</code>.
- *
- * @param redraw <code>true</code> if any previously applied decoration should be removed
- * @see #paint(int)
- */
- void deactivate(boolean redraw);
-
- /**
- * Sets the paint position manager that can be used by this painter or removes any previously
- * set paint position manager.
- *
- * @param manager the paint position manager or <code>null</code>
- */
- void setPositionManager(IPaintPositionManager manager);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IRewriteTarget.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IRewriteTarget.java
deleted file mode 100644
index 317721e29fb..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IRewriteTarget.java
+++ /dev/null
@@ -1,55 +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 target publishing the required functions to modify a document that is displayed
- * in the ui, such as in a text viewer. It provides access to the document and control
- * over the redraw behavior and the batching of document changes into undo commands.
- *
- * @see org.eclipse.jface.text.ITextViewer
- * @see org.eclipse.jface.text.IDocument
- * @see org.eclipse.jface.text.IUndoManager
- * @since 2.0
- */
-public interface IRewriteTarget {
-
- /**
- * Returns the document of this target.
- *
- * @return the document of this target
- */
- IDocument getDocument();
-
- /**
- * Disables/enables redrawing of the ui while modifying the target's document.
- *
- * @param redraw <code>true</code> if the document's ui presentation should
- * be updated, <code>false</code> otherwise
- */
- void setRedraw(boolean redraw);
-
- /**
- * If an undo manager is connected to the document's ui presentation, this
- * method tells the undo manager to fold all subsequent changes into
- * one single undo command until <code>endCompoundChange</code> is called.
- */
- void beginCompoundChange();
-
- /**
- * If an undo manager is connected to the document's ui presentation, this method
- * tells the undo manager to stop the folding of changes into a single undo command.
- * After this call, all subsequent changes are considered to be individually undoable.
- */
- void endCompoundChange();
-}
-
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextDoubleClickStrategy.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextDoubleClickStrategy.java
deleted file mode 100644
index b9ee145dc69..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextDoubleClickStrategy.java
+++ /dev/null
@@ -1,33 +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 text double click strategy defines the reaction of a text viewer
- * to mouse double click events. For that the strategy must be installed
- * on the text viewer.<p>
- * Clients may implements this interface or use the standard implementation
- * <code>DefaultTextDoubleClickStrategy</code>.
- *
- * @see org.eclipse.jface.text.ITextViewer
- * @see org.eclipse.swt.events.MouseListener#mouseDoubleClick(MouseEvent)
- */
-public interface ITextDoubleClickStrategy {
-
- /**
- * The mouse has been double clicked on the given text viewer.
- *
- * @param viewer the viewer into which has been double clicked
- */
- void doubleClicked(ITextViewer viewer);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextHover.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextHover.java
deleted file mode 100644
index dce5cd7ad28..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextHover.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.jface.text;
-
-
-
-/**
- * Provides a hover popup which appears on top of the text viewer with
- * relevant display information. If the text hover does not provide information
- * no hover popup is shown. Any implementer of this interface must be capable of
- * operating in a non-UI thread.<p>
- * Clients may implement this interface.
- *
- * @see org.eclipse.jface.text.ITextViewer
- */
-public interface ITextHover {
-
- /**
- * Returns the text which should be presented if a hover popup is shown
- * for the specified hover region. The hover region has the same semantics
- * as the region returned by <code>getHoverRegion</code>. If the returned
- * string is <code>null</code> or empty no hover popup will be shown.
- *
- * @param textViewer the viewer on which the hover popup should be shown
- * @param hoverRegion the text range in the viewer which is used to determine
- * the hover display information
- * @return the hover popup display information
- */
- String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion);
-
- /**
- * Returns the text region which should serve as the source of information
- * to compute the hover popup display information. The popup has been requested
- * for the given offset.<p>
- * For example, if hover information can be provided on a per method basis in a
- * source viewer, the offset should be used to find the enclosing method and the
- * source range of the method should be returned.
- *
- * @param textViewer the viewer on which the hover popup should be shown
- * @param offset the offset for which the hover request has been issued
- * @return the hover region used to compute the hover display information
- */
- IRegion getHoverRegion(ITextViewer textViewer, int offset);
-}
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
deleted file mode 100644
index e1257ccee8f..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextHoverExtension.java
+++ /dev/null
@@ -1,29 +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;
-
-/**
- * Extension to <code>ITextHover</code> for providing its own information
- * control creator.
- *
- * @see org.eclipse.jface.text.IInformationControlCreator
- * @see org.eclipse.jface.text.ITextHover
- * @since 3.0
- */
-public interface ITextHoverExtension {
-
- /**
- * Returns the information control creator of this text hover.
- *
- * @return the information control creator
- */
- IInformationControlCreator getInformationControlCreator();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextInputListener.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextInputListener.java
deleted file mode 100644
index 2e7b505d16e..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextInputListener.java
+++ /dev/null
@@ -1,40 +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;
-
-
-
-/**
- * Text input listeners registered with an text viewer are informed
- * if the document serving as the text viewer's model is replaced.
- * Clients may implement this interface.
- *
- * @see org.eclipse.jface.text.ITextViewer
- * @see org.eclipse.jface.text.IDocument
- */
-public interface ITextInputListener {
-
- /**
- * Called before the input document is replaced.
- *
- * @param oldInput the text viewer's previous input document
- * @param newInput the text viewer's new input document
- */
- void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput);
-
- /**
- * Called after the input document has been replaced.
- *
- * @param oldInput the text viewer's previous input document
- * @param newInput the text viewer's new input document
- */
- void inputDocumentChanged(IDocument oldInput, IDocument newInput);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextListener.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextListener.java
deleted file mode 100644
index 0df04f7e94c..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextListener.java
+++ /dev/null
@@ -1,39 +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;
-
-
-
-/**
- * Text listeners registered with an text viewer are informed about
- * all text viewer modifications by means of text events. A text event
- * describes a change as a replace operation.<p>
- * The changes described in the event are the changes applied to the text viewer's
- * widget (i.e. its visual representation) and not those applied to the text viewer's
- * document. The text event can be asked to return the according document
- * event. If a text listener receives a text event, it is guaranteed that
- * both the document and the viewer's visual representation are in sync.<p>
- * Clients may implement this interface.
- *
- * @see org.eclipse.jface.text.ITextViewer
- * @see org.eclipse.jface.text.TextEvent
- * @see org.eclipse.jface.text.DocumentEvent
- */
-public interface ITextListener {
-
- /**
- * The visual representation of a text viewer this listener is registered with
- * has been changed.
- *
- * @param event the description of the change
- */
- void textChanged(TextEvent event);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextOperationTarget.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextOperationTarget.java
deleted file mode 100644
index 1608ff57504..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextOperationTarget.java
+++ /dev/null
@@ -1,101 +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;
-
-
-
-/**
- * Defines the target for a text operation.
- */
-public interface ITextOperationTarget {
-
-
- /**
- * Text operation code for undoing the last edit command.
- */
- static final int UNDO= 1;
-
- /**
- * Text operation code for redoing the last undone edit command.
- */
- static final int REDO= 2;
-
- /**
- * Text operation code for moving the selected text to the clipboard.
- */
- static final int CUT= 3;
-
- /**
- * Text operation code for copying the selected text to the clipboard.
- */
- static final int COPY= 4;
-
- /**
- * Text operation code for inserting the clipboard content at the
- * current position.
- */
- static final int PASTE= 5;
-
- /**
- * Text operation code for deleting the selected text or if selection
- * is empty the character at the right of the current position.
- */
- static final int DELETE= 6;
-
- /**
- * Text operation code for selecting the complete text.
- */
- static final int SELECT_ALL= 7;
-
- /**
- * Text operation code for shifting the selected text block to the right.
- */
- static final int SHIFT_RIGHT= 8;
-
- /**
- * Text operation code for unshifting the selected text block to the left.
- */
- static final int SHIFT_LEFT= 9;
-
- /**
- * Text operation code for printing the complete text.
- */
- static final int PRINT= 10;
-
- /**
- * Text operation code for prefixing the selected text block.
- */
- static final int PREFIX= 11;
-
- /**
- * Text operation code for removing the prefix from the selected text block.
- */
- static final int STRIP_PREFIX= 12;
-
-
- /**
- * Returns whether the operation specified by the given operation code
- * can be performed.
- *
- * @param operation the operation code
- * @return <code>true</code> if the specified operation can be performed
- */
- boolean canDoOperation(int operation);
-
- /**
- * Performs the operation specified by the operation code on the target.
- * <code>doOperation</code> must only be called if <code>canDoOperation</code>
- * returns <code>true</code>.
- *
- * @param operation the operation code
- */
- void doOperation(int operation);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextOperationTargetExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextOperationTargetExtension.java
deleted file mode 100644
index 4e0be75bff4..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextOperationTargetExtension.java
+++ /dev/null
@@ -1,32 +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;
-
-
-/**
- * Extension interface to <code>ITextOperationTarget</code>. Allows a client to control
- * the enable state of operations provided by this target.
- *
- * @see org.eclipse.jface.text.ITextOperationTarget
- * @since 2.0
- */
-public interface ITextOperationTargetExtension {
-
- /**
- * Enables/disabled the given text operation.
- *
- * @param operation the operation to enable/disable
- * @param enable <code>true</code> to enable the operation otherwise <code>false</code>
- */
- void enableOperation(int operation, boolean enable);
-}
-
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextSelection.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextSelection.java
deleted file mode 100644
index 2ddcc07705a..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextSelection.java
+++ /dev/null
@@ -1,84 +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 org.eclipse.jface.viewers.ISelection;
-
-
-/**
- * This interface represents a textual selection. A text selection is
- * a range of characters. Although a text selection is a snapshot taken
- * at a particular point in time, it must not copy the line information
- * and the selected text from the selection provider.<p>
- * If, for example, the selection provider is a source viewer, and a text
- * selection is created for the range [5, 10], the line formation for
- * the 5th character must not be determined and remembered at the point
- * of creation. It can rather be determined at the point, when
- * <code>getStartLine</code> is called. If the source viewer range [0, 15]
- * has been changed in the meantime between the creation of the text
- * selection object and the invocation of <code>getStartLine</code>, the returned
- * line number may differ from the line number of the 5th character at the
- * point of creation of the text selection object.<p> The contract of this
- * interface is that weak in order to allow for efficient implementations.<p>
- * Clients may implement this interface or use the default implementation provided
- * by <code>TextSelection</code>.
- *
- * @see org.eclipse.jface.text.TextSelection
- */
-public interface ITextSelection extends ISelection {
-
- /**
- * Returns the offset of the selected text.
- *
- * @return the offset of the selected text
- */
- int getOffset();
-
- /**
- * Returns the length of the selected text.
- *
- * @return the length of the selected text
- */
- int getLength();
-
- /**
- * Returns number of the line containing the offset of the selected text.
- * If the underlying text has been changed between the creation of this
- * selection object and the call of this method, the value returned might
- * differ from what it would have been at the point of creation.
- *
- * @return the start line of this selection or -1 if there is no valid line information
- */
- int getStartLine();
-
- /**
- * Returns the number of the line containing the last character of the selected text.
- * If the underlying text has been changed between the creation of this
- * selection object and the call of this method, the value returned might
- * differ from what it would have been at the point of creation.
- *
- * @return the end line of this selection or -1 if there is no valid line information
- */
- int getEndLine();
-
- /**
- * Returns the selected text.
- * If the underlying text has been changed between the creation of this
- * selection object and the call of this method, the value returned might
- * differ from what it would have been at the point of creation.
- *
- * @return the selected text or <code>null</code> if there is no valid text information
- */
- String getText();
-}
-
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewer.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewer.java
deleted file mode 100644
index 312779bcc4b..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewer.java
+++ /dev/null
@@ -1,432 +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 org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Point;
-
-import org.eclipse.jface.viewers.ISelectionProvider;
-
-
-/**
- * A text viewer turns a text widget into a document-based text widget.
- * It supports the following kinds of listeners:
- * <ul>
- * <li> viewport listeners to inform about changes of the viewer's viewport
- * <li> text listeners to inform about changes of the document and the subsequent viewer change
- * <li> text input listeners to inform about changes of the viewer's input document.
- * </ul>
- * A text viewer supports a set of plug-ins which define its behavior:
- * <ul>
- * <li> undo manager
- * <li> double click behavior
- * <li> auto indentation
- * <li> text hover
- * </ul>
- * Installed plug-ins are not automatically activated. Plug-ins must be activated with the
- * <code>activatePlugins</code> call. Most plug-ins can be defined per content type.
- * Content types are derived from the partitioning of the text viewer's input document.<p>
- * A text viewer also provides the concept of event consumption. Events handled by the
- * viewer can be filtered and processed by a dynamic event consumer.<p>
- * A text viewer provides several text editing functions, some of them are configurable,
- * through a text operation target interface. It also supports a presentation mode
- * in which it only shows specified sections of its document. The viewer's presentation mode
- * does not affect any client of the viewer other than text listeners.<p>
- * Clients may implement this interface or use the standard implementation
- * <code>TextViewer</code>.
- *
- * @see IDocument
- * @see ITextInputListener
- * @see IViewportListener
- * @see ITextListener
- * @see IEventConsumer
- */
-public interface ITextViewer {
-
-
- /* ---------- widget --------- */
-
- /**
- * Returns this viewer's SWT control, <code>null</code> if the control is disposed.
- *
- * @return the SWT control
- */
- StyledText getTextWidget();
-
-
- /* --------- plugins --------- */
-
- /**
- * Sets this viewer's undo manager.
- *
- * @param undoManager the new undo manager. <code>null</code> is a valid argument.
- */
- void setUndoManager(IUndoManager undoManager);
-
- /**
- * Sets this viewer's text double click strategy for the given content type.
- *
- * @param strategy the new double click strategy. <code>null</code> is a valid argument.
- * @param contentType the type for which the strategy is registered
- */
- void setTextDoubleClickStrategy(ITextDoubleClickStrategy strategy, String contentType);
-
- /**
- * Sets this viewer's auto indent strategy for the given content type.
- *
- * @param strategy the new auto indent strategy. <code>null</code> is a valid argument.
- * @param contentType the type for which the strategy is registered
- */
- void setAutoIndentStrategy(IAutoIndentStrategy strategy, String contentType);
-
- /**
- * Sets this viewer's text hover for the given content type.
- *
- * @param textViewerHover the new hover. <code>null</code> is a valid argument.
- * @param contentType the type for which the hover is registered
- */
- void setTextHover(ITextHover textViewerHover, String contentType);
-
- /**
- * Activates the installed plug-ins. If the plug-ins are already activated
- * this call has no effect.
- */
- void activatePlugins();
-
- /**
- * Resets the installed plug-ins. If plug-ins change their state or
- * behavior over the course of time, this method causes them to be set
- * back to their initial state and behavior. E.g., if an <code>IUndoManager</code>
- * has been installed on this text viewer, the manager's list of remembered
- * text editing operations is removed.
- */
- void resetPlugins();
-
-
-
- /* ---------- listeners ------------- */
-
- /**
- * Adds the given viewport listener to this viewer. The listener
- * is informed about all changes to the visible area of this viewer.
- * If the listener is already registered with this viewer, this call
- * has no effect.
- *
- * @param listener the listener to be added
- */
- void addViewportListener(IViewportListener listener);
-
- /**
- * Removes the given listener from this viewer's set of viewport listeners.
- * If the listener is not registered with this viewer, this call has
- * no effect.
- *
- * @param listener the listener to be removed
- */
- void removeViewportListener(IViewportListener listener);
-
- /**
- * Adds a text listener to this viewer. If the listener is already registered
- * with this viewer, this call has no effect.
- *
- * @param listener the listener to be added
- */
- void addTextListener(ITextListener listener);
-
- /**
- * Removes the given listener from this viewer's set of text listeners.
- * If the listener is not registered with this viewer, this call has
- * no effect.
- *
- * @param listener the listener to be removed
- */
- void removeTextListener(ITextListener listener);
-
- /**
- * Adds a text input listener to this viewer. If the listener is already registered
- * with this viewer, this call has no effect.
- *
- * @param listener the listener to be added
- */
- void addTextInputListener(ITextInputListener listener);
-
- /**
- * Removes the given listener from this viewer's set of text input listeners.
- * If the listener is not registered with this viewer, this call has
- * no effect.
- *
- * @param listener the listener to be removed
- */
- void removeTextInputListener(ITextInputListener listener);
-
-
-
- /* -------------- model manipulation ------------- */
-
- /**
- * Sets the given document as the text viewer's model and updates the
- * presentation accordingly. An approriate <code>TextEvent</code> is
- * issued. This text event does not carry a related document event.
- *
- * @param document the viewer's new input document
- */
- void setDocument(IDocument document);
-
- /**
- * Returns the text viewer's input document.
- *
- * @return the viewer's input document
- */
- IDocument getDocument();
-
-
- /* -------------- event handling ----------------- */
-
- /**
- * Registers an event consumer with this viewer.
- *
- * @param consumer the viewer's event consumer. <code>null</code> is a valid argument.
- */
- void setEventConsumer(IEventConsumer consumer);
-
- /**
- * Sets the editable mode.
- *
- * @param editable the editable mode
- */
- void setEditable(boolean editable);
-
- /**
- * Returns whether the shown text can be manipulated.
- *
- * @return the viewer's editable mode
- */
- boolean isEditable();
-
-
- /* ----------- visible region support ------------- */
-
- /**
- * Sets the given document as this viewer's model and
- * makes the specified region visible in the presentation. An approriate
- * <code>TextEvent</code> is issued. The text event does not carry a
- * related document event. This method is a convenience method for
- * <code>setDocument(document);setVisibleRegion(offset, length)</code>.
- *
- * @param document the new input document
- * @param visibleRegionOffset the offset of the visible region
- * @param visibleRegionLength the length of the visible region
- */
- void setDocument(IDocument document, int visibleRegionOffset, int visibleRegionLength);
-
- /**
- * Sets the region of this viewer's document which will be visible in the presentation.
- *
- * @param offset the offset of the visible region
- * @param length the length of the visible region
- */
- void setVisibleRegion(int offset, int length);
-
- /**
- * Resets the region of this viewer's document which is visible in the presentation.
- * Afterwards, the whole document is presented again.
- */
- void resetVisibleRegion();
-
- /**
- * Returns the current visible region of this viewer's document.
- * The result may differ from the argument passed to <code>setVisibleRegion</code>
- * if the document has been modified since then.
- *
- * @return this viewer's current visible region
- */
- IRegion getVisibleRegion();
-
- /**
- * Returns whether a given range overlaps with the visible region of this viewer's document.
- *
- * @return <code>true</code> if the specified range overlaps with the visible region
- */
- boolean overlapsWithVisibleRegion(int offset, int length);
-
-
-
- /* ------------- presentation manipulation ----------- */
-
- /**
- * Applies the color information encoded in the given text presentation.
- * <code>controlRedraw</code> tells this viewer whether it should take care of
- * redraw management or not. If, e.g., this call is one in a sequence of multiple
- * coloring calls, it is more appropriate to explicitly control redrawing at the
- * beginning and the end of the sequence.
- *
- * @param presentation the presentation to be applied to this viewer
- * @param controlRedraw indicates whether this viewer should manage redraws
- */
- void changeTextPresentation(TextPresentation presentation, boolean controlRedraw);
-
- /**
- * Marks the currently applied text presentation as invalid. It is the viewer's
- * responsibility to take any action it can to repair the text presentation.
- *
- * @since 2.0
- */
- void invalidateTextPresentation();
-
- /**
- * Applies the given color to this viewer's selection.
- *
- * @param color the color to be applied
- */
- void setTextColor(Color color);
-
- /**
- * Applies the given color to the specified section of this viewer.
- * <code>controlRedraw</code> tells this viewer whether it should take care of
- * redraw management or not.
- *
- * @param color the color to be applied
- * @param offset the offset of the range to be colored
- * @param length the length of the range to be colored
- * @param controlRedraw indicates whether this viewer should manage redraws
- */
- void setTextColor(Color color, int offset, int length, boolean controlRedraw);
-
-
- /* --------- target handling and configuration ------------ */
-
- /**
- * Returns the text operation target of this viewer.
- *
- * @return the text operation target of this viewer
- */
- ITextOperationTarget getTextOperationTarget();
-
- /**
- * Returns the find/replace operation target of this viewer.
- *
- * @return the find/replace operation target of this viewer
- */
- IFindReplaceTarget getFindReplaceTarget();
-
- /**
- * Sets the string that is used as prefix when lines of the given
- * content type are prefixed by the prefix text operation.
- * Sets the strings that are used as prefixes when lines of the given content type
- * are prefixed using the prefix text operation. The prefixes are considered equivalent.
- * Inserting a prefix always inserts the defaultPrefixes[0].
- * Removing a prefix removes all of the specified prefixes.
- *
- * @param defaultPrefixes the prefixes to be used
- * @param contentType the content type for which the prefixes are specified
- * @since 2.0
- */
- void setDefaultPrefixes(String[] defaultPrefixes, String contentType);
-
- /**
- * Sets the strings that are used as prefixes when lines of the given content type
- * are shifted using the shift text operation. The prefixes are considered equivalent.
- * Thus "\t" and " " can both be used as prefix characters.
- * Shift right always inserts the indentPrefixes[0].
- * Shift left removes all of the specified prefixes.
- *
- * @param indentPrefixes the prefixes to be used
- * @param contentType the content type for which the prefixes are specified
- */
- void setIndentPrefixes(String[] indentPrefixes, String contentType);
-
-
-
- /* --------- selection handling -------------- */
-
- /**
- * Sets the selection to the specified range.
- *
- * @param offset the offset of the selection range
- * @param length the length of the selection range
- */
- void setSelectedRange(int offset, int length);
-
- /**
- * Returns the range of the current selection in coordinates of this viewer's document.
- *
- * @return the current selection
- */
- Point getSelectedRange();
-
- /**
- * Returns a selection provider dedicated to this viewer. Subsequent
- * calls to this method return always the same selection provider.
- *
- * @return this viewer's selection provider
- */
- ISelectionProvider getSelectionProvider();
-
-
- /* ------------- appearance manipulation --------------- */
-
- /**
- * Ensures that the given range is visible.
- *
- * @param offset the offset of the range to be revealed
- * @param length the length of the range to be revealed
- */
- void revealRange(int offset, int length);
-
- /**
- * Scrolls the widget so the the given index is the line
- * with the smallest line number of all visible lines.
- *
- * @param index the line which should become the top most line
- */
- void setTopIndex(int index);
-
- /**
- * Returns the visible line with the smallest line number.
- *
- * @return the number of the top most visible line
- */
- int getTopIndex();
-
- /**
- * Returns the document offset of the upper left corner of this viewer's viewport.
- *
- * @return the upper left corner offset
- */
- int getTopIndexStartOffset();
-
- /**
- * Returns the visible line with the highest line number.
- *
- * @return the number of the bottom most line
- */
- int getBottomIndex();
-
- /**
- * Returns the document offset of the lower right
- * corner of this viewer's viewport. This is the visible character
- * with the highest character position. If the content of this viewer
- * is shorter, the position of the last character of the content is returned.
- *
- * @return the lower right corner offset
- */
- int getBottomIndexEndOffset();
-
- /**
- * Returns the vertical offset of the first visible line.
- *
- * @return the vertical offset of the first visible line
- */
- int getTopInset();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension.java
deleted file mode 100644
index 9a5b7452da7..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension.java
+++ /dev/null
@@ -1,103 +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 org.eclipse.swt.custom.VerifyKeyListener;
-import org.eclipse.swt.widgets.Control;
-
-
-/**
- * Extension interface for <code>ITextViewer</code>. Extends <code>ITextViewer</code> with
- * <ul>
- * <li> a replacement of the event consumer mechanism (methods dealing with <code>VerifyKeyListener</code>)
- * <li> access to the control of this viewer
- * <li> marked region support a la emacs
- * <li> control of the viewer's redraw behavior (@see #setRedraw)
- * <li> access to the viewer's rewrite target
- * </ul>
- *
- * @since 2.0
- */
-public interface ITextViewerExtension {
-
- /**
- * Inserts the verify key listener at the beginning of the viewer's
- * list of verify key listeners. If the listener is already registered
- * with the viewer this call moves the listener to the beginnng of
- * the list.
- *
- * @param listener the listener to be inserted
- */
- void prependVerifyKeyListener(VerifyKeyListener listener);
-
- /**
- * Appends a verify key listener to the viewer's list of verify
- * key listeners. If the listener is already registered with the viewer
- * this call moves the listener to the end of the list.
- *
- * @param listener the listener to be added
- */
- void appendVerifyKeyListener(VerifyKeyListener listener);
-
- /**
- * Removes the verify key listener from the viewer's list of verify key listeners.
- * If the listener is not registered with this viewer, this call has no effect.
- *
- * @param listener the listener to be removed
- */
- void removeVerifyKeyListener(VerifyKeyListener listener);
-
- /**
- * Returns the control of this viewer.
- *
- * @return the control of this viewer
- */
- Control getControl();
-
- /**
- * Sets or clears the mark. If offset is <code>-1</code>, the mark is cleared.
- * If a mark is set and the selection is empty, cut and copy actions performed on this
- * text viewer peform on the region limited by the positions of the mark and the cursor.
- *
- * @param offset the offset of the mark
- */
- void setMark(int offset);
-
- /**
- * Returns the mark position, <code>-1</code> if mark is not set.
- *
- * @return the mark position or <code>-1</code> if no mark is set
- */
- int getMark();
-
- /**
- * Enables/disables the redrawing of this text viewer. This temporarily disconnects
- * the viewer from its underlying StyledText widget. While being disconnected only
- * the viewer's selection may be changed using <code>setSelectedRange</code>.
- * Any direct manipulation of the widget as well as calls to methods that change the viewer's
- * presentation state (such as enabling the segmented view) are not allowed.
- * When redrawing is disabled the viewer does not send out any selection or
- * view port change notification. When redrawing is enabled again, a selection
- * change notification is sent out for the selected range and this range is revealed.
- *
- * @param redraw <code>true</code> to enable redrawing, <code>false</code> otherwise
- */
- void setRedraw(boolean redraw);
-
- /**
- * Returns the viewer's rewrite target.
- *
- * @return the viewer's rewrite target
- */
- IRewriteTarget getRewriteTarget();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension2.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension2.java
deleted file mode 100644
index 80187c3bae3..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension2.java
+++ /dev/null
@@ -1,108 +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 org.eclipse.swt.graphics.Point;
-
-/**
- * Extension interface for <code>ITextViewer</code>. Extends <code>ITextViewer</code> with
- * <ul>
- * <li> a replacement of the <code>ITextViewer.invalidateTextPresentation</code> method
- * <li> a replacement of the <code>ITextViewer.setTextHover</code> method now accepting state masks
- * </ul>
- *
- * @since 2.1
- */
-public interface ITextViewerExtension2 {
-
- /**
- * The state mask of the default hover (value <code>0xff</code>).
- */
- final int DEFAULT_HOVER_STATE_MASK= 0xff;
-
- /**
- * Invalidates the viewer's text presentation for the given range.
- *
- * @param offset the offset of the first character to be redrawn
- * @param length the length of the range to be redrawn
- */
- void invalidateTextPresentation(int offset, int length);
-
- /**
- * Sets this viewer's text hover for the given content type and the given state mask. If the given text hower
- * is <code>null</code>, any hover installed for the given content type and state mask is uninstalled.
- *
- * @param textViewerHover the new hover or <code>null</code>
- * @param contentType the type for which the hover is to be registered or unregistered
- * @param stateMask the SWT event state mask; <code>DEFAULT_HOVER_STATE_MASK</code> indicates that
- * the hover is installed as the default hover.
- */
- void setTextHover(ITextHover textViewerHover, String contentType, int stateMask);
-
- /**
- * Removes all text hovers for the given content type.
- * <p>
- * Note: To remove a hover for a given content type and state mask
- * use {@link #setTextHover(ITextHover, String, int)} with <code>null</code>
- * as parameter for the text hover.
- * </p>
- * @param contentType the type for which all text hovers are to be unregistered
- */
- void removeTextHovers(String contentType);
-
- /**
- * Returns the currently displayed text hover if any, <code>null</code> otherwise.
- */
- ITextHover getCurrentTextHover();
-
- /**
- * Returns the location at which the most recent mouse hover event
- * has been issued.
- *
- * @return the location of the most recent mouse hover event
- */
- Point getHoverEventLocation();
-
- /**
- * Prepends the given auto edit strategy to the existing list of strategies for the
- * specified content type. The strategies are called in the order in which they appear in the
- * list of strategies.
- *
- * @param strategy the auto edit strategy
- * @param contentType the content type
- */
- void prependAutoEditStrategy(IAutoEditStrategy strategy, String contentType);
-
- /**
- * Removes the first occurrence of the given auto edit strategy in the list of strategies
- * registered under the specified content type.
- *
- * @param strategy the auto edit strategy
- * @param contentType the content type
- */
- void removeAutoEditStrategy(IAutoEditStrategy strategy, String contentType);
-
- /**
- * Adds the given painter to this viewer.
- *
- * @param painter the painter to be added
- */
- void addPainter(IPainter painter);
-
- /**
- * Removes the given painter from this viewer. If the painter has not been
- * added to this viewer, this call is without effect.
- *
- * @param painter the painter to be removed
- */
- void removePainter(IPainter painter);
-}
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
deleted file mode 100644
index 7b5f691b51a..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension3.java
+++ /dev/null
@@ -1,95 +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;
-
-
-/**
- * Extension interface for <code>ITextViewer</code>. Extends <code>ITextViewer</code> with the explicit
- * concept of model and widget coordinates. For example, a selection returned by the text viewer's control is
- * a widget selection. A widget selection always maps to a certain range of the viewer's document. This
- * range is considered the model selection.<p>
- * This general concepts replaces the notion of <code>visible region</code>.
- *
- * @since 2.1
- */
-public interface ITextViewerExtension3 {
-
-
- /**
- * Returns the minimal region of the viewer's document that completely comprises everything that is
- * visible in the viewer's widget.
- *
- * @return the minimal region of the viewer's document comprising the contents of the viewer's widget
- */
- public IRegion getModelCoverage();
-
-
- /**
- * Returns the widget line that corresponds to the given line of the viewer's document or <code>-1</code> if there is no such line.
- *
- * @param modelLine the line of the viewer's document
- * @return the corresponding widget line or <code>-1</code>
- */
- public int modelLine2WidgetLine(int modelLine);
-
- /**
- * Returns the widget offset that corresponds to the given offset in the viewer's document
- * or <code>-1</code> if there is no such offset
- *
- * @param modelOffset the offset in the viewer's document
- * @return the corresponding widget offset or <code>-1</code>
- */
- public int modelOffset2WidgetOffset(int modelOffset);
-
- /**
- * Returns the minimal region of the viewer's widget that completely comprises the given region of the
- * viewer's document or <code>null</code> if there is no such region.
- *
- * @param modelRange the region of the viewer's document
- * @return the minimal region of the widget comprising <code>modelRange</code> or <code>null</code>
- */
- public IRegion modelRange2WidgetRange(IRegion modelRange);
-
-
- /**
- * Returns the offset of the viewer's document that corresponds to the given widget offset
- * or <code>-1</code> if there is no such offset
- *
- * @param widgetOffset the widget offset
- * @return the corresponding offset in the viewer's document or <code>-1</code>
- */
- public int widgetOffset2ModelOffset(int widgetOffset);
-
- /**
- * Returns the minimal region of the viewer's document that completely comprises the given widget region
- * or <code>null</code> if there is no such region.
- *
- * @param widgetRange the widget region
- * @return the minimal region of the viewer's document comprising <code>widgetlRange</code> or <code>null</code>
- */
- public IRegion widgetRange2ModelRange(IRegion widgetRange);
-
- /**
- * Returns the line of the viewer's document that corresponds to the given widget line or <code>-1</code> if there is no such line.
- *
- * @param widgetLine the widget line
- * @return the corresponding line of the viewer's document or <code>-1</code>
- */
- public int widgetlLine2ModelLine(int widgetLine);
-
- /**
- * Returns the widget line of the given widget offset.
- *
- * @param widgetOffset the widget offset
- * @return the widget line of the widget offset
- */
- public int widgetLineOfWidgetOffset(int widgetOffset);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension4.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension4.java
deleted file mode 100644
index a321d2fb74e..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension4.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/**********************************************************************
-Copyright (c) 2000, 2003 IBM Corp. 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 implementation
-**********************************************************************/
-package org.eclipse.jface.text;
-
-/**
- * Extension interface for <code>ITextViewer</code>. Adds the following functionality:
- * <ul>
- * <li>focus handling for widget token keepers</li>
- * </ul>
- *
- * @since 3.0
- */
-public interface ITextViewerExtension4 {
-
- /**
- * Instructs the receiver to request the <code>IWidgetTokenKeeper</code>
- * currently holding the widget token to take the keyboard focus.
- *
- * @return <code>true</code> if there was any <code>IWidgetTokenKeeper</code> that was asked to take the focus, <code>false</code> otherwise
- */
- boolean moveFocusToWidgetToken();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IUndoManager.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IUndoManager.java
deleted file mode 100644
index 48a9644f179..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IUndoManager.java
+++ /dev/null
@@ -1,94 +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;
-
-
-
-/**
- * An undo manager is connected to at most one text viewer.
- * It monitors the text viewer and keeps a history of the
- * changes applied to the viewer. The undo manager groups those
- * changes into user interactions which on an undo request are
- * rolled back in one atomic change. <p>
- * Clients may implement this interface or use the standard
- * implementation <code>DefaultUndoManager</code>.
- *
- * @see org.eclipse.jface.text.DefaultUndoManager
- */
-public interface IUndoManager {
-
- /**
- * Connects this undo manager to the given text viewer.
- *
- * @param viewer the viewer the undo manager is connected to
- */
- void connect(ITextViewer viewer);
-
- /**
- * Disconnects this undo manager from its text viewer.
- * If this undo manager hasn't been connected before this
- * operation has no effect.
- */
- void disconnect();
-
- /**
- * Signals the undo manager that all subsequent changes until
- * <code>endCompoundChange</code> is called are to be undone in one piece.
- */
- void beginCompoundChange();
-
- /**
- * Signals the undo manager that the sequence of changes which started with
- * <code>beginCompoundChange</code> has been finished. All subsequent changes
- * are considered to be individually undoable.
- */
- void endCompoundChange();
-
- /**
- * Resets the history of the undo manager. After that call,
- * there aren't any undoable or redoable text changes.
- */
- void reset();
-
- /**
- * The given parameter determines the maximal length of the history
- * remembered by the undo manager.
- *
- * @param undoLevel the length of this undo manager's history
- */
- void setMaximalUndoLevel(int undoLevel);
-
- /**
- * Returns whether at least one text change can be rolled back.
- *
- * @return <code>true</code> if at least one text change can be rolled back
- */
- boolean undoable();
-
- /**
- * Returns whether at least one text change can be repeated. A text change
- * can be repeated only if it was executed and rolled back.
- *
- * @return <code>true</code> if at least on text change can be repeated
- */
- boolean redoable();
-
- /**
- * Rolls back the most recently executed text change.
- */
- void undo();
-
- /**
- * Repeats the most recently rolled back text change.
- */
- void redo();
-
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IViewportListener.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IViewportListener.java
deleted file mode 100644
index 65e5de91246..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IViewportListener.java
+++ /dev/null
@@ -1,30 +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;
-
-
-
-/**
- * Registered with a text viewer, viewport listeners are
- * informed about changes of a text viewer's viewport. The view port is that
- * portion of the viewer's document which is visible in the viewer. <p>
- * Clients may implement this interface.
- *
- * @see org.eclipse.jface.text.ITextViewer
- */
-public interface IViewportListener {
-
- /**
- * Informs about viewport changes. The given vertical position
- * is the new vertical scrolling offset measured in pixels.
- */
- void viewportChanged(int verticalOffset);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IWidgetTokenKeeper.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IWidgetTokenKeeper.java
deleted file mode 100644
index 6507ddb8263..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IWidgetTokenKeeper.java
+++ /dev/null
@@ -1,34 +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 widget token keeper may require a widget token from an
- * <code>IWidgetTokenOwner</code> and release the token
- * to the owner after usage. A widget token owner may request
- * the token from the token keeper. The keeper may deny that.
- *
- * @since 2.0
- */
-public interface IWidgetTokenKeeper {
-
- /**
- * The given widget token owner requests the widget token from
- * this token keeper. Returns <code>true</code> if the token is released
- * by this token keeper. Note, the keeper must not call
- * <code>releaseWidgetToken(IWidgetTokenKeeper)</code> explicitly.
- *
- * @param owner the token owner
- * @return <code>true</code> if token has been released <code>false</code> otherwise
- */
- boolean requestWidgetToken(IWidgetTokenOwner owner);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IWidgetTokenKeeperExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IWidgetTokenKeeperExtension.java
deleted file mode 100644
index 4b6d09a4c01..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IWidgetTokenKeeperExtension.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**********************************************************************
-Copyright (c) 2000, 2003 IBM Corp. 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 implementation
-**********************************************************************/
-package org.eclipse.jface.text;
-
-/**
- * Extension interface to <code>IWidgetTokenKeeper</code>. Replaces the original
- * <code>requestWidgetToken</code> functionality with a new priority based approach.
- * Adds the concept of focus handling.
- *
- * @since 3.0
- */
-public interface IWidgetTokenKeeperExtension {
-
- /**
- * The given widget token owner requests the widget token from
- * this token keeper. Returns <code>true</code> if the token is released
- * by this token keeper. Note, the keeper must not call
- * <code>releaseWidgetToken(IWidgetTokenKeeper)</code> explicitly.
- *
- * <p>The general contract is that the receiver should release the token
- * if <code>priority</code> exceeds the receiver's priority.</p>
- *
- * @param owner the token owner
- * @param priority the priority of the request
- * @return <code>true</code> if token has been released <code>false</code> otherwise
- */
- boolean requestWidgetToken(IWidgetTokenOwner owner, int priority);
-
- /**
- * Requests the receiver to give focus to its popup shell, hover, or similar. There is
- * no assumption made whether the receiver actually succeeded in taking the focus. The return
- * value gives a hint whether the receiver tried to take focus.
- *
- * @param owner the token owner
- * @return <code>true</code> if the receiver tried to take focus, <code>false</code> if it did not.
- */
- boolean setFocus(IWidgetTokenOwner owner);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IWidgetTokenOwner.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IWidgetTokenOwner.java
deleted file mode 100644
index 7fee31d9e60..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IWidgetTokenOwner.java
+++ /dev/null
@@ -1,45 +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 widget token must be aquired in order to display
- * information in a temporary window. The intent behind this concept is that
- * only one temporary window should be presented at any moment in time and
- * also to avoid overlapping temporary windows.
- *
- * @since 2.0
- */
-public interface IWidgetTokenOwner {
-
- /**
- * Requests the widget token from this token owner. Returns
- * <code>true</code> if the token has been aquired or is
- * already owned by the requester. This method is non-blocking.
- *
- * @param requester the token requester
- * @return <code>true</code> if requester aquires the token,
- * <code>false</code> otherwise
- */
- boolean requestWidgetToken(IWidgetTokenKeeper requester);
-
- /**
- * The given token keeper releases the token to this
- * token owner. If the token has previously not been held
- * by the given token keeper, nothing happens. This
- * method is non-blocking.
- *
- * @param tokenKeeper the token keeper
- */
- void releaseWidgetToken(IWidgetTokenKeeper tokenKeeper);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IWidgetTokenOwnerExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IWidgetTokenOwnerExtension.java
deleted file mode 100644
index ea77557593c..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IWidgetTokenOwnerExtension.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/**********************************************************************
-Copyright (c) 2000, 2003 IBM Corp. 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 implementation
-**********************************************************************/
-package org.eclipse.jface.text;
-
-/**
- * Extension interface to <code>IWidgetTokenOwner</code>. Replaces the original
- * <code>requestWidgetToken</code> functionality with a new priority based approach.
- *
- * @since 3.0
- */
-public interface IWidgetTokenOwnerExtension {
-
- /**
- * Requests the widget token from this token owner. Returns
- * <code>true</code> if the token has been aquired or is
- * already owned by the requester. This method is non-blocking.
- *
- * <p><code>priority</code> is forwarded to any existing token keeper
- * to give it an estimate on whether the request has higher priority than
- * the current keeper's. There is, however, no guarantee that another keeper
- * will release the token even if it has a high priority.</p>
- *
- * @param requester the token requester
- * @param priority the priority of the request
- * @return <code>true</code> if requester aquires the token,
- * <code>false</code> otherwise
- */
- boolean requestWidgetToken(IWidgetTokenKeeper requester, int priority);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/JFaceTextMessages.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/JFaceTextMessages.java
deleted file mode 100644
index bff498fee1f..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/JFaceTextMessages.java
+++ /dev/null
@@ -1,32 +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.MissingResourceException;
-import java.util.ResourceBundle;
-
-class JFaceTextMessages {
-
- private static final String RESOURCE_BUNDLE= "org.eclipse.jface.text.JFaceTextMessages";//$NON-NLS-1$
-
- private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
-
- private JFaceTextMessages() {
- }
-
- public static String getString(String key) {
- try {
- return fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/JFaceTextMessages.properties b/org.eclipse.jface.text/src/org/eclipse/jface/text/JFaceTextMessages.properties
deleted file mode 100644
index f95e16d782b..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/JFaceTextMessages.properties
+++ /dev/null
@@ -1,37 +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
-###############################################################################
-
-
-TextViewer.error.bad_location.WidgetCommand.setEvent=TextViewer.WidgetCommand.setEvent: BadLocationException
-TextViewer.error.bad_location.findAndSelect=TextViewer.findAndSelect: BadLocationException
-TextViewer.error.bad_location.getBottomIndex=TextViewer.getBottomIndex: BadLocationException
-TextViewer.error.bad_location.getBottomIndexEndOffset=TextViewer.getBottomIndexEndOffset: BadLocationException
-TextViewer.error.bad_location.getFirstCompleteLineOfRegion=TextViewer.getFirstCompleteLineOfRegion: BadLocationException
-TextViewer.error.bad_location.getTopIndex=TextViewer.getTopIndex: BadLocationException
-TextViewer.error.bad_location.getTopIndexStartOffset=TextViewer.getTopIndexStartOffset: BadLocationException
-TextViewer.error.bad_location.selectContentTypePlugin=TextViewer.selectContentTypePlugin: BadLocationException
-TextViewer.error.bad_location.setTopIndex_1=TextViewer.setTopIndex: BadLocationException
-TextViewer.error.bad_location.setTopIndex_2=TextViewer.setTopIndex: BadLocationException
-TextViewer.error.bad_location.shift_1=TextViewer.shift: BadLocationException
-TextViewer.error.bad_location.shift_2=TextViewer.shift: BadLocationException
-TextViewer.error.bad_location.verifyText=TextViewer.verifyText: BadLocationException
-TextViewer.error.invalid_range=Invalid range argument
-TextViewer.error.invalid_visible_region_1=Invalid visible region argument
-TextViewer.error.invalid_visible_region_2=Invalid visible region argument
-
-InfoPopup.info_delay_timer_name=AdditionalInfo Delay
-
-ContentAssistant.assist_delay_timer_name=AutoAssist Delay
-
-AbstractHoverInformationControlManager.hover.restarter=Hover Restart Delay
-
-# The first parameter is the annotation type label and the second is the number of annotations
-OverviewRulerHeader.toolTipTextEntry= {0}: {1}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/MarginPainter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/MarginPainter.java
deleted file mode 100644
index 5e6bcf56d0c..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/MarginPainter.java
+++ /dev/null
@@ -1,171 +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 org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Rectangle;
-
-
-/**
- * Paints a vertical line (margin line) after a given column respecting the text viewer's font.
- * Clients usually instantiate and configure objects of this class. <p>
- * This class is not intended to be subclassed.
- *
- * @since 2.1
- */
-public class MarginPainter implements IPainter, PaintListener {
-
- /** The widget of the text viewer */
- private StyledText fTextWidget;
-
- /** The column after which to paint the line, default value <code>80</code> */
- private int fMarginWidth= 80;
- /** The color in which to paint the line */
- private Color fColor;
- /** The line style of the line to be painted, default value <code>SWT.LINE_SOLID</code> */
- private int fLineStyle= SWT.LINE_SOLID;
- /** The line width of the line to be painted, default value <code>1</code> */
- private int fLineWidth= 1;
- /** The cached x-offset of the <code>fMarginWidth</code> for the current font */
- private int fCachedWidgetX= -1;
- /** The active state of this painter */
- private boolean fIsActive= false;
-
- /**
- * Creates a new painter for the given text viewer.
- *
- * @param textViewer the text viewer
- */
- public MarginPainter(ITextViewer textViewer) {
- fTextWidget= textViewer.getTextWidget();
- }
-
- /**
- * Sets the column after which to draw the margin line.
- *
- * @param width the column
- */
- public void setMarginRulerColumn(int width) {
- fMarginWidth= width;
- initialize();
- }
-
- /**
- * Sets the line style of the margin line.
- *
- * @param lineStyle a <code>SWT</code> style constant describing the line style
- */
- public void setMarginRulerStyle(int lineStyle) {
- fLineStyle= lineStyle;
- }
-
- /**
- * Sets the line width of the margin line.
- *
- * @param lineWidth the line width
- */
- public void setMarginRulerWidth(int lineWidth) {
- fLineWidth= lineWidth;
- }
-
- /**
- * Sets the color of the margin line. Must be called before <code>paint</code> is called the first time.
- *
- * @param color the color
- */
- public void setMarginRulerColor(Color color) {
- fColor= color;
- }
-
- /**
- * Initializes this painter, by flushing and recomputing all caches and causing
- * the widget to be redrawn. Must be called explicitly when font of text widget changes.
- */
- public void initialize() {
- computeWidgetX();
- fTextWidget.redraw();
- }
-
- /**
- * Computes and remembers the x-offset of the margin column for the
- * current widget font.
- */
- private void computeWidgetX() {
- GC gc= new GC(fTextWidget);
- int pixels= gc.getFontMetrics().getAverageCharWidth();
- gc.dispose();
-
- fCachedWidgetX= pixels * fMarginWidth;
- }
-
- /*
- * @see IPainter#deactivate(boolean)
- */
- public void deactivate(boolean redraw) {
- if (fIsActive) {
- fIsActive= false;
- fCachedWidgetX= -1;
- fTextWidget.removePaintListener(this);
- if (redraw)
- fTextWidget.redraw();
- }
- }
-
- /*
- * @see IPainter#dispose()
- */
- public void dispose() {
- fTextWidget= null;
- }
-
- /*
- * @see IPainter#paint(int)
- */
- public void paint(int reason) {
- if (!fIsActive) {
- fIsActive= true;
- fTextWidget.addPaintListener(this);
- if (fCachedWidgetX == -1)
- computeWidgetX();
- fTextWidget.redraw();
- } else if (CONFIGURATION == reason || INTERNAL == reason)
- fTextWidget.redraw();
- }
-
- /*
- * @see org.eclipse.swt.events.PaintListener#paintControl(org.eclipse.swt.events.PaintEvent)
- */
- public void paintControl(PaintEvent e) {
- if (fTextWidget != null) {
- int x= fCachedWidgetX - fTextWidget.getHorizontalPixel();
- if (x >= 0) {
- Rectangle area= fTextWidget.getClientArea();
- e.gc.setForeground(fColor);
- e.gc.setLineStyle(fLineStyle);
- e.gc.setLineWidth(fLineWidth);
- e.gc.drawLine(x, 0, x, area.height);
- }
- }
- }
-
- /*
- * @see org.eclipse.jface.text.IPainter#setPositionManager(org.eclipse.jface.text.IPaintPositionManager)
- */
- public void setPositionManager(IPaintPositionManager manager) {
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/MarkSelection.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/MarkSelection.java
deleted file mode 100644
index 6463e61d82d..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/MarkSelection.java
+++ /dev/null
@@ -1,69 +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;
-
-
-/**
- * Default implementation of <code>IMarkSelection</code>.
- * @since 2.0
- */
-public class MarkSelection implements IMarkSelection {
-
- /** The marked document. */
- private final IDocument fDocument;
- /** The offset of the mark selection. */
- private final int fOffset;
- /** The length of the mark selection. */
- private final int fLength;
-
- /**
- * Creates a MarkSelection.
- *
- * @param document the marked document
- * @param offset the offset of the mark
- * @param length the length of the mark, may be negative if caret before offset
- */
- public MarkSelection(IDocument document, int offset, int length) {
- fDocument= document;
- fOffset= offset;
- fLength= length;
- }
-
- /*
- * @see IMarkSelection#getDocument()
- */
- public IDocument getDocument() {
- return fDocument;
- }
-
- /*
- * @see IMarkSelection#getOffset()
- */
- public int getOffset() {
- return fOffset;
- }
-
- /*
- * @see IMarkSelection#getLength()
- */
- public int getLength() {
- return fLength;
- }
-
- /*
- * @see ISelection#isEmpty()
- */
- public boolean isEmpty() {
- return fLength == 0;
- }
-
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/PaintManager.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/PaintManager.java
deleted file mode 100644
index 0bc7e4155a8..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/PaintManager.java
+++ /dev/null
@@ -1,360 +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.Iterator;
-import java.util.List;
-
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.widgets.Control;
-
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-
-
-/**
- * Manages the painters of a text viewer. Clients usually instantiate and configure
- * objects of this type.
- *
- * @since 2.1
- */
-public final class PaintManager implements KeyListener, MouseListener, ISelectionChangedListener, ITextListener, ITextInputListener {
-
- /**
- * Position updater used by the position manager. This position updater differes from the default position
- * updater in that it extends a position when an insertion happens at the position's offset and right behind
- * the position.
- */
- static class PaintPositionUpdater extends DefaultPositionUpdater {
-
- /**
- * Creates the position updater for the given category.
- *
- * @param category the position category
- */
- protected PaintPositionUpdater(String category) {
- super(category);
- }
-
- /**
- * If an insertion happens at a position's 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.
- */
- 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;
- }
- }
-
- /**
- * The paint position manager used by this paint manager. The paint position
- * manager is installed on a single document and control the creation/disposed
- * and updating of a position category that will be used for managing positions.
- */
- static class PositionManager implements IPaintPositionManager {
-
- /** The document this positon manager works on */
- private IDocument fDocument;
- /** The position updater used for the managing position category */
- private IPositionUpdater fPositionUpdater;
- /** The managing position category */
- private String fCategory;
-
- /**
- * Creates a new position manager. Initializes the managing
- * position category using its class name and its hash value.
- */
- public PositionManager() {
- fCategory= getClass().getName() + hashCode();
- fPositionUpdater= new PaintPositionUpdater(fCategory);
- }
-
- /**
- * Installs this position manager in the given document. The position manager stays
- * active until <code>uninstall</code> or <code>dispose</code>
- * is called.
- *
- * @param document the document to be installed on
- */
- public void install(IDocument document) {
- fDocument= document;
- fDocument.addPositionCategory(fCategory);
- fDocument.addPositionUpdater(fPositionUpdater);
- }
-
- /**
- * Diposes this position manager. The position manager is automatically
- * uninstalled from the document it has previously been installed
- * on.
- */
- public void dispose() {
- uninstall(fDocument);
- }
-
- /**
- * Uninstalls this position manager form the given document. If the position
- * manager has no been installed on this document, this method is without effect.
- *
- * @param document the document form which to uninstall
- */
- public void uninstall(IDocument document) {
- if (document == fDocument && document != null) {
- try {
- fDocument.removePositionUpdater(fPositionUpdater);
- fDocument.removePositionCategory(fCategory);
- } catch (BadPositionCategoryException x) {
- // should not happen
- }
- fDocument= null;
- }
- }
-
- /*
- * @see IPositionManager#addManagedPosition(Position)
- */
- public void managePosition(Position position) {
- try {
- fDocument.addPosition(fCategory, position);
- } catch (BadPositionCategoryException x) {
- // should not happen
- } catch (BadLocationException x) {
- // should not happen
- }
- }
-
- /*
- * @see IPositionManager#removeManagedPosition(Position)
- */
- public void unmanagePosition(Position position) {
- try {
- fDocument.removePosition(fCategory, position);
- } catch (BadPositionCategoryException x) {
- // should not happen
- }
- }
- }
-
-
- /** The painters managed by this paint manager. */
- private List fPainters= new ArrayList(2);
- /** The position manager used by this paint manager */
- private PositionManager fManager;
- /** The associated text viewer */
- private ITextViewer fTextViewer;
-
- /**
- * Creates a new paint manager for the given text viewer.
- *
- * @param textViewer the text viewer associated to this newly created paint manager
- */
- public PaintManager(ITextViewer textViewer) {
- fTextViewer= textViewer;
- }
-
-
- /**
- * Adds the given painter to the list of painters managed by this paint manager.
- * If the painter is already registered with this paint manager, this method is
- * without effect.
- *
- * @param painter the painter to be added
- */
- public void addPainter(IPainter painter) {
- if (!fPainters.contains(painter)) {
- fPainters.add(painter);
- if (fPainters.size() == 1)
- install();
- painter.setPositionManager(fManager);
- painter.paint(IPainter.INTERNAL);
- }
- }
-
- /**
- * Removes the given painter from the list of painters managed by this
- * paint manager. If the painter has not previously been added to this
- * paint manager, this method is without effect.
- *
- * @param painter the painter to be removed
- */
- public void removePainter(IPainter painter) {
- if (fPainters.remove(painter))
- painter.setPositionManager(null);
- if (fPainters.size() == 0)
- dispose();
- }
-
- /**
- * Installs/activates this paint manager. Is called as soon as the
- * first painter is to be managed by this paint manager.
- */
- private void install() {
-
- fManager= new PositionManager();
- if (fTextViewer.getDocument() != null)
- fManager.install(fTextViewer.getDocument());
-
- fTextViewer.addTextInputListener(this);
-
- ISelectionProvider provider= fTextViewer.getSelectionProvider();
- provider.addSelectionChangedListener(this);
-
- fTextViewer.addTextListener(this);
-
- StyledText text= fTextViewer.getTextWidget();
- text.addKeyListener(this);
- text.addMouseListener(this);
- }
-
- /**
- * Disposes this paint manager. The paint manager uninstalls itself
- * and clears all registered painters. This method is also called when the
- * last painter is removed from the list of managed painters.
- */
- public void dispose() {
-
- if (fManager != null) {
- fManager.dispose();
- fManager= null;
- }
-
- for (Iterator e = fPainters.iterator(); e.hasNext();)
- ((IPainter) e.next()).dispose();
- fPainters.clear();
-
- fTextViewer.removeTextInputListener(this);
-
- ISelectionProvider provider= fTextViewer.getSelectionProvider();
- if (provider != null)
- provider.removeSelectionChangedListener(this);
-
- fTextViewer.removeTextListener(this);
-
- StyledText text= fTextViewer.getTextWidget();
- if (text != null && !text.isDisposed()) {
- text.removeKeyListener(this);
- text.removeMouseListener(this);
- }
- }
-
- /**
- * Triggers all registered painters for the given reason.
- *
- * @param reason the reason
- * @see IPainter
- */
- void paint(int reason) {
- for (Iterator e = fPainters.iterator(); e.hasNext();)
- ((IPainter) e.next()).paint(reason);
- }
-
- /*
- * @see KeyListener#keyPressed(KeyEvent)
- */
- public void keyPressed(KeyEvent e) {
- paint(IPainter.KEY_STROKE);
- }
-
- /*
- * @see KeyListener#keyReleased(KeyEvent)
- */
- public void keyReleased(KeyEvent e) {
- }
-
- /*
- * @see MouseListener#mouseDoubleClick(MouseEvent)
- */
- public void mouseDoubleClick(MouseEvent e) {
- }
-
- /*
- * @see MouseListener#mouseDown(MouseEvent)
- */
- public void mouseDown(MouseEvent e) {
- paint(IPainter.MOUSE_BUTTON);
- }
-
- /*
- * @see MouseListener#mouseUp(MouseEvent)
- */
- public void mouseUp(MouseEvent e) {
- }
-
- /*
- * @see ISelectionChangedListener#selectionChanged(SelectionChangedEvent)
- */
- public void selectionChanged(SelectionChangedEvent event) {
- paint(IPainter.SELECTION);
- }
-
- /*
- * @see ITextListener#textChanged(TextEvent)
- */
- public void textChanged(TextEvent event) {
-
- if (!event.getViewerRedrawState())
- return;
-
- Control control= fTextViewer.getTextWidget();
- if (control != null) {
- control.getDisplay().asyncExec(new Runnable() {
- public void run() {
- if (fTextViewer != null)
- paint(IPainter.TEXT_CHANGE);
- }
- });
- }
- }
-
- /*
- * @see ITextInputListener#inputDocumentAboutToBeChanged(IDocument, IDocument)
- */
- public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {
- if (oldInput != null) {
- for (Iterator e = fPainters.iterator(); e.hasNext();)
- ((IPainter) e.next()).deactivate(false);
- fManager.uninstall(oldInput);
- }
- }
-
- /*
- * @see ITextInputListener#inputDocumentChanged(IDocument, IDocument)
- */
- public void inputDocumentChanged(IDocument oldInput, IDocument newInput) {
- if (newInput != null) {
- fManager.install(newInput);
- paint(IPainter.TEXT_CHANGE);
- }
- }
-}
-
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
deleted file mode 100644
index 78b9c9b8898..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/PropagatingFontFieldEditor.java
+++ /dev/null
@@ -1,132 +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 org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-
-import org.eclipse.jface.preference.FontFieldEditor;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-
-
-/**
- * This font field editor implements chaining between a source preference
- * store and a target preference store. Any time the source preference
- * store changes, the change is propagated to the target store. Propagation
- * means that the actual value stored in the source store is set as default
- * value in the target store. If the target store does not contain a value
- * other than the default value, the new default value is immediately
- * effective.
- *
- * @see FontFieldEditor
- * @since 2.0
- */
-public class PropagatingFontFieldEditor extends FontFieldEditor {
-
- /** The editor's parent widget */
- private Composite fParent;
- /** The representation of the default font choice */
- private String fDefaultFontLabel;
-
- /**
- * Creates a new font field editor with the given parameters.
- *
- * @param name the editor's name
- * @param labelText the text shown as editor description
- * @param parent the editor's parent widget
- * @param defaultFontLabel the label shown in the editor value field when the default value should be taken
- */
- public PropagatingFontFieldEditor(String name, String labelText, Composite parent, String defaultFontLabel) {
- super(name, labelText, parent);
- fParent= parent;
- fDefaultFontLabel= defaultFontLabel == null ? "" : defaultFontLabel; //$NON-NLS-1$
- }
-
- /*
- * @see FontFieldEditor#doLoad()
- */
- protected void doLoad() {
- if (getPreferenceStore().isDefault(getPreferenceName()))
- loadDefault();
- super.doLoad();
- checkForDefault();
- }
-
- /*
- * @see FontFieldEditor#doLoadDefault()
- */
- protected void doLoadDefault() {
- super.doLoadDefault();
- checkForDefault();
- }
-
- /**
- * Checks whether this editor presents the default value "inheritated"
- * from the workbench rather than its own font.
- */
- private void checkForDefault() {
- if (presentsDefaultValue()) {
- Control c= getValueControl(fParent);
- if (c instanceof Label)
- ((Label) c).setText(fDefaultFontLabel);
- }
- }
-
- /**
- * Propagates the font set in the source store to the
- * target store using the given keys.
- *
- * @param source the store from which to read the text font
- * @param sourceKey the key under which the font can be found
- * @param target the store to which to propagate the font
- * @param targetKey the key under which to store the font
- */
- private static void propagateFont(IPreferenceStore source, String sourceKey, IPreferenceStore target, String targetKey) {
- FontData fd= PreferenceConverter.getFontData(source, sourceKey);
- if (fd != null) {
- boolean isDefault= target.isDefault(targetKey); // save old state!
- PreferenceConverter.setDefault(target, targetKey, fd);
- if (isDefault) {
- // restore old state
- target.setToDefault(targetKey);
- }
- }
- }
-
- /**
- * Starts the propagation of the font preference stored in the source preference
- * store under the source key to the target preference store using the target
- * preference key.
- *
- * @param source the source preference store
- * @param sourceKey the key to be used in the source preference store
- * @param target the target preference store
- * @param targetKey the key to be used in the target preference store
- */
- public static void startPropagate(final IPreferenceStore source, final String sourceKey, final IPreferenceStore target, final String targetKey) {
- source.addPropertyChangeListener(new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- if (sourceKey.equals(event.getProperty()))
- propagateFont(source, sourceKey, target, targetKey);
- }
- });
-
- propagateFont(source, sourceKey, target, targetKey);
- }
-}
-
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextAttribute.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/TextAttribute.java
deleted file mode 100644
index dbc1dc02f69..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextAttribute.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;
-
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-
-
-/**
- * Description of textual attributes such as color and style.
- * Text attributes are considered value objects.
- */
-public class TextAttribute {
-
- /** Foreground color */
- private Color foreground;
-
- /** Background color */
- private Color background;
-
- /** The text style */
- private int style;
-
- /**
- * Creates a text attribute with the given colors and style.
- *
- * @param foreground the foreground color
- * @param background the background color
- * @param style the style
- */
- public TextAttribute(Color foreground, Color background, int style) {
- this.foreground= foreground;
- this.background= background;
- this.style= style;
- }
-
- /**
- * Creates a text attribute for the given foreground color, no background color and
- * with the SWT normal style.
- *
- * @param foreground the foreground color
- */
- public TextAttribute(Color foreground) {
- this(foreground, null, SWT.NORMAL);
- }
-
- /*
- * @see Object#equals(Object)
- */
- public boolean equals(Object object) {
-
- if (object == this)
- return true;
-
- if (!(object instanceof TextAttribute))
- return false;
-
- TextAttribute a= (TextAttribute) object;
- return (a.style == style && equals(a.foreground, foreground) && equals(a.background, background));
- }
-
- /**
- * Returns whether the two given objects are equal.
- *
- * @param o1 the first object, can be <code>null</code>
- * @param o2 the second object, can be <code>null</code>
- * @return <code>true</code> if the given objects are equals
- * @since 2.0
- */
- private boolean equals(Object o1, Object o2) {
- if (o1 != null)
- return o1.equals(o2);
- return (o2 == null);
- }
-
- /*
- * @see Object#hashCode()
- */
- public int hashCode() {
- int foregroundHash= foreground == null ? 0 : foreground.hashCode();
- int backgroundHash= background == null ? 0 : background.hashCode();
- return (foregroundHash << 24) | (backgroundHash << 16) | style;
- }
-
- /**
- * Returns the attribute's foreground color.
- *
- * @return the attribute's foreground color
- */
- public Color getForeground() {
- return foreground;
- }
-
- /**
- * Returns the attribute's background color.
- *
- * @return the attribute's background color
- */
- public Color getBackground() {
- return background;
- }
-
- /**
- * Returns the attribute's style.
- *
- * @return the attribute's style
- */
- public int getStyle() {
- return style;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextEvent.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/TextEvent.java
deleted file mode 100644
index eea6bb6d0c7..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextEvent.java
+++ /dev/null
@@ -1,119 +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;
-
-
-/**
- * This event is sent to implementers of <code>ITextListener</code>. It represents a
- * change applied to text viewer. The change is specified as a replace command using
- * offset, length, inserted text, and replaced text. The text viewer issues a text event
- * after the viewer has been changed either in response to a change of the viewer's document
- * or when the viewer's visual content has been changed. In the first case, the text event
- * also carries the original document event. Depending on the viewer's presentation mode,
- * the text event coordinates are different from the document event's coordinates.
- * Client's other than text viewer's don't create instances of this class.
- *
- * @see ITextListener
- * @see ITextViewer
- * @see DocumentEvent
- */
-public class TextEvent {
-
- /** Start offset of the change */
- private int fOffset;
- /** The length of the change */
- private int fLength;
- /** Inserted text */
- private String fText;
- /** Replaced text */
- private String fReplacedText;
- /** The original document event, may by null */
- private DocumentEvent fDocumentEvent;
- /**
- * The redraw state of the viewer issuing this event
- * @since 2.0
- */
- private boolean fViewerRedrawState;
-
- /**
- * Creates a new <code>TextEvent</code> based on the specification.
- *
- * @param offset the offset
- * @param length the length
- * @param replacedText the replaced text
- * @param event the associated document event or <code>null</code> if none
- * @param viewerRedrawState the redraw state of the viewer
- */
- protected TextEvent(int offset, int length, String text, String replacedText, DocumentEvent event, boolean viewerRedrawState) {
- fOffset= offset;
- fLength= length;
- fText= text;
- fReplacedText= replacedText;
- fDocumentEvent= event;
- fViewerRedrawState= viewerRedrawState;
- }
-
- /**
- * Returns the offset of the event.
- *
- * @return the offset of the event
- */
- public int getOffset() {
- return fOffset;
- }
-
- /**
- * Returns the length of the event.
- *
- * @return the length of the event
- */
- public int getLength() {
- return fLength;
- }
-
- /**
- * Returns the text of the event.
- *
- * @return the text of the event
- */
- public String getText() {
- return fText;
- }
-
- /**
- * Returns the text replaced by this event.
- *
- * @return the text replaced by this event
- */
- public String getReplacedText() {
- return fReplacedText;
- }
-
- /**
- * Returns the corresponding document event that caused the viewer change
- *
- * @return the corresponding document event, <code>null</code> if a visual change only
- */
- public DocumentEvent getDocumentEvent() {
- return fDocumentEvent;
- }
-
- /**
- * Returns the viewer's redraw state.
- *
- * @return <code>true</code> if the viewer's redraw state is <code>true</code>
- * @since 2.0
- */
- public boolean getViewerRedrawState() {
- return fViewerRedrawState;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextPresentation.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/TextPresentation.java
deleted file mode 100644
index 7a66fa5e5ff..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextPresentation.java
+++ /dev/null
@@ -1,417 +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.Iterator;
-import java.util.NoSuchElementException;
-
-import org.eclipse.swt.custom.StyleRange;
-import org.eclipse.swt.custom.StyledText;
-
-
-/**
- * Describes the presentation styles for a section of an indexed text
- * such as a document or string. A text presentation defines a default style
- * for the whole section and in addition style differences for individual
- * subsections. Text presentations can be narrowed down to a particular
- * result window. All methods are result window aware, i.e. ranges outside
- * the result window are always ignored.<p>
- * All iterators provided by a text presentation assume that they enumerate
- * non overlapping, consecutive ranges inside the default range. Thus, all
- * these iterators do not include the default range. The default style range
- * must be explicitly asked for using <code>getDefaultStyleRange</code>.
- */
-public class TextPresentation {
-
- /**
- * Applies the given presentation to the given text widget. Helper method.
- *
- * @param presentation the style information
- * @param the widget to which to apply the style information
- * @since 2.0
- */
- public static void applyTextPresentation(TextPresentation presentation, StyledText text) {
-
- StyleRange[] ranges= new StyleRange[presentation.getDenumerableRanges()];
-
- int i= 0;
- Iterator e= presentation.getAllStyleRangeIterator();
- while (e.hasNext())
- ranges[i++]= (StyleRange) e.next();
-
- text.setStyleRanges(ranges);
- }
-
-
-
-
- /**
- * Enumerates all the <code>StyleRange</code>s included in the presentation.
- */
- class FilterIterator implements Iterator {
-
- /** The index of the next style range to be enumerated */
- protected int fIndex;
- /** The upper bound of the indices of style ranges to be enumerated */
- protected int fLength;
- /** Indicates whether ranges similar to the default range should be enumerated */
- protected boolean fSkipDefaults;
- /** The result window */
- protected IRegion fWindow;
-
- /**
- * <code>skipDefaults</code> tells the enumeration to skip all those style ranges
- * which define the same style as the presentation's default style range.
- *
- * @param skipDefaults <code>false</code> if ranges similar to the default range should be enumerated
- */
- protected FilterIterator(boolean skipDefaults) {
-
- fSkipDefaults= skipDefaults;
-
- fWindow= fResultWindow;
- fIndex= getFirstIndexInWindow(fWindow);
- fLength= getFirstIndexAfterWindow(fWindow);
-
- if (fSkipDefaults)
- computeIndex();
- }
-
- /*
- * @see Iterator#next()
- */
- public Object next() {
- try {
- StyleRange r= (StyleRange) fRanges.get(fIndex++);
- return createWindowRelativeRange(fWindow, r);
- } catch (ArrayIndexOutOfBoundsException x) {
- throw new NoSuchElementException();
- } finally {
- if (fSkipDefaults)
- computeIndex();
- }
- }
-
- /*
- * @see Iterator#hasNext()
- */
- public boolean hasNext() {
- return fIndex < fLength;
- }
-
- /*
- * @see Iterator#remove()
- */
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Returns whether the given object should be skipped.
- *
- * @param o the object to be checked
- * @return <code>true</code> if the object should be skipped by the iterator
- */
- protected boolean skip(Object o) {
- StyleRange r= (StyleRange) o;
- return r.similarTo(fDefaultRange);
- }
-
- /**
- * Computes the index of the styled range that is the next to be enumerated.
- */
- protected void computeIndex() {
- while (fIndex < fLength && skip(fRanges.get(fIndex)))
- ++ fIndex;
- }
- }
-
- /** The syle information for the range covered by the whole presentation */
- private StyleRange fDefaultRange;
- /** The member ranges of the presentation */
- private ArrayList fRanges;
- /** A clipping region against which the presentation can be clipped when asked for results */
- private IRegion fResultWindow;
-
-
- /**
- * Creates a new empty text presentation.
- */
- public TextPresentation() {
- fRanges= new ArrayList(50);
- }
-
- /**
- * Creates a new empty text presentation. <code>sizeHint</code> tells the
- * expected size of this presentation.
- *
- * @param sizeHint the expected size of this presentation
- */
- public TextPresentation(int sizeHint) {
- Assert.isTrue(sizeHint > 0);
- fRanges= new ArrayList(sizeHint);
- }
-
- /**
- * Sets the result window for this presentation. When dealing with
- * this presentation all ranges which are outside the result window
- * are ignored. For example, the size of the presentation is 0
- * when there is no range inside the window even if there are ranges
- * outside the window. All methods are aware of the result window.
- *
- * @param resultWindow the result window
- */
- public void setResultWindow(IRegion resultWindow) {
- fResultWindow= resultWindow;
- }
-
- /**
- * Set the default style range of this presentation.
- * The default style range defines the overall area covered
- * by this presentation and its style information.
- *
- * @param range the range decribing the default region
- */
- public void setDefaultStyleRange(StyleRange range) {
- fDefaultRange= range;
- }
-
- /**
- * Returns this presentation's default style range. The returned <code>StyleRange</code>
- * is relative to the start of the result window.
- *
- * @return this presentation's default style range
- */
- public StyleRange getDefaultStyleRange() {
- return createWindowRelativeRange(fResultWindow, fDefaultRange);
- }
-
- /**
- * Add the given range to the presentation. The range must be a
- * subrange of the presentation's default range.
- *
- * @param range the range to be added
- */
- public void addStyleRange(StyleRange range) {
- checkConsistency(range);
- fRanges.add(range);
- }
-
- /**
- * Checks whether the given range is a subrange of the presentation's
- * default style range.
- *
- * @param range the range to be checked
- * @exception IllegalArgumentAxception if range is not a subrange of the presentation's default range
- */
- private void checkConsistency(StyleRange range) {
-
- if (range == null)
- throw new IllegalArgumentException();
-
- if (fDefaultRange != null) {
-
- if (range.start < fDefaultRange.start)
- range.start= fDefaultRange.start;
-
- int defaultEnd= fDefaultRange.start + fDefaultRange.length;
- int end= range.start + range.length;
- if (end > defaultEnd)
- range.length -= (defaultEnd - end);
- }
- }
-
- /**
- * Returns the index of the first range which overlaps with the
- * specified window.
- *
- * @param window the window to be used for searching
- * @return the index of the first range overlapping with the window
- */
- private int getFirstIndexInWindow(IRegion window) {
- int i= 0;
- if (window != null) {
- int start= window.getOffset();
- while (i < fRanges.size()) {
- StyleRange r= (StyleRange) fRanges.get(i++);
- if (r.start + r.length > start) {
- -- i;
- break;
- }
- }
- }
- return i;
- }
-
- /**
- * Returns the index of the first range which comes after the specified window and does
- * not overlap with this window.
- *
- * @param window the window to be used for searching
- * @return the index of the first range behind the window and not overlapping with the window
- */
- private int getFirstIndexAfterWindow(IRegion window) {
- int i= fRanges.size();
- if (window != null) {
- int end= window.getOffset() + window.getLength();
- while (i > 0) {
- StyleRange r= (StyleRange) fRanges.get(--i);
- if (r.start < end) {
- ++ i;
- break;
- }
- }
- }
- return i;
- }
-
- /**
- * Returns a style range which is relative to the specified window and
- * appropriately clipped if necessary. The original style range is not
- * modified.
- *
- * @param window the reference window
- * @param range the absolute range
- * @return the window relative range based on the absolute range
- */
- private StyleRange createWindowRelativeRange(IRegion window, StyleRange range) {
- if (window == null || range == null)
- return range;
-
- int start= range.start - window.getOffset();
- if (start < 0)
- start= 0;
-
- int rangeEnd= range.start + range.length;
- int windowEnd= window.getOffset() + window.getLength();
- int end= (rangeEnd > windowEnd ? windowEnd : rangeEnd);
- end -= window.getOffset();
-
- StyleRange newRange= (StyleRange) range.clone();
- newRange.start= start;
- newRange.length= end - start;
- return newRange;
- }
-
-
- /**
- * Returns an iterator which enumerates all style ranged which define a style
- * different from the presentation's default style range. The default style range
- * is not enumerated.
- *
- * @return a style range interator
- */
- public Iterator getNonDefaultStyleRangeIterator() {
- return new FilterIterator(fDefaultRange != null);
- }
-
- /**
- * Returns an iterator which enumerates all style ranges of this presentation
- * except the default style range. The returned <code>StyleRange</code>s
- * are relative to the start of the presentation's result window.
- *
- * @return a style range iterator
- */
- public Iterator getAllStyleRangeIterator() {
- return new FilterIterator(false);
- }
-
- /**
- * Returns whether this collection contains any style range including
- * the default style range.
- *
- * @return <code>true</code> if there is no style range in this presentation
- */
- public boolean isEmpty() {
- return (fDefaultRange == null && getDenumerableRanges() == 0);
- }
-
- /**
- * Returns the number of style ranges in the presentation not counting the default
- * style range.
- *
- * @return the number of style ranges in the presentation excluding the default style range
- */
- public int getDenumerableRanges() {
- int size= getFirstIndexAfterWindow(fResultWindow) - getFirstIndexInWindow(fResultWindow);
- return (size < 0 ? 0 : size);
- }
-
- /**
- * Returns the style range with the smallest offset ignoring the default style range or null
- * if the presentation is empty.
- *
- * @return the style range with the smalled offset different from the default style range
- */
- public StyleRange getFirstStyleRange() {
- try {
-
- StyleRange range= (StyleRange) fRanges.get(getFirstIndexInWindow(fResultWindow));
- return createWindowRelativeRange(fResultWindow, range);
-
- } catch (NoSuchElementException x) {
- }
-
- return null;
- }
-
- /**
- * Returns the style range with the highest offset ignoring the default style range.
- *
- * @return the style range with the highest offset different from the default style range
- */
- public StyleRange getLastStyleRange() {
- try {
-
- StyleRange range= (StyleRange) fRanges.get(getFirstIndexAfterWindow(fResultWindow) - 1);
- return createWindowRelativeRange(fResultWindow, range);
-
- } catch (NoSuchElementException x) {
- }
-
- return null;
- }
-
- /**
- * Returns the coverage of this presentation as clipped by the presentation's
- * result window.
- *
- * @return the coverage of this presentation
- */
- public IRegion getCoverage() {
-
- if (fDefaultRange != null) {
- StyleRange range= getDefaultStyleRange();
- return new Region(range.start, range.length);
- }
-
- StyleRange first= getFirstStyleRange();
- StyleRange last= getLastStyleRange();
-
- if (first == null || last == null)
- return null;
-
- return new Region(first.start, last.start - first. start + last.length);
- }
-
- /**
- * Clears this presentation by resetting all applied changes.
- * @since 2.0
- */
- public void clear() {
- fDefaultRange= null;
- fResultWindow= null;
- fRanges.clear();
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextSelection.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/TextSelection.java
deleted file mode 100644
index ed8da0e9cd3..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextSelection.java
+++ /dev/null
@@ -1,188 +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;
-
-
-
-
-/**
- * Standard implementation of <code>ITextSelection</code>.
- * Makes advantage of the weak contract of correctness of its
- * interface. If generated from a selection provider, it only
- * remembers its offset and length and computes the remaining
- * information on request.
- */
-public class TextSelection implements ITextSelection {
-
- /** Internal empty text selection */
- private final static ITextSelection NULL= new TextSelection();
-
- /**
- * Returns a shared instance of an empty text selection.
- *
- * @return a shared instance of an empty text selection
- */
- public static ITextSelection emptySelection() {
- return NULL;
- }
-
- /** Document which delivers the data of the selection */
- private IDocument fDocument;
- /** Offset of the selection */
- private int fOffset;
- /** Length of the selection */
- private int fLength;
-
-
- /**
- * Creates an empty text selection.
- */
- private TextSelection() {
- this(null, -1, -1);
- }
-
- /**
- * Creates a text selection for the given range. This
- * selection object describes generically a text range and
- * is intended to be an argument for the <code>setSelection</code>
- * method of selection providers.
- *
- * @param offset the offset of the range
- * @param length the length of the range
- */
- public TextSelection(int offset, int length) {
- this(null, offset, length);
- }
-
- /**
- * Creates a text selection for the given range of the given document.
- * This selection object is created by selection providers in responds
- * <code>getSelection</code>.
- *
- * @param document the document whose text range is selected in a viewer
- * @param offset the offset of the selected range
- * @param length the length of the selected range
- */
- public TextSelection(IDocument document, int offset, int length) {
- fDocument= document;
- fOffset= offset;
- fLength= length;
- }
-
- /**
- * Returns true if the offset and length are smaller than 0.
- * A selection of length 0, is a valid text selection as it
- * describes, e.g., the cursor position in a viewer.
- */
- /*
- * @see ISelection#isEmpty()
- */
- public boolean isEmpty() {
- return fOffset < 0 || fLength < 0;
- }
-
- /*
- * @see ITextSelection#getOffset()
- */
- public int getOffset() {
- return fOffset;
- }
-
- /*
- * @see ITextSelection#getLength()
- */
- public int getLength() {
- return fLength;
- }
-
- /*
- * @see ITextSelection#getStartLine()
- */
- public int getStartLine() {
-
- try {
- if (fDocument != null)
- return fDocument.getLineOfOffset(fOffset);
- } catch (BadLocationException x) {
- }
-
- return -1;
- }
-
- /*
- * @see ITextSelection#getEndLine()
- */
- public int getEndLine() {
- try {
- if (fDocument != null) {
- int endOffset= fOffset + fLength;
- if (fLength != 0)
- endOffset--;
- return fDocument.getLineOfOffset(endOffset);
- }
- } catch (BadLocationException x) {
- }
-
- return -1;
- }
-
- /*
- * @see ITextSelection#getText()
- */
- public String getText() {
- try {
- if (fDocument != null)
- return fDocument.get(fOffset, fLength);
- } catch (BadLocationException x) {
- }
-
- return null;
- }
-
- /*
- * @see java.lang.Object#equals(Object)
- */
- public boolean equals(Object obj) {
- if (obj == this)
- return true;
-
- if (obj == null || getClass() != obj.getClass())
- return false;
-
- TextSelection s= (TextSelection) obj;
- boolean sameRange= (s.fOffset == fOffset && s.fLength == fLength);
- if (sameRange) {
-
- if (s.fDocument == null && fDocument == null)
- return true;
- if (s.fDocument == null || fDocument == null)
- return false;
-
- try {
- String sContent= s.fDocument.get(fOffset, fLength);
- String content= fDocument.get(fOffset, fLength);
- return sContent.equals(content);
- } catch (BadLocationException x) {
- }
- }
-
- return false;
- }
-
- /*
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- int low= fDocument != null ? fDocument.hashCode() : 0;
- return (fOffset << 24) | (fLength << 16) | low;
- }
-}
-
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
deleted file mode 100644
index a1d45e2289f..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java
+++ /dev/null
@@ -1,4668 +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.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.PatternSyntaxException;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.LineBackgroundEvent;
-import org.eclipse.swt.custom.LineBackgroundListener;
-import org.eclipse.swt.custom.ST;
-import org.eclipse.swt.custom.StyleRange;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.custom.VerifyKeyListener;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.ControlListener;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.events.TraverseEvent;
-import org.eclipse.swt.events.TraverseListener;
-import org.eclipse.swt.events.VerifyEvent;
-import org.eclipse.swt.events.VerifyListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.printing.PrintDialog;
-import org.eclipse.swt.printing.Printer;
-import org.eclipse.swt.printing.PrinterData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.ScrollBar;
-
-import org.eclipse.jface.viewers.IPostSelectionProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.Viewer;
-
-
-
-/**
- * SWT based implementation of <code>ITextViewer</code>. Once the viewer and its SWT control
- * have been created the viewer can only indirectly be disposed by disposing its SWT control.<p>
- * Clients are supposed to instantiate a text viewer and subsequently to communicate with it
- * exclusively using the <code>ITextViewer</code> interface or any of the implemented extension
- * interfaces. <p>
- * A text viewer serves as text operation target. It only partially supports the external control of
- * the enable state of its text operations. A text viewer is also a widget token owner. Anything that
- * wants to display an overlay window on top of a text viewer should implement the
- * <code>IWidgetTokenKeeper</code> interface and participate in the widget token negotiation between
- * the text viewer and all its potential widget token keepers.<p>
- * Clients should not subclass this class as it is rather likely that subclasses will be broken by
- * future releases.
- *
- * @see ITextViewer
- */
-public class TextViewer extends Viewer implements
- ITextViewer, ITextViewerExtension, ITextViewerExtension2, ITextViewerExtension4,
- ITextOperationTarget, ITextOperationTargetExtension,
- IWidgetTokenOwner, IWidgetTokenOwnerExtension, IPostSelectionProvider {
-
- /** Internal flag to indicate the debug state. */
- public static boolean TRACE_ERRORS= false;
-
- /**
- * Represents a replace command that brings the text viewer's text widget
- * back in sync with text viewer's document after the document has been changed.
- */
- protected class WidgetCommand {
-
- public DocumentEvent event;
- public int start, length;
- public String text, preservedText;
-
- /**
- * Translates a document event into the presentation coordinates of this text viewer.
- *
- * @param e the event to be translated
- */
- public void setEvent(DocumentEvent e) {
-
- event= e;
-
- start= e.getOffset();
- length= e.getLength();
- text= e.getText();
-
- if (length != 0) {
- try {
- preservedText= e.getDocument().get(e.getOffset(), e.getLength());
- } catch (BadLocationException x) {
- preservedText= null;
- if (TRACE_ERRORS)
- System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.WidgetCommand.setEvent")); //$NON-NLS-1$
- }
- } else
- preservedText= null;
- }
- }
-
- /**
- * Connects a text double click strategy to this viewer's text widget.
- * Calls the double click strategy when the mouse has been double clicked
- * inside the text editor.
- */
- class TextDoubleClickStrategyConnector extends MouseAdapter {
-
- /** Internal flag to remember that a double clicked occurred. */
- private boolean fDoubleClicked= false;
-
- public TextDoubleClickStrategyConnector() {
- }
-
- /*
- * @see MouseListener#mouseDoubleClick(MouseEvent)
- */
- public void mouseDoubleClick(MouseEvent e) {
- fDoubleClicked= true;
- }
-
- /*
- * @see MouseListener#mouseUp(MouseEvent)
- */
- public void mouseUp(MouseEvent e) {
- if (fDoubleClicked) {
- fDoubleClicked= false;
- ITextDoubleClickStrategy s= (ITextDoubleClickStrategy) selectContentTypePlugin(getSelectedRange().x, fDoubleClickStrategies);
- if (s != null)
- s.doubleClicked(TextViewer.this);
- }
- }
- }
-
- /**
- * Monitors the area of the viewer's document that is visible in the viewer.
- * If the area might have changed, it informs the text viewer about this
- * potential change and its origin. The origin is internally used for optimization
- * purposes.
- */
- class ViewportGuard extends MouseAdapter
- implements ControlListener, KeyListener, SelectionListener {
-
- /*
- * @see ControlListener#controlResized(ControlEvent)
- */
- public void controlResized(ControlEvent e) {
- updateViewportListeners(RESIZE);
- }
-
- /*
- * @see ControlListener#controlMoved(ControlEvent)
- */
- public void controlMoved(ControlEvent e) {
- }
-
- /*
- * @see KeyListener#keyReleased
- */
- public void keyReleased(KeyEvent e) {
- updateViewportListeners(KEY);
- }
-
- /*
- * @see KeyListener#keyPressed
- */
- public void keyPressed(KeyEvent e) {
- updateViewportListeners(KEY);
- }
-
- /*
- * @see MouseListener#mouseUp
- */
- public void mouseUp(MouseEvent e) {
- if (fTextWidget != null)
- fTextWidget.removeSelectionListener(this);
- updateViewportListeners(MOUSE_END);
- }
-
- /*
- * @see MouseListener#mouseDown
- */
- public void mouseDown(MouseEvent e) {
- if (fTextWidget != null)
- fTextWidget.addSelectionListener(this);
- }
-
- /*
- * @see SelectionListener#widgetSelected
- */
- public void widgetSelected(SelectionEvent e) {
- if (e.widget == fScroller)
- updateViewportListeners(SCROLLER);
- else
- updateViewportListeners(MOUSE);
- }
-
- /*
- * @see SelectionListener#widgetDefaultSelected
- */
- public void widgetDefaultSelected(SelectionEvent e) {}
- }
-
- /**
- * This position updater is used to keep the selection during text shift operations.
- */
- static class ShiftPositionUpdater extends DefaultPositionUpdater {
-
- /**
- * Creates the position updater for the given category.
- *
- * @param category the category this updater takes care of
- */
- protected ShiftPositionUpdater(String category) {
- super(category);
- }
-
- /**
- * If an insertion happens at the selection's start offset,
- * the position is extended rather than shifted.
- */
- protected void adaptToInsert() {
-
- int myStart= fPosition.offset;
- int myEnd= fPosition.offset + fPosition.length -1;
- 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;
- return;
- }
-
- if (myStart > yoursStart)
- fPosition.offset += fReplaceLength;
- }
- }
-
- /**
- * Internal document listener.
- */
- class DocumentListener implements IDocumentListener {
-
- /*
- * @see IDocumentListener#documentAboutToBeChanged
- */
- public void documentAboutToBeChanged(DocumentEvent e) {
- if (e.getDocument() == getVisibleDocument())
- fWidgetCommand.setEvent(e);
- }
-
- /*
- * @see IDocumentListener#documentChanged
- */
- public void documentChanged(final DocumentEvent e) {
- if (fWidgetCommand.event == e)
- updateTextListeners(fWidgetCommand);
- fLastSentSelectionChange= null;
- }
- }
-
-
- /**
- * Internal verify listener.
- */
- class TextVerifyListener implements VerifyListener {
-
- /**
- * Indicates whether verify events are forwarded or ignored.
- * @since 2.0
- */
- private boolean fForward= true;
-
- /**
- * Tells the listener to forward received events.
- *
- * @param forward <code>true</code> if forwarding should be enabled.
- * @since 2.0
- */
- public void forward(boolean forward) {
- fForward= forward;
- }
-
- /*
- * @see VerifyListener#verifyText(VerifyEvent)
- */
- public void verifyText(VerifyEvent e) {
- if (fForward)
- handleVerifyEvent(e);
- }
- }
-
- /**
- * The viewer's manager reponsible for registered verify key listeners.
- * Uses batches rather than robust iterators because of performance issues.
- *
- * @since 2.0
- */
- class VerifyKeyListenersManager implements VerifyKeyListener {
-
- /**
- * Represents a batched addListener/removeListener command.
- */
- class Batch {
- /** The index at which to insert the listener. */
- int index;
- /** The listener to be inserted. */
- VerifyKeyListener listener;
-
- /**
- * Creates a new batch containing the given listener for the given index.
- *
- * @param l the listener to be added
- * @param i the index at which to insert the listener
- */
- public Batch(VerifyKeyListener l, int i) {
- listener= l;
- index= i;
- }
- }
-
- /** List of registed verify key listeners. */
- private List fListeners= new ArrayList();
- /** List of pending batches. */
- private List fBatched= new ArrayList();
- /** The currently active iterator. */
- private Iterator fIterator;
-
- /*
- * @see VerifyKeyListener#verifyKey(VerifyEvent)
- */
- public void verifyKey(VerifyEvent event) {
- if (fListeners.isEmpty())
- return;
-
- fIterator= fListeners.iterator();
- while (fIterator.hasNext() && event.doit) {
- VerifyKeyListener listener= (VerifyKeyListener) fIterator.next();
- listener.verifyKey(event);
- }
- fIterator= null;
-
- processBatchedRequests();
- }
-
- /**
- * Processes the pending batched requests.
- */
- private void processBatchedRequests() {
- if (!fBatched.isEmpty()) {
- Iterator e= fBatched.iterator();
- while (e.hasNext()) {
- Batch batch= (Batch) e.next();
- insertListener(batch.listener, batch.index);
- }
- fBatched.clear();
- }
- }
-
- /**
- * Returns the number of registered verify key listeners.
- *
- * @return the number of registered verify key listeners
- */
- public int numberOfListeners() {
- return fListeners.size();
- }
-
- /**
- * Inserts the given listener at the given index or moves it
- * to that index.
- *
- * @param listener the listener to be inserted
- * @param index the index of the listener or -1 for remove
- */
- public void insertListener(VerifyKeyListener listener, int index) {
-
- if (index == -1) {
- removeListener(listener);
- } else if (listener != null) {
-
- if (fIterator != null) {
-
- fBatched.add(new Batch(listener, index));
-
- } else {
-
- int idx= -1;
-
- // find index based on identity
- int size= fListeners.size();
- for (int i= 0; i < size; i++) {
- if (listener == fListeners.get(i)) {
- idx= i;
- break;
- }
- }
-
- // move or add it
- if (idx != index) {
-
- if (idx != -1)
- fListeners.remove(idx);
-
- if (index > fListeners.size())
- fListeners.add(listener);
- else
- fListeners.add(index, listener);
- }
-
- if (size == 0) // checking old size, i.e. current size == size + 1
- install();
- }
- }
- }
-
- /**
- * Removes the given listener.
- *
- * @param listener the listener to be removed
- */
- public void removeListener(VerifyKeyListener listener) {
- if (listener == null)
- return;
-
- if (fIterator != null) {
-
- fBatched.add(new Batch(listener, -1));
-
- } else {
-
- int size= fListeners.size();
- for (int i= 0; i < size; i++) {
- if (listener == fListeners.get(i)) {
- fListeners.remove(i);
- if (size == 1) // checking old size, i.e. current size == size - 1
- uninstall();
- return;
- }
- }
- }
- }
-
- /**
- * Installs this manager.
- */
- private void install() {
- StyledText textWidget= getTextWidget();
- if (textWidget != null && !textWidget.isDisposed())
- textWidget.addVerifyKeyListener(this);
- }
-
- /**
- * Uninstalls this manager.
- */
- private void uninstall() {
- StyledText textWidget= getTextWidget();
- if (textWidget != null && !textWidget.isDisposed())
- textWidget.removeVerifyKeyListener(this);
- }
- }
-
-
- /**
- * Reification of a range in which a find replace operation is performed. This range is visually
- * highlighted in the viewer as long as the replace operation is in progress.
- *
- * @since 2.0
- */
- class FindReplaceRange implements LineBackgroundListener, ITextListener, IPositionUpdater {
-
- /** Internal name for the position category used to update the range. */
- private final static String RANGE_CATEGORY= "org.eclipse.jface.text.TextViewer.find.range"; //$NON-NLS-1$
-
- /** The highlight color of this range. */
- private Color fHighlightColor;
- /** The position used to lively update this range's extent. */
- private Position fPosition;
-
- /** Creates a new find/replace range with the given extent.
- *
- * @param range the extent of this range
- */
- public FindReplaceRange(IRegion range) {
- setRange(range);
- }
-
- /**
- * Sets the extent of this range.
- *
- * @param range the extent of this range
- */
- public void setRange(IRegion range) {
- fPosition= new Position(range.getOffset(), range.getLength());
- }
-
- /**
- * Returns the extent of this range.
- *
- * @return the extent of this range
- */
- public IRegion getRange() {
- return new Region(fPosition.getOffset(), fPosition.getLength());
- }
-
- /**
- * Sets the highlight color of this range. Causes the range to be redrawn.
- *
- * @param color the highlight color
- */
- public void setHighlightColor(Color color) {
- fHighlightColor= color;
- paint();
- }
-
- /*
- * @see LineBackgroundListener#lineGetBackground(LineBackgroundEvent)
- * @since 2.0
- */
- public void lineGetBackground(LineBackgroundEvent event) {
- /* Don't use cached line information because of patched redrawing events. */
-
- if (fTextWidget != null) {
- int offset= widgetOffset2ModelOffset(event.lineOffset);
- if (fPosition.includes(offset))
- event.lineBackground= fHighlightColor;
- }
- }
-
- /**
- * Installs this range. The range registers itself as background
- * line painter and text listener. Also, it creates a category with the
- * viewer's document to maintain its own extent.
- */
- public void install() {
- TextViewer.this.addTextListener(this);
- fTextWidget.addLineBackgroundListener(this);
-
- IDocument document= TextViewer.this.getDocument();
- try {
- document.addPositionCategory(RANGE_CATEGORY);
- document.addPosition(RANGE_CATEGORY, fPosition);
- document.addPositionUpdater(this);
- } catch (BadPositionCategoryException e) {
- // should not happen
- } catch (BadLocationException e) {
- // should not happen
- }
-
- paint();
- }
-
- /**
- * Uninstalls this range.
- * @see #install()
- */
- public void uninstall() {
-
- // http://bugs.eclipse.org/bugs/show_bug.cgi?id=19612
-
- IDocument document= TextViewer.this.getDocument();
- if (document != null) {
- document.removePositionUpdater(this);
- document.removePosition(fPosition);
- }
-
- if (fTextWidget != null && !fTextWidget.isDisposed())
- fTextWidget.removeLineBackgroundListener(this);
-
- TextViewer.this.removeTextListener(this);
-
- clear();
- }
-
- /**
- * Clears the highlighting of this range.
- */
- private void clear() {
- if (fTextWidget != null && !fTextWidget.isDisposed())
- fTextWidget.redraw();
- }
-
- /**
- * Paints the highlighting of this range.
- */
- private void paint() {
-
- IRegion widgetRegion= modelRange2WidgetRange(fPosition);
- int offset= widgetRegion.getOffset();
- int length= widgetRegion.getLength();
-
- int count= fTextWidget.getCharCount();
- if (offset + length >= count) {
- length= count - offset; // clip
-
- Point upperLeft= fTextWidget.getLocationAtOffset(offset);
- Point lowerRight= fTextWidget.getLocationAtOffset(offset + length);
- int width= fTextWidget.getClientArea().width;
- int height= fTextWidget.getLineHeight() + lowerRight.y - upperLeft.y;
- fTextWidget.redraw(upperLeft.x, upperLeft.y, width, height, false);
- }
-
- fTextWidget.redrawRange(offset, length, true);
- }
-
- /*
- * @see ITextListener#textChanged(TextEvent)
- * @since 2.0
- */
- public void textChanged(TextEvent event) {
- if (event.getViewerRedrawState())
- paint();
- }
-
- /*
- * @see IPositionUpdater#update(DocumentEvent)
- * @since 2.0
- */
- public void update(DocumentEvent event) {
- int offset= event.getOffset();
- int length= event.getLength();
- int delta= event.getText().length() - length;
-
- if (offset < fPosition.getOffset())
- fPosition.setOffset(fPosition.getOffset() + delta);
- else if (offset < fPosition.getOffset() + fPosition.getLength())
- fPosition.setLength(fPosition.getLength() + delta);
- }
- }
-
- /**
- * This viewer's find/replace target.
- */
- class FindReplaceTarget implements IFindReplaceTarget, IFindReplaceTargetExtension, IFindReplaceTargetExtension3 {
-
- /** The range for this target. */
- private FindReplaceRange fRange;
- /** The highlight color of the range of this target. */
- private Color fScopeHighlightColor;
- /** The document partitioner remembered in case of a "Replace All". */
- private Map fRememberedPartitioners;
-
- /**
- * Resets the find/replace document adapter.
- *
- * @return the find/replace document adapter.
- * @since 3.0
- */
- void resetFindRepalceDocumentAdapter() {
- fFindRepalceDocumentAdapter= new FindReplaceDocumentAdapter(TextViewer.this.getVisibleDocument());
- }
-
- /*
- * @see IFindReplaceTarget#getSelectionText()
- */
- public String getSelectionText() {
- Point s= TextViewer.this.getSelectedRange();
- if (s.x > -1 && s.y > -1) {
- try {
- IDocument document= TextViewer.this.getDocument();
- return document.get(s.x, s.y);
- } catch (BadLocationException x) {
- }
- }
- return null;
- }
-
- /*
- * @see IFindReplaceTarget#replaceSelection(String)
- */
- public void replaceSelection(String text) {
- replaceSelection(text, false);
- }
-
- /*
- * @see IFindReplaceTarget#replaceSelection(String)
- */
- public void replaceSelection(String text, boolean regExReplace) {
- Point s= TextViewer.this.getSelectedRange();
- if (s.x > -1 && s.y > -1) {
- try {
- IRegion matchRegion= TextViewer.this.getFindRepalceDocumentAdapter().replace(text, regExReplace);
- int length= -1;
- if (matchRegion != null)
- length= matchRegion.getLength();
-
- if (text != null && length > 0)
- TextViewer.this.setSelectedRange(s.x, length);
- } catch (BadLocationException x) {
- }
- }
- }
-
- /*
- * @see IFindReplaceTarget#isEditable()
- */
- public boolean isEditable() {
- return TextViewer.this.isEditable();
- }
-
- /*
- * @see IFindReplaceTarget#getSelection()
- */
- public Point getSelection() {
- Point point= TextViewer.this.getSelectedRange();
- return modelSelection2WidgetSelection(point);
- }
-
- /*
- * @see IFindReplaceTarget#findAndSelect(int, String, boolean, boolean, boolean)
- */
- public int findAndSelect(int offset, String findString, boolean searchForward, boolean caseSensitive, boolean wholeWord) {
- try {
- return findAndSelect(offset, findString, searchForward, caseSensitive, wholeWord, false);
- } catch (PatternSyntaxException ex) {
- return -1;
- }
- }
-
- /*
- * @see IFindReplaceTarget#findAndSelect(int, String, boolean, boolean, boolean)
- */
- public int findAndSelect(int offset, String findString, boolean searchForward, boolean caseSensitive, boolean wholeWord, boolean regExSearch) {
-
- int modelOffset= offset == -1 ? -1 : widgetOffset2ModelOffset(offset);
-
- if (fRange != null) {
- IRegion range= fRange.getRange();
- modelOffset= TextViewer.this.findAndSelectInRange(modelOffset, findString, searchForward, caseSensitive, wholeWord, range.getOffset(), range.getLength(), regExSearch);
- } else {
- modelOffset= TextViewer.this.findAndSelect(modelOffset, findString, searchForward, caseSensitive, wholeWord, regExSearch);
- }
-
- offset= modelOffset == -1 ? -1 : modelOffset2WidgetOffset(modelOffset);
- return offset;
- }
-
- /*
- * @see IFindReplaceTarget#canPerformFind()
- */
- public boolean canPerformFind() {
- return TextViewer.this.canPerformFind();
- }
-
- /*
- * @see IFindReplaceTargetExtension#beginSession()
- * @since 2.0
- */
- public void beginSession() {
- fRange= null;
- }
-
- /*
- * @see IFindReplaceTargetExtension#endSession()
- * @since 2.0
- */
- public void endSession() {
- if (fRange != null) {
- fRange.uninstall();
- fRange= null;
- }
- }
-
- /*
- * @see IFindReplaceTargetExtension#getScope()
- * @since 2.0
- */
- public IRegion getScope() {
- return fRange == null ? null : fRange.getRange();
- }
-
- /*
- * @see IFindReplaceTargetExtension#getLineSelection()
- * @since 2.0
- */
- public Point getLineSelection() {
- Point point= TextViewer.this.getSelectedRange();
-
- try {
- IDocument document= TextViewer.this.getDocument();
-
- // beginning of line
- int line= document.getLineOfOffset(point.x);
- int offset= document.getLineOffset(line);
-
- // end of line
- IRegion lastLineInfo= document.getLineInformationOfOffset(point.x + point.y);
- int lastLine= document.getLineOfOffset(point.x + point.y);
- int length;
- if (lastLineInfo.getOffset() == point.x + point.y && lastLine > 0)
- length= document.getLineOffset(lastLine - 1) + document.getLineLength(lastLine - 1) - offset;
- else
- length= lastLineInfo.getOffset() + lastLineInfo.getLength() - offset;
-
- return new Point(offset, length);
-
- } catch (BadLocationException e) {
- // should not happen
- return new Point(point.x, 0);
- }
- }
-
- /*
- * @see IFindReplaceTargetExtension#setSelection(int, int)
- * @since 2.0
- */
- public void setSelection(int modelOffset, int modelLength) {
- TextViewer.this.setSelectedRange(modelOffset, modelLength);
- }
-
- /*
- * @see IFindReplaceTargetExtension#setScope(IRegion)
- * @since 2.0
- */
- public void setScope(IRegion scope) {
- if (fRange != null)
- fRange.uninstall();
-
- if (scope == null) {
- fRange= null;
- return;
- }
-
- fRange= new FindReplaceRange(scope);
- fRange.setHighlightColor(fScopeHighlightColor);
- fRange.install();
- }
-
- /*
- * @see IFindReplaceTargetExtension#setScopeHighlightColor(Color)
- * @since 2.0
- */
- public void setScopeHighlightColor(Color color) {
- if (fRange != null)
- fRange.setHighlightColor(color);
- fScopeHighlightColor= color;
- }
-
- /*
- * @see IFindReplaceTargetExtension#setReplaceAllMode(boolean)
- * @since 2.0
- */
- public void setReplaceAllMode(boolean replaceAll) {
-
- // http://bugs.eclipse.org/bugs/show_bug.cgi?id=18232
-
- if (replaceAll) {
-
- TextViewer.this.setRedraw(false);
- TextViewer.this.startSequentialRewriteMode(false);
-
- if (fUndoManager != null)
- fUndoManager.beginCompoundChange();
-
- IDocument document= TextViewer.this.getDocument();
- fRememberedPartitioners= TextUtilities.removeDocumentPartitioners(document);
-
- } else {
-
- TextViewer.this.setRedraw(true);
- TextViewer.this.stopSequentialRewriteMode();
-
- if (fUndoManager != null)
- fUndoManager.endCompoundChange();
-
- if (fRememberedPartitioners != null) {
- IDocument document= TextViewer.this.getDocument();
- TextUtilities.addDocumentPartitioners(document, fRememberedPartitioners);
- }
- }
- }
- }
-
-
- /**
- * The viewer's rewrite target.
- * @since 2.0
- */
- class RewriteTarget implements IRewriteTarget {
-
- /*
- * @see org.eclipse.jface.text.IRewriteTarget#beginCompoundChange()
- */
- public void beginCompoundChange() {
- if (fUndoManager != null)
- fUndoManager.beginCompoundChange();
- }
-
- /*
- * @see org.eclipse.jface.text.IRewriteTarget#endCompoundChange()
- */
- public void endCompoundChange() {
- if (fUndoManager != null)
- fUndoManager.endCompoundChange();
- }
-
- /*
- * @see org.eclipse.jface.text.IRewriteTarget#getDocument()
- */
- public IDocument getDocument() {
- return TextViewer.this.getDocument();
- }
-
- /*
- * @see org.eclipse.jface.text.IRewriteTarget#setRedraw(boolean)
- */
- public void setRedraw(boolean redraw) {
- TextViewer.this.setRedraw(redraw);
- }
- }
-
- /**
- * Value object used as key in the text hover configuration table. It is
- * modifiable only inside this compilation unit to allow the reuse of created
- * objects for efficiency reasons
- *
- * @since 2.1
- */
- protected class TextHoverKey {
-
- /** The content type this key belongs to */
- private String fContentType;
- /** The state mask */
- private int fStateMask;
-
- /**
- * Creates a new text hover key for the given content type and state mask.
- *
- * @param contentType the content type
- * @param stateMask the state mask
- */
- protected TextHoverKey(String contentType, int stateMask) {
- Assert.isNotNull(contentType);
- fContentType= contentType;
- fStateMask= stateMask;
- }
-
- /*
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object obj) {
- if (obj == null || obj.getClass() != getClass())
- return false;
- TextHoverKey textHoverKey= (TextHoverKey)obj;
- return textHoverKey.fContentType.equals(fContentType) && textHoverKey.fStateMask == fStateMask;
- }
-
- /*
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- return fStateMask << 16 | fContentType.hashCode();
- }
-
- /**
- * Sets the state mask of this text hover key.
- *
- * @param stateMask the state mask
- */
- private void setStateMask(int stateMask) {
- fStateMask= stateMask;
- }
- }
-
- /**
- * A position reflecting a viewer selection and the selection anchor.
- * The anchor is represnted by the caret.
- *
- * @since 2.1
- */
- static class SelectionPosition extends Position {
-
- /** The flag indicating the anchor of this selection */
- private boolean reverse;
-
- /**
- * Creates a new selection position for the specified selection.
- *
- * @param point the specified selection
- */
- public SelectionPosition(Point point) {
- super();
- reverse= point.y < 0;
- if (reverse) {
- offset= point.x + point.y;
- length= -point.y;
- } else {
- offset= point.x;
- length= point.y;
- }
- }
-
- /**
- * Returns the selection in a format where the selection length
- * is always non-negative.
- *
- * @return the normalized selection
- */
- public Point getNormalizedSelection() {
- return new Point(offset, length);
- }
-
- /**
- * Returns the selection reflecting its anchor.
- *
- * @return the selection reflecting the selection achor.
- */
- public Point getSelection() {
- return reverse ? new Point(offset - length, -length) : new Point(offset, length);
- }
- }
-
- /**
- * Internal cursor listener i.e. aggregation of mouse and key listener.
- *
- * @since 3.0
- */
- private class CursorListener implements KeyListener, MouseListener {
-
- /**
- * Installs this cursor listener.
- */
- private void install() {
- if (fTextWidget != null && !fTextWidget.isDisposed()) {
- fTextWidget.addKeyListener(this);
- fTextWidget.addMouseListener(this);
- }
- }
-
- /**
- * Uninstalls this cursor listener.
- */
- private void uninstall() {
- if (fTextWidget != null && !fTextWidget.isDisposed()) {
- fTextWidget.removeKeyListener(this);
- fTextWidget.removeMouseListener(this);
- }
- }
-
- /*
- * @see KeyListener#keyPressed(org.eclipse.swt.events.KeyEvent)
- */
- public void keyPressed(KeyEvent event) {
- }
-
- /*
- * @see KeyListener#keyPressed(org.eclipse.swt.events.KeyEvent)
- */
- public void keyReleased(KeyEvent e) {
- if (fTextWidget.getSelectionCount() == 0)
- queuePostSelectionChanged();
- }
-
- /*
- * @see MouseListener#mouseDoubleClick(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseDoubleClick(MouseEvent e) {
- }
-
- /*
- * @see MouseListener#mouseDown(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseDown(MouseEvent e) {
- }
-
- /*
- * @see MouseListener#mouseUp(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseUp(MouseEvent event) {
- if (fTextWidget.getSelectionCount() == 0)
- queuePostSelectionChanged();
- }
- }
-
- /**
- * Identifies the scrollbars as originators of a view port change.
- */
- protected static final int SCROLLER= 1;
- /**
- * Identifies mouse moves as originators of a view port change.
- */
- protected static final int MOUSE= 2;
- /**
- * Identifies mouse button up as originator of a view port change.
- */
- protected static final int MOUSE_END= 3;
- /**
- * Identifies key strokes as originators of a view port change.
- */
- protected static final int KEY= 4;
- /**
- * Identifies window resizing as originator of a view port change.
- */
- protected static final int RESIZE= 5;
- /**
- * Identifies internal reasons as originators of a view port change.
- */
- protected static final int INTERNAL= 6;
-
- /** Internal name of the position category used selection preservation during shift. */
- protected static final String SHIFTING= "__TextViewer_shifting"; //$NON-NLS-1$
-
- /** The viewer's text widget */
- private StyledText fTextWidget;
- /** The viewer's input document */
- private IDocument fDocument;
- /** The viewer's visible document */
- private IDocument fVisibleDocument;
- /** The viewer's document adapter */
- private IDocumentAdapter fDocumentAdapter;
- /** The slave document manager */
- private ISlaveDocumentManager fSlaveDocumentManager;
- /** The text viewer's double click strategies connector */
- private TextDoubleClickStrategyConnector fDoubleClickStrategyConnector;
- /**
- * The text viewer's hovering controller
- * @since 2.0
- */
- private TextViewerHoverManager fTextHoverManager;
- /** The text viewer's viewport guard */
- private ViewportGuard fViewportGuard;
- /** Caches the graphical coordinate of the first visible line */
- private int fTopInset= 0;
- /** The most recent document modification as widget command */
- private WidgetCommand fWidgetCommand= new WidgetCommand();
- /** The SWT control's scrollbars */
- private ScrollBar fScroller;
- /** Document listener */
- private DocumentListener fDocumentListener= new DocumentListener();
- /** Verify listener */
- private TextVerifyListener fVerifyListener= new TextVerifyListener();
- /** The most recent widget modification as document command */
- private DocumentCommand fDocumentCommand= new DocumentCommand();
- /** The viewer's find/replace target */
- private IFindReplaceTarget fFindReplaceTarget;
- /**
- * The viewer widget token keeper
- * @since 2.0
- */
- private IWidgetTokenKeeper fWidgetTokenKeeper;
- /**
- * The viewer's manager of verify key listeners
- * @since 2.0
- */
- private VerifyKeyListenersManager fVerifyKeyListenersManager= new VerifyKeyListenersManager();
- /**
- * The mark position.
- * @since 2.0
- */
- private Position fMarkPosition;
- /**
- * The mark position category.
- * @since 2.0
- */
- private final String MARK_POSITION_CATEGORY="__mark_category_" + hashCode(); //$NON-NLS-1$
- /**
- * The mark position updater
- * @since 2.0
- */
- private final IPositionUpdater fMarkPositionUpdater= new DefaultPositionUpdater(MARK_POSITION_CATEGORY);
- /**
- * The flag indicating the redraw behavior
- * @since 2.0
- */
- private int fRedrawCounter= 0;
- /**
- * The selection when working in non-redraw state
- * @since 2.0
- */
- private SelectionPosition fDocumentSelection;
- /**
- * The viewer's rewrite target
- * @since 2.0
- */
- private IRewriteTarget fRewriteTarget;
- /**
- * The viewer's cursor listener.
- * @since 3.0
- */
- private CursorListener fCursorListener;
- /**
- * Last selection range sent to selection change liseners.
- * @since 3.0
- */
- private IRegion fLastSentSelectionChange;
- /**
- * The registered post selection changed listeners.
- * @since 3.0
- */
- private List fPostSelectionChangedListeners;
- /**
- * Queued post selection changed events count.
- * @since 3.0
- */
- private final int[] fNumberOfPostSelectionChangedEvents= new int[1];
- /**
- * Last selection range sent to post selection change listeners.
- * @since 3.0
- */
- private IRegion fLastSentPostSelectionChange;
-
- /**
- * The find/replace document adapter.
- *
- * @since 3.0
- */
- private FindReplaceDocumentAdapter fFindRepalceDocumentAdapter;
-
- /** Should the auto indent strategies ignore the next edit operation */
- protected boolean fIgnoreAutoIndent= false;
- /** The strings a line is prefixed with on SHIFT_RIGHT and removed from each line on SHIFT_LEFT */
- protected Map fIndentChars;
- /** The string a line is prefixed with on PREFIX and removed from each line on STRIP_PREFIX */
- protected Map fDefaultPrefixChars;
- /** The text viewer's text double click strategies */
- protected Map fDoubleClickStrategies;
- /** The text viewer's undo manager */
- protected IUndoManager fUndoManager;
- /** The text viewer's auto indent strategies */
- protected Map fAutoIndentStrategies;
- /** The text viewer's text hovers */
- protected Map fTextHovers;
- /**
- * The creator of the text hover control
- * @since 2.0
- */
- protected IInformationControlCreator fHoverControlCreator;
- /** All registered viewport listeners> */
- protected List fViewportListeners;
- /** The last visible vertical position of the top line */
- protected int fLastTopPixel;
- /** All registered text listeners */
- protected List fTextListeners;
- /** All registered text input listeners */
- protected List fTextInputListeners;
- /** The text viewer's event consumer */
- protected IEventConsumer fEventConsumer;
- /** Indicates whether the viewer's text presentation should be replaced are modified. */
- protected boolean fReplaceTextPresentation= false;
- /**
- * The mapping between model and visible document.
- * @since 2.1
- */
- protected IDocumentInformationMapping fInformationMapping;
- /**
- * The viewer's paint manager;
- * @since 2.1
- */
- protected PaintManager fPaintManager;
- /**
- * The viewers partitioning, i.e. the partitioning name the viewer uses to access partitioning information of its input document.
- * @since 3.0
- */
- protected String fPartitioning;
-
-
-
- //---- Construction and disposal ------------------
-
-
- /**
- * Internal use only
- */
- protected TextViewer() {
- }
-
- /**
- * Create a new text viewer with the given SWT style bits.
- * The viewer is ready to use but does not have any plug-in installed.
- *
- * @param parent the parent of the viewer's control
- * @param styles the SWT style bits for the viewer's control
- */
- public TextViewer(Composite parent, int styles) {
- createControl(parent, styles);
- }
-
- /**
- * Factory method to create the text widget to be used as the viewer's text widget.
- *
- * @return the text widget to be used
- */
- protected StyledText createTextWidget(Composite parent, int styles) {
- return new StyledText(parent, styles);
- }
-
- /**
- * Factory method to create the document adapter to be used by this viewer.
- *
- * @return the document adapter to be used
- */
- protected IDocumentAdapter createDocumentAdapter() {
- return new DocumentAdapter();
- }
-
- /**
- * Creates the viewer's SWT control. The viewer's text widget either is
- * the control or is a child of the control.
- *
- * @param parent the parent of the viewer's control
- * @param styles the SWT style bits for the viewer's control
- */
- protected void createControl(Composite parent, int styles) {
-
- fTextWidget= createTextWidget(parent, styles);
- fTextWidget.addDisposeListener(
- new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- setDocument(null);
- handleDispose();
- fTextWidget= null;
- }
- }
- );
-
- fTextWidget.setFont(parent.getFont());
- fTextWidget.setDoubleClickEnabled(false);
-
- /*
- * Disable SWT Shift+TAB traversal in this viewer
- * 1GIYQ9K: ITPUI:WINNT - StyledText swallows Shift+TAB
- */
- fTextWidget.addTraverseListener(new TraverseListener() {
- public void keyTraversed(TraverseEvent e) {
- if ((SWT.SHIFT == e.stateMask) && ('\t' == e.character))
- e.doit = false;
- }
- });
-
- // where does the first line start
- fTopInset= -fTextWidget.computeTrim(0, 0, 0, 0).y;
-
- fVerifyListener.forward(true);
- fTextWidget.addVerifyListener(fVerifyListener);
-
- fTextWidget.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent event) {
- selectionChanged(event.x, event.y - event.x);
- }
- public void widgetSelected(SelectionEvent event) {
- selectionChanged(event.x, event.y - event.x);
- }
- });
-
- fCursorListener= new CursorListener();
- fCursorListener.install();
-
- initializeViewportUpdate();
- }
-
- /*
- * @see Viewer#getControl()
- */
- public Control getControl() {
- return fTextWidget;
- }
-
- /*
- * @see ITextViewer#activatePlugins()
- */
- public void activatePlugins() {
-
- if (fDoubleClickStrategies != null && !fDoubleClickStrategies.isEmpty() && fDoubleClickStrategyConnector == null) {
- fDoubleClickStrategyConnector= new TextDoubleClickStrategyConnector();
- fTextWidget.addMouseListener(fDoubleClickStrategyConnector);
- }
-
- ensureHoverControlManagerInstalled();
-
- if (fUndoManager != null) {
- fUndoManager.connect(this);
- fUndoManager.reset();
- }
- }
-
- /**
- * After this method has been executed the caller knows that any installed text hover has been installed.
- */
- private void ensureHoverControlManagerInstalled() {
- if (fTextHovers != null && !fTextHovers.isEmpty() && fHoverControlCreator != null && fTextHoverManager == null) {
- fTextHoverManager= new TextViewerHoverManager(this, fHoverControlCreator);
- fTextHoverManager.install(this.getTextWidget());
- fTextHoverManager.setSizeConstraints(60, 10, false, true);
- }
- }
-
- /*
- * @see ITextViewer#resetPlugins()
- */
- public void resetPlugins() {
- if (fUndoManager != null)
- fUndoManager.reset();
- }
-
- /**
- * Frees all resources allocated by this viewer. Internally called when the viewer's
- * control has been disposed.
- */
- protected void handleDispose() {
-
- if (fPaintManager != null) {
- fPaintManager.dispose();
- fPaintManager= null;
- }
-
- removeViewPortUpdate();
- fViewportGuard= null;
-
- if (fViewportListeners != null) {
- fViewportListeners.clear();
- fViewportListeners= null;
- }
-
- if (fTextListeners != null) {
- fTextListeners.clear();
- fTextListeners= null;
- }
-
- if (fTextInputListeners != null) {
- fTextInputListeners.clear();
- fTextInputListeners= null;
- }
-
- if (fPostSelectionChangedListeners != null) {
- fPostSelectionChangedListeners.clear();
- fPostSelectionChangedListeners= null;
- }
-
- if (fAutoIndentStrategies != null) {
- fAutoIndentStrategies.clear();
- fAutoIndentStrategies= null;
- }
-
- if (fUndoManager != null) {
- fUndoManager.disconnect();
- fUndoManager= null;
- }
-
- if (fDoubleClickStrategies != null) {
- fDoubleClickStrategies.clear();
- fDoubleClickStrategies= null;
- }
-
- if (fTextHovers != null) {
- fTextHovers.clear();
- fTextHovers= null;
- }
-
- fDoubleClickStrategyConnector= null;
-
- if (fTextHoverManager != null) {
- fTextHoverManager.dispose();
- fTextHoverManager= null;
- }
-
- if (fDocumentListener !=null) {
- if (fVisibleDocument != null)
- fVisibleDocument.removeDocumentListener(fDocumentListener);
- fDocumentListener= null;
- }
-
- if (fDocumentAdapter != null) {
- fDocumentAdapter.setDocument(null);
- fDocumentAdapter= null;
- }
-
- if (fSlaveDocumentManager != null) {
- if (fVisibleDocument != null)
- fSlaveDocumentManager.freeSlaveDocument(fVisibleDocument);
- fSlaveDocumentManager= null;
- }
-
- if (fCursorListener != null) {
- fCursorListener.uninstall();
- fCursorListener= null;
- }
-
- fVisibleDocument= null;
- fDocument= null;
- fScroller= null;
- }
-
-
- //---- simple getters and setters
-
- /**
- * Returns viewer's text widget.
- */
- public StyledText getTextWidget() {
- return fTextWidget;
- }
-
- /**
- * The delay in milliseconds before an empty selection
- * changed event is sent by the cursor listener.
- * <p>
- * Note: The return value is used to initialize the cursor
- * listener. To return a non-constant value has no effect.
- * <p>
- * The same value (<code>500</code>) is used in the <code>OpenStrategy</code>.
- * </p>
- * @see CursorListener
- * @see org.eclipse.jface.util.OpenStrategy#TIME
- * @since 3.0
- */
- protected int getEmptySelectionChangedEventDelay() {
- return 500;
- }
-
- /*
- * @see ITextViewer#setAutoIndentStrategy(IAutoIndentStrategy, String)
- */
- public void setAutoIndentStrategy(IAutoIndentStrategy strategy, String contentType) {
-
- if (fAutoIndentStrategies == null)
- fAutoIndentStrategies= new HashMap();
-
- List autoEditStrategies= (List) fAutoIndentStrategies.get(contentType);
-
- if (strategy == null) {
- if (autoEditStrategies == null)
- return;
-
- fAutoIndentStrategies.put(contentType, null);
-
- } else {
- if (autoEditStrategies == null) {
- autoEditStrategies= new ArrayList();
- fAutoIndentStrategies.put(contentType, autoEditStrategies);
- }
-
- autoEditStrategies.clear();
- autoEditStrategies.add(strategy);
- }
- }
-
- /*
- * @see org.eclipse.jface.text.ITextViewerExtension2#prependAutoEditStrategy(org.eclipse.jface.text.IAutoEditStrategy, java.lang.String)
- * @since 2.1
- */
- public void prependAutoEditStrategy(IAutoEditStrategy strategy, String contentType) {
-
- if (strategy == null || contentType == null)
- throw new IllegalArgumentException();
-
- if (fAutoIndentStrategies == null)
- fAutoIndentStrategies= new HashMap();
-
- List autoEditStrategies= (List) fAutoIndentStrategies.get(contentType);
- if (autoEditStrategies == null) {
- autoEditStrategies= new ArrayList();
- fAutoIndentStrategies.put(contentType, autoEditStrategies);
- }
-
- autoEditStrategies.add(0, strategy);
- }
-
- /*
- * @see org.eclipse.jface.text.ITextViewerExtension2#removeAutoEditStrategy(org.eclipse.jface.text.IAutoEditStrategy, java.lang.String)
- * @since 2.1
- */
- public void removeAutoEditStrategy(IAutoEditStrategy strategy, String contentType) {
- if (fAutoIndentStrategies == null)
- return;
-
- List autoEditStrategies= (List) fAutoIndentStrategies.get(contentType);
- if (autoEditStrategies == null)
- return;
-
- for (final Iterator iterator= autoEditStrategies.iterator(); iterator.hasNext(); ) {
- if (iterator.next().equals(strategy)) {
- iterator.remove();
- break;
- }
- }
-
- if (autoEditStrategies.isEmpty())
- fAutoIndentStrategies.put(contentType, null);
- }
-
- /*
- * @see ITextViewer#setEventConsumer(IEventConsumer)
- */
- public void setEventConsumer(IEventConsumer consumer) {
- fEventConsumer= consumer;
- }
-
- /*
- * @see ITextViewer#setIndentPrefixes(String[], String)
- */
- public void setIndentPrefixes(String[] indentPrefixes, String contentType) {
-
- int i= -1;
- boolean ok= (indentPrefixes != null);
- while (ok && ++i < indentPrefixes.length)
- ok= (indentPrefixes[i] != null);
-
- if (ok) {
-
- if (fIndentChars == null)
- fIndentChars= new HashMap();
-
- fIndentChars.put(contentType, indentPrefixes);
-
- } else if (fIndentChars != null)
- fIndentChars.remove(contentType);
- }
-
- /*
- * @see ITextViewer#getTopInset()
- */
- public int getTopInset() {
- return fTopInset;
- }
-
- /*
- * @see ITextViewer#isEditable()
- */
- public boolean isEditable() {
- if (fTextWidget == null)
- return false;
- return fTextWidget.getEditable();
- }
-
- /*
- * @see ITextViewer#setEditable(boolean)
- */
- public void setEditable(boolean editable) {
- if (fTextWidget != null)
- fTextWidget.setEditable(editable);
- }
-
- /*
- * @see ITextViewer#setDefaultPrefixes
- * @since 2.0
- */
- public void setDefaultPrefixes(String[] defaultPrefixes, String contentType) {
-
- if (defaultPrefixes != null && defaultPrefixes.length > 0) {
- if (fDefaultPrefixChars == null)
- fDefaultPrefixChars= new HashMap();
- fDefaultPrefixChars.put(contentType, defaultPrefixes);
- } else if (fDefaultPrefixChars != null)
- fDefaultPrefixChars.remove(contentType);
- }
-
- /*
- * @see ITextViewer#setUndoManager(IUndoManager)
- */
- public void setUndoManager(IUndoManager undoManager) {
- fUndoManager= undoManager;
- }
-
- /*
- * @see ITextViewer#setTextHover(ITextHover, String)
- */
- public void setTextHover(ITextHover hover, String contentType) {
- setTextHover(hover, contentType, ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK);
- }
-
- /*
- * @see ITextViewerExtension2#setTextHover(ITextHover, String, int)
- * @since 2.1
- */
- public void setTextHover(ITextHover hover, String contentType, int stateMask) {
- TextHoverKey key= new TextHoverKey(contentType, stateMask);
- if (hover != null) {
- if (fTextHovers == null) {
- fTextHovers= new HashMap();
- }
- fTextHovers.put(key, hover);
- } else if (fTextHovers != null)
- fTextHovers.remove(key);
-
- ensureHoverControlManagerInstalled();
- }
-
- /*
- * @see ITextViewerExtension2#removeTextHovers(String)
- * @since 2.1
- */
- public void removeTextHovers(String contentType) {
- if (fTextHovers == null)
- return;
-
- Iterator iter= new HashSet(fTextHovers.keySet()).iterator();
- while (iter.hasNext()) {
- TextHoverKey key= (TextHoverKey)iter.next();
- if (key.fContentType.equals(contentType))
- fTextHovers.remove(key);
- }
- }
-
- /**
- * Returns the text hover for a given offset.
- *
- * @param offset the offset for which to return the text hover
- * @return the text hover for the given offset
- */
- protected ITextHover getTextHover(int offset) {
- return getTextHover(offset, ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK);
- }
-
- /**
- * Returns the text hover for a given offset and a given state mask.
- *
- * @param offset the offset for which to return the text hover
- * @param stateMask the SWT event state mask
- * @return the text hover for the given offset and state mask
- * @since 2.1
- */
- protected ITextHover getTextHover(int offset, int stateMask) {
- if (fTextHovers == null)
- return null;
-
- IDocument document= getDocument();
- if (document == null)
- return null;
-
- try {
- TextHoverKey key= new TextHoverKey(TextUtilities.getContentType(document, getDocumentPartitioning(), offset), stateMask);
- Object textHover= fTextHovers.get(key);
- if (textHover == null) {
- // Use default text hover
- key.setStateMask(ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK);
- textHover= fTextHovers.get(key);
- }
- return (ITextHover) textHover;
- } catch (BadLocationException x) {
- if (TRACE_ERRORS)
- System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.selectContentTypePlugin")); //$NON-NLS-1$
- }
- return null;
- }
-
- /**
- * Returns the text hovering controller of this viewer.
- *
- * @return the text hovering controller of this viewer
- * @since 2.0
- */
- protected AbstractInformationControlManager getTextHoveringController() {
- return fTextHoverManager;
- }
-
- /**
- * Sets the creator for the hover controls.
- *
- * @param creator the hover control creator
- * @since 2.0
- */
- public void setHoverControlCreator(IInformationControlCreator creator) {
- fHoverControlCreator= creator;
- }
-
- /*
- * @see IWidgetTokenOwner#requestWidgetToken(IWidgetTokenKeeper)
- * @since 2.0
- */
- public boolean requestWidgetToken(IWidgetTokenKeeper requester) {
- if (fTextWidget != null) {
- if (fWidgetTokenKeeper != null) {
- if (fWidgetTokenKeeper == requester)
- return true;
- if (fWidgetTokenKeeper.requestWidgetToken(this)) {
- fWidgetTokenKeeper= requester;
- return true;
- }
- } else {
- fWidgetTokenKeeper= requester;
- return true;
- }
- }
- return false;
- }
-
- /*
- * @see org.eclipse.jface.text.IWidgetTokenOwnerExtension#requestWidgetToken(org.eclipse.jface.text.IWidgetTokenKeeper, int)
- * @since 3.0
- */
- public boolean requestWidgetToken(IWidgetTokenKeeper requester, int priority) {
- if (fTextWidget != null) {
- if (fWidgetTokenKeeper != null) {
-
- if (fWidgetTokenKeeper == requester)
- return true;
-
- boolean accepted= false;
- if (fWidgetTokenKeeper instanceof IWidgetTokenKeeperExtension) {
- IWidgetTokenKeeperExtension extension= (IWidgetTokenKeeperExtension) fWidgetTokenKeeper;
- accepted= extension.requestWidgetToken(this, priority);
- } else {
- fWidgetTokenKeeper.requestWidgetToken(this);
- }
-
- if (accepted) {
- fWidgetTokenKeeper= requester;
- return true;
- }
-
- } else {
- fWidgetTokenKeeper= requester;
- return true;
- }
- }
- return false;
- }
-
- /*
- * @see IWidgetTokenOwner#releaseWidgetToken(IWidgetTokenKeeper)
- * @since 2.0
- */
- public void releaseWidgetToken(IWidgetTokenKeeper tokenKeeper) {
- if (fWidgetTokenKeeper == tokenKeeper)
- fWidgetTokenKeeper= null;
- }
-
-
- //---- Selection
-
- /*
- * @see ITextViewer#getSelectedRange()
- */
- public Point getSelectedRange() {
-
- if (!redraws())
- return fDocumentSelection.getNormalizedSelection();
-
- if (fTextWidget != null) {
- Point p= fTextWidget.getSelectionRange();
- return widgetSelection2ModelSelection(p);
- }
-
- return new Point(-1, -1);
- }
-
- /*
- * @see ITextViewer#setSelectedRange(int, int)
- */
- public void setSelectedRange(int selectionOffset, int selectionLength) {
-
- if (!redraws()) {
- if (fDocumentSelection != null) {
- fDocumentSelection.offset= selectionOffset;
- fDocumentSelection.length= selectionLength;
- // http://bugs.eclipse.org/bugs/show_bug.cgi?id=32795
- fDocumentSelection.isDeleted= false;
- }
- return;
- }
-
- if (fTextWidget == null)
- return;
-
- IRegion widgetSelection= modelRange2WidgetRange(new Region(selectionOffset, selectionLength));
- if (widgetSelection != null) {
-
- int[] selectionRange= new int[] { widgetSelection.getOffset(), widgetSelection.getLength() };
- validateSelectionRange(selectionRange);
- if (selectionRange[0] >= 0) {
- fTextWidget.setSelectionRange(selectionRange[0], selectionRange[1]);
- selectionChanged(selectionRange[0], selectionRange[1]);
- }
- }
- }
-
- /**
- * Validates and adapts the given selection range if it is not a valid
- * widget selection. The widget selection is invalid if it starts or ends
- * inside a multi-character line delimiter. If so, the selection is adapted to
- * start <b>after</b> the divided line delimiter and to end <b>before</b>
- * the divided line delimiter. The parameter passed in is changed in-place
- * when being adapted. An adaptation to <code>[-1, -1]</code> indicates
- * that the selection range could not be validated.
- * Subclasses may reimplement this method.
- *
- * @param selectionRange selectionRange[0] is the offset, selectionRange[1]
- * the length of the selection to validate.
- * @since 2.0
- */
- protected void validateSelectionRange(int[] selectionRange) {
-
- IDocument document= getVisibleDocument();
- if (document == null) {
- selectionRange[0]= -1;
- selectionRange[1]= -1;
- return;
- }
-
- int documentLength= document.getLength();
- int offset= selectionRange[0];
- int length= selectionRange[1];
-
- if (length < 0) {
- length= - length;
- offset -= length;
- }
-
- if (offset <0)
- offset= 0;
-
- if (offset > documentLength)
- offset= documentLength;
-
- int delta= (offset + length) - documentLength;
- if (delta > 0)
- length -= delta;
-
- try {
-
- int lineNumber= document.getLineOfOffset(offset);
- IRegion lineInformation= document.getLineInformation(lineNumber);
-
- int lineEnd= lineInformation.getOffset() + lineInformation.getLength();
- delta= offset - lineEnd;
- if (delta > 0) {
- // in the middle of a multi-character line delimiter
- offset= lineEnd;
- String delimiter= document.getLineDelimiter(lineNumber);
- if (delimiter != null)
- offset += delimiter.length();
- }
-
- int end= offset + length;
- lineInformation= document.getLineInformationOfOffset(end);
- lineEnd= lineInformation.getOffset() + lineInformation.getLength();
- delta= end - lineEnd;
- if (delta > 0) {
- // in the middle of a multi-character line delimiter
- length -= delta;
- }
-
- } catch (BadLocationException x) {
- selectionRange[0]= -1;
- selectionRange[1]= -1;
- return;
- }
-
- if (selectionRange[1] < 0) {
- selectionRange[0]= offset + length;
- selectionRange[1]= -length;
- } else {
- selectionRange[0]= offset;
- selectionRange[1]= length;
- }
- }
-
- /*
- * @see Viewer#setSelection(ISelection)
- */
- public void setSelection(ISelection selection, boolean reveal) {
- if (selection instanceof ITextSelection) {
- ITextSelection s= (ITextSelection) selection;
- setSelectedRange(s.getOffset(), s.getLength());
- if (reveal)
- revealRange(s.getOffset(), s.getLength());
- }
- }
-
- /*
- * @see Viewer#getSelection()
- */
- public ISelection getSelection() {
- Point p= getSelectedRange();
- if (p.x == -1 || p.y == -1)
- return TextSelection.emptySelection();
-
- return new TextSelection(getDocument(), p.x, p.y);
- }
-
- /*
- * @see ITextViewer#getSelectionProvider()
- */
- public ISelectionProvider getSelectionProvider() {
- return this;
- }
-
- /*
- * @see org.eclipse.jface.text.IPostSelectionProvider#addPostSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
- * @since 3.0
- */
- public void addPostSelectionChangedListener(ISelectionChangedListener listener) {
-
- Assert.isNotNull(listener);
-
- if (fPostSelectionChangedListeners == null)
- fPostSelectionChangedListeners= new ArrayList();
-
- if (! fPostSelectionChangedListeners.contains(listener))
- fPostSelectionChangedListeners.add(listener);
- }
-
- /*
- * @see org.eclipse.jface.text.IPostSelectionProvider#removePostSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
- * @since 3.0
- */
- public void removePostSelectionChangedListener(ISelectionChangedListener listener) {
-
- Assert.isNotNull(listener);
-
- if (fPostSelectionChangedListeners != null) {
- fPostSelectionChangedListeners.remove(listener);
- if (fPostSelectionChangedListeners.size() == 0)
- fPostSelectionChangedListeners= null;
- }
- }
-
- /**
- * Get the text widget's display.
- *
- * @return the display or <code>null</code> if the display cannot be retrieved or if the display is disposed
- * @since 3.0
- */
- private Display getDisplay() {
- if (fTextWidget == null || fTextWidget.isDisposed())
- return null;
-
- Display display= fTextWidget.getDisplay();
- if (display != null && display.isDisposed())
- return null;
-
- return display;
- }
-
- /**
- * Starts a timer to send out a post selection changed event.
- *
- * @since 3.0
- */
- private void queuePostSelectionChanged() {
- Display display= getDisplay();
- if (display == null)
- return;
-
- fNumberOfPostSelectionChangedEvents[0]++;
- display.timerExec(getEmptySelectionChangedEventDelay(), new Runnable() {
- final int id= fNumberOfPostSelectionChangedEvents[0];
- public void run() {
- if (id == fNumberOfPostSelectionChangedEvents[0]) {
- // Check again because this is executed after the delay
- if (getDisplay() != null) {
- Point selection= fTextWidget.getSelectionRange();
- if (selection != null)
- firePostSelectionChanged(selection.x, selection.y);
- }
- }
- }
- });
- }
-
- /**
- * Sends out a text selection changed event to all registered post selection changed listeners.
- *
- * @param offset the offset of the newly selected range in the visible document
- * @param length the length of the newly selected range in the visible document
- * @since 3.0
- */
- protected void firePostSelectionChanged(int offset, int length) {
- if (redraws()) {
- IRegion r= widgetRange2ModelRange(new Region(offset, length));
- if ((r != null && !r.equals(fLastSentPostSelectionChange)) || r == null) {
- fLastSentPostSelectionChange= r;
- ISelection selection= r != null ? new TextSelection(getDocument(), r.getOffset(), r.getLength()) : TextSelection.emptySelection();
- SelectionChangedEvent event= new SelectionChangedEvent(this, selection);
- firePostSelectionChanged(event);
- }
- }
- }
-
- /**
- * Sends out a text selection changed event to all registered listeners and
- * registers the selection changed event to be send out to all post selection
- * listeners.
- *
- * @param offset the offset of the newly selected range in the visible document
- * @param length the length of the newly selected range in the visible document
- */
- protected void selectionChanged(int offset, int length) {
- queuePostSelectionChanged();
- fireSelectionChanged(offset, length);
- }
-
- /**
- * Sends out a text selection changed event to all registered listeners.
- *
- * @param offset the offset of the newly selected range in the visible document
- * @param length the length of the newly selected range in the visible document
- * @since 3.0
- */
- protected void fireSelectionChanged(int offset, int length) {
- if (redraws()) {
- IRegion r= widgetRange2ModelRange(new Region(offset, length));
- if ((r != null && !r.equals(fLastSentSelectionChange)) || r == null) {
- fLastSentSelectionChange= r;
- ISelection selection= r != null ? new TextSelection(getDocument(), r.getOffset(), r.getLength()) : TextSelection.emptySelection();
- SelectionChangedEvent event= new SelectionChangedEvent(this, selection);
- fireSelectionChanged(event);
- }
- }
- }
-
- /**
- * Sends the given event to all registered post selection changed listeners.
- *
- * @param event the selection event
- * @since 3.0
- */
- private void firePostSelectionChanged(SelectionChangedEvent event) {
- if (fPostSelectionChangedListeners != null) {
- for (int i= 0; i < fPostSelectionChangedListeners.size(); i++) {
- ISelectionChangedListener l= (ISelectionChangedListener) fPostSelectionChangedListeners.get(i);
- l.selectionChanged(event);
- }
- }
- }
-
- /**
- * Sends out a mark selection changed event to all registered listeners.
- *
- * @param offset the offset of the mark selection in the visible document, the offset is <code>-1</code> if the mark was cleared
- * @param length the length of the mark selection, may be negative if the caret is before the mark.
- * @since 2.0
- */
- protected void markChanged(int offset, int length) {
- if (redraws()) {
-
- if (offset != -1) {
- IRegion r= widgetRange2ModelRange(new Region(offset, length));
- offset= r.getOffset();
- length= r.getLength();
- }
-
- ISelection selection= new MarkSelection(getDocument(), offset, length);
- SelectionChangedEvent event= new SelectionChangedEvent(this, selection);
- fireSelectionChanged(event);
- }
- }
-
-
- //---- Text listeners
-
- /*
- * @see ITextViewer#addTextListener(ITextListener)
- */
- public void addTextListener(ITextListener listener) {
-
- Assert.isNotNull(listener);
-
- if (fTextListeners == null)
- fTextListeners= new ArrayList();
-
- if (!fTextListeners.contains(listener))
- fTextListeners.add(listener);
- }
-
- /*
- * @see ITextViewer#removeTextListener(ITextListener)
- */
- public void removeTextListener(ITextListener listener) {
-
- Assert.isNotNull(listener);
-
- if (fTextListeners != null) {
- fTextListeners.remove(listener);
- if (fTextListeners.size() == 0)
- fTextListeners= null;
- }
- }
-
- /**
- * Informs all registered text listeners about the change specified by the
- * widget command. This method does not use a robust iterator.
- *
- * @param cmd the widget command translated into a text event sent to all text listeners
- */
- protected void updateTextListeners(WidgetCommand cmd) {
-
- if (fTextListeners != null) {
-
- DocumentEvent event= cmd.event;
- if (event instanceof SlaveDocumentEvent)
- event= ((SlaveDocumentEvent) event).getMasterEvent();
-
- TextEvent e= new TextEvent(cmd.start, cmd.length, cmd.text, cmd.preservedText, event, redraws());
- for (int i= 0; i < fTextListeners.size(); i++) {
- ITextListener l= (ITextListener) fTextListeners.get(i);
- l.textChanged(e);
- }
- }
- }
-
- //---- Text input listeners
-
- /*
- * @see ITextViewer#addTextInputListener(ITextInputListener)
- */
- public void addTextInputListener(ITextInputListener listener) {
-
- Assert.isNotNull(listener);
-
- if (fTextInputListeners == null)
- fTextInputListeners= new ArrayList();
-
- if (!fTextInputListeners.contains(listener))
- fTextInputListeners.add(listener);
- }
-
- /*
- * @see ITextViewer#removeTextInputListener(ITextInputListener)
- */
- public void removeTextInputListener(ITextInputListener listener) {
-
- Assert.isNotNull(listener);
-
- if (fTextInputListeners != null) {
- fTextInputListeners.remove(listener);
- if (fTextInputListeners.size() == 0)
- fTextInputListeners= null;
- }
- }
-
- /**
- * Informs all registered text input listeners about the forthcoming input change,
- * This method does not use a robust iterator.
- *
- * @param oldInput the old input document
- * @param newInput the new input document
- */
- protected void fireInputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {
- if (fTextInputListeners != null) {
- for (int i= 0; i < fTextInputListeners.size(); i++) {
- ITextInputListener l= (ITextInputListener) fTextInputListeners.get(i);
- l.inputDocumentAboutToBeChanged(oldInput, newInput);
- }
- }
- }
-
- /**
- * Informs all registered text input listeners about the sucessful input change,
- * This method does not use a robust iterator.
- *
- * @param oldInput the old input document
- * @param newInput the new input document
- */
- protected void fireInputDocumentChanged(IDocument oldInput, IDocument newInput) {
- if (fTextInputListeners != null) {
- for (int i= 0; i < fTextInputListeners.size(); i++) {
- ITextInputListener l= (ITextInputListener) fTextInputListeners.get(i);
- l.inputDocumentChanged(oldInput, newInput);
- }
- }
- }
-
- //---- Document
-
- /*
- * @see Viewer#getInput()
- */
- public Object getInput() {
- return getDocument();
- }
-
- /*
- * @see ITextViewer#getDocument()
- */
- public IDocument getDocument() {
- return fDocument;
- }
-
- /*
- * @see Viewer#setInput(Object)
- */
- public void setInput(Object input) {
-
- IDocument document= null;
- if (input instanceof IDocument)
- document= (IDocument) input;
-
- setDocument(document);
- }
-
- /*
- * @see ITextViewer#setDocument(IDocument)
- */
- public void setDocument(IDocument document) {
-
- fReplaceTextPresentation= true;
- fireInputDocumentAboutToBeChanged(fDocument, document);
-
- IDocument oldDocument= fDocument;
- fDocument= document;
-
- setVisibleDocument(fDocument);
-
- inputChanged(fDocument, oldDocument);
-
- fireInputDocumentChanged(oldDocument, fDocument);
- fLastSentSelectionChange= null;
- fReplaceTextPresentation= false;
- }
-
- /*
- * @see ITextViewer#setDocument(IDocument, int, int)
- */
- public void setDocument(IDocument document, int visibleRegionOffset, int visibleRegionLength) {
-
- fReplaceTextPresentation= true;
- fireInputDocumentAboutToBeChanged(fDocument, document);
-
- IDocument oldDocument= fDocument;
- fDocument= document;
-
- try {
-
- IDocument visibleDocument= createSlaveDocument(document);
- updateVisibleDocument(visibleDocument, visibleRegionOffset, visibleRegionLength);
- setVisibleDocument(visibleDocument);
-
- } catch (BadLocationException x) {
- throw new IllegalArgumentException(JFaceTextMessages.getString("TextViewer.error.invalid_visible_region_1")); //$NON-NLS-1$
- }
-
- inputChanged(fDocument, oldDocument);
-
- fireInputDocumentChanged(oldDocument, fDocument);
- fLastSentSelectionChange= null;
- fReplaceTextPresentation= false;
- }
-
- /**
- * Creates a slave document for the given document if there is a slave document manager
- * associated with this viewer.
- *
- * @param document the master document
- * @return the newly created slave document
- * @since 2.1
- */
- protected IDocument createSlaveDocument(IDocument document) {
- ISlaveDocumentManager manager= getSlaveDocumentManager();
- if (manager != null) {
- if (manager.isSlaveDocument(document))
- return document;
- return manager.createSlaveDocument(document);
- }
- return document;
- }
-
- /**
- * Sets the given slave document to the specified range of its master document.
- *
- * @param visibleDocument the slave document
- * @param visibleRegionOffset the offset of the master document range
- * @param visibleRegionLength the length of the master document range
- * @return <code>true</code> if the slave has been adapted successfully
- * @throws BadLocationException in case the specified range is not valid in the master document
- * @since 2.1
- */
- protected boolean updateVisibleDocument(IDocument visibleDocument, int visibleRegionOffset, int visibleRegionLength) throws BadLocationException {
- if (visibleDocument instanceof ChildDocument) {
- ChildDocument childDocument= (ChildDocument) visibleDocument;
-
- IDocument document= childDocument.getParentDocument();
- int line= document.getLineOfOffset(visibleRegionOffset);
- int offset= document.getLineOffset(line);
- int length= (visibleRegionOffset - offset) + visibleRegionLength;
-
- Position parentRange= childDocument.getParentDocumentRange();
- if (offset != parentRange.getOffset() || length != parentRange.getLength()) {
- childDocument.setParentDocumentRange(offset, length);
- return true;
- }
- }
- return false;
- }
-
-
- //---- Viewports
-
- /**
- * Initializes all listeners and structures required to set up viewport listeners.
- */
- private void initializeViewportUpdate() {
-
- if (fViewportGuard != null)
- return;
-
- if (fTextWidget != null) {
-
- fViewportGuard= new ViewportGuard();
- fLastTopPixel= -1;
-
- fTextWidget.addKeyListener(fViewportGuard);
- fTextWidget.addMouseListener(fViewportGuard);
-
- fScroller= fTextWidget.getVerticalBar();
- if (fScroller != null)
- fScroller.addSelectionListener(fViewportGuard);
- }
- }
-
- /**
- * Removes all listeners and structures required to set up viewport listeners.
- */
- private void removeViewPortUpdate() {
-
- if (fTextWidget != null) {
-
- fTextWidget.removeKeyListener(fViewportGuard);
- fTextWidget.removeMouseListener(fViewportGuard);
-
- if (fScroller != null && !fScroller.isDisposed()) {
- fScroller.removeSelectionListener(fViewportGuard);
- fScroller= null;
- }
-
- fViewportGuard= null;
- }
- }
-
- /*
- * @see ITextViewer#addViewportListener(IViewportListener)
- */
- public void addViewportListener(IViewportListener listener) {
-
- if (fViewportListeners == null) {
- fViewportListeners= new ArrayList();
- initializeViewportUpdate();
- }
-
- if (!fViewportListeners.contains(listener))
- fViewportListeners.add(listener);
- }
-
- /*
- * @see ITextViewer#removeViewportListener(IVewportListener)
- */
- public void removeViewportListener(IViewportListener listener) {
- if (fViewportListeners != null)
- fViewportListeners.remove(listener);
- }
-
- /**
- * Checks whether the viewport changed and if so informs all registered
- * listeners about the change.
- *
- * @param origin describes under which circumstances this method has been called.
- *
- * @see IViewportListener
- */
- protected void updateViewportListeners(int origin) {
-
- if (redraws()) {
- int topPixel= fTextWidget.getTopPixel();
- if (topPixel >= 0 && topPixel != fLastTopPixel) {
- if (fViewportListeners != null) {
- for (int i= 0; i < fViewportListeners.size(); i++) {
- IViewportListener l= (IViewportListener) fViewportListeners.get(i);
- l.viewportChanged(topPixel);
- }
- }
- fLastTopPixel= topPixel;
- }
- }
- }
-
- //---- scrolling and revealing
-
- /*
- * @see ITextViewer#getTopIndex()
- */
- public int getTopIndex() {
-
- if (fTextWidget != null) {
-
- int top= fTextWidget.getTopIndex();
- return widgetlLine2ModelLine(top);
- }
-
- return -1;
- }
-
- /*
- * @see ITextViewer#setTopIndex(int)
- */
- public void setTopIndex(int index) {
-
- if (fTextWidget != null) {
-
- int widgetLine= modelLine2WidgetLine(index);
- if (widgetLine == -1)
- widgetLine= getClosestWidgetLineForModelLine(index);
-
- if (widgetLine > -1) {
- fTextWidget.setTopIndex(widgetLine);
- updateViewportListeners(INTERNAL);
- }
- }
- }
-
- /**
- * Returns the viewport height in lines. The actual visible lines can be fewer if the
- * document is shorter than the viewport.
- *
- * @return the viewport height in lines
- */
- protected int getVisibleLinesInViewport() {
- if (fTextWidget != null) {
- Rectangle clArea= fTextWidget.getClientArea();
- if (!clArea.isEmpty())
- return clArea.height / fTextWidget.getLineHeight();
- }
- return -1;
- }
-
- /*
- * @see ITextViewer#getBottomIndex()
- */
- public int getBottomIndex() {
-
- if (fTextWidget == null)
- return -1;
-
- IRegion coverage= getModelCoverage();
-
- try {
-
- IDocument d= getDocument();
-
- if (d == null)
- return -1;
-
- int startLine= d.getLineOfOffset(coverage.getOffset());
- int endLine= d.getLineOfOffset(coverage.getOffset() + coverage.getLength() - 1);
- int lines= getVisibleLinesInViewport();
-
- if (startLine + lines < endLine) {
- int widgetTopIndex= fTextWidget.getTopIndex();
- int widgetBottomIndex= widgetTopIndex + lines -1;
- return widgetlLine2ModelLine(widgetBottomIndex);
- }
-
- return endLine;
-
- } catch (BadLocationException x) {
- if (TRACE_ERRORS)
- System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.getBottomIndex")); //$NON-NLS-1$
- }
-
- return -1;
- }
-
- /*
- * @see ITextViewer#getTopIndexStartOffset()
- */
- public int getTopIndexStartOffset() {
-
- if (fTextWidget != null) {
- int top= fTextWidget.getTopIndex();
- try {
- top= getVisibleDocument().getLineOffset(top);
- return widgetlLine2ModelLine(top);
- } catch (BadLocationException ex) {
- if (TRACE_ERRORS)
- System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.getTopIndexStartOffset")); //$NON-NLS-1$
- }
- }
-
- return -1;
- }
-
- /*
- * @see ITextViewer#getBottomIndexEndOffset()
- */
- public int getBottomIndexEndOffset() {
- try {
-
- IRegion line= getDocument().getLineInformation(getBottomIndex());
- int bottomEndOffset= line.getOffset() + line.getLength() - 1;
-
- IRegion coverage= getModelCoverage();
- int coverageEndOffset= coverage.getOffset() + coverage.getLength() - 1;
- return Math.min(coverageEndOffset, bottomEndOffset);
-
- } catch (BadLocationException ex) {
- if (TRACE_ERRORS)
- System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.getBottomIndexEndOffset")); //$NON-NLS-1$
- return getDocument().getLength() - 1;
- }
- }
-
- /*
- * @see ITextViewer#revealRange(int, int)
- */
- public void revealRange(int start, int length) {
-
- if (fTextWidget == null || !redraws())
- return;
-
- IRegion modelRange= new Region(start, length);
- IRegion widgetRange= modelRange2WidgetRange(modelRange);
- if (widgetRange != null) {
-
- int[] range= new int[] { widgetRange.getOffset(), widgetRange.getLength() };
- validateSelectionRange(range);
- if (range[0] >= 0)
- internalRevealRange(range[0], range[0] + range[1]);
-
- } else {
-
- IRegion coverage= getModelCoverage();
- int cursor= start < coverage.getOffset() ? 0 : getVisibleDocument().getLength();
- internalRevealRange(cursor, cursor);
- }
- }
-
- /**
- * Reveals the given range of the visible document.
- *
- * @param start the start offset of the range
- * @param end the end offset of the range
- */
- protected void internalRevealRange(int start, int end) {
-
- try {
-
- IDocument doc= getVisibleDocument();
-
- int startLine= doc.getLineOfOffset(start);
- int endLine= doc.getLineOfOffset(end);
-
- int top= fTextWidget.getTopIndex();
- if (top > -1) {
-
- // scroll vertically
-
- int lines= getVisibleLinesInViewport();
- int bottom= top + lines;
-
- // two lines at the top and the bottom should always be left
- // if window is smaller than 5 lines, always center position is chosen
- int bufferZone= 2;
-
- if (startLine >= top + bufferZone
- && startLine <= bottom - bufferZone
- && endLine >= top + bufferZone
- && endLine <= bottom - bufferZone) {
-
- // do not scroll at all as it is already visible
-
- } else {
-
- int delta= Math.max(0, lines - (endLine - startLine));
- fTextWidget.setTopIndex(startLine - delta/3);
- updateViewportListeners(INTERNAL);
- }
-
- // scroll horizontally
-
- if (endLine < startLine) {
- endLine += startLine;
- startLine= endLine - startLine;
- endLine -= startLine;
- }
-
- int startPixel= -1;
- int endPixel= -1;
-
- if (endLine > startLine) {
- // reveal the beginning of the range in the start line
- IRegion extent= getExtent(start, start);
- startPixel= extent.getOffset() + fTextWidget.getHorizontalPixel();
- endPixel= startPixel;
-
- } else {
- IRegion extent= getExtent(start, end);
- startPixel= extent.getOffset() + fTextWidget.getHorizontalPixel();
- endPixel= startPixel + extent.getLength();
- }
-
- int visibleStart= fTextWidget.getHorizontalPixel();
- int visibleEnd= visibleStart + fTextWidget.getClientArea().width;
-
- // scroll only if not yet visible
- if (startPixel < visibleStart || visibleEnd < endPixel) {
-
- // set buffer zone to 10 pixels
- bufferZone= 10;
-
- int newOffset= visibleStart;
-
- int visibleWidth= visibleEnd - visibleStart;
- int selectionPixelWidth= endPixel - startPixel;
-
- if (startPixel < visibleStart)
- newOffset= startPixel;
- else if (selectionPixelWidth + bufferZone < visibleWidth)
- newOffset= endPixel + bufferZone - visibleWidth;
- else
- newOffset= startPixel;
-
- float index= ((float)newOffset) / ((float)getAverageCharWidth());
-
- fTextWidget.setHorizontalIndex(Math.round(index));
- }
-
- }
- } catch (BadLocationException e) {
- throw new IllegalArgumentException(JFaceTextMessages.getString("TextViewer.error.invalid_range")); //$NON-NLS-1$
- }
- }
-
- /**
- * Returns the width of the text when being drawed into this viewer's widget.
- *
- * @param the string to messure
- * @return the width of the presentation of the given string
- * @deprecated use <code>getWidthInPixels(int, int)</code> instead
- */
- final protected int getWidthInPixels(String text) {
- GC gc= new GC(fTextWidget);
- gc.setFont(fTextWidget.getFont());
- Point extent= gc.textExtent(text);
- gc.dispose();
- return extent.x;
- }
-
- /**
- * Returns the region covered by the given start and end offset.
- * The result is relative to the upper left corner of the widget
- * client area.
- *
- * @param start offset relative to the start of this viewer's viewport
- * 0 <= offset <= getCharCount()
- * @param end offset relative to the start of this viewer's viewport
- * 0 <= offset <= getCharCount()
- * @return the region covered by start and end offset
- */
- final protected IRegion getExtent(int start, int end) {
- Point left= fTextWidget.getLocationAtOffset(start);
- Point right= new Point(left.x, left.y);
-
- for (int i= start +1; i <= end; i++) {
-
- Point p= fTextWidget.getLocationAtOffset(i);
-
- if (left.x > p.x)
- left.x= p.x;
-
- if (right.x < p.x)
- right.x= p.x;
- }
-
- return new Region(left.x, right.x - left.x);
- }
-
- /**
- * Returns the width of the representation of a text range in the
- * visible region of the viewer's document as drawn in this viewer's
- * widget.
- *
- * @param offset the offset of the text range in the visible region
- * @param length the length of the text range in the visible region
- * @return the width of the presentation of the specified text range
- * @since 2.0
- */
- final protected int getWidthInPixels(int offset, int length) {
-
- Point left= fTextWidget.getLocationAtOffset(offset);
- Point right= new Point(left.x, left.y);
-
- int end= offset + length;
- for (int i= offset +1; i <= end; i++) {
-
- Point p= fTextWidget.getLocationAtOffset(i);
-
- if (left.x > p.x)
- left.x= p.x;
-
- if (right.x < p.x)
- right.x= p.x;
- }
-
- return right.x - left.x;
- }
-
- /**
- * Returns the average character width of this viewer's widget.
- *
- * @return the average character width of this viewer's widget
- */
- final protected int getAverageCharWidth() {
- GC gc= new GC(fTextWidget);
- gc.setFont(fTextWidget.getFont());
- int increment= gc.getFontMetrics().getAverageCharWidth();
- gc.dispose();
- return increment;
- }
-
- /*
- * @see Viewer#refresh()
- */
- public void refresh() {
- setDocument(getDocument());
- }
-
- //---- visible range support
-
- /**
- * Returns the slave document manager
- *
- * @return the slave document manager
- * @since 2.1
- */
- protected ISlaveDocumentManager getSlaveDocumentManager() {
- if (fSlaveDocumentManager == null)
- fSlaveDocumentManager= createSlaveDocumentManager();
- return fSlaveDocumentManager;
- }
-
- /**
- * Creates a new slave document manager. This implementation always
- * returns a <code>ChildDocumentManager</code>.
- *
- * @return ISlaveDocumentManager
- * @since 2.1
- */
- protected ISlaveDocumentManager createSlaveDocumentManager() {
- return new ChildDocumentManager();
- }
-
- /*
- * @see org.eclipse.jface.text.ITextViewer#invalidateTextPresentation()
- */
- public final void invalidateTextPresentation() {
- if (fVisibleDocument != null) {
- fWidgetCommand.event= null;
- fWidgetCommand.start= 0;
- fWidgetCommand.length= fVisibleDocument.getLength();
- fWidgetCommand.text= fVisibleDocument.get();
- updateTextListeners(fWidgetCommand);
- }
- }
-
- /**
- * Invalidates the given range of the text presentation.
- *
- * @param offset the offset of the range to be invalidated
- * @param length the length of the range to be invalidated
- * @since 2.1
- */
- public final void invalidateTextPresentation(int offset, int length) {
- if (fVisibleDocument != null) {
-
- IRegion widgetRange= modelRange2WidgetRange(new Region(offset, length));
- if (widgetRange != null) {
-
- fWidgetCommand.event= null;
- fWidgetCommand.start= widgetRange.getOffset();
- fWidgetCommand.length= widgetRange.getLength();
-
- try {
- fWidgetCommand.text= fVisibleDocument.get(widgetRange.getOffset(), widgetRange.getLength());
- updateTextListeners(fWidgetCommand);
- } catch (BadLocationException x) {
- // can not happen because of previous checking
- }
- }
- }
- }
-
- /**
- * Initializes the text widget with the visual document and
- * invalidates the overall presentation.
- */
- private void initializeWidgetContents() {
-
- if (fTextWidget != null && fVisibleDocument != null) {
-
- // set widget content
- if (fDocumentAdapter == null)
- fDocumentAdapter= createDocumentAdapter();
-
- fDocumentAdapter.setDocument(fVisibleDocument);
- fTextWidget.setContent(fDocumentAdapter);
-
- // invalidate presentation
- invalidateTextPresentation();
- }
- }
-
- /**
- * Sets this viewer's visible document. The visible document represents the
- * visible region of the viewer's input document.
- *
- * @param document the visible document
- */
- protected void setVisibleDocument(IDocument document) {
-
- if (fVisibleDocument != null && fDocumentListener != null)
- fVisibleDocument.removeDocumentListener(fDocumentListener);
-
- fVisibleDocument= document;
- initializeDocumentInformationMapping(fVisibleDocument);
-
- initializeWidgetContents();
- resetPlugins();
-
- if (fVisibleDocument != null) {
- fFindRepalceDocumentAdapter= new FindReplaceDocumentAdapter(getVisibleDocument());
- if (fDocumentListener != null)
- fVisibleDocument.addDocumentListener(fDocumentListener);
- }
- }
-
- /**
- * Initializes the document information mapping between the given slave document and
- * its master document.
- *
- * @param visibleDocument the slave document
- * @since 2.1
- */
- protected void initializeDocumentInformationMapping(IDocument visibleDocument) {
- ISlaveDocumentManager manager= getSlaveDocumentManager();
- fInformationMapping= manager == null ? null : manager.createMasterSlaveMapping(visibleDocument);
- }
-
- /**
- * Returns the viewer's visible document.
- *
- * @return the viewer's visible document
- */
- protected IDocument getVisibleDocument() {
- return fVisibleDocument;
- }
-
- /**
- * Returns the offset of the visible region.
- *
- * @return the offset of the visible region
- */
- protected int _getVisibleRegionOffset() {
-
- IDocument document= getVisibleDocument();
- if (document instanceof ChildDocument) {
- ChildDocument cdoc= (ChildDocument) document;
- return cdoc.getParentDocumentRange().getOffset();
- }
-
- return 0;
- }
-
- /*
- * @see ITextViewer#getVisibleRegion()
- */
- public IRegion getVisibleRegion() {
-
- IDocument document= getVisibleDocument();
- if (document instanceof ChildDocument) {
- Position p= ((ChildDocument) document).getParentDocumentRange();
- return new Region(p.getOffset(), p.getLength());
- }
-
- return new Region(0, document == null ? 0 : document.getLength());
- }
-
- /*
- * @see ITextViewer#overlapsWithVisibleRegion(int, int)
- */
- public boolean overlapsWithVisibleRegion(int start, int length) {
- IDocument document= getVisibleDocument();
- if (document instanceof ChildDocument) {
- ChildDocument cdoc= (ChildDocument) document;
- return cdoc.getParentDocumentRange().overlapsWith(start, length);
- } else if (document != null) {
- int size= document.getLength();
- return (start >= 0 && length >= 0 && start + length <= size);
- }
- return false;
- }
-
- /*
- * @see ITextViewer#setVisibleRegion(int, int)
- */
- public void setVisibleRegion(int start, int length) {
-
- IRegion region= getVisibleRegion();
- if (start == region.getOffset() && length == region.getLength()) {
- // nothing to change
- return;
- }
-
- try {
- IDocument visibleDocument= createSlaveDocument(getVisibleDocument());
- if (updateVisibleDocument(visibleDocument, start, length))
- setVisibleDocument(visibleDocument);
- } catch (BadLocationException x) {
- throw new IllegalArgumentException(JFaceTextMessages.getString("TextViewer.error.invalid_visible_region_2")); //$NON-NLS-1$
- }
-
- getPaintManager().paint(IPainter.INTERNAL);
- }
-
- /*
- * @see ITextViewer#resetVisibleRegion()
- */
- public void resetVisibleRegion() {
- ISlaveDocumentManager manager= getSlaveDocumentManager();
- if (manager != null) {
- IDocument slave= getVisibleDocument();
- IDocument master= manager.getMasterDocument(slave);
- if (master != null) {
- setVisibleDocument(master);
- manager.freeSlaveDocument(slave);
- }
- }
- getPaintManager().paint(IPainter.INTERNAL);
- }
-
-
- //--------------------------------------
-
- /*
- * @see ITextViewer#setTextDoubleClickStrategy(ITextDoubleClickStrategy, String)
- */
- public void setTextDoubleClickStrategy(ITextDoubleClickStrategy strategy, String contentType) {
-
- if (strategy != null) {
- if (fDoubleClickStrategies == null)
- fDoubleClickStrategies= new HashMap();
- fDoubleClickStrategies.put(contentType, strategy);
- } else if (fDoubleClickStrategies != null)
- fDoubleClickStrategies.remove(contentType);
- }
-
- /**
- * Selects from the given map the one which is registered under
- * the content type of the partition in which the given offset is located.
- *
- * @param plugins the map from which to choose
- * @param offset the offset for which to find the plugin
- * @return the plugin registered under the offset's content type
- */
- protected Object selectContentTypePlugin(int offset, Map plugins) {
- try {
- return selectContentTypePlugin(TextUtilities.getContentType(getDocument(), getDocumentPartitioning(), offset), plugins);
- } catch (BadLocationException x) {
- if (TRACE_ERRORS)
- System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.selectContentTypePlugin")); //$NON-NLS-1$
- }
- return null;
- }
-
- /**
- * Selects from the given <code>plugins</code> this one which is registered for
- * the given content <code>type</code>.
- *
- * @param type the type to be used as lookup key
- * @param plugins the table to be searched
- */
- private Object selectContentTypePlugin(String type, Map plugins) {
-
- if (plugins == null)
- return null;
-
- return plugins.get(type);
- }
-
- /**
- * Hook called on receipt of a <code>VerifyEvent</code>. The event has
- * been translated into a <code>DocumentCommand</code> which can now be
- * manipulated by interested parties. By default, the hook forwards the command
- * to the installed instances of <code>IAutoEditStrategy</code>.
- *
- * @param command the document command representing the verify event
- */
- protected void customizeDocumentCommand(DocumentCommand command) {
- if (isIgnoringAutoEditStrategies())
- return;
-
- List strategies= (List) selectContentTypePlugin(command.offset, fAutoIndentStrategies);
- if (strategies == null)
- return;
-
- switch (strategies.size()) {
- // optimizations
- case 0:
- break;
-
- case 1:
- ((IAutoEditStrategy) strategies.iterator().next()).customizeDocumentCommand(getDocument(), command);
- break;
-
- // make iterator robust against adding/removing strategies from within strategies
- default:
- strategies= new ArrayList(strategies);
-
- IDocument document= getDocument();
- for (final Iterator iterator= strategies.iterator(); iterator.hasNext(); )
- ((IAutoEditStrategy) iterator.next()).customizeDocumentCommand(document, command);
-
- break;
- }
- }
-
- /**
- * @see VerifyListener#verifyText(VerifyEvent)
- */
- protected void handleVerifyEvent(VerifyEvent e) {
-
- if (fEventConsumer != null) {
- fEventConsumer.processEvent(e);
- if (!e.doit)
- return;
- }
-
- IRegion modelRange= event2ModelRange(e);
- fDocumentCommand.setEvent(e, modelRange);
- customizeDocumentCommand(fDocumentCommand);
- if (!fDocumentCommand.fillEvent(e, modelRange)) {
-
- boolean compoundChange= fDocumentCommand.getCommandCount() > 1;
- try {
-
- fVerifyListener.forward(false);
-
- if (compoundChange && fUndoManager != null)
- fUndoManager.beginCompoundChange();
-
- if (fSlaveDocumentManager != null) {
- IDocument visible= getVisibleDocument();
- try {
- fSlaveDocumentManager.setAutoExpandMode(visible, true);
- fDocumentCommand.execute(getDocument());
- } finally {
- fSlaveDocumentManager.setAutoExpandMode(visible, false);
- }
- } else {
- fDocumentCommand.execute(getDocument());
- }
-
- if (fTextWidget != null) {
- int documentCaret= fDocumentCommand.caretOffset;
- if (documentCaret == -1) {
- // old behaviour of document command
- documentCaret= fDocumentCommand.offset + (fDocumentCommand.text == null ? 0 : fDocumentCommand.text.length());
- }
-
- int widgetCaret= modelOffset2WidgetOffset(documentCaret);
- if (widgetCaret == -1) {
- // try to move it to the closest spot
- IRegion region= getModelCoverage();
- if (documentCaret <= region.getOffset())
- widgetCaret= 0;
- else if (documentCaret >= region.getOffset() + region.getLength())
- widgetCaret= getVisibleRegion().getLength();
- }
-
- if (widgetCaret != -1) {
- // there is a valid widget caret
- fTextWidget.setCaretOffset(widgetCaret);
- }
-
- fTextWidget.showSelection();
- }
- } catch (BadLocationException x) {
-
- if (TRACE_ERRORS)
- System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.verifyText")); //$NON-NLS-1$
-
- } finally {
-
- if (compoundChange && fUndoManager != null)
- fUndoManager.endCompoundChange();
-
- fVerifyListener.forward(true);
-
- }
- }
- }
-
- //---- text manipulation
-
- /**
- * Returns whether the marked region of this viewer is empty.
- *
- * @return <code>true</code> if the marked region of this viewer is empty, otherwise <code>false</code>
- * @since 2.0
- */
- private boolean isMarkedRegionEmpty() {
- return
- fTextWidget == null ||
- fMarkPosition == null ||
- fMarkPosition.isDeleted() ||
- modelRange2WidgetRange(fMarkPosition) == null;
- }
-
- /*
- * @see ITextViewer#canDoOperation(int)
- */
- public boolean canDoOperation(int operation) {
-
- if (fTextWidget == null || !redraws())
- return false;
-
- switch (operation) {
- case CUT:
- return isEditable() &&(fTextWidget.getSelectionCount() > 0 || !isMarkedRegionEmpty());
- case COPY:
- return fTextWidget.getSelectionCount() > 0 || !isMarkedRegionEmpty();
- case DELETE:
- case PASTE:
- return isEditable();
- case SELECT_ALL:
- return true;
- case SHIFT_LEFT:
- return isEditable() && fIndentChars != null;
- case SHIFT_RIGHT:
- return isEditable() && fIndentChars != null && areMultipleLinesSelected();
- case PREFIX:
- case STRIP_PREFIX:
- return isEditable() && fDefaultPrefixChars != null;
- case UNDO:
- return fUndoManager != null && fUndoManager.undoable();
- case REDO:
- return fUndoManager != null && fUndoManager.redoable();
- case PRINT:
- return isPrintable();
- }
-
- return false;
- }
-
- /*
- * @see ITextViewer#doOperation(int)
- */
- public void doOperation(int operation) {
-
- if (fTextWidget == null || !redraws())
- return;
-
- Point selection= null;
-
- switch (operation) {
-
- case UNDO:
- if (fUndoManager != null) {
- ignoreAutoEditStrategies(true);
- fUndoManager.undo();
- ignoreAutoEditStrategies(false);
- }
- break;
- case REDO:
- if (fUndoManager != null) {
- ignoreAutoEditStrategies(true);
- fUndoManager.redo();
- ignoreAutoEditStrategies(false);
- }
- break;
- case CUT:
- if (fTextWidget.getSelectionCount() == 0)
- copyMarkedRegion(true);
- else
- fTextWidget.cut();
-
- selection= fTextWidget.getSelectionRange();
- fireSelectionChanged(selection.x, selection.y);
-
- break;
- case COPY:
- if (fTextWidget.getSelectionCount() == 0)
- copyMarkedRegion(false);
- else
- fTextWidget.copy();
- break;
- case PASTE:
-// ignoreAutoEditStrategies(true);
- fTextWidget.paste();
- selection= fTextWidget.getSelectionRange();
- fireSelectionChanged(selection.x, selection.y);
-// ignoreAutoEditStrategies(false);
- break;
- case DELETE:
- deleteText();
- selection= fTextWidget.getSelectionRange();
- fireSelectionChanged(selection.x, selection.y);
- break;
- case SELECT_ALL: {
- if (getDocument() != null)
- setSelectedRange(0, getDocument().getLength());
- break;
- }
- case SHIFT_RIGHT:
- shift(false, true, false);
- break;
- case SHIFT_LEFT:
- shift(false, false, false);
- break;
- case PREFIX:
- shift(true, true, true);
- break;
- case STRIP_PREFIX:
- shift(true, false, true);
- break;
- case PRINT:
- print();
- break;
- }
- }
-
- /**
- * Tells this viewer whether the registered auto edit strategies should be ignored.
- *
- * @param ignore <code>true</code> if the strategies should be ignored.
- * @since 2.1
- */
- protected void ignoreAutoEditStrategies(boolean ignore) {
-
- fIgnoreAutoIndent= ignore;
-
- IDocument document= getDocument();
- if (document instanceof IDocumentExtension2) {
- IDocumentExtension2 extension= (IDocumentExtension2) document;
- if (ignore)
- extension.ignorePostNotificationReplaces();
- else
- extension.acceptPostNotificationReplaces();
- }
- }
-
- /**
- * Returns whether this viewer ignores the registered auto edit strategies.
- *
- * @return <code>true</code> if the strategies are ignored
- * @since 2.1
- */
- protected boolean isIgnoringAutoEditStrategies() {
- return fIgnoreAutoIndent;
- }
-
- /*
- * @see ITextOperationTargetExtension#enableOperation(int, boolean)
- * @since 2.0
- */
- public void enableOperation(int operation, boolean enable) {
- /*
- * No-op by default.
- * Will be changed to regularily disable the known operations.
- */
- }
-
- /**
- * Copies/cuts the marked region.
- *
- * @param delete <code>true</code> if the region should be deleted rather than copied.
- * @since 2.0
- */
- private void copyMarkedRegion(boolean delete) {
-
- if (fTextWidget == null)
- return;
-
- if (fMarkPosition == null || fMarkPosition.isDeleted() || modelRange2WidgetRange(fMarkPosition) == null)
- return;
-
- int widgetMarkOffset= modelOffset2WidgetOffset(fMarkPosition.offset);
- Point selection= fTextWidget.getSelection();
- if (selection.x <= widgetMarkOffset)
- fTextWidget.setSelection(selection.x, widgetMarkOffset);
- else
- fTextWidget.setSelection(widgetMarkOffset, selection.x);
-
- if (delete) {
- fTextWidget.cut();
- } else {
- fTextWidget.copy();
- fTextWidget.setSelection(selection.x); // restore old cursor position
- }
- }
-
- /**
- * Deletes the current selection. If the selection has the length 0
- * the selection is automatically extended to the right - either by 1
- * or by the length of line delimiter if at the end of a line.
- *
- * @deprecated use <code>StyledText.invokeAction</code> instead
- */
- protected void deleteText() {
- fTextWidget.invokeAction(ST.DELETE_NEXT);
- }
-
- /**
- * A block is selected if the character preceding the start of the
- * selection is a new line character.
- *
- * @return <code>true</code> if a block is selected
- */
- protected boolean isBlockSelected() {
-
- Point s= getSelectedRange();
- if (s.y == 0)
- return false;
-
- try {
-
- IDocument document= getDocument();
- int line= document.getLineOfOffset(s.x);
- int start= document.getLineOffset(line);
- return (s.x == start);
-
- } catch (BadLocationException x) {
- }
-
- return false;
- }
-
- /**
- * Returns <code>true</code> if one line is completely selected or if multiple lines are selected.
- * Being completely selected means that all characters except the new line characters are
- * selected.
- *
- * @return <code>true</code> if one or multiple lines are selected
- * @since 2.0
- */
- protected boolean areMultipleLinesSelected() {
- Point s= getSelectedRange();
- if (s.y == 0)
- return false;
-
- try {
-
- IDocument document= getDocument();
- int startLine= document.getLineOfOffset(s.x);
- int endLine= document.getLineOfOffset(s.x + s.y);
- IRegion line= document.getLineInformation(startLine);
- return startLine != endLine || (s.x == line.getOffset() && s.y == line.getLength());
-
- } catch (BadLocationException x) {
- }
-
- return false;
- }
-
- /**
- * Returns the index of the first line whose start offset is in the given text range.
- *
- * @param region the text range in characters where to find the line
- * @return the first line whose start index is in the given range, -1 if there is no such line
- */
- private int getFirstCompleteLineOfRegion(IRegion region) {
-
- try {
-
- IDocument d= getDocument();
-
- int startLine= d.getLineOfOffset(region.getOffset());
-
- int offset= d.getLineOffset(startLine);
- if (offset >= region.getOffset())
- return startLine;
-
- offset= d.getLineOffset(startLine + 1);
- return (offset > region.getOffset() + region.getLength() ? -1 : startLine + 1);
-
- } catch (BadLocationException x) {
- if (TRACE_ERRORS)
- System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.getFirstCompleteLineOfRegion")); //$NON-NLS-1$
- }
-
- return -1;
- }
-
-
- /**
- * Creates a region describing the text block (something that starts at
- * the beginning of a line) completely containing the current selection.
- *
- * @param selection the selection to use
- * @return the region describing the text block comprising the given selection
- * @since 2.0
- */
- private IRegion getTextBlockFromSelection(Point selection) {
-
- try {
- IDocument document= getDocument();
- IRegion line= document.getLineInformationOfOffset(selection.x);
- int length= selection.y == 0 ? line.getLength() : selection.y + (selection.x - line.getOffset());
- return new Region(line.getOffset(), length);
-
- } catch (BadLocationException x) {
- }
-
- return null;
- }
-
- /**
- * Shifts a text block to the right or left using the specified set of prefix characters.
- * The prefixes must start at the beginnig of the line.
- *
- * @param useDefaultPrefixes says whether the configured default or indent prefixes should be used
- * @param right says whether to shift to the right or the left
- *
- * @deprecated use shift(boolean, boolean, boolean) instead
- */
- protected void shift(boolean useDefaultPrefixes, boolean right) {
- shift(useDefaultPrefixes, right, false);
- }
-
- /**
- * Shifts a text block to the right or left using the specified set of prefix characters.
- * If white space should be ignored the prefix characters must not be at the beginning of
- * the line when shifting to the left. There may be whitespace in front of the prefixes.
- *
- * @param useDefaultPrefixes says whether the configured default or indent prefixes should be used
- * @param right says whether to shift to the right or the left
- * @param ignoreWhitespace says whether whitepsace in front of prefixes is allowed
- * @since 2.0
- */
- protected void shift(boolean useDefaultPrefixes, boolean right, boolean ignoreWhitespace) {
-
- if (fUndoManager != null)
- fUndoManager.beginCompoundChange();
-
- setRedraw(false);
- startSequentialRewriteMode(true);
-
- IDocument d= getDocument();
- Map partitioners= null;
-
- try {
-
- Point selection= getSelectedRange();
- IRegion block= getTextBlockFromSelection(selection);
- ITypedRegion[] regions= TextUtilities.computePartitioning(d, getDocumentPartitioning(), block.getOffset(), block.getLength());
-
- int lineCount= 0;
- int[] lines= new int[regions.length * 2]; // [startline, endline, startline, endline, ...]
- for (int i= 0, j= 0; i < regions.length; i++, j+= 2) {
- // start line of region
- lines[j]= getFirstCompleteLineOfRegion(regions[i]);
- // end line of region
- int offset= regions[i].getOffset() + regions[i].getLength() - 1;
- lines[j + 1]= (lines[j] == -1 ? -1 : d.getLineOfOffset(offset));
- lineCount += lines[j + 1] - lines[j] + 1;
- }
-
- if (lineCount >= 20)
- partitioners= TextUtilities.removeDocumentPartitioners(d);
-
- // Remember the selection range.
- IPositionUpdater positionUpdater= new ShiftPositionUpdater(SHIFTING);
- Position rememberedSelection= new Position(selection.x, selection.y);
- d.addPositionCategory(SHIFTING);
- d.addPositionUpdater(positionUpdater);
- try {
- d.addPosition(SHIFTING, rememberedSelection);
- } catch (BadPositionCategoryException ex) {
- // should not happen
- }
-
- // Perform the shift operation.
- Map map= (useDefaultPrefixes ? fDefaultPrefixChars : fIndentChars);
- for (int i= 0, j= 0; i < regions.length; i++, j += 2) {
- String[] prefixes= (String[]) selectContentTypePlugin(regions[i].getType(), map);
- if (prefixes != null && prefixes.length > 0 && lines[j] >= 0 && lines[j + 1] >= 0) {
- if (right)
- shiftRight(lines[j], lines[j + 1], prefixes[0]);
- else
- shiftLeft(lines[j], lines[j + 1], prefixes, ignoreWhitespace);
- }
- }
-
- // Restore the selection.
- setSelectedRange(rememberedSelection.getOffset(), rememberedSelection.getLength());
-
- try {
- d.removePositionUpdater(positionUpdater);
- d.removePositionCategory(SHIFTING);
- } catch (BadPositionCategoryException ex) {
- // should not happen
- }
-
- } catch (BadLocationException x) {
- if (TRACE_ERRORS)
- System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.shift_1")); //$NON-NLS-1$
-
- } finally {
-
- if (partitioners != null)
- TextUtilities.addDocumentPartitioners(d, partitioners);
-
- stopSequentialRewriteMode();
- setRedraw(true);
-
- if (fUndoManager != null)
- fUndoManager.endCompoundChange();
- }
- }
-
- /**
- * Shifts the specified lines to the right inserting the given prefix
- * at the beginning of each line
- *
- * @param prefix the prefix to be inserted
- * @param startLine the first line to shift
- * @param endLine the last line to shift
- * @since 2.0
- */
- private void shiftRight(int startLine, int endLine, String prefix) {
-
- try {
-
- IDocument d= getDocument();
- while (startLine <= endLine) {
- d.replace(d.getLineOffset(startLine++), 0, prefix);
- }
-
- } catch (BadLocationException x) {
- if (TRACE_ERRORS)
- System.out.println("TextViewer.shiftRight: BadLocationException"); //$NON-NLS-1$
- }
- }
-
- /**
- * Shifts the specified lines to the right or to the left. On shifting to the right
- * it insert <code>prefixes[0]</code> at the beginning of each line. On shifting to the
- * left it tests whether each of the specified lines starts with one of the specified
- * prefixes and if so, removes the prefix.
- *
- * @param prefixes the prefixes to be used for shifting
- * @param right if <code>true</code> shift to the right otherwise to the left
- * @param startLine the first line to shift
- * @param endLine the last line to shift
- * @since 2.0
- */
- private void shiftLeft(int startLine, int endLine, String[] prefixes, boolean ignoreWhitespace) {
-
- IDocument d= getDocument();
-
- try {
-
- IRegion[] occurrences= new IRegion[endLine - startLine + 1];
-
- // find all the first occurrences of prefix in the given lines
- for (int i= 0; i < occurrences.length; i++) {
-
- IRegion line= d.getLineInformation(startLine + i);
- String text= d.get(line.getOffset(), line.getLength());
-
- int index= -1;
- int[] found= TextUtilities.indexOf(prefixes, text, 0);
- if (found[0] != -1) {
- if (ignoreWhitespace) {
- String s= d.get(line.getOffset(), found[0]);
- s= s.trim();
- if (s.length() == 0)
- index= line.getOffset() + found[0];
- } else if (found[0] == 0)
- index= line.getOffset();
- }
-
- if (index > -1) {
- // remember where prefix is in line, so that it can be removed
- int length= prefixes[found[1]].length();
- if (length == 0 && !ignoreWhitespace && line.getLength() > 0) {
- // found a non-empty line which cannot be shifted
- return;
- } else
- occurrences[i]= new Region(index, length);
- } else {
- // found a line which cannot be shifted
- return;
- }
- }
-
- // ok - change the document
- int decrement= 0;
- for (int i= 0; i < occurrences.length; i++) {
- IRegion r= occurrences[i];
- d.replace(r.getOffset() - decrement, r.getLength(), ""); //$NON-NLS-1$
- decrement += r.getLength();
- }
-
- } catch (BadLocationException x) {
- if (TRACE_ERRORS)
- System.out.println("TextViewer.shiftLeft: BadLocationException"); //$NON-NLS-1$
- }
- }
-
- /**
- * Returns whether the shown text can be printed.
- *
- * @return the viewer's printable mode
- */
- protected boolean isPrintable() {
- /*
- * 1GK7Q10: ITPUI:WIN98 - internal error after invoking print at editor view
- * Changed from returning true to testing the length of the printer queue
- */
- PrinterData[] printerList= Printer.getPrinterList();
- return (printerList != null && printerList.length > 0);
- }
-
- /**
- * Brings up a print dialog and calls <code>printContents(Printer)</code> which
- * performs the actual print.
- */
- protected void print() {
-
- final PrintDialog dialog= new PrintDialog(fTextWidget.getShell(), SWT.PRIMARY_MODAL);
- final PrinterData data= dialog.open();
-
- if (data != null) {
-
- final Printer printer= new Printer(data);
- final Runnable styledTextPrinter= fTextWidget.print(printer);
-
- Thread printingThread= new Thread("Printing") { //$NON-NLS-1$
- public void run() {
- styledTextPrinter.run();
- printer.dispose();
- }
- };
- printingThread.start();
- }
- }
-
-
- //------ find support
-
- /**
- * @see IFindReplaceTarget#canPerformFind
- */
- protected boolean canPerformFind() {
- IDocument d= getVisibleDocument();
- return (fTextWidget != null && d != null && d.getLength() > 0);
- }
-
- /**
- * @see IFindReplaceTarget#findAndSelect(int, String, boolean, boolean, boolean)
- * @deprecated as of 3.0 use {@link #findAndSelect(int, String, boolean, boolean, boolean, boolean)
- */
- protected int findAndSelect(int startPosition, String findString, boolean forwardSearch, boolean caseSensitive, boolean wholeWord) {
- try {
- return findAndSelect(startPosition, findString, forwardSearch, caseSensitive, wholeWord, false);
- } catch (IllegalStateException ex) {
- return -1;
- } catch (PatternSyntaxException ex) {
- return -1;
- }
- }
-
- /**
- * @see IFindReplaceTargetExtension3#findAndSelect(int, String, boolean, boolean, boolean, boolean)
- */
- protected int findAndSelect(int startPosition, String findString, boolean forwardSearch, boolean caseSensitive, boolean wholeWord, boolean regExSearch) {
- if (fTextWidget == null)
- return -1;
-
- try {
-
- int widgetOffset= (startPosition == -1 ? startPosition : modelOffset2WidgetOffset(startPosition));
- IRegion matchRegion= getFindRepalceDocumentAdapter().search(widgetOffset, findString, forwardSearch, caseSensitive, wholeWord, regExSearch);
- if (matchRegion != null) {
- int widgetPos= matchRegion.getOffset();
- int length= matchRegion.getLength();
- if (redraws()) {
- fTextWidget.setSelectionRange(widgetPos, length);
- internalRevealRange(widgetPos, widgetPos + length);
- selectionChanged(widgetPos, length);
- } else {
- setSelectedRange(widgetOffset2ModelOffset(widgetPos), length);
- }
-
- return widgetOffset2ModelOffset(widgetPos);
- }
-
- } catch (BadLocationException x) {
- if (TRACE_ERRORS)
- System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.findAndSelect")); //$NON-NLS-1$
- }
-
- return -1;
- }
-
- /**
- * @see IFindReplaceTargetExtension3#findAndSelect(int, String, boolean, boolean, boolean, boolean)
- * @since 3.0
- */
- private int findAndSelectInRange(int startPosition, String findString, boolean forwardSearch, boolean caseSensitive, boolean wholeWord, int rangeOffset, int rangeLength, boolean regExSearch) {
- if (fTextWidget == null)
- return -1;
-
- try {
-
- int modelOffset;
- if (forwardSearch && (startPosition == -1 || startPosition < rangeOffset)) {
- modelOffset= rangeOffset;
- } else if (!forwardSearch && (startPosition == -1 || startPosition > rangeOffset + rangeLength)) {
- modelOffset= rangeOffset + rangeLength;
- } else {
- modelOffset= startPosition;
- }
-
- int widgetOffset= modelOffset2WidgetOffset(modelOffset);
- if (widgetOffset == -1)
- return -1;
-
- IRegion matchRegion= getFindRepalceDocumentAdapter().search(widgetOffset, findString, forwardSearch, caseSensitive, wholeWord, regExSearch);
- int widgetPos= -1;
- int length= 0;
- if (matchRegion != null) {
- widgetPos= matchRegion.getOffset();
- length= matchRegion.getLength();
- }
- int modelPos= widgetPos == -1 ? -1 : widgetOffset2ModelOffset(widgetPos);
-
- if (widgetPos != -1 && (modelPos < rangeOffset || modelPos + length > rangeOffset + rangeLength))
- widgetPos= -1;
-
- if (widgetPos > -1) {
-
- if (redraws()) {
- fTextWidget.setSelectionRange(widgetPos, length);
- internalRevealRange(widgetPos, widgetPos + length);
- selectionChanged(widgetPos, length);
- } else {
- setSelectedRange(modelPos, length);
- }
-
- return modelPos;
- }
-
-
- } catch (BadLocationException x) {
- if (TRACE_ERRORS)
- System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.findAndSelect")); //$NON-NLS-1$
- }
-
- return -1;
- }
-
- //---------- text presentation support
-
- /*
- * @see ITextViewer#setTextColor(Color)
- */
- public void setTextColor(Color color) {
- if (color != null)
- setTextColor(color, 0, getDocument().getLength(), true);
- }
-
- /*
- * @see ITextViewer#setTextColor(Color, start, length, boolean)
- */
- public void setTextColor(Color color, int start, int length, boolean controlRedraw) {
-
- if (fTextWidget != null) {
-
- if (controlRedraw)
- fTextWidget.setRedraw(false);
-
- StyleRange s= new StyleRange();
- s.foreground= color;
- s.start= start;
- s.length= length;
-
- s= modelStyleRange2WidgetStyleRange(s);
- if (s != null) {
-
- if (controlRedraw)
- fTextWidget.setRedraw(false);
-
- fTextWidget.setStyleRange(s);
-
- if (controlRedraw)
- fTextWidget.setRedraw(true);
- }
- }
- }
-
- /**
- * Adds the given presentation to the viewer's style information.
- *
- * @param presentation the presentation to be added
- */
- private void addPresentation(TextPresentation presentation) {
-
- StyleRange range= presentation.getDefaultStyleRange();
- if (range != null) {
-
- range= modelStyleRange2WidgetStyleRange(range);
- if (range != null)
- fTextWidget.setStyleRange(range);
-
- Iterator e= presentation.getNonDefaultStyleRangeIterator();
- while (e.hasNext()) {
- range= (StyleRange) e.next();
- range= modelStyleRange2WidgetStyleRange(range);
- if (range != null)
- fTextWidget.setStyleRange(range);
- }
-
- } else {
-
- List list= new ArrayList();
- Iterator e= presentation.getAllStyleRangeIterator();
- while (e.hasNext()) {
- range= (StyleRange) e.next();
- range= modelStyleRange2WidgetStyleRange(range);
- if (range != null)
- list.add(range);
- }
-
- if (!list.isEmpty()) {
- StyleRange[] ranges= new StyleRange[list.size()];
- list.toArray(ranges);
- IRegion region= modelRange2WidgetRange(presentation.getCoverage());
- fTextWidget.replaceStyleRanges(region.getOffset(), region.getLength(), ranges);
- }
- }
- }
-
- /**
- * Applies the given presentation to the given text widget. Helper method.
- *
- * @param presentation the style information
- * @since 2.1
- */
- private void applyTextPresentation(TextPresentation presentation) {
-
- List list= new ArrayList(presentation.getDenumerableRanges());
- Iterator e= presentation.getAllStyleRangeIterator();
- while (e.hasNext()) {
- StyleRange range= (StyleRange) e.next();
- range= modelStyleRange2WidgetStyleRange(range);
- if (range != null)
- list.add(range);
- }
-
- if (!list.isEmpty()) {
- StyleRange[] ranges= new StyleRange[list.size()];
- list.toArray(ranges);
- fTextWidget.setStyleRanges(ranges);
- }
- }
-
- /**
- * Returns the visible region if it is not equal to the whole document.
- * Otherwise returns <code>null</code>.
- *
- * @return the viewer's visible region if smaller than input document, otherwise <code>null</code>
- */
- protected IRegion _internalGetVisibleRegion() {
-
- IDocument document= getVisibleDocument();
- if (document instanceof ChildDocument) {
- Position p= ((ChildDocument) document).getParentDocumentRange();
- return new Region(p.getOffset(), p.getLength());
- }
-
- return null;
- }
-
- /*
- * @see ITextViewer#changeTextPresentation(TextPresentation, boolean)
- */
- public void changeTextPresentation(TextPresentation presentation, boolean controlRedraw) {
-
- if (presentation == null || !redraws())
- return;
-
- if (presentation.isEmpty() || fTextWidget == null)
- return;
-
- if (controlRedraw)
- fTextWidget.setRedraw(false);
-
- if (fReplaceTextPresentation)
- applyTextPresentation(presentation);
- else
- addPresentation(presentation);
-
- if (controlRedraw)
- fTextWidget.setRedraw(true);
- }
-
- /*
- * @see ITextViewer#getFindReplaceTarget()
- */
- public IFindReplaceTarget getFindReplaceTarget() {
- if (fFindReplaceTarget == null)
- fFindReplaceTarget= new FindReplaceTarget();
- return fFindReplaceTarget;
- }
-
- /**
- * Returns the find/replace document adapter.
- *
- * @return the find/replace document adapter.
- * @since 3.0
- */
- private FindReplaceDocumentAdapter getFindRepalceDocumentAdapter() {
- if (fFindRepalceDocumentAdapter == null)
- fFindRepalceDocumentAdapter= new FindReplaceDocumentAdapter(getVisibleDocument());
- return fFindRepalceDocumentAdapter;
- }
-
- /*
- * @see ITextViewer#getTextOperationTarget()
- */
- public ITextOperationTarget getTextOperationTarget() {
- return this;
- }
-
- /*
- * @see ITextViewerExtension#appendVerifyKeyListener(VerifyKeyListener)
- * @since 2.0
- */
- public void appendVerifyKeyListener(VerifyKeyListener listener) {
- int index= fVerifyKeyListenersManager.numberOfListeners();
- fVerifyKeyListenersManager.insertListener(listener, index);
- }
-
- /*
- * @see ITextViewerExtension#prependVerifyKeyListener(VerifyKeyListener)
- * @since 2.0
- */
- public void prependVerifyKeyListener(VerifyKeyListener listener) {
- fVerifyKeyListenersManager.insertListener(listener, 0);
-
- }
-
- /*
- * @see ITextViewerExtension#removeVerifyKeyListener(VerifyKeyListener)
- * @since 2.0
- */
- public void removeVerifyKeyListener(VerifyKeyListener listener) {
- fVerifyKeyListenersManager.removeListener(listener);
- }
-
- /*
- * @see ITextViewerExtension#getMark()
- * @since 2.0
- */
- public int getMark() {
- return fMarkPosition == null || fMarkPosition.isDeleted() ? -1 : fMarkPosition.getOffset();
- }
-
- /*
- * @see ITextViewerExtension#setMark(int)
- * @since 2.0
- */
- public void setMark(int offset) {
-
- // clear
- if (offset == -1) {
- if (fMarkPosition != null && !fMarkPosition.isDeleted()) {
-
- IDocument document= getDocument();
- if (document != null)
- document.removePosition(fMarkPosition);
- }
-
- fMarkPosition= null;
-
- markChanged(-1, 0);
-
- // set
- } else {
-
- IDocument document= getDocument();
- if (document == null) {
- fMarkPosition= null;
- return;
- }
-
- if (fMarkPosition != null)
- document.removePosition(fMarkPosition);
-
- fMarkPosition= null;
-
- try {
-
- Position position= new Position(offset);
- document.addPosition(MARK_POSITION_CATEGORY, position);
- fMarkPosition= position;
-
- } catch (BadLocationException e) {
- return;
- } catch (BadPositionCategoryException e) {
- return;
- }
-
- markChanged(modelOffset2WidgetOffset(fMarkPosition.offset), 0);
- }
- }
-
- /*
- * @see Viewer#inputChanged(Object, Object)
- * @since 2.0
- */
- protected void inputChanged(Object newInput, Object oldInput) {
-
- IDocument oldDocument= (IDocument) oldInput;
- if (oldDocument != null) {
- if (fMarkPosition != null && !fMarkPosition.isDeleted())
- oldDocument.removePosition(fMarkPosition);
-
- try {
- oldDocument.removePositionUpdater(fMarkPositionUpdater);
- oldDocument.removePositionCategory(MARK_POSITION_CATEGORY);
-
- } catch (BadPositionCategoryException e) {
- }
- }
-
- fMarkPosition= null;
-
- super.inputChanged(newInput, oldInput);
-
- IDocument newDocument= (IDocument) newInput;
- if (newDocument != null) {
- newDocument.addPositionCategory(MARK_POSITION_CATEGORY);
- newDocument.addPositionUpdater(fMarkPositionUpdater);
- }
- }
-
- /**
- * Informs all text listeners about the change of the viewer's redraw state.
- * @since 2.0
- */
- private void fireRedrawChanged() {
- fWidgetCommand.start= 0;
- fWidgetCommand.length= 0;
- fWidgetCommand.text= null;
- fWidgetCommand.event= null;
- updateTextListeners(fWidgetCommand);
- }
-
- /**
- * Forgets the previously remembered selection position. After that
- * call the selection position can no longer be queried and is longer updated
- * in responds to content changes of the viewer.
- *
- * @return the remembered and updated selection position or <code>null</code> if no selection position has been remembered
- * @since 2.1
- */
- private Point forgetDocumentSelection() {
- if (fDocumentSelection == null)
- return null;
-
- Point selection= fDocumentSelection.isDeleted() ? null : fDocumentSelection.getSelection();
- IDocument document= getDocument();
- if (document != null)
- document.removePosition(fDocumentSelection);
- fDocumentSelection= null;
-
- return selection;
- }
-
- /**
- * Enables the redrawing of this text viewer.
- * @since 2.0
- */
- protected void enabledRedrawing() {
- if (fDocumentAdapter instanceof IDocumentAdapterExtension) {
- IDocumentAdapterExtension extension= (IDocumentAdapterExtension) fDocumentAdapter;
- StyledText textWidget= getTextWidget();
- if (textWidget != null && !textWidget.isDisposed()) {
- int topPixel= textWidget.getTopPixel();
- extension.resumeForwardingDocumentChanges();
- if (topPixel > -1) {
- try {
- textWidget.setTopPixel(topPixel);
- } catch (IllegalArgumentException x) {
- // changes don't allow for the previous top pixel
- }
- }
- }
- }
-
- Point selection= forgetDocumentSelection();
- if (selection != null) {
- setSelectedRange(selection.x, selection.y);
- revealRange(selection.x, selection.y);
- }
-
- if (fTextWidget != null && !fTextWidget.isDisposed())
- fTextWidget.setRedraw(true);
-
- fireRedrawChanged();
- }
-
- /**
- * Remembers the current selection in a <code>SelectionPosition</code> . The selection
- * position can be queried and is updated to changes made to the viewer's contents.
- * @since 2.1
- */
- private void rememberDocumentSelection() {
- Point selection= getSelectedRange();
- if (selection != null) {
- SelectionPosition p= new SelectionPosition(selection);
- IDocument document= getDocument();
- if (document != null) {
- try {
- document.addPosition(p);
- fDocumentSelection= p;
- } catch (BadLocationException x) {
- }
- }
- }
- }
-
- /**
- * Disables the redrawing of this text viewer. Subclasses may extend.
- * @since 2.0
- */
- protected void disableRedrawing() {
-
- rememberDocumentSelection();
-
- if (fDocumentAdapter instanceof IDocumentAdapterExtension) {
- IDocumentAdapterExtension extension= (IDocumentAdapterExtension) fDocumentAdapter;
- extension.stopForwardingDocumentChanges();
- }
-
- if (fTextWidget != null && !fTextWidget.isDisposed())
- fTextWidget.setRedraw(false);
-
- fireRedrawChanged();
- }
-
- /*
- * @see ITextViewerExtension#setRedraw(boolean)
- * @since 2.0
- */
- public final void setRedraw(boolean redraw) {
- if (!redraw) {
- if (fRedrawCounter == 0)
- disableRedrawing();
- ++ fRedrawCounter;
- } else {
- -- fRedrawCounter;
- if (fRedrawCounter == 0)
- enabledRedrawing();
- }
- }
-
- /**
- * Returns whether this viewer redraws itself.
- *
- * @return <code>true</code> if this viewer redraws itself
- * @since 2.0
- */
- protected final boolean redraws() {
- return fRedrawCounter <= 0;
- }
-
- /**
- * Starts the sequential rewrite mode of the viewer's document.
- *
- * @param normalized <code>true</code> if the rewrite is performed from the start to the end of the document
- * @since 2.0
- */
- protected final void startSequentialRewriteMode(boolean normalized) {
- IDocument document= getDocument();
- if (document instanceof IDocumentExtension) {
- IDocumentExtension extension= (IDocumentExtension) document;
- extension.startSequentialRewrite(normalized);
- }
- }
-
- /**
- * Sets the sequential rewrite mode of the viewer's document.
- * @since 2.0
- */
- protected final void stopSequentialRewriteMode() {
- IDocument document= getDocument();
- if (document instanceof IDocumentExtension) {
- IDocumentExtension extension= (IDocumentExtension) document;
- extension.stopSequentialRewrite();
- }
- }
-
- /*
- * @see org.eclipse.jface.text.ITextViewerExtension#getRewriteTarget()
- * @since 2.0
- */
- public IRewriteTarget getRewriteTarget() {
- if (fRewriteTarget == null)
- fRewriteTarget= new RewriteTarget();
- return fRewriteTarget;
- }
-
- /*
- * @see org.eclipse.jface.text.ITextViewerExtension2#getCurrentTextHover()
- */
- public ITextHover getCurrentTextHover() {
- if (fTextHoverManager == null)
- return null;
- return fTextHoverManager.getCurrentTextHover();
- }
-
- /*
- * @see org.eclipse.jface.text.ITextViewerExtension2#getHoverEventLocation()
- */
- public Point getHoverEventLocation() {
- if (fTextHoverManager == null)
- return null;
- return fTextHoverManager.getHoverEventLocation();
- }
-
- /**
- * Returns the paint manager of this viewer.
- *
- * @return the paint manager of this viewer
- * @since 2.1
- */
- protected PaintManager getPaintManager() {
- if (fPaintManager == null)
- fPaintManager= new PaintManager(this);
- return fPaintManager;
- }
-
- /**
- * Adds the given painter to this viewer. If the painter is already registered
- * this method is without effect.
- *
- * @param painter the painter to be added
- * @since 2.1
- */
- public void addPainter(IPainter painter) {
- getPaintManager().addPainter(painter);
- }
-
- /**
- * Removes the given painter from this viewer. If the painter has previously not been
- * added to this viewer this method is without effect.
- *
- * @param painter the painter to be removed
- * @since 2.1
- */
- public void removePainter(IPainter painter) {
- getPaintManager().removePainter(painter);
- }
-
- // ----------------------------------- conversions -------------------------------------------------------
-
- /*
- * @see org.eclipse.jface.text.ITextViewerExtension3#modelLine2WidgetLine(int)
- * @since 2.1
- */
- public int modelLine2WidgetLine(int modelLine) {
- if (fInformationMapping == null)
- return modelLine;
-
- try {
- return fInformationMapping.toImageLine(modelLine);
- } catch (BadLocationException x) {
- }
-
- return -1;
- }
-
- /*
- * @see org.eclipse.jface.text.ITextViewerExtension3#modelOffset2WidgetOffset(int)
- * @since 2.1
- */
- public int modelOffset2WidgetOffset(int modelOffset) {
- if (fInformationMapping == null)
- return modelOffset;
-
- try {
- return fInformationMapping.toImageOffset(modelOffset);
- } catch (BadLocationException x) {
- }
-
- return -1;
- }
-
- /*
- * @see org.eclipse.jface.text.ITextViewerExtension3#modelRange2WidgetRange(org.eclipse.jface.text.IRegion)
- * @since 2.1
- */
- public IRegion modelRange2WidgetRange(IRegion modelRange) {
- if (fInformationMapping == null)
- return modelRange;
-
- try {
-
- if (modelRange.getLength() < 0) {
- Region reversed= new Region(modelRange.getOffset() + modelRange.getLength(), -modelRange.getLength());
- IRegion result= fInformationMapping.toImageRegion(reversed);
- return new Region(result.getOffset() + result.getLength(), -result.getLength());
- } else {
- return fInformationMapping.toImageRegion(modelRange);
- }
-
- } catch (BadLocationException x) {
- }
-
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.ITextViewerExtension3#widgetlLine2ModelLine(int)
- * @since 2.1
- */
- public int widgetlLine2ModelLine(int widgetLine) {
- if (fInformationMapping == null)
- return widgetLine;
-
- try {
- return fInformationMapping.toOriginLine(widgetLine);
- } catch (BadLocationException x) {
- }
-
- return -1;
- }
-
- /*
- * @see org.eclipse.jface.text.ITextViewerExtension3#widgetOffset2ModelOffset(int)
- * @since 2.1
- */
- public int widgetOffset2ModelOffset(int widgetOffset) {
- if (fInformationMapping == null)
- return widgetOffset;
-
- try {
- return fInformationMapping.toOriginOffset(widgetOffset);
- } catch (BadLocationException x) {
- if (widgetOffset == getVisibleDocument().getLength()) {
- IRegion coverage= fInformationMapping.getCoverage();
- return coverage.getOffset() + coverage.getLength();
- }
- }
-
- return -1;
- }
-
- /*
- * @see org.eclipse.jface.text.ITextViewerExtension3#widgetRange2ModelRange(org.eclipse.jface.text.IRegion)
- * @since 2.1
- */
- public IRegion widgetRange2ModelRange(IRegion widgetRange) {
- if (fInformationMapping == null)
- return widgetRange;
-
- try {
-
- if (widgetRange.getLength() < 0) {
- Region reveresed= new Region(widgetRange.getOffset() + widgetRange.getLength(), -widgetRange.getLength());
- IRegion result= fInformationMapping.toOriginRegion(reveresed);
- return new Region(result.getOffset() + result.getLength(), -result.getLength());
- } else {
- return fInformationMapping.toOriginRegion(widgetRange);
- }
-
- } catch (BadLocationException x) {
- int modelOffset= widgetOffset2ModelOffset(widgetRange.getOffset());
- if (modelOffset > -1) {
- int modelEndOffset= widgetOffset2ModelOffset(widgetRange.getOffset() + widgetRange.getLength());
- if (modelEndOffset > -1)
- return new Region(modelOffset, modelEndOffset - modelOffset);
- }
- }
-
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.ITextViewerExtension3#getModelCoverage()
- * @since 2.1
- */
- public IRegion getModelCoverage() {
- if (fInformationMapping == null) {
- IDocument document= getDocument();
- if (document == null)
- return null;
- return new Region(0, document.getLength());
- }
-
- return fInformationMapping.getCoverage();
- }
-
- /**
- * Returns the line of the widget whose corresponding line in the viewer's document
- * is closest to the given line in the viewer's document.
- *
- * @param modelLine the line in the viewer's document
- * @return the line in the widget that corresponds best to the given line in the viewer's document
- * @since 2.1
- */
- protected int getClosestWidgetLineForModelLine(int modelLine) {
- if (fInformationMapping == null)
- return modelLine;
-
- try {
- return fInformationMapping.toClosestImageLine(modelLine);
- } catch (BadLocationException x) {
- }
-
- return -1;
- }
-
- /**
- * Translates a style range given relative to the viewer's document into style
- * ranges relative to the viewer's widget.
- *
- * @param range the style range in the coordinates of the viewer's document
- * @return the style range in the coordinates of the viewer's widget
- * @since 2.1
- */
- protected StyleRange modelStyleRange2WidgetStyleRange(StyleRange range) {
- IRegion region= modelRange2WidgetRange(new Region(range.start, range.length));
- if (region != null) {
- StyleRange result= (StyleRange) range.clone();
- result.start= region.getOffset();
- result.length= region.getLength();
- return result;
- }
- return null;
- }
-
- /**
- * @see #modelRange2WidgetRange(IRegion)
- *
- * @param modelPosition the position describing a range in the viewer's document
- * @return a region describing a range in the viewer's widget
- * @since 2.1
- */
- protected IRegion modelRange2WidgetRange(Position modelPosition) {
- return modelRange2WidgetRange(new Region(modelPosition.getOffset(), modelPosition.getLength()));
- }
-
- /**
- * Translates the widget region of the given verify event into
- * the corresponding region of the viewer's document.
- *
- * @param event the verify event
- * @return the region of the viewer's document corresponding to the verify event
- * @since 2.1
- */
- protected IRegion event2ModelRange(VerifyEvent event) {
-
- Region region= null;
- if (event.start <= event.end)
- region= new Region(event.start, event.end - event.start);
- else
- region= new Region(event.end, event.start - event.end);
-
- return widgetRange2ModelRange(region);
- }
-
- /**
- * Translates the given widget selection into the corresponding region
- * of the viewer's document.
- *
- * @param widgetSelection the widget selection
- * @return the region of the viewer's document corresponding to the widget selection
- * @since 2.1
- */
- protected Point widgetSelection2ModelSelection(Point widgetSelection) {
- IRegion region= new Region(widgetSelection.x, widgetSelection.y);
- region= widgetRange2ModelRange(region);
- return region == null ? null : new Point(region.getOffset(), region.getLength());
- }
-
- /**
- * Translates the given selection range of the viewer's document into
- * the corresponding widget range.
- *
- * @param modelSelection the selection range of the viewer's document
- * @return the widget range corresponding to the selection range
- * @since 2.1
- */
- protected Point modelSelection2WidgetSelection(Point modelSelection) {
- if (fInformationMapping == null)
- return modelSelection;
-
- try {
- IRegion region= new Region(modelSelection.x, modelSelection.y);
- region= fInformationMapping.toImageRegion(region);
- return new Point(region.getOffset(), region.getLength());
- } catch (BadLocationException x) {
- }
-
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.ITextViewerExtension3#widgetLineOfWidgetOffset(int)
- */
- public int widgetLineOfWidgetOffset(int widgetOffset) {
- IDocument document= getVisibleDocument();
- if (document != null) {
- try {
- return document.getLineOfOffset(widgetOffset);
- } catch (BadLocationException e) {
- }
- }
- return -1;
- }
-
- /*
- * @see org.eclipse.jface.text.ITextViewerExtension4#moveFocusToWidgetToken()
- * @since 3.0
- */
- public boolean moveFocusToWidgetToken() {
- if (fWidgetTokenKeeper instanceof IWidgetTokenKeeperExtension) {
- IWidgetTokenKeeperExtension extension= (IWidgetTokenKeeperExtension) fWidgetTokenKeeper;
- return extension.setFocus(this);
- } else {
- return false;
- }
- }
-
- /**
- * Sets the document partitioning of this viewer. The partitioning is used by this viewer to
- * access partitioning information of the viewers input document.
- *
- * @param partitioning the partitioning name
- * @since 3.0
- */
- public void setDocumentPartitioning(String partitioning) {
- fPartitioning= partitioning;
- }
-
- /**
- * Returns the document partitioning for this viewer.
- *
- * @return the document partitioning for this viewer
- * @since 3.0
- */
- protected String getDocumentPartitioning() {
- return fPartitioning;
- }
-}
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
deleted file mode 100644
index ca7a2730f0b..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewerHoverManager.java
+++ /dev/null
@@ -1,358 +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 org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Display;
-
-
-/**
- * This manager controls the layout, content, and visibility of an information
- * control in reaction to mouse hover events issued by the text widget of a
- * text viewer. It overrides <code>computeInformation</code>, so that the
- * computation is performed in a dedicated background thread. This implies
- * that the used <code>ITextHover</code> objects must be capable of
- * operating in a non-UI thread.
- *
- * @since 2.0
- */
-class TextViewerHoverManager extends AbstractHoverInformationControlManager implements IWidgetTokenKeeper, IWidgetTokenKeeperExtension {
-
-
- /**
- * Priority of the hovers managed by this manager.
- * Default value: <code>0</code>;
- * @since 3.0
- */
- public final static int WIDGET_PRIORITY= 0;
-
-
- /** The text viewer */
- private TextViewer fTextViewer;
- /** The hover information computation thread */
- private Thread fThread;
- /** The stopper of the computation thread */
- private ITextListener fStopper;
- /** Internal monitor */
- private Object fMutex= new Object();
- /** The currently shown text hover. */
- private volatile ITextHover fTextHover;
-
- /**
- * Creates a new text viewer hover manager specific for the given text viewer.
- * The manager uses the given information control creator.
- *
- * @param textViewer the viewer for which the controller is created
- * @param creator the information control creator
- */
- public TextViewerHoverManager(TextViewer textViewer, IInformationControlCreator creator) {
- super(creator);
- fTextViewer= textViewer;
- fStopper= new ITextListener() {
- public void textChanged(TextEvent event) {
- synchronized (fMutex) {
- if (fThread != null) {
- fThread.interrupt();
- fThread= null;
- }
- }
- }
- };
- }
-
- /**
- * Determines all necessary details and delegates the computation into
- * a background thread.
- */
- protected void computeInformation() {
-
- Point location= getHoverEventLocation();
- int offset= computeOffsetAtLocation(location.x, location.y);
- if (offset == -1) {
- setInformation(null, null);
- return;
- }
-
- final ITextHover hover= fTextViewer.getTextHover(offset, getHoverEventStateMask());
- if (hover == null) {
- setInformation(null, null);
- return;
- }
-
- final IRegion region= hover.getHoverRegion(fTextViewer, offset);
- if (region == null) {
- setInformation(null, null);
- return;
- }
-
- final Rectangle area= computeArea(region);
- if (area == null || area.isEmpty()) {
- setInformation(null, null);
- return;
- }
-
- if (fThread != null) {
- setInformation(null, null);
- return;
- }
-
- fThread= new Thread("Text Viewer Hover Presenter") { //$NON-NLS-1$
- public void run() {
- // http://bugs.eclipse.org/bugs/show_bug.cgi?id=17693
- boolean hasFinished= false;
- try {
- if (fThread != null) {
- String information;
- try {
- information= hover.getHoverInfo(fTextViewer, region);
- } catch (ArrayIndexOutOfBoundsException x) {
- /*
- * This code runs in a separate thread which can
- * lead to text offsets being out of bounds when
- * computing the hover info (see bug 32848).
- */
- information= null;
- }
-
- if (hover instanceof ITextHoverExtension)
- setCustomInformationControlCreator(((ITextHoverExtension) hover).getInformationControlCreator());
- else
- setCustomInformationControlCreator(null);
-
- setInformation(information, area);
- if (information != null && area != null)
- fTextHover= hover;
- } else {
- setInformation(null, null);
- }
- hasFinished= true;
- } finally {
- synchronized (fMutex) {
- if (fTextViewer != null)
- fTextViewer.removeTextListener(fStopper);
- fThread= null;
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=44756
- if (!hasFinished)
- setInformation(null, null);
- }
- }
- }
- };
-
- fThread.setDaemon(true);
- fThread.setPriority(Thread.MIN_PRIORITY);
- synchronized (fMutex) {
- fTextViewer.addTextListener(fStopper);
- fThread.start();
- }
- }
-
- /**
- * As computation is done in the background, this method is
- * also called in the background thread. Delegates the control
- * flow back into the ui thread, in order to allow displaying the
- * information in the information control.
- */
- protected void presentInformation() {
- if (fTextViewer == null)
- return;
-
- StyledText textWidget= fTextViewer.getTextWidget();
- if (textWidget != null && !textWidget.isDisposed()) {
- Display display= textWidget.getDisplay();
- if (display == null)
- return;
-
- display.asyncExec(new Runnable() {
- public void run() {
- doPresentInformation();
- }
- });
- }
- }
-
- /*
- * @see AbstractInformationControlManager#presentInformation()
- */
- protected void doPresentInformation() {
- super.presentInformation();
- }
-
- /**
- * Computes the document offset underlying the given text widget coordinates.
- * This method uses a linear search as it cannot make any assumption about
- * how the document is actually presented in the widget. (Covers cases such
- * as bidi text.)
- *
- * @param x the x coordinate inside the text widget
- * @param y the y coordinate inside the text widget
- * @return the document offset corresponding to the given point
- */
- private int computeOffsetAtLocation(int x, int y) {
-
- try {
-
- StyledText styledText= fTextViewer.getTextWidget();
- int widgetOffset= styledText.getOffsetAtLocation(new Point(x, y));
-
- if (fTextViewer instanceof ITextViewerExtension3) {
- ITextViewerExtension3 extension= (ITextViewerExtension3) fTextViewer;
- return extension.widgetOffset2ModelOffset(widgetOffset);
- }
-
- return widgetOffset + fTextViewer._getVisibleRegionOffset();
-
- } catch (IllegalArgumentException e) {
- return -1;
- }
- }
-
- /**
- * Determines graphical area covered by the given text region.
- *
- * @param region the region whose graphical extend must be computed
- * @return the graphical extend of the given region
- */
- private Rectangle computeArea(IRegion region) {
-
- IRegion widgetRegion= modelRange2WidgetRange(region);
- int start= widgetRegion.getOffset();
- int end= widgetRegion.getOffset() + widgetRegion.getLength();
-
- StyledText styledText= fTextViewer.getTextWidget();
- Point upperLeft= styledText.getLocationAtOffset(start);
- Point lowerRight= new Point(upperLeft.x, upperLeft.y);
-
- for (int i= start +1; i < end; i++) {
-
- Point p= styledText.getLocationAtOffset(i);
-
- if (upperLeft.x > p.x)
- upperLeft.x= p.x;
-
- if (upperLeft.y > p.y)
- upperLeft.y= p.y;
-
- if (lowerRight.x < p.x)
- lowerRight.x= p.x;
-
- if (lowerRight.y < p.y)
- lowerRight.y= p.y;
- }
-
- lowerRight.x += fTextViewer.getAverageCharWidth();
- lowerRight.y += styledText.getLineHeight();
-
- int width= lowerRight.x - upperLeft.x;
- int height= lowerRight.y - upperLeft.y;
- return new Rectangle(upperLeft.x, upperLeft.y, width, height);
- }
-
- /**
- * Translates a given region of the text viewer's document into
- * the corresponding region of the viewer's widget.
- *
- * @param region the document region
- * @return the corresponding widget region
- * @since 2.1
- */
- private IRegion modelRange2WidgetRange(IRegion region) {
- if (fTextViewer instanceof ITextViewerExtension3) {
- ITextViewerExtension3 extension= (ITextViewerExtension3) fTextViewer;
- return extension.modelRange2WidgetRange(region);
- }
-
- IRegion visibleRegion= fTextViewer.getVisibleRegion();
- int start= region.getOffset() - visibleRegion.getOffset();
- int end= start + region.getLength();
- if (end > visibleRegion.getLength())
- end= visibleRegion.getLength();
-
- return new Region(start, end - start);
- }
-
- /*
- * @see AbstractInformationControlManager#showInformationControl(Rectangle)
- */
- protected void showInformationControl(Rectangle subjectArea) {
- if (fTextViewer != null && fTextViewer.requestWidgetToken(this, WIDGET_PRIORITY))
- super.showInformationControl(subjectArea);
- }
-
- /*
- * @see AbstractInformationControlManager#hideInformationControl()
- */
- protected void hideInformationControl() {
- try {
- fTextHover= null;
- super.hideInformationControl();
- } finally {
- if (fTextViewer != null)
- fTextViewer.releaseWidgetToken(this);
- }
- }
-
- /*
- * @see AbstractInformationControlManager#handleInformationControlDisposed()
- */
- protected void handleInformationControlDisposed() {
- try {
- super.handleInformationControlDisposed();
- } finally {
- if (fTextViewer != null)
- fTextViewer.releaseWidgetToken(this);
- }
- }
-
- /*
- * @see IWidgetTokenKeeper#requestWidgetToken(IWidgetTokenOwner)
- */
- public boolean requestWidgetToken(IWidgetTokenOwner owner) {
- fTextHover= null;
- super.hideInformationControl();
- return true;
- }
-
- /*
- * @see org.eclipse.jface.text.IWidgetTokenKeeperExtension#requestWidgetToken(org.eclipse.jface.text.IWidgetTokenOwner, int)
- * @since 3.0
- */
- public boolean requestWidgetToken(IWidgetTokenOwner owner, int priority) {
- if (priority > WIDGET_PRIORITY) {
- fTextHover= null;
- super.hideInformationControl();
- return true;
- }
- return false;
- }
-
- /*
- * @see org.eclipse.jface.text.IWidgetTokenKeeperExtension#setFocus(org.eclipse.jface.text.IWidgetTokenOwner)
- * @since 3.0
- */
- public boolean setFocus(IWidgetTokenOwner owner) {
- return false;
- }
-
- /**
- * Returns the currently shown text hover or <code>null</code> if no text
- * hover is shown.
- *
- * @return the currently shown text hover or <code>null</code>
- */
- protected ITextHover getCurrentTextHover() {
- return fTextHover;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AdditionalInfoController.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AdditionalInfoController.java
deleted file mode 100644
index 30d1ae18795..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AdditionalInfoController.java
+++ /dev/null
@@ -1,241 +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.contentassist;
-
-
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-
-import org.eclipse.jface.text.AbstractInformationControlManager;
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.IInformationControl;
-import org.eclipse.jface.text.IInformationControlCreator;
-
-
-
-/**
- * Displays the additional information available for a completion proposal.
- *
- * @since 2.0
- */
-class AdditionalInfoController extends AbstractInformationControlManager implements Runnable {
-
- /**
- * Internal table selection listener.
- */
- private class TableSelectionListener implements SelectionListener {
-
- /*
- * @see SelectionListener#widgetSelected(SelectionEvent)
- */
- public void widgetSelected(SelectionEvent e) {
- handleTableSelectionChanged();
- }
-
- /*
- * @see SelectionListener#widgetDefaultSelected(SelectionEvent)
- */
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- }
-
-
- /** The proposal table */
- private Table fProposalTable;
- /** The thread controlling the delayed display of the additional info */
- private Thread fThread;
- /** Indicates whether the display delay has been reset */
- private boolean fIsReset= false;
- /** Object to synchronize display thread and table selection changes */
- private Object fMutex= new Object();
- /** Object to synchronize initial display of additonal info */
- private Object fStartSignal;
- /** The table selection listener */
- private SelectionListener fSelectionListener= new TableSelectionListener();
- /** The delay after which additional information is displayed */
- private int fDelay;
-
-
- /**
- * Creates a new additional information controller.
- *
- * @param creator the information control creator to be used by this controller
- * @param delay time in milliseconds after which additional info should be displayed
- */
- AdditionalInfoController(IInformationControlCreator creator, int delay) {
- super(creator);
- fDelay= delay;
- setAnchor(ANCHOR_RIGHT);
- setFallbackAnchors(new Anchor[] { ANCHOR_LEFT, ANCHOR_BOTTOM, ANCHOR_RIGHT });
- }
-
- /*
- * @see AbstractInformationControlManager#install(Control)
- */
- public void install(Control control) {
-
- if (fProposalTable == control) {
- // already installed
- return;
- }
-
- super.install(control);
-
- Assert.isTrue(control instanceof Table);
- fProposalTable= (Table) control;
- fProposalTable.addSelectionListener(fSelectionListener);
- fThread= new Thread(this, JFaceTextMessages.getString("InfoPopup.info_delay_timer_name")); //$NON-NLS-1$
-
- fStartSignal= new Object();
- synchronized (fStartSignal) {
- fThread.start();
- try {
- // wait until thread is ready
- fStartSignal.wait();
- } catch (InterruptedException x) {
- }
- }
- }
-
- /*
- * @see AbstractInformationControlManager#disposeInformationControl()
- */
- public void disposeInformationControl() {
-
- if (fThread != null) {
- fThread.interrupt();
- fThread= null;
- }
-
- if (fProposalTable != null && !fProposalTable.isDisposed()) {
- fProposalTable.removeSelectionListener(fSelectionListener);
- fProposalTable= null;
- }
-
- super.disposeInformationControl();
- }
-
- /*
- * @see java.lang.Runnable#run()
- */
- public void run() {
- try {
- while (true) {
-
- synchronized (fMutex) {
-
- if (fStartSignal != null) {
- synchronized (fStartSignal) {
- fStartSignal.notifyAll();
- fStartSignal= null;
- }
- }
-
- // Wait for a selection event to occur.
- fMutex.wait();
-
- while (true) {
- fIsReset= false;
- // Delay before showing the popup.
- fMutex.wait(fDelay);
- if (!fIsReset)
- break;
- }
- }
-
- if (fProposalTable != null && !fProposalTable.isDisposed()) {
- fProposalTable.getDisplay().asyncExec(new Runnable() {
- public void run() {
- if (!fIsReset)
- showInformation();
- }
- });
- }
-
- }
- } catch (InterruptedException e) {
- }
-
- fThread= null;
- }
-
- /**
- *Handles a change of the line selected in the associated selector.
- */
- public void handleTableSelectionChanged() {
-
- if (fProposalTable != null && !fProposalTable.isDisposed() && fProposalTable.isVisible()) {
- synchronized (fMutex) {
- fIsReset= true;
- fMutex.notifyAll();
- }
- }
- }
-
- /*
- * @see AbstractInformationControlManager#computeInformation()
- */
- protected void computeInformation() {
-
- if (fProposalTable == null || fProposalTable.isDisposed())
- return;
-
- TableItem[] selection= fProposalTable.getSelection();
- if (selection != null && selection.length > 0) {
-
- TableItem item= selection[0];
-
- // compute information
- String information= null;
- Object d= item.getData();
-
- if (d instanceof ICompletionProposal) {
- ICompletionProposal p= (ICompletionProposal) d;
- information= p.getAdditionalProposalInfo();
- }
-
- if (d instanceof ICompletionProposalExtension3)
- setCustomInformationControlCreator(((ICompletionProposalExtension3) d).getInformationControlCreator());
- else
- setCustomInformationControlCreator(null);
-
- // compute subject area
- setMargins(4, -1);
- Rectangle area= fProposalTable.getBounds();
- area.x= 0; // subject area is the whole subject control
- area.y= 0;
-
- // set information & subject area
- setInformation(information, area);
- }
- }
-
- /*
- * @see org.eclipse.jface.text.AbstractInformationControlManager#computeSizeConstraints(Control, IInformationControl)
- */
- protected Point computeSizeConstraints(Control subjectControl, IInformationControl informationControl) {
- Point sizeConstraint= super.computeSizeConstraints(subjectControl, informationControl);
- Point size= subjectControl.getSize();
- if (sizeConstraint.x < size.x)
- sizeConstraint.x= size.x;
- if (sizeConstraint.y < size.y)
- sizeConstraint.y= size.y;
- return sizeConstraint;
- }
-}
-
-
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposal.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposal.java
deleted file mode 100644
index 21f1f69e6a9..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposal.java
+++ /dev/null
@@ -1,135 +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.contentassist;
-
-
-
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-
-
-
-/**
- * The standard implementation of the <code>ICompletionProposal</code> interface.
- */
-public final class CompletionProposal implements ICompletionProposal {
-
- /** The string to be displayed in the completion proposal popup */
- private String fDisplayString;
- /** The replacement string */
- private String fReplacementString;
- /** The replacement offset */
- private int fReplacementOffset;
- /** The replacement length */
- private int fReplacementLength;
- /** The cursor position after this proposal has been applied */
- private int fCursorPosition;
- /** The image to be displayed in the completion proposal popup */
- private Image fImage;
- /** The context information of this proposal */
- private IContextInformation fContextInformation;
- /** The additional info of this proposal */
- private String fAdditionalProposalInfo;
-
- /**
- * Creates a new completion proposal based on the provided information. The replacement string is
- * considered being the display string too. All remaining fields are set to <code>null</code>.
- *
- * @param replacementString the actual string to be inserted into the document
- * @param replacementOffset the offset of the text to be replaced
- * @param replacementLength the length of the text to be replaced
- * @param cursorPosition the position of the cursor following the insert relative to replacementOffset
- */
- public CompletionProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition) {
- this(replacementString, replacementOffset, replacementLength, cursorPosition, null, null, null, null);
- }
-
- /**
- * Creates a new completion proposal. All fields are initialized based on the provided information.
- *
- * @param replacementString the actual string to be inserted into the document
- * @param replacementOffset the offset of the text to be replaced
- * @param replacementLength the length of the text to be replaced
- * @param cursorPosition the position of the cursor following the insert relative to replacementOffset
- * @param image the image to display for this proposal
- * @param displayString the string to be displayed for the proposal
- * @param contentInformation the context information associated with this proposal
- * @param additionalProposalInfo the additional information associated with this proposal
- */
- public CompletionProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition, Image image, String displayString, IContextInformation contextInformation, String additionalProposalInfo) {
- Assert.isNotNull(replacementString);
- Assert.isTrue(replacementOffset >= 0);
- Assert.isTrue(replacementLength >= 0);
- Assert.isTrue(cursorPosition >= 0);
-
- fReplacementString= replacementString;
- fReplacementOffset= replacementOffset;
- fReplacementLength= replacementLength;
- fCursorPosition= cursorPosition;
- fImage= image;
- fDisplayString= displayString;
- fContextInformation= contextInformation;
- fAdditionalProposalInfo= additionalProposalInfo;
- }
-
- /*
- * @see ICompletionProposal#apply(IDocument)
- */
- public void apply(IDocument document) {
- try {
- document.replace(fReplacementOffset, fReplacementLength, fReplacementString);
- } catch (BadLocationException x) {
- // ignore
- }
- }
-
- /*
- * @see ICompletionProposal#getSelection(IDocument)
- */
- public Point getSelection(IDocument document) {
- return new Point(fReplacementOffset + fCursorPosition, 0);
- }
-
- /*
- * @see ICompletionProposal#getContextInformation()
- */
- public IContextInformation getContextInformation() {
- return fContextInformation;
- }
-
- /*
- * @see ICompletionProposal#getImage()
- */
- public Image getImage() {
- return fImage;
- }
-
- /*
- * @see ICompletionProposal#getDisplayString()
- */
- public String getDisplayString() {
- if (fDisplayString != null)
- return fDisplayString;
- return fReplacementString;
- }
-
- /*
- * @see ICompletionProposal#getAdditionalProposalInfo()
- */
- public String getAdditionalProposalInfo() {
- return fAdditionalProposalInfo;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java
deleted file mode 100644
index c878bd78d77..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java
+++ /dev/null
@@ -1,815 +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.contentassist;
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.ControlListener;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.events.VerifyEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentListener;
-import org.eclipse.jface.text.IRewriteTarget;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.ITextViewerExtension;
-import org.eclipse.jface.text.TextUtilities;
-
-
-
-/**
- * This class is used to present proposals to the user. If additional
- * information exists for a proposal, then selecting that proposal
- * will result in the information being displayed in a secondary
- * window.
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal
- * @see org.eclipse.jface.text.contentassist.AdditionalInfoController
- */
-class CompletionProposalPopup implements IContentAssistListener {
-
- /** The associated text viewer */
- private ITextViewer fViewer;
- /** The associated content assistant */
- private ContentAssistant fContentAssistant;
- /** The used additional info controller */
- private AdditionalInfoController fAdditionalInfoController;
- /** The closing strategy for this completion proposal popup */
- private PopupCloser fPopupCloser= new PopupCloser();
- /** The popup shell */
- private Shell fProposalShell;
- /** The proposal table */
- private Table fProposalTable;
- /** Indicates whether a completion proposal is being inserted */
- private boolean fInserting= false;
- /** The key listener to control navigation */
- private KeyListener fKeyListener;
- /** List of document events used for filtering proposals */
- private List fDocumentEvents= new ArrayList();
- /** Listener filling the document event queue */
- private IDocumentListener fDocumentListener;
- /** Reentrance count for <code>filterProposals</code> */
- private long fInvocationCounter= 0;
- /** The filter list of proposals */
- private ICompletionProposal[] fFilteredProposals;
- /** The computed list of proposals */
- private ICompletionProposal[] fComputedProposals;
- /** The offset for which the proposals have been computed */
- private int fInvocationOffset;
- /** The offset for which the computed proposaks have been filtered */
- private int fFilterOffset;
- /** The default line delimiter of the viewer's widget */
- private String fLineDelimiter;
- /** The most recently selected proposal. */
- private ICompletionProposal fLastProposal;
- /**
- * The content assist subject.
- * This replaces <code>fViewer</code>
- *
- * @since 3.0
- */
- private IContentAssistSubject fContentAssistSubject;
- /**
- * The content assist subject adapter.
- * This replaces <code>fViewer</code>
- *
- * @since 3.0
- */
- private ContentAssistSubjectAdapter fContentAssistSubjectAdapter;
-
-
- /**
- * Creates a new completion proposal popup for the given elements.
- *
- * @param contentAssistant the content assistant feeding this popup
- * @param viewer the viewer on top of which this popup appears
- * @param infoController the info control collaborating with this popup
- * @since 2.0
- */
- public CompletionProposalPopup(ContentAssistant contentAssistant, ITextViewer viewer, AdditionalInfoController infoController) {
- fContentAssistant= contentAssistant;
- fViewer= viewer;
- fAdditionalInfoController= infoController;
- fContentAssistSubjectAdapter= new ContentAssistSubjectAdapter(fViewer);
- }
-
- /**
- * Creates a new completion proposal popup for the given elements.
- * <p>
- * XXX: This is work in progress and can change anytime until API for 3.0 is frozen.
- * </p>
- * @param contentAssistant the content assistant feeding this popup
- * @param contentAssistSubject the content assist subject on top of which this popup appears
- * @param infoController the info control collaborating with this popup
- * @since 3.0
- */
- public CompletionProposalPopup(ContentAssistant contentAssistant, IContentAssistSubject contentAssistSubject, AdditionalInfoController infoController) {
- fContentAssistant= contentAssistant;
- fContentAssistSubject= contentAssistSubject;
- fAdditionalInfoController= infoController;
- fContentAssistSubjectAdapter= new ContentAssistSubjectAdapter(fContentAssistSubject);
- }
-
- /**
- * Computes and presents completion proposals. The flag indicates whether this call has
- * be made out of an auto activation context.
- *
- * @param autoActivated <code>true</code> if auto activation context
- * @return an error message or <code>null</code> in case of no error
- */
- public String showProposals(final boolean autoActivated) {
-
- if (fKeyListener == null) {
- fKeyListener= new KeyListener() {
- public void keyPressed(KeyEvent e) {
- if (!Helper.okToUse(fProposalShell))
- return;
-
- if (e.character == 0 && e.keyCode == SWT.MOD1) {
- // http://dev.eclipse.org/bugs/show_bug.cgi?id=34754
- int index= fProposalTable.getSelectionIndex();
- if (index >= 0)
- selectProposal(index, true);
- }
- }
-
- public void keyReleased(KeyEvent e) {
- if (!Helper.okToUse(fProposalShell))
- return;
-
- if (e.character == 0 && e.keyCode == SWT.MOD1) {
- // http://dev.eclipse.org/bugs/show_bug.cgi?id=34754
- int index= fProposalTable.getSelectionIndex();
- if (index >= 0)
- selectProposal(index, false);
- }
- }
- };
- }
-
- final Control control= fContentAssistSubjectAdapter.getControl();
- if (control != null && !control.isDisposed())
- fContentAssistSubjectAdapter.addKeyListener(fKeyListener);
-
- BusyIndicator.showWhile(control.getDisplay(), new Runnable() {
- public void run() {
-
- fInvocationOffset= fContentAssistSubjectAdapter.getSelectedRange().x;
- fComputedProposals= computeProposals(fInvocationOffset);
-
- int count= (fComputedProposals == null ? 0 : fComputedProposals.length);
- if (count == 0) {
-
- if (!autoActivated)
- control.getDisplay().beep();
-
- } else {
-
- if (count == 1 && !autoActivated && fContentAssistant.isAutoInserting())
-
- insertProposal(fComputedProposals[0], (char) 0, 0, fInvocationOffset);
-
- else {
-
- if (fLineDelimiter == null)
- fLineDelimiter= fContentAssistSubjectAdapter.getLineDelimiter();
-
- createProposalSelector();
- setProposals(fComputedProposals);
- displayProposals();
- }
- }
- }
- });
-
- return getErrorMessage();
- }
-
- /**
- * Returns the completion proposal available at the given offset of the
- * viewer's document. Delegates the work to the content assistant.
- *
- * @param offset the offset
- * @return the completion proposals available at this offset
- */
- private ICompletionProposal[] computeProposals(int offset) {
- if (fContentAssistSubject != null)
- return fContentAssistant.computeCompletionProposals(fContentAssistSubject, offset);
- else
- return fContentAssistant.computeCompletionProposals(fViewer, offset);
- }
-
- /**
- * Returns the error message.
- *
- * @return the error message
- */
- private String getErrorMessage() {
- return fContentAssistant.getErrorMessage();
- }
-
- /**
- * Creates the proposal selector.
- */
- private void createProposalSelector() {
- if (Helper.okToUse(fProposalShell))
- return;
-
- Control control= fContentAssistSubjectAdapter.getControl();
- fProposalShell= new Shell(control.getShell(), SWT.ON_TOP | SWT.RESIZE );
- fProposalTable= new Table(fProposalShell, SWT.H_SCROLL | SWT.V_SCROLL);
-
- fProposalTable.setLocation(0, 0);
- if (fAdditionalInfoController != null)
- fAdditionalInfoController.setSizeConstraints(50, 10, true, false);
-
- GridLayout layout= new GridLayout();
- layout.marginWidth= 0;
- layout.marginHeight= 0;
- fProposalShell.setLayout(layout);
-
- GridData data= new GridData(GridData.FILL_BOTH);
- data.heightHint= fProposalTable.getItemHeight() * 10;
- data.widthHint= 300;
- fProposalTable.setLayoutData(data);
-
- fProposalShell.pack();
-
- if (fAdditionalInfoController != null) {
- fProposalShell.addControlListener(new ControlListener() {
-
- public void controlMoved(ControlEvent e) {}
-
- public void controlResized(ControlEvent e) {
- // resets the cached resize constraints
- fAdditionalInfoController.setSizeConstraints(50, 10, true, false);
- }
- });
- }
-
- if (!"carbon".equals(SWT.getPlatform())) //$NON-NLS-1$
- fProposalShell.setBackground(control.getDisplay().getSystemColor(SWT.COLOR_BLACK));
-
- Color c= fContentAssistant.getProposalSelectorBackground();
- if (c == null)
- c= control.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND);
- fProposalTable.setBackground(c);
-
- c= fContentAssistant.getProposalSelectorForeground();
- if (c == null)
- c= control.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND);
- fProposalTable.setForeground(c);
-
- fProposalTable.addSelectionListener(new SelectionListener() {
-
- public void widgetSelected(SelectionEvent e) {}
-
- public void widgetDefaultSelected(SelectionEvent e) {
- selectProposalWithMask(e.stateMask);
- }
- });
-
- fPopupCloser.install(fContentAssistant, fProposalTable);
-
- fProposalShell.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- unregister(); // but don't dispose the shell, since we're being called from its disposal event!
- }
- });
-
- fProposalTable.setHeaderVisible(false);
- fContentAssistant.addToLayout(this, fProposalShell, ContentAssistant.LayoutManager.LAYOUT_PROPOSAL_SELECTOR, fContentAssistant.getSelectionOffset());
- }
-
- /**
- * Returns the proposal selected in the proposal selector.
- *
- * @return the selected proposal
- * @since 2.0
- */
- private ICompletionProposal getSelectedProposal() {
- int i= fProposalTable.getSelectionIndex();
- if (i < 0 || i >= fFilteredProposals.length)
- return null;
- return fFilteredProposals[i];
- }
-
- /**
- * Takes the selected proposal and applies it.
- *
- * @param stateMask the state mask
- * @since 2.1
- */
- private void selectProposalWithMask(int stateMask) {
- ICompletionProposal p= getSelectedProposal();
- hide();
- if (p != null)
- insertProposal(p, (char) 0, stateMask, fContentAssistSubjectAdapter.getSelectedRange().x);
- }
-
- /**
- * Applies the given proposal at the given offset. The given character is the
- * one that triggered the insertion of this proposal.
- *
- * @param p the completion proposal
- * @param trigger the trigger character
- * @param offset the offset
- * @since 2.1
- */
- private void insertProposal(ICompletionProposal p, char trigger, int stateMask, int offset) {
-
- fInserting= true;
- IRewriteTarget target= null;
-
- try {
-
- IDocument document= fContentAssistSubjectAdapter.getDocument();
-
- if (fViewer instanceof ITextViewerExtension) {
- ITextViewerExtension extension= (ITextViewerExtension) fViewer;
- target= extension.getRewriteTarget();
- }
-
- if (target != null)
- target.beginCompoundChange();
-
- if (p instanceof ICompletionProposalExtension2 && fViewer != null) {
- ICompletionProposalExtension2 e= (ICompletionProposalExtension2) p;
- e.apply(fViewer, trigger, stateMask, offset);
- } else if (p instanceof ICompletionProposalExtension) {
- ICompletionProposalExtension e= (ICompletionProposalExtension) p;
- e.apply(document, trigger, offset);
- } else {
- p.apply(document);
- }
-
- Point selection= p.getSelection(document);
- if (selection != null) {
- fContentAssistSubjectAdapter.setSelectedRange(selection.x, selection.y);
- fContentAssistSubjectAdapter.revealRange(selection.x, selection.y);
- }
-
- IContextInformation info= p.getContextInformation();
- if (info != null) {
-
- int position;
- if (p instanceof ICompletionProposalExtension) {
- ICompletionProposalExtension e= (ICompletionProposalExtension) p;
- position= e.getContextInformationPosition();
- } else {
- if (selection == null)
- selection= fContentAssistSubjectAdapter.getSelectedRange();
- position= selection.x + selection.y;
- }
-
- fContentAssistant.showContextInformation(info, position);
- }
-
- } finally {
- if (target != null)
- target.endCompoundChange();
- fInserting= false;
- }
- }
-
- /**
- * Returns whether this popup has the focus.
- *
- * @return <code>true</code> if the popup has the focus
- */
- public boolean hasFocus() {
- if (Helper.okToUse(fProposalShell))
- return (fProposalShell.isFocusControl() || fProposalTable.isFocusControl());
-
- return false;
- }
-
- /**
- * Hides this popup.
- */
- public void hide() {
-
- unregister();
-
- if (Helper.okToUse(fProposalShell)) {
-
- fContentAssistant.removeContentAssistListener(this, ContentAssistant.PROPOSAL_SELECTOR);
-
- fPopupCloser.uninstall();
- fProposalShell.setVisible(false);
- fProposalShell.dispose();
- fProposalShell= null;
- }
- }
-
- private void unregister() {
- if (fDocumentListener != null) {
- IDocument document= fContentAssistSubjectAdapter.getDocument();
- if (document != null)
- document.removeDocumentListener(fDocumentListener);
- fDocumentListener= null;
- }
- fDocumentEvents.clear();
-
- if (fKeyListener != null && fContentAssistSubjectAdapter.getControl() != null && !fContentAssistSubjectAdapter.getControl().isDisposed())
- fContentAssistSubjectAdapter.removeKeyListener(fKeyListener);
-
- if (fLastProposal != null) {
- if (fLastProposal instanceof ICompletionProposalExtension2 && fViewer != null) {
- ICompletionProposalExtension2 extension= (ICompletionProposalExtension2) fLastProposal;
- extension.unselected(fViewer);
- }
- fLastProposal= null;
- }
-
- fFilteredProposals= null;
-
- fContentAssistant.possibleCompletionsClosed();
- }
-
- /**
- *Returns whether this popup is active. It is active if the propsal selector is visible.
- *
- * @return <code>true</code> if this popup is active
- */
- public boolean isActive() {
- return fProposalShell != null && !fProposalShell.isDisposed();
- }
-
- /**
- * Initializes the proposal selector with these given proposals.
- *
- * @param proposals the proposals
- */
- private void setProposals(ICompletionProposal[] proposals) {
- if (Helper.okToUse(fProposalTable)) {
-
- ICompletionProposal oldProposal= getSelectedProposal();
- if (oldProposal instanceof ICompletionProposalExtension2 && fViewer != null)
- ((ICompletionProposalExtension2) oldProposal).unselected(fViewer);
-
- fFilteredProposals= proposals;
-
- fProposalTable.setRedraw(false);
- fProposalTable.removeAll();
-
- TableItem item;
- ICompletionProposal p;
- for (int i= 0; i < proposals.length; i++) {
- p= proposals[i];
- item= new TableItem(fProposalTable, SWT.NULL);
- if (p.getImage() != null)
- item.setImage(p.getImage());
- item.setText(p.getDisplayString());
- item.setData(p);
- }
-
- Point currentLocation= fProposalShell.getLocation();
- Point newLocation= getLocation();
- if ((newLocation.x < currentLocation.x && newLocation.y == currentLocation.y) || newLocation.y < currentLocation.y)
- fProposalShell.setLocation(newLocation);
-
- selectProposal(0, false);
- fProposalTable.setRedraw(true);
- }
- }
-
- /**
- * Returns the graphical location at which this popup should be made visible.
- *
- * @return the location of this popup
- */
- private Point getLocation() {
- int caret= fContentAssistSubjectAdapter.getCaretOffset();
- Point p= fContentAssistSubjectAdapter.getLocationAtOffset(caret);
- if (p.x < 0) p.x= 0;
- if (p.y < 0) p.y= 0;
- p= new Point(p.x, p.y + fContentAssistSubjectAdapter.getLineHeight());
- p= fContentAssistSubjectAdapter.getControl().toDisplay(p);
- if (p.x < 0) p.x= 0;
- if (p.y < 0) p.y= 0;
- return p;
- }
-
- /**
- *Displays this popup and install the additional info controller, so that additional info
- * is displayed when a proposal is selected and additional info is available.
- */
- private void displayProposals() {
-
- if (!Helper.okToUse(fProposalShell) || !Helper.okToUse(fProposalTable))
- return;
-
- if (fContentAssistant.addContentAssistListener(this, ContentAssistant.PROPOSAL_SELECTOR)) {
-
- if (fDocumentListener == null)
- fDocumentListener= new IDocumentListener() {
- public void documentAboutToBeChanged(DocumentEvent event) {
- if (!fInserting)
- fDocumentEvents.add(event);
- }
-
- public void documentChanged(DocumentEvent event) {
- if (!fInserting)
- filterProposals();
- }
- };
- IDocument document= fContentAssistSubjectAdapter.getDocument();
- if (document != null)
- document.addDocumentListener(fDocumentListener);
-
- fProposalShell.setVisible(true);
- // XXX: transfer focus since no verify key listern can be attached
- if (!fContentAssistSubjectAdapter.supportsVerifyKeyListener())
- fProposalShell.setFocus();
-
- if (fAdditionalInfoController != null) {
- fAdditionalInfoController.install(fProposalTable);
- fAdditionalInfoController.handleTableSelectionChanged();
- }
- }
- }
-
- /*
- * @see IContentAssistListener#verifyKey(VerifyEvent)
- */
- public boolean verifyKey(VerifyEvent e) {
- if (!Helper.okToUse(fProposalShell))
- return true;
-
- char key= e.character;
- if (key == 0) {
- int newSelection= fProposalTable.getSelectionIndex();
- int visibleRows= (fProposalTable.getSize().y / fProposalTable.getItemHeight()) - 1;
- boolean smartToggle= false;
- switch (e.keyCode) {
-
- case SWT.ARROW_LEFT :
- case SWT.ARROW_RIGHT :
- filterProposals();
- return true;
-
- case SWT.ARROW_UP :
- newSelection -= 1;
- if (newSelection < 0)
- newSelection= fProposalTable.getItemCount() - 1;
- break;
-
- case SWT.ARROW_DOWN :
- newSelection += 1;
- if (newSelection > fProposalTable.getItemCount() - 1)
- newSelection= 0;
- break;
-
- case SWT.PAGE_DOWN :
- newSelection += visibleRows;
- if (newSelection >= fProposalTable.getItemCount())
- newSelection= fProposalTable.getItemCount() - 1;
- break;
-
- case SWT.PAGE_UP :
- newSelection -= visibleRows;
- if (newSelection < 0)
- newSelection= 0;
- break;
-
- case SWT.HOME :
- newSelection= 0;
- break;
-
- case SWT.END :
- newSelection= fProposalTable.getItemCount() - 1;
- break;
-
- default :
- if (e.keyCode != SWT.MOD1 && e.keyCode != SWT.MOD2 && e.keyCode != SWT.MOD3 && e.keyCode != SWT.MOD4)
- hide();
- return true;
- }
-
- selectProposal(newSelection, smartToggle);
-
- e.doit= false;
- return false;
-
- } else {
-
- switch (key) {
- case 0x1B: // Esc
- e.doit= false;
- hide();
- break;
-
- case '\n': // Ctrl-Enter on w2k
- case '\r': // Enter
- e.doit= false;
- selectProposalWithMask(e.stateMask);
- break;
-
- case '\t':
- e.doit= false;
- fProposalShell.setFocus();
- return false;
-
- default:
- ICompletionProposal p= getSelectedProposal();
- if (p instanceof ICompletionProposalExtension) {
- ICompletionProposalExtension t= (ICompletionProposalExtension) p;
- char[] triggers= t.getTriggerCharacters();
- if (contains(triggers, key)) {
- e.doit= false;
- hide();
- insertProposal(p, key, e.stateMask, fContentAssistSubjectAdapter.getSelectedRange().x);
- }
- }
- }
- }
-
- return true;
- }
-
- /**
- * Selects the entry with the given index in the proposal selector and feeds
- * the selection to the additional info controller.
- *
- * @param index the index in the list
- * @param smartToggle <code>true</code> if the smart toogle key has been pressed
- * @since 2.1
- */
- private void selectProposal(int index, boolean smartToggle) {
-
- ICompletionProposal oldProposal= getSelectedProposal();
- if (oldProposal instanceof ICompletionProposalExtension2 && fViewer != null)
- ((ICompletionProposalExtension2) oldProposal).unselected(fViewer);
-
- ICompletionProposal proposal= fFilteredProposals[index];
- if (proposal instanceof ICompletionProposalExtension2 && fViewer != null)
- ((ICompletionProposalExtension2) proposal).selected(fViewer, smartToggle);
-
- fLastProposal= proposal;
-
- fProposalTable.setSelection(index);
- fProposalTable.showSelection();
- if (fAdditionalInfoController != null)
- fAdditionalInfoController.handleTableSelectionChanged();
- }
-
- /**
- * Returns whether the given character is contained in the given array of
- * characters.
- *
- * @param characters the list of characters
- * @param c the character to look for in the list
- * @return <code>true</code> if character belongs to the list
- * @since 2.0
- */
- private boolean contains(char[] characters, char c) {
-
- if (characters == null)
- return false;
-
- for (int i= 0; i < characters.length; i++) {
- if (c == characters[i])
- return true;
- }
-
- return false;
- }
-
- /*
- * @see IEventConsumer#processEvent(VerifyEvent)
- */
- public void processEvent(VerifyEvent e) {
- }
-
- /**
- * Filters the displayed proposal based on the given cursor position and the
- * offset of the original invocation of the content assistant.
- */
- private void filterProposals() {
- ++ fInvocationCounter;
- Control control= fContentAssistSubjectAdapter.getControl();
- control.getDisplay().asyncExec(new Runnable() {
- long fCounter= fInvocationCounter;
- public void run() {
-
- if (fCounter != fInvocationCounter) return;
-
- int offset= fContentAssistSubjectAdapter.getSelectedRange().x;
- ICompletionProposal[] proposals= null;
- try {
- if (offset > -1) {
- DocumentEvent event= TextUtilities.mergeProcessedDocumentEvents(fDocumentEvents);
- proposals= computeFilteredProposals(offset, event);
- }
- } catch (BadLocationException x) {
- } finally {
- fDocumentEvents.clear();
- }
- fFilterOffset= offset;
-
- if (proposals != null && proposals.length > 0)
- setProposals(proposals);
- else
- hide();
- }
- });
- }
-
- /**
- * Computes the subset of already computed propsals that are still valid for
- * the given offset.
- *
- * @param offset the offset
- * @param event the merged document event
- * @return the set of filtered proposals
- * @since 2.0
- */
- private ICompletionProposal[] computeFilteredProposals(int offset, DocumentEvent event) {
-
- if (offset == fInvocationOffset && event == null)
- return fComputedProposals;
-
- if (offset < fInvocationOffset) {
- fInvocationOffset= offset;
- fComputedProposals= computeProposals(fInvocationOffset);
- return fComputedProposals;
- }
-
- ICompletionProposal[] proposals= fComputedProposals;
- if (offset > fFilterOffset)
- proposals= fFilteredProposals;
-
- if (proposals == null)
- return null;
-
- IDocument document= fContentAssistSubjectAdapter.getDocument();
- int length= proposals.length;
- List filtered= new ArrayList(length);
- for (int i= 0; i < length; i++) {
-
- if (proposals[i] instanceof ICompletionProposalExtension2) {
-
- ICompletionProposalExtension2 p= (ICompletionProposalExtension2) proposals[i];
- if (p.validate(document, offset, event))
- filtered.add(p);
-
- } else if (proposals[i] instanceof ICompletionProposalExtension) {
-
- ICompletionProposalExtension p= (ICompletionProposalExtension) proposals[i];
- if (p.isValidFor(document, offset))
- filtered.add(p);
-
- } else {
- // restore original behavior
- fInvocationOffset= offset;
- fComputedProposals= computeProposals(fInvocationOffset);
- return fComputedProposals;
- }
- }
-
- ICompletionProposal[] p= new ICompletionProposal[filtered.size()];
- filtered.toArray(p);
- return p;
- }
-
- /**
- * Requests the proposal shell to take focus.
- *
- * @since 3.0
- */
- public void setFocus() {
- if (Helper.okToUse(fProposalShell)) {
- fProposalShell.setFocus();
- }
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistSubjectAdapter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistSubjectAdapter.java
deleted file mode 100644
index ae4c1820d1e..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistSubjectAdapter.java
+++ /dev/null
@@ -1,406 +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.contentassist;
-
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.custom.VerifyKeyListener;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Control;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IEventConsumer;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.ITextViewerExtension;
-import org.eclipse.jface.text.contentassist.ContextInformationPopup.ContextFrame;
-
-/**
- * This content assist adapter delegates the calles either to
- * a text viewer or to a content assist subject.
- *
- * @since 3.0
- */
-final class ContentAssistSubjectAdapter implements IContentAssistSubject {
-
- /**
- * The text viewer which is used as content assist subject.
- */
- private ITextViewer fViewer;
-
- /**
- * The content assist subject.
- */
- private IContentAssistSubject fContentAssistSubject;
-
-
- /**
- * Creates an adapter for the given content assist subject.
- *
- * @param contentAssistSubject the content assist subject
- */
- public ContentAssistSubjectAdapter(IContentAssistSubject contentAssistSubject) {
- Assert.isNotNull(contentAssistSubject);
- fContentAssistSubject= contentAssistSubject;
- }
-
- /**
- * Creates an adapter for the given text viewer.
- *
- * @param viewer the text viewer
- */
- public ContentAssistSubjectAdapter(ITextViewer viewer) {
- Assert.isNotNull(viewer);
- fViewer= viewer;
- }
-
- /*
- * @see IContentAssistSubject#getLineHeight()
- */
- public int getLineHeight() {
- if (fContentAssistSubject != null)
- return fContentAssistSubject.getLineHeight();
- else
- return fViewer.getTextWidget().getLineHeight();
- }
-
- /*
- * @see IContentAssistSubject#getControl()
- */
- public Control getControl() {
- if (fContentAssistSubject != null)
- return fContentAssistSubject.getControl();
- else
- return fViewer.getTextWidget();
- }
-
- /*
- * @see IContentAssistSubject#getLocationAtOffset(int)
- */
- public Point getLocationAtOffset(int offset) {
- if (fContentAssistSubject != null)
- return fContentAssistSubject.getLocationAtOffset(offset);
- else
- return fViewer.getTextWidget().getLocationAtOffset(offset);
- }
-
- /*
- * @see IContentAssistSubject#getWidgetSelectionRange()
- */
- public Point getWidgetSelectionRange() {
- if (fContentAssistSubject != null)
- return fContentAssistSubject.getWidgetSelectionRange();
- else
- return fViewer.getTextWidget().getSelectionRange();
- }
-
- /*
- * @see IContentAssistSubject#getSelectedRange()
- */
- public Point getSelectedRange() {
- if (fContentAssistSubject != null)
- return fContentAssistSubject.getSelectedRange();
- else
- return fViewer.getSelectedRange();
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubject#getCaretOffset()
- */
- public int getCaretOffset() {
- if (fContentAssistSubject != null)
- return fContentAssistSubject.getCaretOffset();
- else
- return fViewer.getTextWidget().getCaretOffset();
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubject#getLineDelimiter()
- */
- public String getLineDelimiter() {
- if (fContentAssistSubject != null)
- return fContentAssistSubject.getLineDelimiter();
- else
- return fViewer.getTextWidget().getLineDelimiter();
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubject#addKeyListener(org.eclipse.swt.events.KeyListener)
- */
- public void addKeyListener(KeyListener keyListener) {
- if (fContentAssistSubject != null)
- fContentAssistSubject.addKeyListener(keyListener);
- else
- fViewer.getTextWidget().addKeyListener(keyListener);
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubject#removeKeyListener(org.eclipse.swt.events.KeyListener)
- */
- public void removeKeyListener(KeyListener keyListener) {
- if (fContentAssistSubject != null)
- fContentAssistSubject.removeKeyListener(keyListener);
- else
- fViewer.getTextWidget().removeKeyListener(keyListener);
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubject#getDocument()
- */
- public IDocument getDocument() {
- if (fContentAssistSubject != null)
- return fContentAssistSubject.getDocument();
- else
- return fViewer.getDocument();
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubject#prependVerifyKeyListener(VerifyKeyListener)
- */
- public boolean prependVerifyKeyListener(VerifyKeyListener verifyKeyListener) {
- if (fContentAssistSubject != null) {
- return fContentAssistSubject.prependVerifyKeyListener(verifyKeyListener);
- } else if (fViewer instanceof ITextViewerExtension) {
- ITextViewerExtension e= (ITextViewerExtension) fViewer;
- e.prependVerifyKeyListener(verifyKeyListener);
- return true;
- } else {
-
- StyledText textWidget= fViewer.getTextWidget();
- if (Helper.okToUse(textWidget)) {
- textWidget.addVerifyKeyListener(verifyKeyListener);
- return true;
- }
- }
- return false;
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubject#appendVerifyKeyListener(org.eclipse.swt.custom.VerifyKeyListener)
- */
- public boolean appendVerifyKeyListener(VerifyKeyListener verifyKeyListener) {
- if (fContentAssistSubject != null)
- return fContentAssistSubject.appendVerifyKeyListener(verifyKeyListener);
- else if (fViewer instanceof ITextViewerExtension) {
- ITextViewerExtension extension= (ITextViewerExtension)fViewer;
- extension.appendVerifyKeyListener(verifyKeyListener);
- return true;
- } else {
- StyledText textWidget= fViewer.getTextWidget();
- if (Helper.okToUse(textWidget)) {
- textWidget.addVerifyKeyListener(verifyKeyListener);
- return true;
- }
- }
- return false;
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubject#removeVerifyKeyListener(org.eclipse.swt.custom.VerifyKeyListener)
- */
- public void removeVerifyKeyListener(VerifyKeyListener verifyKeyListener) {
- if (fContentAssistSubject != null) {
- fContentAssistSubject.removeVerifyKeyListener(verifyKeyListener);
- } else if (fViewer instanceof ITextViewerExtension) {
- ITextViewerExtension extension= (ITextViewerExtension) fViewer;
- extension.removeVerifyKeyListener(verifyKeyListener);
- } else {
- StyledText textWidget= fViewer.getTextWidget();
- if (Helper.okToUse(textWidget))
- textWidget.removeVerifyKeyListener(verifyKeyListener);
- }
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubject#setEventConsumer(org.eclipse.jface.text.contentassist.ContentAssistant.InternalListener)
- */
- public void setEventConsumer(IEventConsumer eventConsumer) {
- if (fContentAssistSubject != null)
- fContentAssistSubject.setEventConsumer(eventConsumer);
- else
- fViewer.setEventConsumer(eventConsumer);
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubject#setSelectedRange(int, int)
- */
- public void setSelectedRange(int i, int j) {
- if (fContentAssistSubject != null)
- fContentAssistSubject.setSelectedRange(i, j);
- else
- fViewer.getTextWidget().setSelectionRange(i, j);
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubject#revealRange(int, int)
- */
- public void revealRange(int i, int j) {
- if (fContentAssistSubject != null)
- fContentAssistSubject.revealRange(i, j);
- else
- fViewer.revealRange(i, j);
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubject#canAddVerifyKeyListener()
- */
- public boolean supportsVerifyKeyListener() {
- if (fContentAssistSubject != null)
- return fContentAssistSubject.supportsVerifyKeyListener();
- else
- return true;
- }
- /**
- * Returns the characters which when typed by the user should automatically
- * initiate proposing completions. The position is used to determine the
- * appropriate content assist processor to invoke.
- *
- * @param contentAssistant the content assistant
- * @param offset a document offset
- * @return the auto activation characters
- * @see IContentAssistProcessor#getCompletionProposalAutoActivationCharacters
- */
- public char[] getCompletionProposalAutoActivationCharacters(ContentAssistant contentAssistant, int offset) {
- if (fContentAssistSubject != null)
- return contentAssistant.getCompletionProposalAutoActivationCharacters(fContentAssistSubject, offset);
- else
- return contentAssistant.getCompletionProposalAutoActivationCharacters(fViewer, offset);
- }
-
- /**
- * Returns the characters which when typed by the user should automatically
- * initiate the presentation of context information. The position is used
- * to determine the appropriate content assist processor to invoke.
- *
- * @param contentAssistant the content assistant
- * @param offset a document offset
- * @return the auto activation characters
- *
- * @see IContentAssistProcessor#getContextInformationAutoActivationCharacters
- */
- char[] getContextInformationAutoActivationCharacters(ContentAssistant contentAssistant, int offset) {
- if (fContentAssistSubject != null)
- return contentAssistant.getContextInformationAutoActivationCharacters(fContentAssistSubject, offset);
- else
- return contentAssistant.getContextInformationAutoActivationCharacters(fViewer, offset);
- }
-
- /**
- * Creates and returns a completion proposal popup for the given content assistant.
- *
- * @param contentAssistant the content assistant
- * @param controller the additional info controller
- * @return the completion proposal popup
- */
- CompletionProposalPopup createCompletionProposalPopup(ContentAssistant contentAssistant, AdditionalInfoController controller) {
- if (fContentAssistSubject != null)
- return new CompletionProposalPopup(contentAssistant, fContentAssistSubject, controller);
- else
- return new CompletionProposalPopup(contentAssistant, fViewer, controller);
-
- }
-
- /**
- * Creates and returns a context info popup for the given content assistant.
- *
- * @param contentAssistant the content assistant
- * @return the context info popup or <code>null</code>
- */
- ContextInformationPopup createContextInfoPopup(ContentAssistant contentAssistant) {
- if (fContentAssistSubject != null)
- return new ContextInformationPopup(contentAssistant, fContentAssistSubject);
- else
- return new ContextInformationPopup(contentAssistant, fViewer);
-
- }
-
- /**
- * @param contentAssistant
- * @param offset
- * @return
- */
- public IContextInformationValidator getContextInformationValidator(ContentAssistant contentAssistant, int offset) {
- if (fContentAssistSubject != null)
- return contentAssistant.getContextInformationValidator(fContentAssistSubject, offset);
- else
- return contentAssistant.getContextInformationValidator(fViewer, offset);
- }
-
- /**
- * @param contentAssistant
- * @param offset
- * @return
- */
- public IContextInformationPresenter getContextInformationPresenter(ContentAssistant contentAssistant, int offset) {
- if (fContentAssistSubject != null)
- return contentAssistant.getContextInformationPresenter(fContentAssistSubject, offset);
- else
- return contentAssistant.getContextInformationPresenter(fViewer, offset);
- }
-
- /**
- * @param frame
- */
- public void installValidator(ContextFrame frame) {
- if (fContentAssistSubject != null) {
- if (frame.fValidator instanceof IContextInformationValidatorExtension)
- ((IContextInformationValidatorExtension)frame.fValidator).install(frame.fInformation, fContentAssistSubject, frame.fOffset);
- } else
- frame.fValidator.install(frame.fInformation, fViewer, frame.fOffset);
- }
-
- /**
- * @param frame
- */
- public void installContextInformationPresenter(ContextFrame frame) {
- if (fContentAssistSubject != null) {
- if (frame.fPresenter instanceof IContextInformationPresenterExtension)
- ((IContextInformationPresenterExtension)frame.fValidator).install(frame.fInformation, fContentAssistSubject, frame.fBeginOffset);
- } else
- frame.fPresenter.install(frame.fInformation, fViewer, frame.fBeginOffset);
- }
-
- /**
- * @param contentAssistant
- * @param position
- * @return
- */
- public IContextInformation[] computeContextInformation(ContentAssistant contentAssistant, int position) {
- if (fContentAssistSubject != null)
- return contentAssistant.computeContextInformation(fContentAssistSubject, position);
- else
- return contentAssistant.computeContextInformation(fViewer, position);
- }
-
- /*
- * @see IContentAssistSubject#addSelectionListener(SelectionListener)
- */
- public boolean addSelectionListener(SelectionListener selectionListener) {
- if (fContentAssistSubject != null)
- return fContentAssistSubject.addSelectionListener(selectionListener);
- else {
- fViewer.getTextWidget().addSelectionListener(selectionListener);
- return true;
- }
- }
-
- /*
- * @see IContentAssistSubject#removeSelectionListener(SelectionListener)
- */
- public void removeSelectionListener(SelectionListener selectionListener) {
- if (fContentAssistSubject != null)
- fContentAssistSubject.removeSelectionListener(selectionListener);
- else
- fViewer.getTextWidget().removeSelectionListener(selectionListener);
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java
deleted file mode 100644
index b8fda8885c9..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java
+++ /dev/null
@@ -1,1614 +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.contentassist;
-
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.SWTError;
-import org.eclipse.swt.custom.VerifyKeyListener;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.ControlListener;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.VerifyEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Widget;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentExtension3;
-import org.eclipse.jface.text.IEventConsumer;
-import org.eclipse.jface.text.IInformationControlCreator;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.IViewportListener;
-import org.eclipse.jface.text.IWidgetTokenKeeper;
-import org.eclipse.jface.text.IWidgetTokenKeeperExtension;
-import org.eclipse.jface.text.IWidgetTokenOwner;
-import org.eclipse.jface.text.IWidgetTokenOwnerExtension;
-import org.eclipse.jface.text.TextUtilities;
-
-
-
-/**
- * The standard implementation of the <code>IContentAssistant</code> interface.
- * Usually, clients instantiate this class and configure it before using it.
- */
-public class ContentAssistant implements IContentAssistant, IContentAssistantExtension, IWidgetTokenKeeper, IWidgetTokenKeeperExtension {
-
- /**
- * A generic closer class used to monitor various
- * interface events in order to determine whether
- * content-assist should be terminated and all
- * associated windows closed.
- */
- class Closer implements ControlListener, MouseListener, FocusListener, DisposeListener, IViewportListener {
-
- /**
- * Installs this closer on it's viewer's text widget.
- */
- protected void install() {
- Control control= fContentAssistSubjectAdapter.getControl();
- if (Helper.okToUse(control)) {
-
- Control shell= control.getShell();
- shell.addControlListener(this);
-
- control.addMouseListener(this);
- control.addFocusListener(this);
-
- /*
- * 1GGYYWK: ITPJUI:ALL - Dismissing editor with code assist up causes lots of Internal Errors
- */
- control.addDisposeListener(this);
- }
- if (fViewer != null)
- fViewer.addViewportListener(this);
- }
-
- /**
- * Uninstalls this closer from the viewer's text widget.
- */
- protected void uninstall() {
- Control control= fContentAssistSubjectAdapter.getControl();
- if (Helper.okToUse(control)) {
-
- Control shell= control.getShell();
- if (Helper.okToUse(shell))
- shell.removeControlListener(this);
-
- control.removeMouseListener(this);
- control.removeFocusListener(this);
-
- /*
- * 1GGYYWK: ITPJUI:ALL - Dismissing editor with code assist up causes lots of Internal Errors
- */
- control.removeDisposeListener(this);
- }
-
- if (fViewer != null)
- fViewer.removeViewportListener(this);
- }
-
- /*
- * @see ControlListener#controlResized(ControlEvent)
- */
- public void controlResized(ControlEvent e) {
- hide();
- }
-
- /*
- * @see ControlListener#controlMoved(ControlEvent)
- */
- public void controlMoved(ControlEvent e) {
- hide();
- }
-
- /*
- * @see MouseListener#mouseDown(MouseEvent)
- */
- public void mouseDown(MouseEvent e) {
- hide();
- }
-
- /*
- * @see MouseListener#mouseUp(MouseEvent)
- */
- public void mouseUp(MouseEvent e) {
- }
-
- /*
- * @see MouseListener#mouseDoubleClick(MouseEvent)
- */
- public void mouseDoubleClick(MouseEvent e) {
- hide();
- }
-
- /*
- * @see FocusListener#focusGained(FocusEvent)
- */
- public void focusGained(FocusEvent e) {
- }
-
- /*
- * @see FocusListener#focusLost(FocusEvent)
- */
- public void focusLost(FocusEvent e) {
- Control control= fContentAssistSubjectAdapter.getControl();
- if (control != null) {
- Display d= control.getDisplay();
- if (d != null) {
- d.asyncExec(new Runnable() {
- public void run() {
- if (!fProposalPopup.hasFocus() && (fContextInfoPopup == null || !fContextInfoPopup.hasFocus()))
- hide();
- }
- });
- }
- }
- }
-
- /*
- * @seeDisposeListener#widgetDisposed(DisposeEvent)
- */
- public void widgetDisposed(DisposeEvent e) {
- /*
- * 1GGYYWK: ITPJUI:ALL - Dismissing editor with code assist up causes lots of Internal Errors
- */
- hide();
- }
-
- /*
- * @see IViewportListener#viewportChanged(int)
- */
- public void viewportChanged(int topIndex) {
- hide();
- }
- }
-
- /**
- * An implementation of <code>IContentAssistListener</code>, this class is
- * used to monitor key events in support of automatic activation
- * of the content assistant. If enabled, the implementation utilizes a
- * thread to watch for input characters matching the activation
- * characters specified by the content assist processor, and if
- * detected, will wait the indicated delay interval before
- * activating the content assistant.
- */
- class AutoAssistListener extends KeyAdapter implements KeyListener, Runnable {
-
- private Thread fThread;
- private boolean fIsReset= false;
- private Object fMutex= new Object();
- private int fShowStyle;
-
- private final static int SHOW_PROPOSALS= 1;
- private final static int SHOW_CONTEXT_INFO= 2;
-
- protected AutoAssistListener() {
- }
-
- protected void start(int showStyle) {
- fShowStyle= showStyle;
- fThread= new Thread(this, JFaceTextMessages.getString("ContentAssistant.assist_delay_timer_name")); //$NON-NLS-1$
- fThread.start();
- }
-
- public void run() {
- try {
- while (true) {
- synchronized (fMutex) {
- if (fAutoActivationDelay != 0)
- fMutex.wait(fAutoActivationDelay);
- if (fIsReset) {
- fIsReset= false;
- continue;
- }
- }
- showAssist(fShowStyle);
- break;
- }
- } catch (InterruptedException e) {
- }
- fThread= null;
- }
-
- protected void reset(int showStyle) {
- synchronized (fMutex) {
- fShowStyle= showStyle;
- fIsReset= true;
- fMutex.notifyAll();
- }
- }
-
- protected void stop() {
- if (fThread != null) {
- fThread.interrupt();
- }
- }
-
- private boolean contains(char[] characters, char character) {
- if (characters != null) {
- for (int i= 0; i < characters.length; i++) {
- if (character == characters[i])
- return true;
- }
- }
- return false;
- }
-
- public void keyPressed(KeyEvent e) {
- // Only act on typed characters and ignore modifier-only events
- if (e.character == 0 && (e.keyCode & SWT.KEYCODE_BIT) == 0)
- return;
-
- int showStyle;
- int pos= fContentAssistSubjectAdapter.getSelectedRange().x;
- char[] activation;
-
- activation= fContentAssistSubjectAdapter.getCompletionProposalAutoActivationCharacters(ContentAssistant.this, pos);
-
- if (contains(activation, e.character) && !fProposalPopup.isActive())
- showStyle= SHOW_PROPOSALS;
- else {
- activation= fContentAssistSubjectAdapter.getContextInformationAutoActivationCharacters(ContentAssistant.this, pos);
- if (contains(activation, e.character) && fContextInfoPopup != null && !fContextInfoPopup.isActive())
- showStyle= SHOW_CONTEXT_INFO;
- else {
- if (fThread != null && fThread.isAlive())
- stop();
- return;
- }
- }
-
- if (fThread != null && fThread.isAlive())
- reset(showStyle);
- else
- start(showStyle);
- }
-
- protected void showAssist(final int showStyle) {
- Display d= fContentAssistSubjectAdapter.getControl().getDisplay();
- if (d != null) {
- try {
- d.syncExec(new Runnable() {
- public void run() {
- if (showStyle == SHOW_PROPOSALS)
- fProposalPopup.showProposals(true);
- else if (showStyle == SHOW_CONTEXT_INFO && fContextInfoPopup != null)
- fContextInfoPopup.showContextProposals(true);
- }
- });
- } catch (SWTError e) {
- }
- }
- }
- }
-
- /**
- * The laypout manager layouts the various
- * windows associated with the content assistant based on the
- * settings of the content assistant.
- */
- class LayoutManager implements Listener {
-
- // Presentation types.
- public final static int LAYOUT_PROPOSAL_SELECTOR= 0;
- public final static int LAYOUT_CONTEXT_SELECTOR= 1;
- public final static int LAYOUT_CONTEXT_INFO_POPUP= 2;
-
- int fContextType= LAYOUT_CONTEXT_SELECTOR;
- Shell[] fShells= new Shell[3];
- Object[] fPopups= new Object[3];
-
- protected void add(Object popup, Shell shell, int type, int offset) {
- Assert.isNotNull(popup);
- Assert.isTrue(shell != null && !shell.isDisposed());
- checkType(type);
-
- if (fShells[type] != shell) {
- if (fShells[type] != null)
- fShells[type].removeListener(SWT.Dispose, this);
- shell.addListener(SWT.Dispose, this);
- fShells[type]= shell;
- }
-
- fPopups[type]= popup;
- if (type == LAYOUT_CONTEXT_SELECTOR || type == LAYOUT_CONTEXT_INFO_POPUP)
- fContextType= type;
-
- layout(type, offset);
- adjustListeners(type);
- }
-
- protected void checkType(int type) {
- Assert.isTrue(type == LAYOUT_PROPOSAL_SELECTOR ||
- type == LAYOUT_CONTEXT_SELECTOR || type == LAYOUT_CONTEXT_INFO_POPUP);
- }
-
- public void handleEvent(Event event) {
- Widget source= event.widget;
- source.removeListener(SWT.Dispose, this);
-
- int type= getShellType(source);
- checkType(type);
- fShells[type]= null;
-
- switch (type) {
- case LAYOUT_PROPOSAL_SELECTOR:
- if (fContextType == LAYOUT_CONTEXT_SELECTOR &&
- Helper.okToUse(fShells[LAYOUT_CONTEXT_SELECTOR])) {
- // Restore event notification to the tip popup.
- addContentAssistListener((IContentAssistListener) fPopups[LAYOUT_CONTEXT_SELECTOR], CONTEXT_SELECTOR);
- }
- break;
-
- case LAYOUT_CONTEXT_SELECTOR:
- if (Helper.okToUse(fShells[LAYOUT_PROPOSAL_SELECTOR])) {
- if (fProposalPopupOrientation == PROPOSAL_STACKED)
- layout(LAYOUT_PROPOSAL_SELECTOR, getSelectionOffset());
- // Restore event notification to the proposal popup.
- addContentAssistListener((IContentAssistListener) fPopups[LAYOUT_PROPOSAL_SELECTOR], PROPOSAL_SELECTOR);
- }
- fContextType= LAYOUT_CONTEXT_INFO_POPUP;
- break;
-
- case LAYOUT_CONTEXT_INFO_POPUP:
- if (Helper.okToUse(fShells[LAYOUT_PROPOSAL_SELECTOR])) {
- if (fContextInfoPopupOrientation == CONTEXT_INFO_BELOW)
- layout(LAYOUT_PROPOSAL_SELECTOR, getSelectionOffset());
- }
- fContextType= LAYOUT_CONTEXT_SELECTOR;
- break;
- }
- }
-
- protected int getShellType(Widget shell) {
- for (int i=0; i<fShells.length; i++) {
- if (fShells[i] == shell)
- return i;
- }
- return -1;
- }
-
- protected void layout(int type, int offset) {
- switch (type) {
- case LAYOUT_PROPOSAL_SELECTOR:
- layoutProposalSelector(offset);
- break;
- case LAYOUT_CONTEXT_SELECTOR:
- layoutContextSelector(offset);
- break;
- case LAYOUT_CONTEXT_INFO_POPUP:
- layoutContextInfoPopup(offset);
- break;
- }
- }
-
- protected void layoutProposalSelector(int offset) {
- if (fContextType == LAYOUT_CONTEXT_INFO_POPUP &&
- fContextInfoPopupOrientation == CONTEXT_INFO_BELOW &&
- Helper.okToUse(fShells[LAYOUT_CONTEXT_INFO_POPUP])) {
- // Stack proposal selector beneath the tip box.
- Shell shell= fShells[LAYOUT_PROPOSAL_SELECTOR];
- Shell parent= fShells[LAYOUT_CONTEXT_INFO_POPUP];
- shell.setLocation(getStackedLocation(shell, parent));
- } else if (fContextType != LAYOUT_CONTEXT_SELECTOR ||
- !Helper.okToUse(fShells[LAYOUT_CONTEXT_SELECTOR])) {
- // There are no other presentations to be concerned with,
- // so place the proposal selector beneath the cursor line.
- Shell shell= fShells[LAYOUT_PROPOSAL_SELECTOR];
- shell.setLocation(getBelowLocation(shell, offset));
- } else {
- switch (fProposalPopupOrientation) {
- case PROPOSAL_REMOVE: {
- // Remove the tip selector and place the
- // proposal selector beneath the cursor line.
- fShells[LAYOUT_CONTEXT_SELECTOR].dispose();
- Shell shell= fShells[LAYOUT_PROPOSAL_SELECTOR];
- shell.setLocation(getBelowLocation(shell, offset));
- break;
- }
- case PROPOSAL_OVERLAY: {
- // Overlay the tip selector with the proposal selector.
- Shell shell= fShells[LAYOUT_PROPOSAL_SELECTOR];
- shell.setLocation(getBelowLocation(shell, offset));
- break;
- }
- case PROPOSAL_STACKED: {
- // Stack the proposal selector beneath the tip selector.
- Shell shell= fShells[LAYOUT_PROPOSAL_SELECTOR];
- Shell parent= fShells[LAYOUT_CONTEXT_SELECTOR];
- shell.setLocation(getStackedLocation(shell, parent));
- break;
- }
- }
- }
- }
-
- protected void layoutContextSelector(int offset) {
- // Always place the context selector beneath the cursor line.
- Shell shell= fShells[LAYOUT_CONTEXT_SELECTOR];
- shell.setLocation(getBelowLocation(shell, offset));
-
- if (Helper.okToUse(fShells[LAYOUT_PROPOSAL_SELECTOR])) {
- switch (fProposalPopupOrientation) {
- case PROPOSAL_REMOVE:
- // Remove the proposal selector.
- fShells[LAYOUT_PROPOSAL_SELECTOR].dispose();
- break;
-
- case PROPOSAL_OVERLAY:
- // The proposal selector has been overlayed by the tip selector.
- break;
-
- case PROPOSAL_STACKED: {
- // Stack the proposal selector beneath the tip selector.
- shell= fShells[LAYOUT_PROPOSAL_SELECTOR];
- Shell parent= fShells[LAYOUT_CONTEXT_SELECTOR];
- shell.setLocation(getStackedLocation(shell, parent));
- break;
- }
- }
- }
- }
-
- protected void layoutContextInfoPopup(int offset) {
- switch (fContextInfoPopupOrientation) {
- case CONTEXT_INFO_ABOVE: {
- // Place the popup above the cursor line.
- Shell shell= fShells[LAYOUT_CONTEXT_INFO_POPUP];
- shell.setLocation(getAboveLocation(shell, offset));
- break;
- }
- case CONTEXT_INFO_BELOW: {
- // Place the popup beneath the cursor line.
- Shell parent= fShells[LAYOUT_CONTEXT_INFO_POPUP];
- parent.setLocation(getBelowLocation(parent, offset));
- if (Helper.okToUse(fShells[LAYOUT_PROPOSAL_SELECTOR])) {
- // Stack the proposal selector beneath the context info popup.
- Shell shell= fShells[LAYOUT_PROPOSAL_SELECTOR];
- shell.setLocation(getStackedLocation(shell, parent));
- }
- break;
- }
- }
- }
-
- protected void shiftHorizontalLocation(Point location, Rectangle shellBounds, Rectangle displayBounds) {
- if (location.x + shellBounds.width > displayBounds.width)
- location.x= displayBounds.width - shellBounds.width;
-
- if (location.x < displayBounds.x)
- location.x= displayBounds.x;
- }
-
- protected void shiftVerticalLocation(Point location, Rectangle shellBounds, Rectangle displayBounds) {
- if (location.y + shellBounds.height > displayBounds.height)
- location.y= displayBounds.height - shellBounds.height;
-
- if (location.y < displayBounds.y)
- location.y= displayBounds.y;
- }
-
- protected Point getAboveLocation(Shell shell, int offset) {
- Point location= fContentAssistSubjectAdapter.getLocationAtOffset(offset);
- location= fContentAssistSubjectAdapter.getControl().toDisplay(location);
-
- Rectangle shellBounds= shell.getBounds();
- Rectangle displayBounds= shell.getDisplay().getClientArea();
-
- location.y=location.y - shellBounds.height;
-
- shiftHorizontalLocation(location, shellBounds, displayBounds);
- shiftVerticalLocation(location, shellBounds, displayBounds);
-
- return location;
- }
-
- protected Point getBelowLocation(Shell shell, int offset) {
- Point location= fContentAssistSubjectAdapter.getLocationAtOffset(offset);
- if (location.x < 0) location.x= 0;
- if (location.y < 0) location.y= 0;
- location= fContentAssistSubjectAdapter.getControl().toDisplay(location);
-
- Rectangle shellBounds= shell.getBounds();
- Rectangle displayBounds= shell.getDisplay().getClientArea();
-
- location.y= location.y + fContentAssistSubjectAdapter.getLineHeight();
- shiftHorizontalLocation(location, shellBounds, displayBounds);
- shiftVerticalLocation(location, shellBounds, displayBounds);
-
- return location;
- }
-
- protected Point getStackedLocation(Shell shell, Shell parent) {
- Point p= parent.getLocation();
- Point size= parent.getSize();
- p.x += size.x / 4;
- p.y += size.y;
-
- p= parent.toDisplay(p);
-
- Rectangle shellBounds= shell.getBounds();
- Rectangle displayBounds= shell.getDisplay().getClientArea();
- shiftHorizontalLocation(p, shellBounds, displayBounds);
- shiftVerticalLocation(p, shellBounds, displayBounds);
-
- return p;
- }
-
- protected void adjustListeners(int type) {
- switch (type) {
- case LAYOUT_PROPOSAL_SELECTOR:
- if (fContextType == LAYOUT_CONTEXT_SELECTOR &&
- Helper.okToUse(fShells[LAYOUT_CONTEXT_SELECTOR]))
- // Disable event notification to the tip selector.
- removeContentAssistListener((IContentAssistListener) fPopups[LAYOUT_CONTEXT_SELECTOR], CONTEXT_SELECTOR);
- break;
- case LAYOUT_CONTEXT_SELECTOR:
- if (Helper.okToUse(fShells[LAYOUT_PROPOSAL_SELECTOR]))
- // Disable event notification to the proposal selector.
- removeContentAssistListener((IContentAssistListener) fPopups[LAYOUT_PROPOSAL_SELECTOR], PROPOSAL_SELECTOR);
- break;
- case LAYOUT_CONTEXT_INFO_POPUP:
- break;
- }
- }
- }
-
- /**
- * Internal key listener and event consumer.
- */
- class InternalListener implements VerifyKeyListener, IEventConsumer {
-
- /**
- * Verifies key events by notifying the registered listeners.
- * Each listener is allowed to indicate that the event has been
- * handled and should not be further processed.
- *
- * @param event the verify event
- * @see VerifyKeyListener#verifyKey
- */
- public void verifyKey(VerifyEvent e) {
- IContentAssistListener[] listeners= (IContentAssistListener[]) fListeners.clone();
- for (int i= 0; i < listeners.length; i++) {
- if (listeners[i] != null) {
- if (!listeners[i].verifyKey(e) || !e.doit)
- break;
- }
- }
- if (fAutoAssistListener != null)
- fAutoAssistListener.keyPressed(e);
- }
-
- /*
- * @see IEventConsumer#processEvent
- */
- public void processEvent(VerifyEvent event) {
-
- installKeyListener();
-
- IContentAssistListener[] listeners= (IContentAssistListener[])fListeners.clone();
- for (int i= 0; i < listeners.length; i++) {
- if (listeners[i] != null) {
- listeners[i].processEvent(event);
- if (!event.doit)
- return;
- }
- }
- }
- }
-
-
- // Content-Assist Listener types
- final static int CONTEXT_SELECTOR= 0;
- final static int PROPOSAL_SELECTOR= 1;
- final static int CONTEXT_INFO_POPUP= 2;
-
- /**
- * The popup priority: &gt; linked position proposals and hover popups.
- * Default value: <code>20</code>;
- *
- * @since 3.0
- */
- public static final int WIDGET_PRIORITY= 20;
-
- private static final int DEFAULT_AUTO_ACTIVATION_DELAY= 500;
-
- private IInformationControlCreator fInformationControlCreator;
- private int fAutoActivationDelay= DEFAULT_AUTO_ACTIVATION_DELAY;
- private boolean fIsAutoActivated= false;
- private boolean fIsAutoInserting= false;
- private int fProposalPopupOrientation= PROPOSAL_OVERLAY;
- private int fContextInfoPopupOrientation= CONTEXT_INFO_ABOVE;
- private Map fProcessors;
- private String fPartitioning;
-
- private Color fContextInfoPopupBackground;
- private Color fContextInfoPopupForeground;
- private Color fContextSelectorBackground;
- private Color fContextSelectorForeground;
- private Color fProposalSelectorBackground;
- private Color fProposalSelectorForeground;
-
- private ITextViewer fViewer;
- private String fLastErrorMessage;
-
- private Closer fCloser;
- private LayoutManager fLayoutManager;
- private AutoAssistListener fAutoAssistListener;
- private InternalListener fInternalListener;
- private CompletionProposalPopup fProposalPopup;
- private ContextInformationPopup fContextInfoPopup;
-
- private boolean fVerifyKeyListenerHooked= false;
- private IContentAssistListener[] fListeners= new IContentAssistListener[4];
- /**
- * The content assist subject.
- *
- * @since 3.0
- */
- private IContentAssistSubject fContentAssistSubject;
- /**
- * The content assist subject adapter.
- *
- * @since 3.0
- */
- private ContentAssistSubjectAdapter fContentAssistSubjectAdapter;
-
-
- /**
- * Creates a new content assistant. The content assistant is not automatically activated,
- * overlays the completion proposals with context information list if necessary, and
- * shows the context information above the location at which it was activated. If auto
- * activation will be enabled, without further configuration steps, this content assistant
- * is activated after a 500 ms delay. It uses the default partitioning.
- */
- public ContentAssistant() {
- fPartitioning= IDocumentExtension3.DEFAULT_PARTITIONING;
- }
-
- /**
- * Sets the document partitioning this content assistant is using.
- *
- * @param partitioning the document partitioning for this content assistant
- */
- public void setDocumentPartitioning(String partitioning) {
- Assert.isNotNull(partitioning);
- fPartitioning= partitioning;
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistantExtension#getDocumentPartitioning()
- * @since 3.0
- */
- public String getDocumentPartitioning() {
- return fPartitioning;
- }
-
- /**
- * Registers a given content assist processor for a particular content type.
- * If there is already a processor registered for this type, the new processor
- * is registered instead of the old one.
- *
- * @param processor the content assist processor to register, or <code>null</code> to remove an existing one
- * @param contentType the content type under which to register
- */
- public void setContentAssistProcessor(IContentAssistProcessor processor, String contentType) {
-
- Assert.isNotNull(contentType);
-
- if (fProcessors == null)
- fProcessors= new HashMap();
-
- if (processor == null)
- fProcessors.remove(contentType);
- else
- fProcessors.put(contentType, processor);
- }
-
- /*
- * @see IContentAssistant#getContentAssistProcessor
- */
- public IContentAssistProcessor getContentAssistProcessor(String contentType) {
- if (fProcessors == null)
- return null;
-
- return (IContentAssistProcessor) fProcessors.get(contentType);
- }
-
- /**
- * Enables the content assistant's auto activation mode.
- *
- * @param enabled indicates whether auto activation is enabled or not
- */
- public void enableAutoActivation(boolean enabled) {
- fIsAutoActivated= enabled;
- manageAutoActivation(fIsAutoActivated);
- }
-
- /**
- * Enables the content assistant's auto insertion mode. If enabled,
- * the content assistant inserts a proposal automatically if it is
- * the only proposal. In the case of ambiguities, the user must
- * make the choice.
- *
- * @param enabled indicates whether auto insertion is enabled or not
- * @since 2.0
- */
- public void enableAutoInsert(boolean enabled) {
- fIsAutoInserting= enabled;
- }
-
- /**
- * Returns whether this content assistant is in the auto insertion
- * mode or not.
- *
- * @return <code>true</code> if in auto insertion mode
- * @since 2.0
- */
- boolean isAutoInserting() {
- return fIsAutoInserting;
- }
-
- /**
- * Installs and uninstall the listeners needed for autoactivation.
- * @param start <code>true</code> if listeners must be installed,
- * <code>false</code> if they must be removed
- * @since 2.0
- */
- private void manageAutoActivation(boolean start) {
- if (start) {
-
- if ((fContentAssistSubjectAdapter != null) && fAutoAssistListener == null) {
- fAutoAssistListener= new AutoAssistListener();
- fContentAssistSubjectAdapter.addKeyListener(fAutoAssistListener);
- }
-
- } else if (fAutoAssistListener != null) {
- fContentAssistSubjectAdapter.removeKeyListener(fAutoAssistListener);
- fAutoAssistListener= null;
- }
- }
-
- /**
- * Sets the delay after which the content assistant is automatically invoked
- * if the cursor is behind an auto activation character.
- *
- * @param delay the auto activation delay
- */
- public void setAutoActivationDelay(int delay) {
- fAutoActivationDelay= delay;
- }
-
- /**
- * Sets the proposal popups' orientation.
- * The following values may be used:
- * <ul>
- * <li>PROPOSAL_OVERLAY<p>
- * proposal popup windows should overlay each other
- * </li>
- * <li>PROPOSAL_REMOVE<p>
- * any currently shown proposal popup should be closed
- * </li>
- * <li>PROPOSAL_STACKED<p>
- * proposal popup windows should be vertical stacked, with no overlap,
- * beneath the line containing the current cursor location
- * </li>
- * </ul>
- *
- * @param orientation the popup's orientation
- */
- public void setProposalPopupOrientation(int orientation) {
- fProposalPopupOrientation= orientation;
- }
-
- /**
- * Sets the context information popup's orientation.
- * The following values may be used:
- * <ul>
- * <li>CONTEXT_ABOVE<p>
- * context information popup should always appear above the line containing
- * the current cursor location
- * </li>
- * <li>CONTEXT_BELOW<p>
- * context information popup should always appear below the line containing
- * the current cursor location
- * </li>
- * </ul>
- *
- * @param orientation the popup's orientation
- */
- public void setContextInformationPopupOrientation(int orientation) {
- fContextInfoPopupOrientation= orientation;
- }
-
- /**
- * Sets the context information popup's background color.
- *
- * @param background the background color
- */
- public void setContextInformationPopupBackground(Color background) {
- fContextInfoPopupBackground= background;
- }
-
- /**
- * Returns the background of the context information popup.
- *
- * @return the background of the context information popup
- * @since 2.0
- */
- Color getContextInformationPopupBackground() {
- return fContextInfoPopupBackground;
- }
-
- /**
- * Sets the context information popup's foreground color.
- *
- * @param foreground the foreground color
- * @since 2.0
- */
- public void setContextInformationPopupForeground(Color foreground) {
- fContextInfoPopupForeground= foreground;
- }
-
- /**
- * Returns the foreground of the context information popup.
- *
- * @return the foreground of the context information popup
- * @since 2.0
- */
- Color getContextInformationPopupForeground() {
- return fContextInfoPopupForeground;
- }
-
- /**
- * Sets the proposal selector's background color.
- *
- * @param background the background color
- * @since 2.0
- */
- public void setProposalSelectorBackground(Color background) {
- fProposalSelectorBackground= background;
- }
-
- /**
- * Returns the background of the proposal selector.
- *
- * @return the background of the proposal selector
- * @since 2.0
- */
- Color getProposalSelectorBackground() {
- return fProposalSelectorBackground;
- }
-
- /**
- * Sets the proposal's foreground color.
- *
- * @param foreground the foreground color
- * @since 2.0
- */
- public void setProposalSelectorForeground(Color foreground) {
- fProposalSelectorForeground= foreground;
- }
-
- /**
- * Returns the foreground of the proposal selector.
- *
- * @return the foreground of the proposal selector
- * @since 2.0
- */
- Color getProposalSelectorForeground() {
- return fProposalSelectorForeground;
- }
-
- /**
- * Sets the context selector's background color.
- *
- * @param background the background color
- * @since 2.0
- */
- public void setContextSelectorBackground(Color background) {
- fContextSelectorBackground= background;
- }
-
- /**
- * Returns the background of the context selector.
- *
- * @return the background of the context selector
- * @since 2.0
- */
- Color getContextSelectorBackground() {
- return fContextSelectorBackground;
- }
-
- /**
- * Sets the context selector's foreground color.
- *
- * @param foreground the foreground color
- * @since 2.0
- */
- public void setContextSelectorForeground(Color foreground) {
- fContextSelectorForeground= foreground;
- }
-
- /**
- * Returns the foreground of the context selector.
- *
- * @return the foreground of the context selector
- * @since 2.0
- */
- Color getContextSelectorForeground() {
- return fContextSelectorForeground;
- }
-
- /**
- * Sets the information control creator for the additional information control.
- *
- * @param creator the information control creator for the additional information control
- * @since 2.0
- */
- public void setInformationControlCreator(IInformationControlCreator creator) {
- fInformationControlCreator= creator;
- }
-
- /*
- * @see IContentAssistantExtension#install(IContentAssistSubject)
- */
- public void install(IContentAssistSubject contentAssistSubject) {
- fContentAssistSubject= contentAssistSubject;
- fContentAssistSubjectAdapter= new ContentAssistSubjectAdapter(fContentAssistSubject);
- install();
- }
-
- /*
- * @see IContentAssist#install
- */
- public void install(ITextViewer textViewer) {
- fViewer= textViewer;
- fContentAssistSubjectAdapter= new ContentAssistSubjectAdapter(fViewer);
- install();
- }
-
- protected void install() {
-
- fLayoutManager= new LayoutManager();
- fInternalListener= new InternalListener();
-
- AdditionalInfoController controller= null;
- if (fInformationControlCreator != null) {
- int delay= fAutoActivationDelay;
- if (delay == 0)
- delay= DEFAULT_AUTO_ACTIVATION_DELAY;
- delay= Math.round(delay * 1.5f);
- controller= new AdditionalInfoController(fInformationControlCreator, delay);
- }
-
- fContextInfoPopup= fContentAssistSubjectAdapter.createContextInfoPopup(this);
- fProposalPopup= fContentAssistSubjectAdapter.createCompletionProposalPopup(this, controller);
-
- manageAutoActivation(fIsAutoActivated);
- }
-
- /*
- * @see IContentAssist#uninstall
- */
- public void uninstall() {
- hide();
- manageAutoActivation(false);
-
- if (fCloser != null) {
- fCloser.uninstall();
- fCloser= null;
- }
-
- fViewer= null;
- fContentAssistSubject= null;
- fContentAssistSubjectAdapter= null;
- }
-
- /**
- * Adds the given shell of the specified type to the layout.
- * Valid types are defined by <code>LayoutManager</code>.
- *
- * @param popup a content assist popup
- * @param shell the shell of the content-assist popup
- * @param type the type of popup
- * @param visibleOffset the offset at which to layout the popup relative to the offset of the viewer's visible region
- * @since 2.0
- */
- void addToLayout(Object popup, Shell shell, int type, int visibleOffset) {
- fLayoutManager.add(popup, shell, type, visibleOffset);
- }
-
- /**
- * Layouts the registered popup of the given type relative to the
- * given offset. The offset is relative to the offset of the viewer's visible region.
- * Valid types are defined by <code>LayoutManager</code>.
- *
- * @param type the type of popup to layout
- * @param visibleOffset the offset at which to layout relative to the offset of the viewer's visible region
- * @since 2.0
- */
- void layout(int type, int visibleOffset) {
- fLayoutManager.layout(type, visibleOffset);
- }
-
- /**
- * Notifies the controller that a popup has lost focus.
- *
- * @param e the focus event
- */
- void popupFocusLost(FocusEvent e) {
- fCloser.focusLost(e);
- }
-
- /**
- * Returns the offset of the selection relative to the offset of the visible region.
- *
- * @return the offset of the selection relative to the offset of the visible region
- * @since 2.0
- */
- int getSelectionOffset() {
- return fContentAssistSubjectAdapter.getWidgetSelectionRange().x;
- }
-
- /**
- * Returns whether the widget token could be acquired.
- * The following are valid listener types:
- * <ul>
- * <li>AUTO_ASSIST
- * <li>CONTEXT_SELECTOR
- * <li>PROPOSAL_SELECTOR
- * <li>CONTEXT_INFO_POPUP
- * <ul>
- * @param type the listener type for which to acquire
- * @return <code>true</code> if the widget token could be acquired
- * @since 2.0
- */
- private boolean acquireWidgetToken(int type) {
- switch (type) {
- case CONTEXT_SELECTOR:
- case PROPOSAL_SELECTOR:
- if (fContentAssistSubject instanceof IWidgetTokenOwner) {
- IWidgetTokenOwner owner= (IWidgetTokenOwner)fContentAssistSubject;
- return owner.requestWidgetToken(this);
- } else if (fContentAssistSubject instanceof IWidgetTokenOwnerExtension) {
- IWidgetTokenOwnerExtension extension= (IWidgetTokenOwnerExtension)fContentAssistSubject;
- return extension.requestWidgetToken(this, WIDGET_PRIORITY);
- } else if (fViewer instanceof IWidgetTokenOwner) {
- IWidgetTokenOwner owner= (IWidgetTokenOwner) fViewer;
- return owner.requestWidgetToken(this);
- } else if (fViewer instanceof IWidgetTokenOwnerExtension) {
- IWidgetTokenOwnerExtension extension= (IWidgetTokenOwnerExtension) fViewer;
- return extension.requestWidgetToken(this, WIDGET_PRIORITY);
- }
- }
- return true;
- }
-
- /**
- * Registers a content assist listener.
- * The following are valid listener types:
- * <ul>
- * <li>AUTO_ASSIST
- * <li>CONTEXT_SELECTOR
- * <li>PROPOSAL_SELECTOR
- * <li>CONTEXT_INFO_POPUP
- * <ul>
- * Returns whether the listener could be added successfully. A listener
- * can not be added if the widget token could not be acquired.
- *
- * @param listener the listener to register
- * @param type the type of listener
- * @return <code>true</code> if the listener could be added
- */
- boolean addContentAssistListener(IContentAssistListener listener, int type) {
-
- if (acquireWidgetToken(type)) {
-
- fListeners[type]= listener;
-
- if (getNumberOfListeners() == 1) {
- fCloser= new Closer();
- fCloser.install();
- fContentAssistSubjectAdapter.setEventConsumer(fInternalListener);
- installKeyListener();
- }
- return true;
- }
-
- return false;
- }
-
- /**
- * Installs a key listener on the text viewer's widget.
- */
- private void installKeyListener() {
- if (!fVerifyKeyListenerHooked) {
- if (Helper.okToUse(fContentAssistSubjectAdapter.getControl())) {
- fVerifyKeyListenerHooked= fContentAssistSubjectAdapter.prependVerifyKeyListener(fInternalListener);
- }
- }
- }
-
- /**
- * Releases the previously acquired widget token if the token
- * is no longer necessary.
- * The following are valid listener types:
- * <ul>
- * <li>AUTO_ASSIST
- * <li>CONTEXT_SELECTOR
- * <li>PROPOSAL_SELECTOR
- * <li>CONTEXT_INFO_POPUP
- * <ul>
- *
- * @param type the listener type
- * @since 2.0
- */
- private void releaseWidgetToken(int type) {
- if (fListeners[CONTEXT_SELECTOR] == null && fListeners[PROPOSAL_SELECTOR] == null) {
- IWidgetTokenOwner owner= null;
- if (fContentAssistSubject instanceof IWidgetTokenOwner)
- owner= (IWidgetTokenOwner)fContentAssistSubject;
- else if (fViewer instanceof IWidgetTokenOwner)
- owner= (IWidgetTokenOwner)fViewer;
- if (owner != null)
- owner.releaseWidgetToken(this);
- }
- }
-
- /**
- * Unregisters a content assist listener.
- *
- * @param listener the listener to unregister
- * @param type the type of listener
- *
- * @see #addContentAssistListener
- */
- void removeContentAssistListener(IContentAssistListener listener, int type) {
- fListeners[type]= null;
-
- if (getNumberOfListeners() == 0) {
-
- if (fCloser != null) {
- fCloser.uninstall();
- fCloser= null;
- }
-
- uninstallVerifyKeyListener();
- fContentAssistSubjectAdapter.setEventConsumer(null);
- }
-
- releaseWidgetToken(type);
- }
-
- /**
- * Uninstall the key listener from the text viewer's widget.
- */
- private void uninstallVerifyKeyListener() {
- if (fVerifyKeyListenerHooked) {
- if (Helper.okToUse(fContentAssistSubjectAdapter.getControl()))
- fContentAssistSubjectAdapter.removeVerifyKeyListener(fInternalListener);
- fVerifyKeyListenerHooked= false;
- }
- }
-
- /**
- * Returns the number of listeners.
- *
- * @return the number of listeners
- * @since 2.0
- */
- private int getNumberOfListeners() {
- int count= 0;
- for (int i= 0; i <= CONTEXT_INFO_POPUP; i++) {
- if (fListeners[i] != null)
- ++ count;
- }
- return count;
- }
-
- /*
- * @see IContentAssist#showPossibleCompletions
- */
- public String showPossibleCompletions() {
- return fProposalPopup.showProposals(false);
- }
-
- /**
- * Callback to signal this content assistant that the presentation of the possible completions has been stopped.
- * @since 2.1
- */
- protected void possibleCompletionsClosed() {
- }
-
- /*
- * @see IContentAssist#showContextInformation
- */
- public String showContextInformation() {
- if (fContextInfoPopup != null)
- return fContextInfoPopup.showContextProposals(false);
- else
- return null;
- }
-
- /**
- * Callback to signal this content assistant that the presentation of the context information has been stopped.
- * @since 2.1
- */
- protected void contextInformationClosed() {
- }
-
- /**
- * Requests that the specified context information to be shown.
- *
- * @param contextInformation the context information to be shown
- * @param position the position to which the context information refers to
- * @since 2.0
- */
- void showContextInformation(IContextInformation contextInformation, int position) {
- if (fContextInfoPopup != null)
- fContextInfoPopup.showContextInformation(contextInformation, position);
- }
-
- /**
- * Returns the current content assist error message.
- *
- * @return an error message or <code>null</code> if no error has occurred
- */
- String getErrorMessage() {
- return fLastErrorMessage;
- }
-
- /**
- * Returns the content assist processor for the content
- * type of the specified document position.
- *
- * @param viewer the text viewer
- * @param offset a offset within the document
- * @return a content-assist processor or <code>null</code> if none exists
- */
- private IContentAssistProcessor getProcessor(ITextViewer viewer, int offset) {
- try {
-
- IDocument document= viewer.getDocument();
- String type= TextUtilities.getContentType(document, getDocumentPartitioning(), offset);
-
- return getContentAssistProcessor(type);
-
- } catch (BadLocationException x) {
- }
-
- return null;
- }
-
- /**
- * Returns the content assist processor for the content
- * type of the specified document position.
- *
- * @param contentAssistSubject the content assist subject
- * @param offset a offset within the document
- * @return a content-assist processor or <code>null</code> if none exists
- */
- private IContentAssistProcessor getProcessor(IContentAssistSubject contentAssistSubject, int offset) {
- try {
-
- IDocument document= contentAssistSubject.getDocument();
- String type;
- if (document != null)
- type= TextUtilities.getContentType(document, getDocumentPartitioning(), offset);
- else
- type= IDocument.DEFAULT_CONTENT_TYPE;
-
- return getContentAssistProcessor(type);
-
- } catch (BadLocationException x) {
- }
-
- return null;
- }
-
- /**
- * Returns an array of completion proposals computed based on
- * the specified document position. The position is used to
- * determine the appropriate content assist processor to invoke.
- *
- * @param contentAssistSubject the content assit subject
- * @param position a document position
- * @return an array of completion proposals
- *
- * @see IContentAssistProcessor#computeCompletionProposals
- */
- ICompletionProposal[] computeCompletionProposals(IContentAssistSubject contentAssistSubject, int position) {
- fLastErrorMessage= null;
-
- ICompletionProposal[] result= null;
-
- IContentAssistProcessor p= getProcessor(contentAssistSubject, position);
- if (p instanceof IContentAssistProcessorExtension) {
- result= ((IContentAssistProcessorExtension)p).computeCompletionProposals(contentAssistSubject, position);
- fLastErrorMessage= p.getErrorMessage();
- }
-
- return result;
- }
-
- /**
- * Returns an array of completion proposals computed based on
- * the specified document position. The position is used to
- * determine the appropriate content assist processor to invoke.
- *
- * @param viewer the viewer for which to compute the prosposals
- * @param position a document position
- * @return an array of completion proposals
- *
- * @see IContentAssistProcessor#computeCompletionProposals
- */
- ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int position) {
- fLastErrorMessage= null;
-
- ICompletionProposal[] result= null;
-
- IContentAssistProcessor p= getProcessor(viewer, position);
- if (p != null) {
- result= p.computeCompletionProposals(viewer, position);
- fLastErrorMessage= p.getErrorMessage();
- }
-
- return result;
- }
-
- /**
- * Returns an array of context information objects computed based
- * on the specified document position. The position is used to determine
- * the appropriate content assist processor to invoke.
- *
- * @param viewer the viewer for which to compute the context information
- * @param position a document position
- * @return an array of context information objects
- *
- * @see IContentAssistProcessor#computeContextInformation
- */
- IContextInformation[] computeContextInformation(ITextViewer viewer, int position) {
- fLastErrorMessage= null;
-
- IContextInformation[] result= null;
-
- IContentAssistProcessor p= getProcessor(viewer, position);
- if (p != null) {
- result= p.computeContextInformation(viewer, position);
- fLastErrorMessage= p.getErrorMessage();
- }
-
- return result;
- }
-
- /**
- * Returns an array of context information objects computed based
- * on the specified document position. The position is used to determine
- * the appropriate content assist processor to invoke.
- *
- * @param contentAssistSubject the content assit subject
- * @param position a document position
- * @return an array of context information objects
- *
- * @see IContentAssistProcessor#computeContextInformation
- */
- IContextInformation[] computeContextInformation(IContentAssistSubject contentAssistSubject, int position) {
- fLastErrorMessage= null;
-
- IContextInformation[] result= null;
-
- IContentAssistProcessor p= getProcessor(contentAssistSubject, position);
- if (p instanceof IContentAssistProcessorExtension) {
- result= ((IContentAssistProcessorExtension)p).computeContextInformation(contentAssistSubject, position);
- fLastErrorMessage= p.getErrorMessage();
- }
-
- return result;
- }
-
- /**
- * Returns the context information validator that should be used to
- * determine when the currently displayed context information should
- * be dismissed. The position is used to determine the appropriate
- * content assist processor to invoke.
- *
- * @param viewer the text viewer
- * @param offset a document offset
- * @return an validator
- *
- * @see IContentAssistProcessor#getContextInformationValidator
- */
- IContextInformationValidator getContextInformationValidator(ITextViewer viewer, int offset) {
- IContentAssistProcessor p= getProcessor(viewer, offset);
- return p != null ? p.getContextInformationValidator() : null;
- }
-
- /**
- * Returns the context information validator that should be used to
- * determine when the currently displayed context information should
- * be dismissed. The position is used to determine the appropriate
- * content assist processor to invoke.
- *
- * @param contentAssistSubject the content assist subject
- * @param offset a document offset
- * @return an validator
- * @see IContentAssistProcessor#getContextInformationValidator
- * @since 3.0
- */
- IContextInformationValidator getContextInformationValidator(IContentAssistSubject contentAssistSubject, int offset) {
- IContentAssistProcessor p= getProcessor(contentAssistSubject, offset);
- return p != null ? p.getContextInformationValidator() : null;
- }
-
- /**
- * Returns the context information presenter that should be used to
- * display context information. The position is used to determine the appropriate
- * content assist processor to invoke.
- *
- * @param viewer the text viewer
- * @param offset a document offset
- * @return a presenter
- * @since 2.0
- */
- IContextInformationPresenter getContextInformationPresenter(ITextViewer viewer, int offset) {
- IContextInformationValidator validator= getContextInformationValidator(viewer, offset);
- if (validator instanceof IContextInformationPresenter)
- return (IContextInformationPresenter) validator;
- return null;
- }
-
- /**
- * Returns the context information presenter that should be used to
- * display context information. The position is used to determine the appropriate
- * content assist processor to invoke.
- *
- * @param contentAssistSubject the content assist subject
- * @param offset a document offset
- * @return a presenter
- * @since 3.0
- */
- IContextInformationPresenter getContextInformationPresenter(IContentAssistSubject contentAssistSubject, int offset) {
- IContextInformationValidator validator= getContextInformationValidator(contentAssistSubject, offset);
- if (validator instanceof IContextInformationPresenter)
- return (IContextInformationPresenter) validator;
- return null;
- }
-
- /**
- * Returns the characters which when typed by the user should automatically
- * initiate proposing completions. The position is used to determine the
- * appropriate content assist processor to invoke.
- *
- * @param contentAssistSubject the content assist subject
- * @param offset a document offset
- * @return the auto activation characters
- * @see IContentAssistProcessor#getCompletionProposalAutoActivationCharacters
- * @since 3.0
- */
- char[] getCompletionProposalAutoActivationCharacters(IContentAssistSubject contentAssistSubject, int offset) {
- IContentAssistProcessor p= getProcessor(contentAssistSubject, offset);
- return p != null ? p.getCompletionProposalAutoActivationCharacters() : null;
- }
-
- /**
- * Returns the characters which when typed by the user should automatically
- * initiate proposing completions. The position is used to determine the
- * appropriate content assist processor to invoke.
- *
- * @param viewer the text viewer
- * @param offset a document offset
- * @return the auto activation characters
- *
- * @see IContentAssistProcessor#getCompletionProposalAutoActivationCharacters
- */
- char[] getCompletionProposalAutoActivationCharacters(ITextViewer viewer, int offset) {
- IContentAssistProcessor p= getProcessor(viewer, offset);
- return p != null ? p.getCompletionProposalAutoActivationCharacters() : null;
- }
-
- /**
- * Returns the characters which when typed by the user should automatically
- * initiate the presentation of context information. The position is used
- * to determine the appropriate content assist processor to invoke.
- *
- * @param viewer the text viewer
- * @param offset a document offset
- * @return the auto activation characters
- *
- * @see IContentAssistProcessor#getContextInformationAutoActivationCharacters
- */
- char[] getContextInformationAutoActivationCharacters(ITextViewer viewer, int offset) {
- IContentAssistProcessor p= getProcessor(viewer, offset);
- return p != null ? p.getContextInformationAutoActivationCharacters() : null;
- }
-
- /**
- * Returns the characters which when typed by the user should automatically
- * initiate the presentation of context information. The position is used
- * to determine the appropriate content assist processor to invoke.
- *
- * @param contentAssistSubject the content assist subject
- * @param offset a document offset
- * @return the auto activation characters
- *
- * @see IContentAssistProcessor#getContextInformationAutoActivationCharacters
- */
- char[] getContextInformationAutoActivationCharacters(IContentAssistSubject contentAssistSubject, int offset) {
- IContentAssistProcessor p= getProcessor(contentAssistSubject, offset);
- return p != null ? p.getContextInformationAutoActivationCharacters() : null;
- }
-
- /*
- * @see org.eclipse.jface.text.IWidgetTokenKeeper#requestWidgetToken(IWidgetTokenOwner)
- * @since 2.0
- */
- public boolean requestWidgetToken(IWidgetTokenOwner owner) {
- return false;
- }
-
- /*
- * @see org.eclipse.jface.text.IWidgetTokenKeeperExtension#requestWidgetToken(org.eclipse.jface.text.IWidgetTokenOwner, int)
- * @since 3.0
- */
- public boolean requestWidgetToken(IWidgetTokenOwner owner, int priority) {
- if (priority > WIDGET_PRIORITY) {
- hide();
- return true;
- } else {
- return false;
- }
- }
-
- /*
- * @see org.eclipse.jface.text.IWidgetTokenKeeperExtension#setFocus(org.eclipse.jface.text.IWidgetTokenOwner)
- * @since 3.0
- */
- public boolean setFocus(IWidgetTokenOwner owner) {
- if (fProposalPopup != null) {
- fProposalPopup.setFocus();
- return fProposalPopup.hasFocus();
- }
- return false;
- }
-
- /**
- * Hides any open popups.
- */
- protected void hide() {
- if (fProposalPopup != null)
- fProposalPopup.hide();
-
- if (fContextInfoPopup != null)
- fContextInfoPopup.hide();
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformation.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformation.java
deleted file mode 100644
index 99319642415..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformation.java
+++ /dev/null
@@ -1,96 +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.contentassist;
-
-
-import org.eclipse.swt.graphics.Image;
-
-import org.eclipse.jface.text.Assert;
-
-
-
-/**
- * A default implementation of the <code>IContextInformation</code> interface.
- */
-public final class ContextInformation implements IContextInformation {
-
- /** The name of the context */
- private String fContextDisplayString;
- /** The information to be displayed */
- private String fInformationDisplayString;
- /** The image to be displayed */
- private Image fImage;
-
- /**
- * Creates a new context information without an image.
- *
- * @param contextDisplayString the string to be used when presenting the context
- * @param informationDisplayString the string to be displayed when presenting the context information
- */
- public ContextInformation(String contextDisplayString, String informationDisplayString) {
- this(null, contextDisplayString, informationDisplayString);
- }
-
- /**
- * Creates a new context information with an image.
- *
- * @param image the image to display when presenting the context information
- * @param contextDisplayString the string to be used when presenting the context
- * @param informationDisplayString the string to be displayed when presenting the context information,
- * may not be <code>null</code>
- */
- public ContextInformation(Image image, String contextDisplayString, String informationDisplayString) {
-
- Assert.isNotNull(informationDisplayString);
-
- fImage= image;
- fContextDisplayString= contextDisplayString;
- fInformationDisplayString= informationDisplayString;
- }
-
- /*
- * @see IContextInformation#equals(Object)
- */
- public boolean equals(Object object) {
- if (object instanceof IContextInformation) {
- IContextInformation contextInformation= (IContextInformation) object;
- boolean equals= fInformationDisplayString.equalsIgnoreCase(contextInformation.getInformationDisplayString());
- if (fContextDisplayString != null)
- equals= equals && fContextDisplayString.equalsIgnoreCase(contextInformation.getContextDisplayString());
- return equals;
- }
- return false;
- }
-
- /*
- * @see IContextInformation#getInformationDisplayString()
- */
- public String getInformationDisplayString() {
- return fInformationDisplayString;
- }
-
- /*
- * @see IContextInformation#getImage()
- */
- public Image getImage() {
- return fImage;
- }
-
- /*
- * @see IContextInformation#getContextDisplayString()
- */
- public String getContextDisplayString() {
- if (fContextDisplayString != null)
- return fContextDisplayString;
- return fInformationDisplayString;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.java
deleted file mode 100644
index 68d46876661..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.java
+++ /dev/null
@@ -1,674 +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.contentassist;
-
-
-import java.util.Stack;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.events.VerifyEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.TextPresentation;
-
-
-/**
- * This class is used to present context information to the user.
- * If multiple contexts are valid at the current cursor location,
- * a list is presented from which the user may choose one context.
- * Once the user makes their choice, or if there was only a single
- * possible context, the context information is shown in a tooltip like popup. <p>
- * If the tooltip is visible and the user wants to see context information of
- * a context embedded into the one for which context information is displayed,
- * context information for the embedded context is shown. As soon as the
- * cursor leaves the embedded context area, the context information for
- * the embedding context is shown again.
- *
- * @see IContextInformation
- * @see IContextInformationValidator
- */
-class ContextInformationPopup implements IContentAssistListener {
-
-
-
- /**
- * Represents the state necessary for embedding contexts.
- * @since 2.0
- */
- static class ContextFrame {
- public int fBeginOffset;
- public int fOffset;
- public int fVisibleOffset;
- public IContextInformation fInformation;
- public IContextInformationValidator fValidator;
- public IContextInformationPresenter fPresenter;
- }
-
- private ITextViewer fViewer;
- private ContentAssistant fContentAssistant;
-
- private PopupCloser fPopupCloser= new PopupCloser();
- private Shell fContextSelectorShell;
- private Table fContextSelectorTable;
- private IContextInformation[] fContextSelectorInput;
- private String fLineDelimiter= null;
-
- private Shell fContextInfoPopup;
- private StyledText fContextInfoText;
- private TextPresentation fTextPresentation;
-
- private Stack fContextFrameStack= new Stack();
- /**
- * The content assist subjects.
- *
- * @since 3.0
- */
- private IContentAssistSubject fContentAssistSubject;
- /**
- * The content assist subject adapter.
- *
- * @since 3.0
- */
- private ContentAssistSubjectAdapter fContentAssistSubjectAdapter;
-
- /**
- * Selection listener on the text widget which is active
- * while a context information pop up is shown.
- *
- * @since 3.0
- */
- private SelectionListener fTextWidgetSelectionListener;
-
- /**
- * Creates a new context information popup.
- *
- * @param contentAssistant the content assist for computing the context information
- * @param viewer the viewer on top of which the context information is shown
- */
- public ContextInformationPopup(ContentAssistant contentAssistant, ITextViewer viewer) {
- fContentAssistant= contentAssistant;
- fViewer= viewer;
- fContentAssistSubjectAdapter= new ContentAssistSubjectAdapter(fViewer);
- }
-
- /**
- * Creates a new context information popup.
- *
- * @param contentAssistant the content assist for computing the context information
- * @param contentAssistSubject the content assist subject on top of which the context information is shown
- * @since 3.0
- */
- public ContextInformationPopup(ContentAssistant contentAssistant, IContentAssistSubject contentAssistSubject) {
- fContentAssistant= contentAssistant;
- fContentAssistSubject= contentAssistSubject;
- fContentAssistSubjectAdapter= new ContentAssistSubjectAdapter(fContentAssistSubject);
- }
-
- /**
- * Shows all possible contexts for the given cursor position of the viewer.
- *
- * @param autoActivated <code>true</code> if auto activated
- * @return a potential error message or <code>null</code> in case of no error
- */
- public String showContextProposals(final boolean autoActivated) {
- final Control control= fContentAssistSubjectAdapter.getControl();
- BusyIndicator.showWhile(control.getDisplay(), new Runnable() {
- public void run() {
-
- int position= fContentAssistSubjectAdapter.getSelectedRange().x;
-
- IContextInformation[] contexts= computeContextInformation(position);
- int count = (contexts == null ? 0 : contexts.length);
- if (count == 1) {
-
- // Show context information directly
- internalShowContextInfo(contexts[0], position);
-
- } else if (count > 0) {
- // Precise context must be selected
-
- if (fLineDelimiter == null)
- fLineDelimiter= fContentAssistSubjectAdapter.getLineDelimiter();
-
- createContextSelector();
- setContexts(contexts);
- displayContextSelector();
- hideContextInfoPopup();
-
- } else if (!autoActivated) {
- control.getDisplay().beep();
- }
- }
- });
-
- return getErrorMessage();
- }
-
- /**
- * Displays the given context information for the given offset.
- *
- * @param info the context information
- * @param position the offset
- * @since 2.0
- */
- public void showContextInformation(final IContextInformation info, final int position) {
- Control control= fContentAssistSubjectAdapter.getControl();
- BusyIndicator.showWhile(control.getDisplay(), new Runnable() {
- public void run() {
- internalShowContextInfo(info, position);
- hideContextSelector();
- }
- });
- }
-
- /**
- * Displays the given context information for the given offset.
- *
- * @param info the context information
- * @param position the offset
- * @since 2.0
- */
-
- private void internalShowContextInfo(IContextInformation information, int offset) {
-
- IContextInformationValidator validator= fContentAssistSubjectAdapter.getContextInformationValidator(fContentAssistant, offset);
-
- if (validator != null) {
- ContextFrame current= new ContextFrame();
- current.fInformation= information;
- current.fBeginOffset= (information instanceof IContextInformationExtension) ? ((IContextInformationExtension) information).getContextInformationPosition() : offset;
- if (current.fBeginOffset == -1) current.fBeginOffset= offset;
- current.fOffset= offset;
- current.fVisibleOffset= fContentAssistSubjectAdapter.getWidgetSelectionRange().x - (offset - current.fBeginOffset);
- current.fValidator= validator;
- current.fPresenter= fContentAssistSubjectAdapter.getContextInformationPresenter(fContentAssistant, offset);
-
- fContextFrameStack.push(current);
-
- internalShowContextFrame(current, fContextFrameStack.size() == 1);
- }
- }
-
- /**
- * Shows the given context frame.
- *
- * @param frame the frane to display
- * @param initial <code>true</code> if this is the first frame to be displayed
- * @since 2.0
- */
- private void internalShowContextFrame(ContextFrame frame, boolean initial) {
-
- fContentAssistSubjectAdapter.installValidator(frame);
-
- if (frame.fPresenter != null) {
- if (fTextPresentation == null)
- fTextPresentation= new TextPresentation();
- fContentAssistSubjectAdapter.installContextInformationPresenter(frame);
- frame.fPresenter.updatePresentation(frame.fOffset, fTextPresentation);
- }
-
- createContextInfoPopup();
-
- fContextInfoText.setText(frame.fInformation.getInformationDisplayString());
- if (fTextPresentation != null)
- TextPresentation.applyTextPresentation(fTextPresentation, fContextInfoText);
- resize();
-
- if (initial) {
- if (fContentAssistant.addContentAssistListener(this, ContentAssistant.CONTEXT_INFO_POPUP)) {
- if (fContentAssistSubjectAdapter.getControl() != null) {
- fTextWidgetSelectionListener= new SelectionAdapter() {
- /*
- * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
- */
- public void widgetSelected(SelectionEvent e) {
- validateContextInformation();
- }};
- fContentAssistSubjectAdapter.addSelectionListener(fTextWidgetSelectionListener);
- }
- fContentAssistant.addToLayout(this, fContextInfoPopup, ContentAssistant.LayoutManager.LAYOUT_CONTEXT_INFO_POPUP, frame.fVisibleOffset);
- fContextInfoPopup.setVisible(true);
- }
- } else {
- fContentAssistant.layout(ContentAssistant.LayoutManager.LAYOUT_CONTEXT_INFO_POPUP, frame.fVisibleOffset);
- }
- }
-
- /**
- * Computes all possible context information for the given offset.
- *
- * @param position the offset
- * @return all possible context information for the given offset
- * @since 2.0
- */
- private IContextInformation[] computeContextInformation(int position) {
- return fContentAssistSubjectAdapter.computeContextInformation(fContentAssistant, position);
- }
-
- /**
- *Returns the error message generated while computing context information.
- *
- * @return the error message
- */
- private String getErrorMessage() {
- return fContentAssistant.getErrorMessage();
- }
-
- /**
- * Creates the context information popup. This is the tooltip like overlay window.
- */
- private void createContextInfoPopup() {
- if (Helper.okToUse(fContextInfoPopup))
- return;
-
- Control control= fContentAssistSubjectAdapter.getControl();
- Display display= control.getDisplay();
-
- fContextInfoPopup= new Shell(control.getShell(), SWT.NO_TRIM | SWT.ON_TOP);
- fContextInfoPopup.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
-
- fContextInfoText= new StyledText(fContextInfoPopup, SWT.MULTI | SWT.READ_ONLY);
-
- Color c= fContentAssistant.getContextInformationPopupBackground();
- if (c == null)
- c= display.getSystemColor(SWT.COLOR_INFO_BACKGROUND);
- fContextInfoText.setBackground(c);
-
- c= fContentAssistant.getContextInformationPopupForeground();
- if (c == null)
- c= display.getSystemColor(SWT.COLOR_INFO_FOREGROUND);
- fContextInfoText.setForeground(c);
- }
-
- /**
- * Resizes the context information popup.
- * @since 2.0
- */
- private void resize() {
- Point size= fContextInfoText.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
- size.x += 3;
- fContextInfoText.setSize(size);
- fContextInfoText.setLocation(1,1);
- size.x += 2;
- size.y += 2;
- fContextInfoPopup.setSize(size);
- }
-
- /**
- *Hides the context information popup.
- */
- private void hideContextInfoPopup() {
-
- if (Helper.okToUse(fContextInfoPopup)) {
-
- int size= fContextFrameStack.size();
- if (size > 0) {
- fContextFrameStack.pop();
- -- size;
- }
-
- if (size > 0) {
- ContextFrame current= (ContextFrame) fContextFrameStack.peek();
- internalShowContextFrame(current, false);
- } else {
-
- fContentAssistant.removeContentAssistListener(this, ContentAssistant.CONTEXT_INFO_POPUP);
-
- if (fContentAssistSubjectAdapter.getControl() != null)
- fContentAssistSubjectAdapter.removeSelectionListener(fTextWidgetSelectionListener);
- fTextWidgetSelectionListener= null;
-
- fContextInfoPopup.setVisible(false);
- fContextInfoPopup.dispose();
- fContextInfoPopup= null;
-
- if (fTextPresentation != null) {
- fTextPresentation.clear();
- fTextPresentation= null;
- }
- }
- }
-
- if (fContextInfoPopup == null)
- fContentAssistant.contextInformationClosed();
- }
-
- /**
- * Creates the context selector in case the user has the choice between multiple valid contexts
- * at a given offset.
- */
- private void createContextSelector() {
- if (Helper.okToUse(fContextSelectorShell))
- return;
-
- Control control= fContentAssistSubjectAdapter.getControl();
- fContextSelectorShell= new Shell(control.getShell(), SWT.NO_TRIM | SWT.ON_TOP);
- fContextSelectorTable= new Table(fContextSelectorShell, SWT.H_SCROLL | SWT.V_SCROLL);
-
- int height= fContextSelectorTable.getItemHeight() * 10;
- fContextSelectorShell.setSize(302, height + 2);
- fContextSelectorTable.setSize(300, height);
- fContextSelectorTable.setLocation(1, 1);
-
- fContextSelectorShell.setBackground(control.getDisplay().getSystemColor(SWT.COLOR_BLACK));
-
- Color c= fContentAssistant.getContextSelectorBackground();
- if (c == null)
- c= control.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND);
- fContextSelectorTable.setBackground(c);
-
- c= fContentAssistant.getContextSelectorForeground();
- if (c == null)
- c= control.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND);
- fContextSelectorTable.setForeground(c);
-
- fContextSelectorTable.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- insertSelectedContext();
- hideContextSelector();
- }
- });
-
- fPopupCloser.install(fContentAssistant, fContextSelectorTable);
-
- fContextSelectorTable.setHeaderVisible(false);
- fContentAssistant.addToLayout(this, fContextSelectorShell, ContentAssistant.LayoutManager.LAYOUT_CONTEXT_SELECTOR, fContentAssistant.getSelectionOffset());
- }
-
- /**
- * Causes the context information of the context selected in the context selector
- * to be displayed in the context information popup.
- */
- private void insertSelectedContext() {
- int i= fContextSelectorTable.getSelectionIndex();
-
- if (i < 0 || i >= fContextSelectorInput.length)
- return;
-
- int position= fContentAssistSubjectAdapter.getSelectedRange().x;
- internalShowContextInfo(fContextSelectorInput[i], position);
- }
-
- /**
- * Sets the contexts in the context selector to the given set.
- *
- * @param contexts the possible contexts
- */
- private void setContexts(IContextInformation[] contexts) {
- if (Helper.okToUse(fContextSelectorTable)) {
-
- fContextSelectorInput= contexts;
-
- fContextSelectorTable.setRedraw(false);
- fContextSelectorTable.removeAll();
-
- TableItem item;
- IContextInformation t;
- for (int i= 0; i < contexts.length; i++) {
- t= contexts[i];
- item= new TableItem(fContextSelectorTable, SWT.NULL);
- if (t.getImage() != null)
- item.setImage(t.getImage());
- item.setText(t.getContextDisplayString());
- }
-
- fContextSelectorTable.select(0);
- fContextSelectorTable.setRedraw(true);
- }
- }
-
- /**
- * Displays the context selector.
- */
- private void displayContextSelector() {
- if (fContentAssistant.addContentAssistListener(this, ContentAssistant.CONTEXT_SELECTOR))
- fContextSelectorShell.setVisible(true);
- }
-
- /**
- * Hodes the context selector.
- */
- private void hideContextSelector() {
- if (Helper.okToUse(fContextSelectorShell)) {
- fContentAssistant.removeContentAssistListener(this, ContentAssistant.CONTEXT_SELECTOR);
-
- fPopupCloser.uninstall();
- fContextSelectorShell.setVisible(false);
- fContextSelectorShell.dispose();
- fContextSelectorShell= null;
- }
-
- if (!Helper.okToUse(fContextInfoPopup))
- fContentAssistant.contextInformationClosed();
- }
-
- /**
- *Returns whether the context selector has the focus.
- *
- * @return <code>true</code> if teh context selector has the focus
- */
- public boolean hasFocus() {
- if (Helper.okToUse(fContextSelectorShell))
- return (fContextSelectorShell.isFocusControl() || fContextSelectorTable.isFocusControl());
-
- return false;
- }
-
- /**
- * Hides context selector and context information popup.
- */
- public void hide() {
- hideContextSelector();
- hideContextInfoPopup();
- }
-
- /**
- * Returns whether this context information popup is active. I.e., either
- * a context selector or context information is displayed.
- *
- * @return <code>true</code> if the context selector is active
- */
- public boolean isActive() {
- return (Helper.okToUse(fContextInfoPopup) || Helper.okToUse(fContextSelectorShell));
- }
-
- /*
- * @see IContentAssistListener#verifyKey(VerifyEvent)
- */
- public boolean verifyKey(VerifyEvent e) {
- if (Helper.okToUse(fContextSelectorShell))
- return contextSelectorKeyPressed(e);
- if (Helper.okToUse(fContextInfoPopup))
- return contextInfoPopupKeyPressed(e);
- return true;
- }
-
- /**
- * Processes a key stroke in the context selector.
- *
- * @param e the verify event describing the key stroke
- * @return <code>true</code> if processing can be stopped
- */
- private boolean contextSelectorKeyPressed(VerifyEvent e) {
-
- char key= e.character;
- if (key == 0) {
-
- int change;
- int visibleRows= (fContextSelectorTable.getSize().y / fContextSelectorTable.getItemHeight()) - 1;
- int selection= fContextSelectorTable.getSelectionIndex();
-
- switch (e.keyCode) {
-
- case SWT.ARROW_UP:
- change= (fContextSelectorTable.getSelectionIndex() > 0 ? -1 : 0);
- break;
-
- case SWT.ARROW_DOWN:
- change= (fContextSelectorTable.getSelectionIndex() < fContextSelectorTable.getItemCount() - 1 ? 1 : 0);
- break;
-
- case SWT.PAGE_DOWN :
- change= visibleRows;
- if (selection + change >= fContextSelectorTable.getItemCount())
- change= fContextSelectorTable.getItemCount() - selection;
- break;
-
- case SWT.PAGE_UP :
- change= -visibleRows;
- if (selection + change < 0)
- change= -selection;
- break;
-
- case SWT.HOME :
- change= -selection;
- break;
-
- case SWT.END :
- change= fContextSelectorTable.getItemCount() - selection;
- break;
-
- default:
- if (e.keyCode != SWT.MOD1 && e.keyCode != SWT.MOD2 && e.keyCode != SWT.MOD3 && e.keyCode != SWT.MOD4)
- hideContextSelector();
- return true;
- }
-
- fContextSelectorTable.setSelection(selection + change);
- fContextSelectorTable.showSelection();
- e.doit= false;
- return false;
-
- } else if ('\t' == key) {
- // switch focus to selector shell
- e.doit= false;
- fContextSelectorShell.setFocus();
- return false;
- } else if (key == 0x1B) {
- // terminate on Esc
- hideContextSelector();
- }
-
- return true;
- }
-
- /**
- * Processes a key stroke while the info popup is up.
- *
- * @param e the verify event describing the key stroke
- * @return <code>true</code> if processing can be stopped
- */
- private boolean contextInfoPopupKeyPressed(KeyEvent e) {
-
- char key= e.character;
- if (key == 0) {
-
- switch (e.keyCode) {
-
- case SWT.ARROW_LEFT:
- case SWT.ARROW_RIGHT:
- validateContextInformation();
- break;
- default:
- if (e.keyCode != SWT.MOD1 && e.keyCode != SWT.MOD2 && e.keyCode != SWT.MOD3 && e.keyCode != SWT.MOD4)
- hideContextInfoPopup();
- break;
- }
-
- } else if (key == 0x1B) {
- // terminate on Esc
- hideContextInfoPopup();
- } else {
- validateContextInformation();
- }
- return true;
- }
-
- /*
- * @see IEventConsumer#processEvent(VerifyEvent)
- */
- public void processEvent(VerifyEvent event) {
- if (Helper.okToUse(fContextSelectorShell))
- contextSelectorProcessEvent(event);
- if (Helper.okToUse(fContextInfoPopup))
- contextInfoPopupProcessEvent(event);
- }
-
- /**
- * Processes a key stroke in the context selector.
- *
- * @param e the verify event describing the key stroke
- */
- private void contextSelectorProcessEvent(VerifyEvent e) {
-
- if (e.start == e.end && e.text != null && e.text.equals(fLineDelimiter)) {
- e.doit= false;
- insertSelectedContext();
- }
-
- hideContextSelector();
- }
-
- /**
- * Processes a key stroke while the info popup is up.
- *
- * @param e the verify event describing the key stroke
- */
- private void contextInfoPopupProcessEvent(VerifyEvent e) {
- if (e.start != e.end && (e.text == null || e.text.length() == 0))
- validateContextInformation();
- }
-
- /**
- * Validates the context information for the viewer's actual cursor position.
- */
- private void validateContextInformation() {
- /*
- * Post the code in the event queue in order to ensure that the
- * action described by this verify key event has already beed executed.
- * Otherwise, we'd validate the context information based on the
- * pre-key-stroke state.
- */
- fContextInfoPopup.getDisplay().asyncExec(new Runnable() {
-
- private ContextFrame fFrame= (ContextFrame) fContextFrameStack.peek();
-
- public void run() {
- if (Helper.okToUse(fContextInfoPopup) && fFrame == fContextFrameStack.peek()) {
- int offset= fContentAssistSubjectAdapter.getSelectedRange().x;
- if (fFrame.fValidator == null || !fFrame.fValidator.isContextInformationValid(offset)) {
- hideContextInfoPopup();
- } else if (fFrame.fPresenter != null && fFrame.fPresenter.updatePresentation(offset, fTextPresentation)) {
- TextPresentation.applyTextPresentation(fTextPresentation, fContextInfoText);
- resize();
- }
- }
- }
- });
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationValidator.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationValidator.java
deleted file mode 100644
index 79d11178591..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationValidator.java
+++ /dev/null
@@ -1,80 +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.contentassist;
-
-
-
-import org.eclipse.jface.text.ITextViewer;
-
-
-/**
- * A default implementation of the <code>IContextInfomationValidator</code> interface.
- * This implementation determines whether the information is valid by asking the content
- * assist processor for all context information objects for the current position. If the
- * currently displayed information is in the result set, the context information is
- * considered valid.
- */
-public final class ContextInformationValidator implements IContextInformationValidator, IContextInformationValidatorExtension {
-
- /** The content assist processor */
- private IContentAssistProcessor fProcessor;
- /** The context information to be validated */
- private IContextInformation fContextInformation;
- /** The associated text viewer */
- private ITextViewer fViewer;
- /**
- * The content assist subject.
- *
- * @since 3.0
- */
- private IContentAssistSubject fContentAssistSubject;
-
- /**
- * Creates a new context information validator which is ready to be installed on
- * a particular context information.
- *
- * @param processor the processor to be used for validation
- */
- public ContextInformationValidator(IContentAssistProcessor processor) {
- fProcessor= processor;
- }
-
- /*
- * @see IContextInformationValidator#install(IContextInformation, ITextViewer, int)
- */
- public void install(IContextInformation contextInformation, ITextViewer viewer, int position) {
- fContextInformation= contextInformation;
- fViewer= viewer;
- }
-
- public void install(IContextInformation contextInformation, IContentAssistSubject contentAssistSubject, int position) {
- fContextInformation= contextInformation;
- fContentAssistSubject= contentAssistSubject;
- }
-
- /*
- * @see IContentAssistTipCloser#isContextInformationValid(int)
- */
- public boolean isContextInformationValid(int position) {
- IContextInformation[] infos= null;
- if (fContentAssistSubject != null) {
- if (fProcessor instanceof IContentAssistProcessorExtension)
- infos= ((IContentAssistProcessorExtension)fProcessor).computeContextInformation(fContentAssistSubject, position);
- } else
- infos= fProcessor.computeContextInformation(fViewer, position);
- if (infos != null && infos.length > 0) {
- for (int i= 0; i < infos.length; i++)
- if (fContextInformation.equals(infos[i]))
- return true;
- }
- return false;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/Helper.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/Helper.java
deleted file mode 100644
index 79fd6b22c04..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/Helper.java
+++ /dev/null
@@ -1,32 +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.contentassist;
-
-
-
-import org.eclipse.swt.widgets.Widget;
-
-
-/**
- * Helper class for testing widget state.
- */
-class Helper {
-
- /**
- * Returns whether the widget is <code>null</code> or disposed.
- *
- * @param widget the widget to check
- * @return <code>true</code> if the widget is neither <code>null</code> nor disposed
- */
- public static boolean okToUse(Widget widget) {
- return (widget != null && !widget.isDisposed());
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposal.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposal.java
deleted file mode 100644
index cbf8ecb3402..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposal.java
+++ /dev/null
@@ -1,87 +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.contentassist;
-
-
-
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-
-import org.eclipse.jface.text.IDocument;
-
-
-/**
- * The interface of completion proposals generated by content assist processors.
- * A completion proposal contains information used to present the proposed completion
- * to the user, to insert the completion should the user select it, and to present
- * context information for the choosen completion once it has been inserted.<p>
- * The interface can be implemented by clients. By default, clients use
- * <code>CompletionProposal</code> as the standard implementer of this interface.
- *
- * @see IContentAssistProcessor
- */
-public interface ICompletionProposal {
-
- /**
- * Inserts the proposed completion into the given document.
- *
- * @param document the document into which to insert the proposed completion
- */
- void apply(IDocument document);
-
- /**
- * Returns the new selection after the proposal has been applied to
- * the given document in absolute document coordinates. If it returns
- * <code>null</code>, no new selection is set.
- *
- * A document change can trigger other document changes, which have
- * to be taken into account when calculating the new selection. Typically,
- * this would be done by installing a document listener or by using a
- * document position during apply().
- *
- * @param document the document into which the proposed completion has been inserted
- * @return the new selection in absolute document coordinates
- */
- Point getSelection(IDocument document);
-
- /**
- * Returns optional additional information about the proposal.
- * The additional information will be presented to assist the user
- * in deciding if the selected proposal is the desired choice.
- *
- * @return the additional information or <code>null</code>
- */
- String getAdditionalProposalInfo();
-
- /**
- * Returns the string to be displayed in the list of completion proposals.
- *
- * @return the string to be displayed
- */
- String getDisplayString();
-
- /**
- * Returns the image to be displayed in the list of completion proposals.
- * The image would typically be shown to the left of the display string.
- *
- * @return the image to be shown or <code>null</code> if no image is desired
- */
- Image getImage();
-
- /**
- * Returns optional context information associated with this proposal.
- * The context information will automatically be shown if the proposal
- * has been applied.
- *
- * @return the context information for this proposal or <code>null</code>
- */
- IContextInformation getContextInformation();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposalExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposalExtension.java
deleted file mode 100644
index 504f47d9350..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposalExtension.java
+++ /dev/null
@@ -1,67 +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.contentassist;
-
-
-import org.eclipse.jface.text.IDocument;
-
-
-/**
- * Extension interface to <code>ICompletionProposal</code>.
- * Add the following functions:
- * <ul>
- * <li> handling of trigger characters other then ENTER
- * <li> completion proposal validation for a given offset
- * <li> freely positionable context information
- * </ul>
- *
- * @since 2.0
- */
-public interface ICompletionProposalExtension {
-
- /**
- * Applies the proposed completion to the given document. The insertion
- * has been triggered by entering the given character at the given offset.
- * This method assumes that <code>isValidFor</code> returns
- * <code>true</code> if called for <code>offset</code>.
- *
- * @param document the document into which to insert the proposed completion
- * @param trigger the trigger to apply the completion
- * @param offset the offset at which the trigger has been activated
- */
- void apply(IDocument document, char trigger, int offset);
-
- /**
- * Returns whether this completion proposal is valid for the given
- * position in the given document.
- *
- * @param document the document for which the proposal is tested
- * @param offset the offset for which the proposal is tested
- */
- boolean isValidFor(IDocument document, int offset);
-
- /**
- * Returns the characters which trigger the application of this completion proposal.
- *
- * @return the completion characters for this completion proposal or <code>null</code>
- * if no completion other than the new line character is possible
- */
- char[] getTriggerCharacters();
-
- /**
- * Returns the position to which the computed context information refers to or
- * <code>-1</code> if no context information can be provided by this completion proposal.
- *
- * @return the position to which the context information refers to or <code>-1</code> for no information
- */
- int getContextInformationPosition();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposalExtension2.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposalExtension2.java
deleted file mode 100644
index eba9b8f2061..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposalExtension2.java
+++ /dev/null
@@ -1,74 +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.contentassist;
-
-
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextViewer;
-
-
-/**
- * Extension interface to <code>ICompletionProposal</code>.
- * Add the following functions:
- * <ul>
- * <li> handling of trigger characters with modifiers
- * <li> visual indication for selection of a proposal
- * </ul>
- *
- * @since 2.1
- */
-public interface ICompletionProposalExtension2 {
-
- /**
- * Applies the proposed completion to the given document. The insertion
- * has been triggered by entering the given character with a modifier at the given offset.
- * This method assumes that <code>isValidFor</code> returns
- * <code>true</code> if called for <code>offset</code>.
- *
- * @param viewer the text viewer into which to insert the proposed completion
- * @param trigger the trigger to apply the completion
- * @param stateMask the state mask of the modifiers
- * @param offset the offset at which the trigger has been activated
- */
- void apply(ITextViewer viewer, char trigger, int stateMask, int offset);
-
- /**
- * Called when the proposal is selected.
- *
- * @param viewer the text viewer.
- * @param smartToggle the smart toggle key was pressed
- */
- void selected(ITextViewer viewer, boolean smartToggle);
-
- /**
- * Called when the proposal is unselected.
- *
- * @param viewer the text viewer.
- */
- void unselected(ITextViewer viewer);
-
- /**
- * Requests the proposal to be validated with respect to the document event.
- * If the proposal cannot be validated, the methods returns <code>false</code>.
- * If the document event was <code>null</code>, only the caret offset was changed, but not the document.
- *
- * This method deprecates ICompletionProposalExtension.isValidFor(IDocument, int)
- *
- * @param document the document
- * @param offset the caret offset
- * @param event the document event, may be <code>null</code>
- * @return boolean
- */
- boolean validate(IDocument document, int offset, DocumentEvent event);
-
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposalExtension3.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposalExtension3.java
deleted file mode 100644
index f00d2517e47..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposalExtension3.java
+++ /dev/null
@@ -1,34 +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.contentassist;
-
-
-import org.eclipse.jface.text.IInformationControlCreator;
-
-
-/**
- * Extension interface to <code>ICompletionProposal</code>.
- * Add the following functions:
- * <ul>
- * <li> provision of a custom information control creator
- * </ul>
- *
- * @since 3.0
- */
-public interface ICompletionProposalExtension3 {
- /**
- * Returns the information control creator of this completion proposal.
- *
- * @return the information control creator
- */
- IInformationControlCreator getInformationControlCreator();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistListener.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistListener.java
deleted file mode 100644
index f688c20ca02..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistListener.java
+++ /dev/null
@@ -1,35 +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.contentassist;
-
-
-
-import org.eclipse.swt.events.VerifyEvent;
-
-import org.eclipse.jface.text.IEventConsumer;
-
-
-
-/**
- * An interface whereby listeners can not only receive key events,
- * but can also consume them to prevent subsequent listeners from
- * processing the event.
- */
-interface IContentAssistListener extends IEventConsumer {
-
- /**
- * Verifies the key event.
- *
- * @return <code>true</code> if processing should be continued by additional listeners
- * @see org.eclipse.swt.custom.VerifyKeyListener#verifyKey(VerifyEvent)
- */
- public boolean verifyKey(VerifyEvent event);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistProcessor.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistProcessor.java
deleted file mode 100644
index 9fb6364a5c8..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistProcessor.java
+++ /dev/null
@@ -1,86 +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.contentassist;
-
-
-
-import org.eclipse.jface.text.ITextViewer;
-
-
-
-/**
- * A content assist processor proposes completions and
- * computes context information for a particular content type.
- * A content assist processor is an <code>IContentAssistant</code>-plug-ins.
- * This interface must be implemented by clients. Implementers should be
- * registered with a content assistant in order to get involved in the
- * assisting process.
-*/
-public interface IContentAssistProcessor {
-
- /**
- * Returns a list of completion proposals based on the
- * specified location within the document that corresponds
- * to the current cursor position within the text viewer.
- *
- * @param viewer the viewer whose document is used to compute the proposals
- * @param documentPosition an offset within the document for which completions should be computed
- * @return an array of completion proposals or <code>null</code> if no proposals are possible
- */
- ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset);
-
- /**
- * Returns information about possible contexts based on the
- * specified location within the document that corresponds
- * to the current cursor position within the text viewer.
- *
- * @param viewer the viewer whose document is used to compute the possible contexts
- * @param documentPosition an offset within the document for which context information should be computed
- * @return an array of context information objects or <code>null</code> if no context could be found
- */
- IContextInformation[] computeContextInformation(ITextViewer viewer, int documentOffset);
-
- /**
- * Returns the characters which when entered by the user should
- * automatically trigger the presentation of possible completions.
- *
- * @return the auto activation characters for completion proposal or <code>null</code>
- * if no auto activation is desired
- */
- char[] getCompletionProposalAutoActivationCharacters();
-
- /**
- * Returns the characters which when entered by the user should
- * automatically trigger the presentation of context information.
- *
- * @return the auto activation characters for presenting context information
- * or <code>null</code> if no auto activation is desired
- */
- char[] getContextInformationAutoActivationCharacters();
-
- /**
- * Returns the reason why this content assist processor
- * was unable to produce any completion proposals or context information.
- *
- * @return an error message or <code>null</code> if no error occurred
- */
- String getErrorMessage();
-
- /**
- * Returns a validator used to determine when displayed context information
- * should be dismissed. May only return <code>null</code> if the processor is
- * incapable of computing context information. <p>
- *
- * @return a context information validator, or <code>null</code> if the processor
- * is incapable of computing context information
- */
- IContextInformationValidator getContextInformationValidator();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistProcessorExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistProcessorExtension.java
deleted file mode 100644
index fe00ee3cd3d..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistProcessorExtension.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.jface.text.contentassist;
-
-/**
- * Extends <code>IContentAssit</code> with the concept of a
- * content assist subject which provides the context for
- * the content assistant.
- * <p>
- * XXX: This is work in progress and can change anytime until API for 3.0 is frozen.
- * </p>
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubject
- * @since 3.0
- */
-public interface IContentAssistProcessorExtension {
- /**
- * Returns a list of completion proposals based on the specified location
- * within the document that corresponds to the current cursor position
- * within the text viewer.
- *
- * @param contentAssistSubject the content assist subject whose
- * document is used to compute the proposals
- * @param documentPosition an offset within the document for which
- * completions should be computed
- * @return an array of completion proposals or <code>null</code> if no
- * proposals are possible
- */
- ICompletionProposal[] computeCompletionProposals(IContentAssistSubject contentAssistSubject, int documentOffset);
-
- /**
- * Returns information about possible contexts based on the specified
- * location within the document that corresponds to the current cursor
- * position within the content assist subject.
- *
- * @param contentAssistSubject the content assist subject whose
- * document is used to compute the possible contexts
- * @param documentPosition an offset within the document for which context
- * information should be computed
- * @return an array of context information objects or <code>null</code>
- * if no context could be found
- */
- IContextInformation[] computeContextInformation(IContentAssistSubject contentAssistSubject, int documentOffset);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistSubject.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistSubject.java
deleted file mode 100644
index d3b62969abc..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistSubject.java
+++ /dev/null
@@ -1,297 +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.contentassist;
-
-import org.eclipse.swt.custom.VerifyKeyListener;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Control;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IEventConsumer;
-
-/**
- * A content assist subject can request assistance provided by a
- * {@link org.eclipse.jface.text.contentassist.IContentAssistant content assistant}.
- * <p>
- * XXX: This is work in progress and can change anytime until API for 3.0 is frozen.
- * </p>
- *
- * @since 3.0
- */
-public interface IContentAssistSubject {
-
- /**
- * Returns the control of this content assist subject.
- *
- * @return the control of this content assist subject
- */
- Control getControl();
-
- /**
- * Returns the line height.
- *
- * @return line height in pixel
- * @exception SWTException
- * <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver</li>
- * </ul>
- */
- int getLineHeight();
-
- /**
- * Returns the caret position relative to the start of the text.
- *
- * @return the caret position relative to the start of the text
- * @exception SWTException
- * <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver</li>
- * </ul>
- */
- int getCaretOffset();
-
- /**
- * Returns the x, y location of the upper left corner of the character
- * bounding box at the specified offset in the text. The point is relative
- * to the upper left corner of the widget client area.
- *
- * @param offset offset relative to the start of the content 0
- * <= offset <= getCharCount()
- * @return x, y location of the upper left corner of the character bounding
- * box at the specified offset in the text
- * @exception SWTException
- * <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver</li>
- * </ul>
- * @exception IllegalArgumentException
- * <ul>
- * <li>ERROR_INVALID_RANGE when the offset is outside the
- * valid range (< 0 or >getCharCount())</li>
- * </ul>
- */
- Point getLocationAtOffset(int offset);
-
- /**
- * Returns the line delimiter used for entering new lines by key down or
- * paste operation.
- *
- * @return line delimiter used for entering new lines by key down or paste
- * operation
- * @exception SWTException
- * <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver</li>
- * </ul>
- */
- String getLineDelimiter();
-
- /**
- * Returns the selected range in the subject's widget.
- *
- * @return start and length of the selection, x is the offset of the
- * @exception SWTException
- * <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver</li>
- * </ul>
- */
- Point getWidgetSelectionRange();
-
- /**
- * Returns the selected range.
- *
- * @return start and length of the selection, x is the offset and y the
- * length based on the subject's model (e.g. document)
- */
- Point getSelectedRange();
-
- /**
- * Sets the selected range. Offset and length based on the subject's
- * model (e.g. document).
- *
- * @param offset the offset of the selection based on the subject's model
- * (e.g. document)
- * @param length the length of the selection based on the subject's model
- * (e.g. document)
- */
- void setSelectedRange(int offset, int length);
-
- /**
- * Reveals the given region. Offset and length based on the subject's
- * model (e.g. document).
- *
- * @param offset the offset of the selection based on the subject's model
- * (e.g. document)
- * @param length the length of the selection based on the subject's model
- * (e.g. document)
- */
- void revealRange(int offset, int length);
-
- /**
- * Returns this content assist subject's document.
- *
- * @return the viewer's input document
- */
- IDocument getDocument();
-
- /**
- * If supported, appends a verify key listener to the viewer's list of verify key
- * listeners. If the listener is already registered with the viewer this
- * call moves the listener to the end of the list.
- * <p>
- * Note: This content assist subject may not support appending a verify
- * listener, in which case <code>false</code> will be returned. If this
- * content assist subject only supports <code>addVerifyKeyListener</code>
- * then this method can be used but <code>prependVerifyKeyListener</code>
- * must return <code>false</code>.
- * </p>
- *
- * @param verifyKeyListener the listener to be added
- * @return <code>true</code> if the listener was added
- */
- boolean appendVerifyKeyListener(VerifyKeyListener verifyKeyListener);
-
- /**
- * If supported, inserts the verify key listener at the beginning of this content assist
- * subject's list of verify key listeners. If the listener is already
- * registered with the viewer this call moves the listener to the beginnng
- * of the list.
- * <p>
- * Note: This content assist subject may not support prepending a verify
- * listener, in which case <code>false</code> will be returned. However,
- * <code>appendVerifyKeyListener</code> might work.
- * </p>
- *
- * @param verifyKeyListener the listener to be inserted
- * @return <code>true</code> if the listener was added
- */
- boolean prependVerifyKeyListener(VerifyKeyListener verifyKeyListener);
-
- /**
- * Removes the verify key listener from this content assist subject's
- * list of verify key listeners. If the listener is not registered, this
- * call has no effect.
- *
- * @param verifyKeyListener the listener to be removed
- */
- void removeVerifyKeyListener(VerifyKeyListener verifyKeyListener);
-
- /**
- * Tests whether a verify key listener can be added either using <code>prependVerifyKeyListener</code>
- * or <code>appendVerifyKeyListener</code>.
- *
- * @return <code>true</code> if adding verify key listeners is supported
- */
- boolean supportsVerifyKeyListener();
-
- /**
- * Adds the listener to the collection of listeners who will be notified
- * when keys are pressed and released on the system keyboard, by sending it
- * one of the messages defined in the <code>KeyListener</code> interface.
- *
- * @param keyListener the listener which should be notified
- *
- * @exception IllegalArgumentException
- * <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException
- * <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver</li>
- * </ul>
- *
- * @see KeyListener
- * @see #removeKeyListener
- */
- void addKeyListener(KeyListener keyListener);
-
- /**
- * Removes the listener from the collection of listeners who will be
- * notified when keys are pressed and released on the system keyboard.
- *
- * @param keyListener the listener which should be notified
- *
- * @exception IllegalArgumentException
- * <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException
- * <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver</li>
- * </ul>
- *
- * @see KeyListener
- * @see #addKeyListener
- */
- void removeKeyListener(KeyListener keyListener);
-
- /**
- * If supported, registers an event consumer with this content assist
- * subject.
- *
- * @param consumer the content assist subject's event consumer. <code>null</code>
- * is a valid argument.
- */
- void setEventConsumer(IEventConsumer eventConsumer);
-
- /**
- * Removes the specified selection listener.
- * <p>
- *
- * @param selectionListener the listener
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT when listener is null</li>
- * </ul>
- */
- void removeSelectionListener(SelectionListener selectionListener);
-
- /**
- * If supported, adds a selection listener. A Selection event is sent by the widget when the
- * selection has changed.
- * <p>
- *
- * @param selectionListener the listener
- * @return <code>true</code> if adding a selection listener is supported
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT when listener is null</li>
- * </ul>
- */
- boolean addSelectionListener(SelectionListener selectionListener);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistant.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistant.java
deleted file mode 100644
index edb152ab5d2..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistant.java
+++ /dev/null
@@ -1,91 +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.contentassist;
-
-
-import org.eclipse.jface.text.ITextViewer;
-
-
-/**
- * An <code>IContentAssistant</code> provides support on interactive content completion.
- * The content assistant is a <code>ITextViewer</code> add-on. Its
- * purpose is to propose, display, and insert completions of the content
- * of the text viewer's document at the viewer's cursor position. In addition
- * to handle completions, a content assistant can also be requested to provide
- * context information. Context information is shown in a tooltip like popup.
- * As it is not always possible to determine the exact context at a given
- * document offset, a content assistant displays the possible contexts and requests
- * the user to choose the one whose information should be displayed.<p>
- * A content assistant has a list of <code>IContentAssistProcessor</code>
- * objects each of which is registered for a particular document content
- * type. The content assistant uses the processors to react on the request
- * of completing documents or presenting context information.<p>
- * The interface can be implemented by clients. By default, clients use
- * <code>ContentAssistant</code> as the standard implementer of this interface.
- *
- * @see ITextViewer
- * @see IContentAssistProcessor
- */
-
- public interface IContentAssistant {
-
- //------ proposal popup orientation styles ------------
- /** The context info list will overlay the list of completion proposals. */
- public final static int PROPOSAL_OVERLAY= 10;
- /** The completion proposal list will be removed before the context info list will be shown. */
- public final static int PROPOSAL_REMOVE= 11;
- /** The context info list will be presented without hiding or overlapping the completion proposal list. */
- public final static int PROPOSAL_STACKED= 12;
-
- //------ context info box orientation styles ----------
- /** Context info will be shown above the location it has been requested for without hiding the location. */
- public final static int CONTEXT_INFO_ABOVE= 20;
- /** Context info will be shown below the location it has been requested for without hiding the location. */
- public final static int CONTEXT_INFO_BELOW= 21;
-
-
- /**
- * Installs content assist support on the given text viewer.
- *
- * @param textViewer the text viewer on which content assist will work
- */
- void install(ITextViewer textViewer);
-
- /**
- * Uninstalls content assist support from the text viewer it has
- * previously be installed on.
- */
- void uninstall();
-
- /**
- * Shows all possible completions of the content at the viewer's cursor position.
- *
- * @return an optional error message if no proposals can be computed
- */
- String showPossibleCompletions();
-
- /**
- * Shows context information for the content at the viewer's cursor position.
- *
- * @return an optional error message if no context information can be computed
- */
- String showContextInformation();
-
- /**
- * Returns the content assist processor to be used for the given content type.
- *
- * @param contentType the type of the content for which this
- * content assistant is to be requested
- * @return an instance content assist processor or
- * <code>null</code> if none exists for the specified content type
- */
- IContentAssistProcessor getContentAssistProcessor(String contentType);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistantExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistantExtension.java
deleted file mode 100644
index e2991595805..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistantExtension.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**********************************************************************
-Copyright (c) 2000, 2003 IBM Corp. 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 implementation
-**********************************************************************/
-package org.eclipse.jface.text.contentassist;
-
-/**
- * Extension interface for <code>IContentAssistant</code>.
- * Updates the content assistant to be aware of documents with multiple partitions.
- *
- * @since 3.0
- */
-public interface IContentAssistantExtension {
-
- /**
- * Returns the document partitioning this content assistant is using.
- *
- * @return the document partitioning this content assistant is using
- */
- String getDocumentPartitioning();
-
- /**
- * Installs content assist support on the given subject.
- * <p>
- * XXX: This is work in progress and can change anytime until API for 3.0 is frozen.
- * </p>
- *
- * @param contentAssistSubject the one who requests content assist
- * @throws UnsupportedOperationException if the content assist does not support this method
- */
- void install(IContentAssistSubject contentAssistSubject);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformation.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformation.java
deleted file mode 100644
index a87158f36ae..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformation.java
+++ /dev/null
@@ -1,63 +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.contentassist;
-
-
-
-import org.eclipse.swt.graphics.Image;
-
-
-/**
- * The inferface of context information presented to the user and
- * generated by content assist processors.
- * The interface can be implemented by clients. By default, clients use
- * <code>ContextInformation</code> as the standard implementer of this interface.
- *
- * @see IContentAssistProcessor
- */
-public interface IContextInformation {
-
- /**
- * Returns the string to be displayed in the list of contexts.
- * This method is used to supply a unique presentation for
- * situations where the context is ambiguous. These strings are
- * used to allow the user to select the specific context.
- *
- * @return the string to be displayed for the context
- */
- String getContextDisplayString();
-
- /**
- * Returns the image for this context information.
- * The image will be shown to the left of the display string.
- *
- * @return the image to be shown or <code>null</code> if no image is desired
- */
- Image getImage();
-
- /**
- * Returns the string to be displayed in the tooltip like information popup.
- *
- * @return the string to be displayed
- */
- String getInformationDisplayString();
-
- /**
- * Compares the given object with this receiver. Two context informations are
- * equal if there information display strings and their context display strings
- * are equal.
- *
- * @see Object#equals(Object)
- */
- boolean equals(Object object);
-}
-
-
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformationExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformationExtension.java
deleted file mode 100644
index 7da3180c894..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformationExtension.java
+++ /dev/null
@@ -1,29 +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.contentassist;
-
-
-/**
- * Extension interface for <code>IContextInformation</code>.
- * Adds the functionality of freely positionable context information.
- *
- * @since 2.0
- */
-public interface IContextInformationExtension {
-
- /**
- * Returns the start offset of the range for which this context information is valid.
- *
- * @return the start offset of the range for which this context information is valid
- */
- int getContextInformationPosition();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformationPresenter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformationPresenter.java
deleted file mode 100644
index f7d60fda861..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformationPresenter.java
+++ /dev/null
@@ -1,47 +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.contentassist;
-
-
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.TextPresentation;
-
-
-/**
- * A context information presenter determines the presentation
- * of context information depending on a given document position.
- * The interface can be implemented by clients.
- *
- * @since 2.0
- */
-public interface IContextInformationPresenter {
-
- /**
- * Installs this presenter for the given context information.
- *
- * @param info the context information which this presenter should style
- * @param viewer the text viewer on which the information is presented
- * @param documentPosition the document position for which the information has been computed
- */
- void install(IContextInformation info, ITextViewer viewer, int documentPosition);
-
- /**
- * Updates the given presentation of the given context information
- * at the given document position. Returns whether update changed the
- * presentation.
- *
- * @param documentPosition the current position within the document
- * @param presentation the presentation to be updated
- * @return <code>true</code> if the given presentation has been changed
- */
- boolean updatePresentation(int documentPosition, TextPresentation presentation);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformationPresenterExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformationPresenterExtension.java
deleted file mode 100644
index 94fae1fd82d..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformationPresenterExtension.java
+++ /dev/null
@@ -1,34 +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.contentassist;
-
-/**
- * Extends <code>IContentAssit</code> with the concept of a
- * content assist subject which provides the context for
- * the content assistant.
- * <p>
- * XXX: This is work in progress and can change anytime until API for 3.0 is frozen.
- * </p>
- *
- * @since 3.0
- */
-public interface IContextInformationPresenterExtension {
-
- /**
- * Installs this presenter for the given context information.
- *
- * @param info the context information which this presenter should style
- * @param contentAssistSubject the content assit subject
- * @param documentPosition the document position for which the information has been computed
- */
- void install(IContextInformation info, IContentAssistSubject contentAssistSubject, int documentPosition);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformationValidator.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformationValidator.java
deleted file mode 100644
index 35cec4ca9b7..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformationValidator.java
+++ /dev/null
@@ -1,44 +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.contentassist;
-
-
-
-import org.eclipse.jface.text.ITextViewer;
-
-
-/**
- * A context information validator is used to determine if
- * a displayed context information is still valid or should
- * be dismissed. The interface can be implemented by clients. <p>
- *
- * @see IContextInformationPresenter
- */
-public interface IContextInformationValidator {
-
- /**
- * Installs this validator for the given context information.
- *
- * @param info the context information which this validator should check
- * @param viewer the text viewer on which the information is presented
- * @param documentPosition the document position for which the information has been computed
- */
- void install(IContextInformation info, ITextViewer viewer, int documentPosition);
-
- /**
- * Returns whether the information this validator is installed on is still valid
- * at the given document position.
- *
- * @param documentPosition the current position within the document
- * @return <code>true</code> if the information also valid at the given document position
- */
- boolean isContextInformationValid(int documentPosition);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformationValidatorExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformationValidatorExtension.java
deleted file mode 100644
index cbbd8e02620..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformationValidatorExtension.java
+++ /dev/null
@@ -1,34 +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.contentassist;
-/**
- * Extends <code>IContentAssit</code> with the concept of a content assist
- * subject which provides the context for the content assistant.
- * <p>
- * XXX: This is work in progress and can change anytime until API for 3.0 is
- * frozen.
- * </p>
- *
- * @since 3.0
- */
-public interface IContextInformationValidatorExtension {
-
- /**
- * Installs this validator for the given context information.
- *
- * @param info the context information which this validator should check
- * @param contentAssistSubject the content assist subject
- * @param documentPosition the document position for which the information
- * has been computed
- */
- void install(IContextInformation info, IContentAssistSubject contentAssistSubject, int documentPosition);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/JFaceTextMessages.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/JFaceTextMessages.java
deleted file mode 100644
index cdc432e9882..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/JFaceTextMessages.java
+++ /dev/null
@@ -1,32 +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.contentassist;
-
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-class JFaceTextMessages {
-
- private static final String RESOURCE_BUNDLE= "org.eclipse.jface.text.JFaceTextMessages";//$NON-NLS-1$
-
- private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
-
- private JFaceTextMessages() {
- }
-
- public static String getString(String key) {
- try {
- return fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/PopupCloser.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/PopupCloser.java
deleted file mode 100644
index c83e35b1a81..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/PopupCloser.java
+++ /dev/null
@@ -1,100 +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.contentassist;
-
-
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.ScrollBar;
-import org.eclipse.swt.widgets.Table;
-
-
-/**
- * A generic closer class used to monitor various
- * interface events in order to determine whether
- * a content assistant should be terminated and all
- * associated windows be closed.
- */
-class PopupCloser implements FocusListener, SelectionListener {
-
- /** The content assistant to be monitored */
- private ContentAssistant fContentAssistant;
- /** The table of a selector popup opened by the content assistant */
- private Table fTable;
- /** The scrollbar of the table for the selector popup */
- private ScrollBar fScrollbar;
- /** Indicates whether the scrollbar thumb has been grabed */
- private boolean fScrollbarClicked= false;
-
- /**
- * Installs this closer on the given table opened by the given content assistant.
- *
- * @param contentAssistant the content assistant
- * @param table the table to be tracked
- */
- public void install(ContentAssistant contentAssistant, Table table) {
- fContentAssistant= contentAssistant;
- fTable= table;
- if (Helper.okToUse(fTable)) {
- fTable.addFocusListener(this);
- fScrollbar= fTable.getVerticalBar();
- if (fScrollbar != null)
- fScrollbar.addSelectionListener(this);
- }
- }
-
- /**
- * Uninstalls this closer if previously installed.
- */
- public void uninstall() {
- if (Helper.okToUse(fScrollbar))
- fScrollbar.removeSelectionListener(this);
- if (Helper.okToUse(fTable))
- fTable.removeFocusListener(this);
- }
-
- /*
- * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
- */
- public void widgetSelected(SelectionEvent e) {
- fScrollbarClicked= true;
- }
-
- /*
- * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
- */
- public void widgetDefaultSelected(SelectionEvent e) {
- fScrollbarClicked= true;
- }
-
- /*
- * @see org.eclipse.swt.events.FocusListener#focusGained(org.eclipse.swt.events.FocusEvent)
- */
- public void focusGained(FocusEvent e) {
- }
-
- /*
- * @see org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt.events.FocusEvent)
- */
- public void focusLost(final FocusEvent e) {
- fScrollbarClicked= false;
- Display d= fTable.getDisplay();
- d.asyncExec(new Runnable() {
- public void run() {
- if (Helper.okToUse(fTable) && !fTable.isFocusControl() && !fScrollbarClicked)
- fContentAssistant.popupFocusLost(e);
- }
- });
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/package.html b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/package.html
deleted file mode 100644
index 2d94dfb3203..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/package.html
+++ /dev/null
@@ -1,25 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="Author" content="IBM">
- <meta name="GENERATOR" content="Mozilla/4.51 [en] (WinNT; I) [Netscape]">
- <title>Package-level Javadoc</title>
-</head>
-<body>
-Provides a content assist add-on for an <tt>ITextViewer</tt>.
-Content assist supports the user in writing&nbsp; by proposing context
-sensitive completions at a given document position. A completion can also
-be a incomplete in itself and content assist provides means to deal with
-nested completions.
-<h2>
-Package Specification</h2>
-<tt>IContentAssistant</tt> defines the concept of the content assist add-on.
-It collaborates with content type specific completion processors (<tt>IContentAssistProcessor</tt>)
-in order to generate completion proposals (<tt>ICompletionProposal</tt>)
-valid at the current document position. The package provides a default
-implementation <tt>ContentAssistant</tt> which completely defines and implements
-the UI and the control flow for content assist.
-<br>&nbsp;
-</body>
-</html>
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContentFormatter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContentFormatter.java
deleted file mode 100644
index 0f354260aaa..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContentFormatter.java
+++ /dev/null
@@ -1,809 +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.formatter;
-
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.ChildDocumentManager;
-import org.eclipse.jface.text.DefaultPositionUpdater;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentExtension3;
-import org.eclipse.jface.text.IPositionUpdater;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.TextUtilities;
-import org.eclipse.jface.text.TypedPosition;
-
-
-/**
- * Standard implementation of <code>IContentFormatter</code>.
- * The formatter supports two operation modi: partition aware and
- * partition unaware. <p>
- * In the partition aware mode, the formatter determines the
- * partitioning of the document region to be formatted. For each
- * partition it determines all document positions which are affected
- * when text changes are applied to the partition. Those which overlap
- * with the partition are remembered as character positions. These
- * character positions are passed over to the formatting strategy
- * registered for the partition's content type. The formatting strategy
- * returns a string containing the formatted document partition as well
- * as the adapted character positions. The formatted partition replaces
- * the old content of the partition. The remembered document postions
- * are updated with the adapted character positions. In addition, all
- * other document positions are accordingly adapted to the formatting
- * changes.<p>
- * In the partition unaware mode, the document's partitioning is ignored
- * and the document is considered consisting of only one partition of
- * the content type <code>IDocument.DEFAULT_CONTENT_TYPE</code>. The
- * formatting process is similar to the partition aware mode, with the
- * exception of having only one partition.<p>
- * Usually, clients instantiate this class and configure it before using it.
- *
- * @see IContentFormatter
- * @see IDocument
- * @see ITypedRegion
- * @see Position
- */
-public class ContentFormatter implements IContentFormatter, IContentFormatterExtension {
-
- /**
- * Defines a reference to either the offset or the end offset of
- * a particular position.
- */
- static class PositionReference implements Comparable {
-
- /** The referenced position */
- protected Position fPosition;
- /** The reference to either the offset or the end offset */
- protected boolean fRefersToOffset;
- /** The original category of the referenced position */
- protected String fCategory;
-
- /**
- * Creates a new position reference.
- *
- * @param position the position to be referenced
- * @param refersToOffset <code>true</code> if position offset should be referenced
- * @param category the categpry the given position belongs to
- */
- protected PositionReference(Position position, boolean refersToOffset, String category) {
- fPosition= position;
- fRefersToOffset= refersToOffset;
- fCategory= category;
- }
-
- /**
- * Returns the offset of the referenced position.
- *
- * @return the offset of the referenced position
- */
- protected int getOffset() {
- return fPosition.getOffset();
- }
-
- /**
- * Manipulates the offset of the referenced position.
- *
- * @param offset the new offset of the referenced position
- */
- protected void setOffset(int offset) {
- fPosition.setOffset(offset);
- }
-
- /**
- * Returns the length of the referenced position.
- *
- * @return the length of the referenced position
- */
- protected int getLength() {
- return fPosition.getLength();
- }
-
- /**
- * Manipulates the length of the referenced position.
- *
- * @param the new length of the referenced position
- */
- protected void setLength(int length) {
- fPosition.setLength(length);
- }
-
- /**
- * Returns whether this reference points to the offset or endoffset
- * of the references position.
- *
- * @return <code>true</code> if the offset of the position is referenced, <code>false</code> otherwise
- */
- protected boolean refersToOffset() {
- return fRefersToOffset;
- }
-
- /**
- * Returns the category of the referenced position.
- *
- * @return the category of the referenced position
- */
- protected String getCategory() {
- return fCategory;
- }
-
- /**
- * Returns the referenced position.
- *
- * @return the referenced position
- */
- protected Position getPosition() {
- return fPosition;
- }
-
- /**
- * Returns the referenced character position
- *
- * @return the referenced character position
- */
- protected int getCharacterPosition() {
- if (fRefersToOffset)
- return getOffset();
- return getOffset() + getLength();
- }
-
- /*
- * @see Comparable#compareTo(Object)
- */
- public int compareTo(Object obj) {
-
- if (obj instanceof PositionReference) {
- PositionReference r= (PositionReference) obj;
- return getCharacterPosition() - r.getCharacterPosition();
- }
-
- throw new ClassCastException();
- }
- }
-
- /**
- * The position updater used to update the remembered partitions.
- *
- * @see IPositionUpdater
- * @see DefaultPositionUpdater
- */
- class NonDeletingPositionUpdater extends DefaultPositionUpdater {
-
- /**
- * Creates a new updater for the given category.
- *
- * @param category the category
- */
- protected NonDeletingPositionUpdater(String category) {
- super(category);
- }
-
- /*
- * @see DefaultPositionUpdater#notDeleted()
- */
- protected boolean notDeleted() {
- return true;
- }
- }
-
- /**
- * The position updater which runs as first updater on the document's positions.
- * Used to remove all affected positions from their categories to avoid them
- * from being regularily updated.
- *
- * @see IPositionUpdater
- */
- class RemoveAffectedPositions implements IPositionUpdater {
- /**
- * @see IPositionUpdater#update(DocumentEvent)
- */
- public void update(DocumentEvent event) {
- removeAffectedPositions(event.getDocument());
- }
- }
-
- /**
- * The position updater which runs as last updater on the document's positions.
- * Used to update all affected positions and adding them back to their
- * original categories.
- *
- * @see IPositionUpdater
- */
- class UpdateAffectedPositions implements IPositionUpdater {
-
- /** The affected positions */
- private int[] fPositions;
- /** The offset */
- private int fOffset;
-
- /**
- * Creates a new updater.
- *
- * @param positions the affected positions
- * @param offset the offset
- */
- public UpdateAffectedPositions(int[] positions, int offset) {
- fPositions= positions;
- fOffset= offset;
- }
-
- /*
- * @see IPositionUpdater#update(DocumentEvent)
- */
- public void update(DocumentEvent event) {
- updateAffectedPositions(event.getDocument(), fPositions, fOffset);
- }
- }
-
-
- /** Internal position category used for the formatter partitioning */
- private final static String PARTITIONING= "__formatter_partitioning"; //$NON-NLS-1$
-
- /** The map of <code>IFormattingStrategy</code> objects */
- private Map fStrategies;
- /** The indicator of whether the formatter operates in partition aware mode or not */
- private boolean fIsPartitionAware= true;
-
- /** The partition information managing document position categories */
- private String[] fPartitionManagingCategories;
- /** The list of references to offset and end offset of all overlapping positions */
- private List fOverlappingPositionReferences;
- /** Position updater used for partitioning positions */
- private IPositionUpdater fPartitioningUpdater;
- /**
- * The document partitioning used by this formatter.
- * @since 3.0
- */
- private String fPartitioning;
- /**
- * The document this formatter works on.
- * @since 3.0
- */
- private IDocument fDocument;
- /**
- * The external partition managing categories.
- * @since 3.0
- */
- private String[] fExternalPartitonManagingCategories;
- /**
- * Indicates whether <code>fPartitionManagingCategories</code> must be computed.
- * @since 3.0
- */
- private boolean fNeedsComputation= true;
-
-
- /**
- * Creates a new content formatter. The content formatter operates by default
- * in the partition-aware mode. There are no preconfigured formatting strategies.
- * Will use the default document partitioning if not further configured.
- */
- public ContentFormatter() {
- fPartitioning= IDocumentExtension3.DEFAULT_PARTITIONING;
- }
-
- /**
- * Registers a strategy for a particular content type. If there is already a strategy
- * registered for this type, the new strategy is registered instead of the old one.
- * If the given content type is <code>null</code> the given strategy is registered for
- * all content types as is called only once per formatting session.
- *
- * @param strategy the formatting strategy to register, or <code>null</code> to remove an existing one
- * @param contentType the content type under which to register, or <code>null</code> for all content types
- */
- public void setFormattingStrategy(IFormattingStrategy strategy, String contentType) {
-
- Assert.isNotNull(contentType);
-
- if (fStrategies == null)
- fStrategies= new HashMap();
-
- if (strategy == null)
- fStrategies.remove(contentType);
- else
- fStrategies.put(contentType, strategy);
- }
-
- /**
- * Informs this content formatter about the names of those position categories
- * which are used to manage the document's partitioning information and thus should
- * be ignored when this formatter updates positions.
- *
- * @param categories the categories to be ignored
- * @deprecated incompatible with an open set of document partitionings. The provided information is only used
- * if this formatter can not compute the partition managing position categories.
- */
- public void setPartitionManagingPositionCategories(String[] categories) {
- fExternalPartitonManagingCategories= categories;
- }
-
- /**
- * Sets the document partitioning to be used by this formatter.
- *
- * @param partitioning the document partitioning
- * @since 3.0
- */
- public void setDocumentPartitioning(String partitioning) {
- fPartitioning= partitioning;
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.IContentFormatterExtension#getDocumentPartitioning()
- * @since 3.0
- */
- public String getDocumentPartitioning() {
- return fPartitioning;
- }
-
- /**
- * Sets the formatter's operation mode.
- *
- * @param enable indicates whether the formatting process should be partition ware
- */
- public void enablePartitionAwareFormatting(boolean enable) {
- fIsPartitionAware= enable;
- }
-
- /*
- * @see IContentFormatter#getFormattingStrategy(String)
- */
- public IFormattingStrategy getFormattingStrategy(String contentType) {
-
- Assert.isNotNull(contentType);
-
- if (fStrategies == null)
- return null;
-
- return (IFormattingStrategy) fStrategies.get(contentType);
- }
-
- /*
- * @see IContentFormatter#format(IDocument, IRegion)
- */
- public void format(IDocument document, IRegion region) {
- fNeedsComputation= true;
- fDocument= document;
- try {
-
- if (fIsPartitionAware)
- formatPartitions(region);
- else
- formatRegion(region);
-
- } finally {
- fNeedsComputation= true;
- fDocument= null;
- }
- }
-
- /**
- * Determines the partitioning of the given region of the document.
- * Informs the formatting strategies of each partition about the start,
- * the process, and the termination of the formatting session.
- *
- * @param region the document region to be formatted
- */
- private void formatPartitions(IRegion region) {
-
- addPartitioningUpdater();
-
- try {
-
- TypedPosition[] ranges= getPartitioning(region);
- if (ranges != null) {
- start(ranges, getIndentation(region.getOffset()));
- format(ranges);
- stop(ranges);
- }
-
- } catch (BadLocationException x) {
- }
-
- removePartitioningUpdater();
- }
-
- /**
- * Formats the given region with the strategy registered for the default
- * content type. The strategy is informed about the start, the process, and
- * the termination of the formatting session.
- *
- * @param region the region to be formatted
- */
- private void formatRegion(IRegion region) {
-
- IFormattingStrategy strategy= getFormattingStrategy(IDocument.DEFAULT_CONTENT_TYPE);
- if (strategy != null) {
- strategy.formatterStarts(getIndentation(region.getOffset()));
- format(strategy, new TypedPosition(region.getOffset(), region.getLength(), IDocument.DEFAULT_CONTENT_TYPE));
- strategy.formatterStops();
- }
- }
-
- /**
- * Returns the partitioning of the given region of the specified document.
- * As one partition after the other will be formatted and formatting will
- * probably change the length of the formatted partition, it must be kept
- * track of the modifications in order to submit the correct partition to all
- * formatting strategies. For this, all partitions are remembered as positions
- * in a dedicated position category. (As formatting stratgies might rely on each
- * other, calling them in reversed order is not an option.)
- *
- * @param region the region for which the partitioning must be determined
- * @return the partitioning of the specified region
- * @exception BadLocationException of region is invalid in the document
- */
- private TypedPosition[] getPartitioning(IRegion region) throws BadLocationException {
-
- ITypedRegion[] regions= TextUtilities.computePartitioning(fDocument, fPartitioning, region.getOffset(), region.getLength());
- TypedPosition[] positions= new TypedPosition[regions.length];
-
- for (int i= 0; i < regions.length; i++) {
- positions[i]= new TypedPosition(regions[i]);
- try {
- fDocument.addPosition(PARTITIONING, positions[i]);
- } catch (BadPositionCategoryException x) {
- // should not happen
- }
- }
-
- return positions;
- }
-
- /**
- * Fires <code>formatterStarts</code> to all formatter strategies
- * which will be involved in the forthcoming formatting process.
- *
- * @param regions the partitioning of the document to be formatted
- * @param indentation the initial indentation
- */
- private void start(TypedPosition[] regions, String indentation) {
- for (int i= 0; i < regions.length; i++) {
- IFormattingStrategy s= getFormattingStrategy(regions[i].getType());
- if (s != null)
- s.formatterStarts(indentation);
- }
- }
-
- /**
- * Formats one partition after the other using the formatter strategy registered for
- * the partition's content type.
- *
- * @param ranges the partitioning of the document region to be formatted
- */
- private void format(TypedPosition[] ranges) {
- for (int i= 0; i < ranges.length; i++) {
- IFormattingStrategy s= getFormattingStrategy(ranges[i].getType());
- if (s != null) {
- format(s, ranges[i]);
- }
- }
- }
-
- /**
- * Formats the given region of the document using the specified formatting
- * strategy. In order to maintain positions correctly, first all affected
- * positions determined, after all document listeners have been informed about
- * the upcoming change, the affected positions are removed to avoid that they
- * are regularily updated. After all position updaters have run, the affected
- * positions are updated with the formatter's information and added back to
- * their categories, right before the first document listener is informed about
- * that a change happend.
- *
- * @param strategy the strategy to be used
- * @param region the region to be formatted
- */
- private void format(IFormattingStrategy strategy, TypedPosition region) {
- try {
-
- final int offset= region.getOffset();
- int length= region.getLength();
-
- String content= fDocument.get(offset, length);
- final int[] positions= getAffectedPositions(offset, length);
- String formatted= strategy.format(content, isLineStart(offset), getIndentation(offset), positions);
-
- if (formatted != null && !formatted.equals(content)) {
-
- IPositionUpdater first= new RemoveAffectedPositions();
- fDocument.insertPositionUpdater(first, 0);
- IPositionUpdater last= new UpdateAffectedPositions(positions, offset);
- fDocument.addPositionUpdater(last);
-
- fDocument.replace(offset, length, formatted);
-
- fDocument.removePositionUpdater(first);
- fDocument.removePositionUpdater(last);
- }
-
- } catch (BadLocationException x) {
- // should not happen
- }
- }
-
- /**
- * Fires <code>formatterStops</code> to all formatter strategies which were
- * involved in the formatting process which is about to terminate.
- *
- * @param regions the partitioning of the document which has been formatted
- */
- private void stop(TypedPosition[] regions) {
- for (int i= 0; i < regions.length; i++) {
- IFormattingStrategy s= getFormattingStrategy(regions[i].getType());
- if (s != null)
- s.formatterStops();
- }
- }
-
- /**
- * Installs those updaters which the formatter needs to keep track of the partitions.
- */
- private void addPartitioningUpdater() {
- fPartitioningUpdater= new NonDeletingPositionUpdater(PARTITIONING);
- fDocument.addPositionCategory(PARTITIONING);
- fDocument.addPositionUpdater(fPartitioningUpdater);
- }
-
- /**
- * Removes the formatter's internal position updater and category.
- */
- private void removePartitioningUpdater() {
-
- try {
-
- fDocument.removePositionUpdater(fPartitioningUpdater);
- fDocument.removePositionCategory(PARTITIONING);
- fPartitioningUpdater= null;
-
- } catch (BadPositionCategoryException x) {
- // should not happen
- }
- }
-
- /**
- * Returns the partition managing position categories for the formatted document.
- *
- * @return the position managing position categories
- * @since 3.0
- */
- private String[] getPartitionManagingCategories() {
- if (fNeedsComputation) {
- fNeedsComputation= false;
- fPartitionManagingCategories= TextUtilities.computePartitionManagingCategories(fDocument);
- if (fPartitionManagingCategories == null)
- fPartitionManagingCategories= fExternalPartitonManagingCategories;
- }
- return fPartitionManagingCategories;
- }
-
- /**
- * Determines whether the given document position category should be ignored
- * by this formatter's position updating.
- *
- * @param category the category to check
- * @return <code>true</code> if the category should be ignored, <code>false</code> otherwise
- */
- private boolean ignoreCategory(String category) {
-
- if (PARTITIONING.equals(category))
- return true;
-
- String[] categories= getPartitionManagingCategories();
- if (categories != null) {
- for (int i= 0; i < categories.length; i++) {
- if (categories[i].equals(category))
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Determines all embracing, overlapping, and follow up positions
- * for the given region of the document.
- *
- * @param offset the offset of the document region to be formatted
- * @param length the length of the document to be formatted
- */
- private void determinePositionsToUpdate(int offset, int length) {
-
- String[] categories= fDocument.getPositionCategories();
- if (categories != null) {
- for (int i= 0; i < categories.length; i++) {
-
- if (ignoreCategory(categories[i]))
- continue;
-
- try {
-
- Position[] positions= fDocument.getPositions(categories[i]);
-
- for (int j= 0; j < positions.length; j++) {
-
- Position p= positions[j];
- if (p.overlapsWith(offset, length)) {
-
- if (offset < p.getOffset())
- fOverlappingPositionReferences.add(new PositionReference(p, true, categories[i]));
-
- if (p.getOffset() + p.getLength() < offset + length)
- fOverlappingPositionReferences.add(new PositionReference(p, false, categories[i]));
- }
- }
-
- } catch (BadPositionCategoryException x) {
- // can not happen
- }
- }
- }
- }
-
- /**
- * Returns all offset and the end offset of all positions overlapping with the
- * specified document range.
- *
- * @param offset the offset of the document region to be formatted
- * @param length the length of the document to be formatted
- * @return all character positions of the interleaving positions
- */
- private int[] getAffectedPositions(int offset, int length) {
-
- fOverlappingPositionReferences= new ArrayList();
-
- determinePositionsToUpdate(offset, length);
-
- Collections.sort(fOverlappingPositionReferences);
-
- int[] positions= new int[fOverlappingPositionReferences.size()];
- for (int i= 0; i < positions.length; i++) {
- PositionReference r= (PositionReference) fOverlappingPositionReferences.get(i);
- positions[i]= r.getCharacterPosition() - offset;
- }
-
- return positions;
- }
-
- /**
- * Removes the affected positions from their categories to avoid
- * that they are invalidly updated.
- *
- * @param document the document
- */
- private void removeAffectedPositions(IDocument document) {
- int size= fOverlappingPositionReferences.size();
- for (int i= 0; i < size; i++) {
- PositionReference r= (PositionReference) fOverlappingPositionReferences.get(i);
- try {
- document.removePosition(r.getCategory(), r.getPosition());
- } catch (BadPositionCategoryException x) {
- // can not happen
- }
- }
- }
-
- /**
- * Updates all the overlapping positions. Note, all other positions are
- * automatically updated by their document position updaters.
- *
- * @param document the document to has been formatted
- * @param positions the adapted character positions to be used to update the document positions
- * @param offset the offset of the document region that has been formatted
- */
- protected void updateAffectedPositions(IDocument document, int[] positions, int offset) {
-
- if (document != fDocument)
- return;
-
- if (positions.length == 0)
- return;
-
- for (int i= 0; i < positions.length; i++) {
-
- PositionReference r= (PositionReference) fOverlappingPositionReferences.get(i);
-
- if (r.refersToOffset())
- r.setOffset(offset + positions[i]);
- else
- r.setLength((offset + positions[i]) - r.getOffset());
-
- Position p= r.getPosition();
- String category= r.getCategory();
- if (!document.containsPosition(category, p.offset, p.length)) {
- try {
- if (positionAboutToBeAdded(document, category, p))
- document.addPosition(r.getCategory(), p);
- } catch (BadPositionCategoryException x) {
- // can not happen
- } catch (BadLocationException x) {
- // should not happen
- }
- }
-
- }
-
- fOverlappingPositionReferences= null;
- }
-
- /**
- * The given position is about to be added to the given position category of the given document. <p>
- * This default implementation enacts the same rule as the TextViewer, i.e. if the position is used for
- * managing slave documents it is ensured that the slave document starts at a line offset.
- *
- * @param document the document
- * @param category the position categroy
- * @param position the position that will be added
- * @return <code>true</code> if the position can be added, <code>false</code> if it should be ignored
- */
- protected boolean positionAboutToBeAdded(IDocument document, String category, Position position) {
- if (ChildDocumentManager.CHILDDOCUMENTS.equals(category)) {
- /*
- * We assume child document offsets to be at the beginning
- * of a line. Because the formatter might have moved the
- * position to be somewhere in the middle of a line we patch it here.
- */
- try {
- int lineOffset= document.getLineInformationOfOffset(position.offset).getOffset();
- position.setLength(position.length + position.offset - lineOffset);
- position.setOffset(lineOffset);
- } catch (BadLocationException x) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Returns the indentation of the line of the given offset.
- *
- * @param offset the offset
- * @return the indentation of the line of the offset
- */
- private String getIndentation(int offset) {
-
- try {
- int start= fDocument.getLineOfOffset(offset);
- start= fDocument.getLineOffset(start);
-
- int end= start;
- char c= fDocument.getChar(end);
- while ('\t' == c || ' ' == c)
- c= fDocument.getChar(++end);
-
- return fDocument.get(start, end - start);
- } catch (BadLocationException x) {
- }
-
- return ""; //$NON-NLS-1$
- }
-
- /**
- * Determines whether the offset is the beginning of a line in the given document.
- *
- * @param offset the offset
- * @return <code>true</code> if offset is the beginning of a line
- * @exception BadLocationException if offset is invalid in document
- */
- private boolean isLineStart(int offset) throws BadLocationException {
- int start= fDocument.getLineOfOffset(offset);
- start= fDocument.getLineOffset(start);
- return (start == offset);
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContentFormatter2.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContentFormatter2.java
deleted file mode 100644
index 4bf79c23ac4..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContentFormatter2.java
+++ /dev/null
@@ -1,1095 +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.formatter;
-
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.ChildDocumentManager;
-import org.eclipse.jface.text.DefaultPositionUpdater;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentExtension3;
-import org.eclipse.jface.text.IPositionUpdater;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextUtilities;
-import org.eclipse.jface.text.TypedPosition;
-
-
-/**
- * Improved standard implementation of <code>IContentFormatter</code>. The formatter
- * supports three operation modi: partition aware, partition unaware and
- * context based.
- * <p>
- * In the partition aware mode, the formatter determines the partitioning of
- * the document region to be formatted. For each partition it determines all
- * document positions which are affected when text changes are applied to the
- * partition. Those which overlap with the partition are remembered as
- * character positions. These character positions are passed over to the
- * formatting strategy registered for the partition's content type. The
- * formatting strategy returns a string containing the formatted document
- * partition as well as the adapted character positions. The formatted
- * partition replaces the old content of the partition. The remembered document
- * postions are updated with the adapted character positions. In addition, all
- * other document positions are accordingly adapted to the formatting changes.
- * <p>
- * In the partition unaware mode, the document's partitioning is ignored and
- * the document is considered consisting of only one partition of the content
- * type <code>IDocument.DEFAULT_CONTENT_TYPE</code>. The formatting process
- * is similar to the partition aware mode, with the exception of having only
- * one partition.
- * <p>
- * The context based mode is supported by the extension interface <code>IContentFormatterExtension2</code>
- * and supersedes the previous modes. Clients using context based formatting
- * call the method <code>format(IDocument, IFormattingContext)</code> with a
- * properly initialized formatting context. <br>The formatting context must be
- * set up according to the desired formatting mode:
- * <ul>
- * <li>For whole document formatting set the property <code>CONTEXT_DOCUMENT</code>.
- * </li>
- * <li>For single partition formatting set the property <code>CONTEXT_PARTITION</code>.
- * </li>
- * <li>For multiple region formatting set the property <code>CONTEXT_REGION</code>.
- * </li>
- * </ul>
- * Depending on the registered formatting strategies, more context information
- * must be passed in the formatting context, like e.g. <code>CONTEXT_PREFERENCES</code>.
- * <p>
- * Note that in context based mode the content formatter is fully reentrant,
- * but not thread-safe. Formatting strategies are therefore allowed to
- * recursively call the method <code>format(IDocument, IFormattingContext)</code>.
- * The formatting context is saved between calls to this method.
- * <p>
- * Usually, clients instantiate this class and configure it before using it.
- *
- * @see IContentFormatter
- * @see IContentFormatterExtension2
- * @see IDocument
- * @see ITypedRegion
- * @see Position
- */
-public class ContentFormatter2 implements IContentFormatter, IContentFormatterExtension, IContentFormatterExtension2 {
-
- /**
- * Defines a reference to either the offset or the end offset of
- * a particular position.
- */
- static class PositionReference implements Comparable {
-
- /** The referenced position */
- protected Position fPosition;
- /** The reference to either the offset or the end offset */
- protected boolean fRefersToOffset;
- /** The original category of the referenced position */
- protected String fCategory;
-
- /**
- * Creates a new position reference.
- *
- * @param position the position to be referenced
- * @param refersToOffset <code>true</code> if position offset should be referenced
- * @param category the categpry the given position belongs to
- */
- protected PositionReference(Position position, boolean refersToOffset, String category) {
- fPosition= position;
- fRefersToOffset= refersToOffset;
- fCategory= category;
- }
-
- /**
- * Returns the offset of the referenced position.
- *
- * @return the offset of the referenced position
- */
- protected int getOffset() {
- return fPosition.getOffset();
- }
-
- /**
- * Manipulates the offset of the referenced position.
- *
- * @param offset the new offset of the referenced position
- */
- protected void setOffset(int offset) {
- fPosition.setOffset(offset);
- }
-
- /**
- * Returns the length of the referenced position.
- *
- * @return the length of the referenced position
- */
- protected int getLength() {
- return fPosition.getLength();
- }
-
- /**
- * Manipulates the length of the referenced position.
- *
- * @param the new length of the referenced position
- */
- protected void setLength(int length) {
- fPosition.setLength(length);
- }
-
- /**
- * Returns whether this reference points to the offset or endoffset
- * of the references position.
- *
- * @return <code>true</code> if the offset of the position is referenced, <code>false</code> otherwise
- */
- protected boolean refersToOffset() {
- return fRefersToOffset;
- }
-
- /**
- * Returns the category of the referenced position.
- *
- * @return the category of the referenced position
- */
- protected String getCategory() {
- return fCategory;
- }
-
- /**
- * Returns the referenced position.
- *
- * @return the referenced position
- */
- protected Position getPosition() {
- return fPosition;
- }
-
- /**
- * Returns the referenced character position
- *
- * @return the referenced character position
- */
- protected int getCharacterPosition() {
- if (fRefersToOffset)
- return getOffset();
- return getOffset() + getLength();
- }
-
- /*
- * @see Comparable#compareTo(Object)
- */
- public int compareTo(Object obj) {
-
- if (obj instanceof PositionReference) {
- PositionReference r= (PositionReference) obj;
- return getCharacterPosition() - r.getCharacterPosition();
- }
-
- throw new ClassCastException();
- }
- }
-
- /**
- * The position updater used to update the remembered partitions.
- *
- * @see IPositionUpdater
- * @see DefaultPositionUpdater
- */
- class NonDeletingPositionUpdater extends DefaultPositionUpdater {
-
- /**
- * Creates a new updater for the given category.
- *
- * @param category the category
- */
- protected NonDeletingPositionUpdater(String category) {
- super(category);
- }
-
- /*
- * @see DefaultPositionUpdater#notDeleted()
- */
- protected boolean notDeleted() {
- return true;
- }
- }
-
- /**
- * The position updater which runs as first updater on the document's positions.
- * Used to remove all affected positions from their categories to avoid them
- * from being regularily updated.
- *
- * @see IPositionUpdater
- */
- class RemoveAffectedPositions implements IPositionUpdater {
- /**
- * @see IPositionUpdater#update(DocumentEvent)
- */
- public void update(DocumentEvent event) {
- removeAffectedPositions(event.getDocument());
- }
- }
-
- /**
- * The position updater which runs as last updater on the document's positions.
- * Used to update all affected positions and adding them back to their
- * original categories.
- *
- * @see IPositionUpdater
- */
- class UpdateAffectedPositions implements IPositionUpdater {
-
- /** The affected positions */
- private int[] fPositions;
- /** The offset */
- private int fOffset;
-
- /**
- * Creates a new updater.
- *
- * @param positions the affected positions
- * @param offset the offset
- */
- public UpdateAffectedPositions(int[] positions, int offset) {
- fPositions= positions;
- fOffset= offset;
- }
-
- /*
- * @see IPositionUpdater#update(DocumentEvent)
- */
- public void update(DocumentEvent event) {
- updateAffectedPositions(event.getDocument(), fPositions, fOffset);
- }
- }
-
-
- /** Internal position category used for the formatter partitioning */
- private final static String PARTITIONING= "__formatter_partitioning"; //$NON-NLS-1$
-
- /** The map of slave <code>IFormattingStrategy</code> objects */
- private Map fStrategies;
- /**
- * The master <code>IFormattingStrategy</code> object
- * @since 3.0
- */
- private IFormattingStrategy fMasterStrategy;
- /** The indicator of whether the formatter operates in partition aware mode or not */
- private boolean fIsPartitionAware= true;
-
- /** The partition information managing document position categories */
- private String[] fPartitionManagingCategories;
- /** The list of references to offset and end offset of all overlapping positions */
- private List fOverlappingPositionReferences;
- /**
- * The document partitioning used by this formatter.
- * @since 3.0
- */
- private String fPartitioning;
- /**
- * The document this formatter works on.
- * @since 3.0
- */
- private IDocument fDocument;
- /**
- * The external partition managing categories.
- * @since 3.0
- */
- private String[] fExternalPartitonManagingCategories;
- /**
- * Indicates whether <code>fPartitionManagingCategories</code> must be computed.
- * @since 3.0
- */
- private boolean fNeedsComputation= true;
- /**
- * Formatting context to use while formatting
- * @since 3.0
- */
- private IFormattingContext fFormattingContext= null;
- /**
- * Queue of position arrays used during formatting.
- * @since 3.0
- */
- private final LinkedList fPositions= new LinkedList();
-
- /**
- * Creates a new content formatter.
- * <p>
- * The content formatter operates by default in the partition-aware mode.
- * There are no preconfigured formatting strategies. It will use the
- * default document partitioning if not further configured. The context
- * based mode is enabled by calls to <code>format(IDocument, IFormattingContext</code>.
- */
- public ContentFormatter2() {
- fPartitioning= IDocumentExtension3.DEFAULT_PARTITIONING;
- }
-
- /**
- * Informs this content formatter about the names of those position categories
- * which are used to manage the document's partitioning information and thus should
- * be ignored when this formatter updates positions.
- *
- * @param categories the categories to be ignored
- * @deprecated incompatible with an open set of document partitionings. The provided information is only used
- * if this formatter can not compute the partition managing position categories.
- */
- public void setPartitionManagingPositionCategories(String[] categories) {
- fExternalPartitonManagingCategories= categories;
- }
-
- /**
- * Sets the document partitioning to be used by this formatter.
- *
- * @param partitioning the document partitioning
- * @since 3.0
- */
- public void setDocumentPartitioning(String partitioning) {
- fPartitioning= partitioning;
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.IContentFormatterExtension#getDocumentPartitioning()
- *
- * @since 3.0
- */
- public String getDocumentPartitioning() {
- return fPartitioning;
- }
-
- /**
- * Sets whether the formatter operates in partition aware mode.
- *
- * @param enable
- * <code>true</code> iff partition aware mode should be
- * enabled, <code>false</code> otherwise.
- */
- public void enablePartitionAwareFormatting(boolean enable) {
- fIsPartitionAware= enable;
- }
-
- /*
- * @see IContentFormatter#getFormattingStrategy(String)
- */
- public IFormattingStrategy getFormattingStrategy(String contentType) {
-
- Assert.isNotNull(contentType);
-
- if (fStrategies == null)
- return null;
-
- return (IFormattingStrategy) fStrategies.get(contentType);
- }
-
- /*
- * @see IContentFormatter#format(IDocument, IRegion)
- */
- public void format(IDocument document, IRegion region) {
-
- fNeedsComputation= true;
- fFormattingContext= null;
-
- final IDocument last= fDocument;
- fDocument= document;
-
- final boolean aware= fIsPartitionAware;
- try {
-
- final int offset= region.getOffset();
- final int length= region.getLength();
-
- if (fIsPartitionAware)
- formatPartitions(offset, length);
- else
- formatRegion(offset, length, IDocument.DEFAULT_CONTENT_TYPE);
-
- } finally {
-
- fNeedsComputation= true;
- fFormattingContext= null;
- fDocument= last;
- fIsPartitionAware= aware;
- }
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.IContentFormatterExtension2#format(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.formatter.IFormattingContext)
- */
- public void format(IDocument document, IFormattingContext context) {
-
- fNeedsComputation= true;
-
- final IDocument last= fDocument;
- fDocument= document;
-
- final LinkedList previous= new LinkedList(fPositions);
- fPositions.clear();
-
- final IFormattingContext predecessor= fFormattingContext;
- fFormattingContext= context;
-
- final boolean aware= fIsPartitionAware;
- try {
-
- final Boolean all= (Boolean)context.getProperty(FormattingContextProperties.CONTEXT_DOCUMENT);
- if (all == null || !all.booleanValue()) {
-
- final TypedPosition partition= (TypedPosition)context.getProperty(FormattingContextProperties.CONTEXT_PARTITION);
- final IRegion region= (IRegion)context.getProperty(FormattingContextProperties.CONTEXT_REGION);
-
- if (partition != null) {
- formatRegion(partition.getOffset(), partition.getLength(), partition.getType());
- } else if (region != null) {
-
- int offset= region.getOffset();
- int length= region.getLength();
-
- final ITypedRegion[] regions= TextUtilities.computePartitioning(fDocument, fPartitioning, offset, length);
- final ITypedRegion start= TextUtilities.getPartition(fDocument, fPartitioning, regions[0].getOffset());
-
- final String type= start.getType();
- if (regions.length > 1) {
-
- if (!type.equals(IDocument.DEFAULT_CONTENT_TYPE)) {
-
- final int delta= offset - start.getOffset();
- offset -= delta;
- length += delta;
- }
-
- final int rest= fDocument.getLength() - length;
- try {
- formatMaster(offset, length);
- } finally {
- formatPartitions(offset, fDocument.getLength() - rest);
- }
- } else if (regions.length == 1)
- formatRegion(offset, length, type);
- }
- } else {
-
- try {
- formatMaster(0, fDocument.getLength());
- } finally {
- formatPartitions(0, fDocument.getLength());
- }
- }
- } catch (BadLocationException exception) {
- // Should not happen
-
- } finally {
-
- fNeedsComputation= true;
- fFormattingContext= predecessor;
- fDocument= last;
- fIsPartitionAware= aware;
-
- fPositions.clear();
- fPositions.addAll(previous);
- }
- }
-
- /**
- * Registers a slave strategy for a particular content type.
- * <p>
- * If there is already a slave strategy registered for this type, the new
- * strategy is registered instead of the old one. The content type <code>type</code>
- * must be a valid content type of the registered partitioning of the
- * formatter.
- * <p>
- * Note that slave strategies can only be registered if a master strategy
- * has been registered before.
- * </p>
- *
- * @param strategy
- * The formatting strategy to register as a slave strategy, or
- * <code>null</code> to remove an existing one
- * @param type
- * The content type under which to register the slave strategy
- */
- public void setFormattingStrategy(IFormattingStrategy strategy, String type) {
-
- Assert.isNotNull(type);
-
- if (fStrategies == null)
- fStrategies= new HashMap();
-
- if (strategy == null)
- fStrategies.remove(type);
- else
- fStrategies.put(type, strategy);
- }
-
- /**
- * Registers the master strategy for this content formatter. If there is
- * already a master strategy registered, the new strategy is registered
- * instead of the old one.
- * <p>
- * Note that slave strategies can only be registered if a master strategy
- * has been registered before.
- * </p>
- *
- * @param strategy
- * The formatting strategy to register as the master strategy, or
- * <code>null</code> to remove the existing one
- */
- public void setFormattingStrategy(IFormattingStrategy strategy) {
- fMasterStrategy= strategy;
- }
-
- /**
- * Aligns the region to a block selection.
- *
- * @param offset
- * Offset of the region
- * @param length
- * Length of the region
- * @return The aligned region
- */
- private IRegion alignBlockSelect(int offset, int length) {
-
- try {
-
- final int aligned= fDocument.getLineOffset(fDocument.getLineOfOffset(offset));
- return new Region(aligned, length + offset - aligned);
-
- } catch (BadLocationException exception) {
- // Should not happen
-
- return new Region(offset, length);
- }
- }
-
- /**
- * Determines the partitioning of the given region of the document and
- * formats each partition in the partitioning separately.
- * <p>
- * The formatting strategies of each partition about the start, the
- * process, and the termination of the formatting session.
- *
- * @param offset
- * The offset of the region to be formatted
- * @param length
- * The length of the region to be formatted
- */
- private void formatPartitions(int offset, int length) {
-
- try {
-
- final TypedPosition[] ranges= getPartitioning(offset, length);
-
- if (ranges != null) {
-
- start(ranges, getIndentation(offset));
- format(ranges);
- stop(ranges);
- }
-
- } catch (BadLocationException exception) {
- // Can not happen
- }
- }
-
- /**
- * Formats the given region with the formatting
- * strategy registered for the indicated type. The
- * indicated type does not necessarily have to be
- * the type of the region in the documents partitioning.
- * <p>
- * The formatting strategy is informed about the start, the process, and
- * the termination of the formatting session.
- *
- * @param offset The offset of the region
- * @param length The length of the region
- * @param type The type of the region
- */
- private void formatRegion(int offset, int length, String type) {
-
- IRegion range= null;
- if (type.equals(IDocument.DEFAULT_CONTENT_TYPE))
- range= alignBlockSelect(offset, length);
- else
- range= new Region(offset, length);
-
- final IFormattingStrategy strategy= getFormattingStrategy(type);
- if (strategy != null) {
-
- final TypedPosition region= new TypedPosition(range.getOffset(), range.getLength(), type);
-
- formatterStarts(strategy, region, getIndentation(region.getOffset()));
- format(strategy, region);
- strategy.formatterStops();
- }
- }
-
- /**
- * Formats the given region with the master formatting strategy.
- * <p>
- * The formatting strategy is informed about the start, the process, and
- * the termination of the formatting session.
- *
- * @param offset
- * The offset of the region
- * @param length
- * The length of the region
- * @param type
- * The type of the region
- */
- private void formatMaster(int offset, int length) {
-
- if (fMasterStrategy != null) {
-
- final IRegion aligned= alignBlockSelect(offset, length);
- final TypedPosition region= new TypedPosition(aligned.getOffset(), aligned.getLength(), IDocument.DEFAULT_CONTENT_TYPE);
-
- formatterStarts(fMasterStrategy, region, getIndentation(region.getOffset()));
- format(fMasterStrategy, region);
- fMasterStrategy.formatterStops();
- }
- }
-
- /**
- * Fires the <code>formatterStarts</code> event for the indicated
- * formatting strategy.
- *
- * @param strategy
- * Formatting strategy to fire the event for
- * @param region
- * Region where the strategy is supposed to format
- * @param indentation
- * Indentation to use while formatting the region
- */
- private void formatterStarts(IFormattingStrategy strategy, TypedPosition region, String indentation) {
-
- if (fFormattingContext != null && strategy instanceof IFormattingStrategyExtension) {
-
- final IFormattingStrategyExtension extension= (IFormattingStrategyExtension)strategy;
- final int[] positions= getAffectedPositions(region.getOffset(), region.getLength());
-
- fPositions.addLast(positions);
-
- fFormattingContext.setProperty(FormattingContextProperties.CONTEXT_INDENTATION, indentation);
- fFormattingContext.setProperty(FormattingContextProperties.CONTEXT_PARTITION, region);
- fFormattingContext.setProperty(FormattingContextProperties.CONTEXT_POSITIONS, positions);
-
- extension.formatterStarts(fFormattingContext);
- } else
- strategy.formatterStarts(indentation);
- }
-
- /**
- * Returns the partitioning of the given region of the specified document.
- * As one partition after the other will be formatted and formatting will
- * probably change the length of the formatted partition, it must be kept
- * track of the modifications in order to submit the correct partition to all
- * formatting strategies. For this, all partitions are remembered as positions
- * in a dedicated position category.
- *
- * @param offset Offset of the region for which the partitioning must be determined
- * @param length Length of the region for which the partitioning must be determined
- * @return the partitioning of the specified region
- * @exception BadLocationException of region is invalid in the document
- */
- private TypedPosition[] getPartitioning(int offset, int length) throws BadLocationException {
-
- ITypedRegion[] regions= TextUtilities.computePartitioning(fDocument, fPartitioning, offset, length);
- TypedPosition[] positions= new TypedPosition[regions.length];
-
- for (int i= 0; i < regions.length; i++)
- positions[i]= new TypedPosition(regions[i]);
-
- return positions;
- }
-
- /**
- * Fires the <code>formatterStarts</code> event to all formatting
- * strategies which will be involved in the forthcoming formatting process.
- *
- * @param partitions
- * The partitioning of the document to be formatted
- * @param indentation
- * The initial indentation
- */
- private void start(TypedPosition[] partitions, String indentation) {
-
- String type= null;
- TypedPosition region= null;
-
- for (int i= partitions.length - 1; i >= 0; i--) {
-
- region= partitions[i];
- type= region.getType();
-
- if (!type.equals(IDocument.DEFAULT_CONTENT_TYPE)) {
-
- final IFormattingStrategy strategy= getFormattingStrategy(type);
- if (strategy != null && strategy != fMasterStrategy)
- formatterStarts(strategy, region, indentation);
- }
- }
- }
-
- /**
- * Formats the partitions using the formatting strategy registered for each
- * partition's content type.
- *
- * @param partitions
- * The partitioning of the document to be formatted
- */
- private void format(TypedPosition[] partitions) {
-
- String type= null;
- TypedPosition region= null;
-
- for (int i= partitions.length - 1; i >= 0; i--) {
-
- region= partitions[i];
- type= region.getType();
-
- if (!type.equals(IDocument.DEFAULT_CONTENT_TYPE)) {
-
- final IFormattingStrategy strategy= getFormattingStrategy(type);
- if (strategy != null && strategy != fMasterStrategy) {
-
- if (fFormattingContext != null && strategy instanceof IFormattingStrategyExtension) {
-
- final IFormattingStrategyExtension extension= (IFormattingStrategyExtension)strategy;
- extension.format();
-
- } else
- format(strategy, region);
- }
- }
- }
- }
-
- /**
- * Formats the given region in the document using the indicated strategy.
- * The type of the region does not have to be the same as the type for
- * which the strategy was originally registred.
- * <p>
- * The formatting process will happen in the mode set up by the formatting
- * context or changes to the partition aware/unaware property.
- *
- * @param strategy
- * The strategy to be used
- * @param region
- * The region to be formatted
- */
- private void format(IFormattingStrategy strategy, TypedPosition region) {
-
- if (fFormattingContext != null && strategy instanceof IFormattingStrategyExtension) {
-
- final int[] positions= (int[])fFormattingContext.getProperty(FormattingContextProperties.CONTEXT_POSITIONS);
-
- IPositionUpdater first= new RemoveAffectedPositions();
- fDocument.insertPositionUpdater(first, 0);
- IPositionUpdater last= new UpdateAffectedPositions(positions, region.getOffset());
- fDocument.addPositionUpdater(last);
-
- final IFormattingStrategyExtension extension= (IFormattingStrategyExtension)strategy;
- extension.format();
-
- fDocument.removePositionUpdater(first);
- fDocument.removePositionUpdater(last);
-
- } else {
-
- try {
-
- final int offset= region.getOffset();
- int length= region.getLength();
-
- String content= fDocument.get(offset, length);
- final int[] positions= getAffectedPositions(offset, length);
- String formatted= strategy.format(content, isLineStart(offset), getIndentation(offset), positions);
-
- if (formatted != null && !formatted.equals(content)) {
-
- IPositionUpdater first= new RemoveAffectedPositions();
- fDocument.insertPositionUpdater(first, 0);
- IPositionUpdater last= new UpdateAffectedPositions(positions, offset);
- fDocument.addPositionUpdater(last);
-
- fDocument.replace(offset, length, formatted);
-
- fDocument.removePositionUpdater(first);
- fDocument.removePositionUpdater(last);
- }
-
- } catch (BadLocationException x) {
- // should not happen
- }
- }
- }
-
- /**
- * Fires the <code>formatterStops</code> event to all formatting
- * strategies which were involved in the formatting process which is about
- * to terminate.
- *
- * @param partitions
- * The partitioning of the document which has been formatted
- */
- private void stop(TypedPosition[] partitions) {
-
- String type= null;
- for (int i= partitions.length - 1; i >= 0; i--) {
-
- type= partitions[i].getType();
- if (!type.equals(IDocument.DEFAULT_CONTENT_TYPE)) {
-
- final IFormattingStrategy strategy= getFormattingStrategy(type);
- if (strategy != null && strategy != fMasterStrategy)
- strategy.formatterStops();
- }
- }
- }
-
- /**
- * Returns the partition managing position categories for the formatted document.
- *
- * @return the position managing position categories
- * @since 3.0
- */
- private String[] getPartitionManagingCategories() {
- if (fNeedsComputation) {
- fNeedsComputation= false;
- fPartitionManagingCategories= TextUtilities.computePartitionManagingCategories(fDocument);
- if (fPartitionManagingCategories == null)
- fPartitionManagingCategories= fExternalPartitonManagingCategories;
- }
- return fPartitionManagingCategories;
- }
-
- /**
- * Determines whether the given document position category should be ignored
- * by this formatter's position updating.
- *
- * @param category the category to check
- * @return <code>true</code> if the category should be ignored, <code>false</code> otherwise
- */
- private boolean ignoreCategory(String category) {
-
- if (PARTITIONING.equals(category))
- return true;
-
- String[] categories= getPartitionManagingCategories();
- if (categories != null) {
- for (int i= 0; i < categories.length; i++) {
- if (categories[i].equals(category))
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Determines all embracing, overlapping, and follow up positions
- * for the given region of the document.
- *
- * @param offset the offset of the document region to be formatted
- * @param length the length of the document to be formatted
- */
- private void determinePositionsToUpdate(int offset, int length) {
-
- String[] categories= fDocument.getPositionCategories();
- if (categories != null) {
- for (int i= 0; i < categories.length; i++) {
-
- if (ignoreCategory(categories[i]))
- continue;
-
- try {
-
- Position[] positions= fDocument.getPositions(categories[i]);
-
- for (int j= 0; j < positions.length; j++) {
-
- Position p= positions[j];
- if (p.overlapsWith(offset, length)) {
-
- if (offset < p.getOffset())
- fOverlappingPositionReferences.add(new PositionReference(p, true, categories[i]));
-
- if (p.getOffset() + p.getLength() < offset + length)
- fOverlappingPositionReferences.add(new PositionReference(p, false, categories[i]));
- }
- }
-
- } catch (BadPositionCategoryException x) {
- // can not happen
- }
- }
- }
- }
-
- /**
- * Returns all offset and the end offset of all positions overlapping with the
- * specified document range.
- *
- * @param offset the offset of the document region to be formatted
- * @param length the length of the document to be formatted
- * @return all character positions of the interleaving positions
- */
- private int[] getAffectedPositions(int offset, int length) {
-
- fOverlappingPositionReferences= new ArrayList();
-
- determinePositionsToUpdate(offset, length);
-
- Collections.sort(fOverlappingPositionReferences);
-
- int[] positions= new int[fOverlappingPositionReferences.size()];
- for (int i= 0; i < positions.length; i++) {
- PositionReference r= (PositionReference) fOverlappingPositionReferences.get(i);
- positions[i]= r.getCharacterPosition() - offset;
- }
-
- return positions;
- }
-
- /**
- * Removes the affected positions from their categories to avoid
- * that they are invalidly updated.
- *
- * @param document the document
- */
- private void removeAffectedPositions(IDocument document) {
- if (fOverlappingPositionReferences != null) {
- int size= fOverlappingPositionReferences.size();
- for (int i= 0; i < size; i++) {
- PositionReference r= (PositionReference)fOverlappingPositionReferences.get(i);
- try {
- document.removePosition(r.getCategory(), r.getPosition());
- } catch (BadPositionCategoryException x) {
- // can not happen
- }
- }
- }
- }
-
- /**
- * Updates all the overlapping positions. Note, all other positions are
- * automatically updated by their document position updaters.
- *
- * @param document the document to has been formatted
- * @param positions the adapted character positions to be used to update the document positions
- * @param offset the offset of the document region that has been formatted
- */
- protected void updateAffectedPositions(IDocument document, int[] positions, int offset) {
-
- if (document != fDocument)
- return;
-
- if (fOverlappingPositionReferences == null || fOverlappingPositionReferences.size() == 0 || positions.length == 0)
- return;
-
- for (int i= 0; i < positions.length; i++) {
-
- PositionReference r= (PositionReference) fOverlappingPositionReferences.get(i);
-
- if (r.refersToOffset())
- r.setOffset(offset + positions[i]);
- else
- r.setLength((offset + positions[i]) - r.getOffset());
-
- Position p= r.getPosition();
- String category= r.getCategory();
- if (!document.containsPosition(category, p.offset, p.length)) {
- try {
- if (positionAboutToBeAdded(document, category, p))
- document.addPosition(r.getCategory(), p);
- } catch (BadPositionCategoryException x) {
- // can not happen
- } catch (BadLocationException x) {
- // should not happen
- }
- }
-
- }
-
- fOverlappingPositionReferences= null;
- }
-
- /**
- * The given position is about to be added to the given position category of the given document. <p>
- * This default implementation enacts the same rule as the TextViewer, i.e. if the position is used for
- * managing slave documents it is ensured that the slave document starts at a line offset.
- *
- * @param document the document
- * @param category the position categroy
- * @param position the position that will be added
- * @return <code>true</code> if the position can be added, <code>false</code> if it should be ignored
- */
- protected boolean positionAboutToBeAdded(IDocument document, String category, Position position) {
- if (ChildDocumentManager.CHILDDOCUMENTS.equals(category)) {
- /*
- * We assume child document offsets to be at the beginning
- * of a line. Because the formatter might have moved the
- * position to be somewhere in the middle of a line we patch it here.
- */
- try {
- int lineOffset= document.getLineInformationOfOffset(position.offset).getOffset();
- position.setLength(position.length + position.offset - lineOffset);
- position.setOffset(lineOffset);
- } catch (BadLocationException x) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Returns the indentation of the line of the given offset.
- *
- * @param offset the offset
- * @return the indentation of the line of the offset
- */
- private String getIndentation(int offset) {
-
- try {
- int start= fDocument.getLineOfOffset(offset);
- start= fDocument.getLineOffset(start);
-
- int end= start;
- char c= fDocument.getChar(end);
- while ('\t' == c || ' ' == c)
- c= fDocument.getChar(++end);
-
- return fDocument.get(start, end - start);
- } catch (BadLocationException x) {
- }
-
- return ""; //$NON-NLS-1$
- }
-
- /**
- * Determines whether the offset is the beginning of a line in the given document.
- *
- * @param offset the offset
- * @return <code>true</code> if offset is the beginning of a line
- * @exception BadLocationException if offset is invalid in document
- */
- private boolean isLineStart(int offset) throws BadLocationException {
- int start= fDocument.getLineOfOffset(offset);
- start= fDocument.getLineOffset(start);
- return (start == offset);
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContextBasedFormattingStrategy.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContextBasedFormattingStrategy.java
deleted file mode 100644
index f0373996ecc..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContextBasedFormattingStrategy.java
+++ /dev/null
@@ -1,113 +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.formatter;
-
-import java.util.LinkedList;
-import java.util.Map;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.source.ISourceViewer;
-
-/**
- * Formatting strategy for context based content formatting.
- * <p>
- * This strategy implements <code>IFormattingStrategyExtension</code>. It
- * must be registered with a content formatter implementing <code>IContentFormatterExtension2<code>
- * to take effect.
- *
- * @see IContentFormatterExtension2
- * @see IFormattingStrategyExtension
- * @since 3.0
- */
-public abstract class ContextBasedFormattingStrategy implements IFormattingStrategy, IFormattingStrategyExtension {
-
- /** The current preferences to apply */
- private Map fCurrentPreference= null;
-
- /** The preferences to apply during formatting */
- private final LinkedList fPreferences= new LinkedList();
-
- /** The source viewer to operate on */
- private final ISourceViewer fViewer;
-
- /**
- * Creates a new abstract formatting strategy.
- *
- * @param viewer
- * ISourceViewer to operate on
- */
- public ContextBasedFormattingStrategy(ISourceViewer viewer) {
- fViewer= viewer;
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.IFormattingStrategyExtension#format()
- */
- public void format() {
-
- Assert.isLegal(fPreferences.size() > 0);
-
- fCurrentPreference= (Map)fPreferences.removeFirst();
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.IFormattingStrategy#format(java.lang.String, boolean, java.lang.String, int[])
- */
- public String format(String content, boolean isLineStart, String indent, int[] positions) {
- // Do nothing
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.IFormattingStrategyExtension#formatterStarts(org.eclipse.jface.text.formatter.IFormattingContext)
- */
- public void formatterStarts(IFormattingContext context) {
-
- final FormattingContext current= (FormattingContext)context;
-
- fPreferences.addLast(current.getProperty(FormattingContextProperties.CONTEXT_PREFERENCES));
- }
-
- /*
- * @see IFormattingStrategy#formatterStarts(String)
- */
- public void formatterStarts(String initialIndentation) {
- // Do nothing
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.IFormattingStrategyExtension#formatterStops()
- */
- public void formatterStops() {
- fPreferences.clear();
-
- fCurrentPreference= null;
- }
-
- /**
- * Returns the preferences to use during formatting.
- *
- * @return The formatting preferences
- */
- public final Map getPreferences() {
- return fCurrentPreference;
- }
-
- /**
- * Returns the source viewer to operate on.
- *
- * @return The source viewer to operate on
- */
- public final ISourceViewer getViewer() {
- return fViewer;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/FormattingContext.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/FormattingContext.java
deleted file mode 100644
index b49426d8bae..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/FormattingContext.java
+++ /dev/null
@@ -1,165 +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.formatter;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-
-/**
- * Default implementation of <code>IFormattingContext</code>.
- *
- * @since 3.0
- */
-public class FormattingContext implements IFormattingContext {
-
- /** Map to store the properties */
- private final Map fMap= new HashMap();
-
- /*
- * @see org.eclipse.jface.text.formatter.IFormattingContext#dispose()
- */
- public void dispose() {
- fMap.clear();
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.IFormattingContext#getPreferenceKeys()
- */
- public String[] getPreferenceKeys() {
- return new String[] {
- };
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.IFormattingContext#getProperty(java.lang.Object)
- */
- public Object getProperty(Object key) {
- return fMap.get(key);
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.IFormattingContext#isBooleanPreference(java.lang.String)
- */
- public boolean isBooleanPreference(String key) {
- return false;
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.IFormattingContext#isDoublePreference(java.lang.String)
- */
- public boolean isDoublePreference(String key) {
- return false;
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.IFormattingContext#isFloatPreference(java.lang.String)
- */
- public boolean isFloatPreference(String key) {
- return false;
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.IFormattingContext#isIntegerPreference(java.lang.String)
- */
- public boolean isIntegerPreference(String key) {
- return false;
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.IFormattingContext#isLongPreference(java.lang.String)
- */
- public boolean isLongPreference(String key) {
- return false;
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.IFormattingContext#isStringPreference(java.lang.String)
- */
- public boolean isStringPreference(String key) {
- return false;
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.IFormattingContext#mapToStore(java.util.Map, org.eclipse.jface.preference.IPreferenceStore)
- */
- public void mapToStore(Map map, IPreferenceStore store) {
-
- final String[] preferences= getPreferenceKeys();
-
- String result= null;
- String preference= null;
-
- for (int index= 0; index < preferences.length; index++) {
-
- preference= preferences[index];
- result= (String)map.get(preference);
-
- if (result != null) {
-
- try {
- if (isBooleanPreference(preference)) {
- store.setValue(preference, result.equals(IPreferenceStore.TRUE));
- } else if (isIntegerPreference(preference)) {
- store.setValue(preference, Integer.parseInt(result));
- } else if (isStringPreference(preference)) {
- store.setValue(preference, result);
- } else if (isDoublePreference(preference)) {
- store.setValue(preference, Double.parseDouble(result));
- } else if (isFloatPreference(preference)) {
- store.setValue(preference, Float.parseFloat(result));
- } else if (isLongPreference(preference)) {
- store.setValue(preference, Long.parseLong(result));
- }
- } catch (NumberFormatException exception) {
- // Do nothing
- }
- }
- }
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.IFormattingContext#setProperty(java.lang.Object, java.lang.Object)
- */
- public void setProperty(Object key, Object property) {
- fMap.put(key, property);
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.IFormattingContext#storeToMap(org.eclipse.jface.preference.IPreferenceStore, java.util.Map, boolean)
- */
- public void storeToMap(IPreferenceStore store, Map map, boolean useDefault) {
-
- final String[] preferences= getPreferenceKeys();
-
- String preference= null;
- for (int index= 0; index < preferences.length; index++) {
-
- preference= preferences[index];
-
- if (isBooleanPreference(preference)) {
- map.put(preference, (useDefault ? store.getDefaultBoolean(preference) : store.getBoolean(preference)) ? IPreferenceStore.TRUE : IPreferenceStore.FALSE);
- } else if (isIntegerPreference(preference)) {
- map.put(preference, String.valueOf(useDefault ? store.getDefaultInt(preference) : store.getInt(preference)));
- } else if (isStringPreference(preference)) {
- map.put(preference, useDefault ? store.getDefaultString(preference) : store.getString(preference));
- } else if (isDoublePreference(preference)) {
- map.put(preference, String.valueOf(useDefault ? store.getDefaultDouble(preference) : store.getDouble(preference)));
- } else if (isFloatPreference(preference)) {
- map.put(preference, String.valueOf(useDefault ? store.getDefaultFloat(preference) : store.getFloat(preference)));
- } else if (isLongPreference(preference)) {
- map.put(preference, String.valueOf(useDefault ? store.getDefaultLong(preference) : store.getLong(preference)));
- }
- }
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/FormattingContextProperties.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/FormattingContextProperties.java
deleted file mode 100644
index b0c549bac63..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/FormattingContextProperties.java
+++ /dev/null
@@ -1,78 +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.formatter;
-
-/**
- * Keys used by <code>IFormattingContext</code> objects to register specific
- * properties needed during the formatting process of a content formatter
- * implementing <code>IContentFormatterExtension2</code>.
- *
- * @see IFormattingContext
- * @see IFormattingStrategyExtension
- * @see IContentFormatterExtension2
- * @since 3.0
- */
-public class FormattingContextProperties {
-
- /**
- * Ensure that this class cannot be instantiated.
- */
- private FormattingContextProperties() {
- }
-
- /**
- * Property key of the indentation property. The property must implement
- * <code>java.lang#String</code>.
- * <p>
- * Value: <code>"formatting.context.indentation"</code>
- */
- public static final String CONTEXT_INDENTATION= "formatting.context.indentation"; //$NON-NLS-1$
-
- /**
- * Property key of the partition property. The property must implement
- * <code>org.eclipse.jface.text#TypedPosition</code>.
- * <p>
- * Value: <code>"formatting.context.partition"</code>
- */
- public static final String CONTEXT_PARTITION= "formatting.context.partition"; //$NON-NLS-1$
-
- /**
- * Property key of the positions property. The property must implement
- * <code>int[]</code>.
- * <p>
- * Value: <code>"formatting.context.positions"</code>
- */
- public static final String CONTEXT_POSITIONS= "formatting.context.positions"; //$NON-NLS-1$
-
- /**
- * Property key of the preferences property. The property must implement
- * <code>java.util#Map</code>.
- * <p>
- * Value: <code>"formatting.context.preferences"</code>
- */
- public static final String CONTEXT_PREFERENCES= "formatting.context.preferences"; //$NON-NLS-1$
-
- /**
- * Property key of the document property. The property must implement
- * <code>java.lang#Boolean</code>.
- * <p>
- * Value: <code>"formatting.context.document"</code>
- */
- public static final String CONTEXT_DOCUMENT= "formatting.context.document"; //$NON-NLS-1$
-
- /**
- * Property key of the region property. The property must implement <code>org.eclipse.jface.text#IRegion</code>.
- * <p>
- * Value: <code>"formatting.context.region"</code>
- */
- public static final String CONTEXT_REGION= "formatting.context.region"; //$NON-NLS-1$
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IContentFormatter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IContentFormatter.java
deleted file mode 100644
index 4b60fdd44fd..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IContentFormatter.java
+++ /dev/null
@@ -1,55 +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.formatter;
-
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-
-
-/**
- * The interface of a document content formatter. The formatter formats ranges
- * within documents. The documents are modified by the formatter.<p>
- * The content formatter is assumed to determine the partitioning of the document
- * range to be formatted. For each partition, the formatter determines based
- * on the partition's content type the formatting strategy to be used. Before
- * the first strategy is activated all strategies are informed about the
- * start of the formatting process. After that, the formatting strategies are
- * activated in the sequence defined by the partitioning of the document range to be
- * formatted. It is assumed that a strategy must be finished before the next strategy
- * can be activated. After the last strategy has been finished, all strategies are
- * informed about the termination of the formatting process.<p>
- * The interface can be implemented by clients. By default, clients use <code>ContentFormatter</code>
- * as the standard implementer of this interface.
- *
- * @see IDocument
- * @see IFormattingStrategy
- */
-public interface IContentFormatter {
-
- /**
- * Formats the given region of the specified document.The formatter may safely
- * assume that it is the only subject that modifies the document at this point in time.
- *
- * @param document the document to be formatted
- * @param region the region within the document to be formatted
- */
- void format(IDocument document, IRegion region);
-
- /**
- * Returns the formatting strategy registered for the given content type.
- *
- * @param contentType the content type for which to look up the formatting strategy
- * @return the formatting strategy for the given content type, or
- * <code>null</code> if there is no such strategy
- */
- IFormattingStrategy getFormattingStrategy(String contentType);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IContentFormatterExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IContentFormatterExtension.java
deleted file mode 100644
index 0ab4f5e5d30..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IContentFormatterExtension.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**********************************************************************
-Copyright (c) 2000, 2003 IBM Corp. 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 implementation
-**********************************************************************/
-package org.eclipse.jface.text.formatter;
-
-/**
- * Extension interface for <code>IContentFormatter</code>.
- * Updates the content formatter to be aware of documents with multiple partitions.
- *
- * @since 3.0
- */
-public interface IContentFormatterExtension {
-
- /**
- * Returns the partitioning this content formatter is using.
- *
- * @return the partitioning this content formatter is using
- */
- String getDocumentPartitioning();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IContentFormatterExtension2.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IContentFormatterExtension2.java
deleted file mode 100644
index bfd98c19a63..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IContentFormatterExtension2.java
+++ /dev/null
@@ -1,86 +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.formatter;
-
-import org.eclipse.jface.text.IDocument;
-
-/**
- * Extension interface for <code>IContentFormatter</code>.
- * <p>
- * Updates the content formatter to be able to pass <code>IFormattingContext</code>
- * context objects to <code>IFormattingStrategyExtension<code> objects
- * operating in context based mode. The context based mode supersedes
- * the previous modes offered by <code>IContentFormatter</code>, namely
- * partition aware/unaware formatting.
- * <p>
- * Clients using context based formatting call the method
- * <code>format(IDocument, IFormattingContext)</code> with a properly
- * initialized formatting context.<br>
- * The formatting context must be set up according to the desired formatting mode:
- * <ul>
- * <li>For whole document formatting set the property <code>CONTEXT_DOCUMENT</code>. This is
- * equivalent to setting <code>CONTEXT_REGION</code> with a region spanning the whole document.</li>
- * <li>For single partition formatting set the property <code>CONTEXT_PARTITION</code>. The partition
- * property must correspond to a document partition in the current partitioning of the content formatter.</li>
- * <li>For multiple region formatting set the property <code>CONTEXT_REGION</code>. Note that
- * the content formatter automatically aligns the region to a block selected region, and if the region spans
- * multiple partitions, it also completes eventual partitions only partially covered by the region.</li>
- * </ul>
- * Depending on the registered formatting strategies, more context information must
- * be passed in the formatting context, like e.g. <code>CONTEXT_PREFERENCES</code>.
- * <p>
- * Note that in context based mode the content formatter is fully reentrant, but not
- * thread-safe. Formatting strategies are therefore allowed to recursively call the
- * method <code>format(IDocument, IFormattingContext)</code>. The formatting
- * context is saved between calls to this method.
- * <p>
- *
- * @see IFormattingContext
- * @see FormattingContextProperties
- * @since 3.0
- */
-public interface IContentFormatterExtension2 {
-
- /**
- * Formats the given region of the specified document.
- * <p>
- * The formatter may safely assume that it is the only subject that
- * modifies the document at this point in time. This method is fully
- * reentrant. Formatting strategies registered with <code>IContentFormatterExtension2</code>
- * objects are therefore allowed to recursively call this method on
- * subregions of the region to be formatted.
- * <p>
- * The formatting process performed by <code>format(IDocument, IFormattingContext)</code>
- * happens as follows:
- * <ul>
- * <li>In a first pass the content formatter formats the range of the
- * document to be formatted by using the master formatting strategy. This
- * happens regardless of the content type of the underlying partition.
- * </li>
- * <li>In the second pass, the range is formatted again, this time using
- * the registered slave formatting strategies. For each partition contained
- * in the range to be formatted, the content formatter determines its
- * content type and formats the partition with the correct formatting
- * strategy.
- * </li>
- *
- * @param document
- * The document to be formatted
- * @param context
- * The formatting context to pass to the formatting strategies.
- * This argument must not be <code>null</code>. Most
- * formatting strategies only require the <code>CONTEXT_DOCUMENT</code>
- * to be set. Depending on the registered formatting strategies,
- * more properties can be required.
- */
- void format(IDocument document, IFormattingContext context);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IFormattingContext.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IFormattingContext.java
deleted file mode 100644
index abe66003aa1..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IFormattingContext.java
+++ /dev/null
@@ -1,157 +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.formatter;
-
-import java.util.Map;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-
-/**
- * Formatting context used in formatting strategies implementing interface
- * <code>IFormattingStrategyExtension</code>.
- *
- * @see IFormattingStrategyExtension
- * @see IFormattingContextProperties
- * @since 3.0
- */
-public interface IFormattingContext {
-
- /**
- * Dispose of the formatting context.
- * <p>
- * Must be called after the formatting context has been used in a
- * formatting process.
- */
- void dispose();
-
- /**
- * Returns the preference keys used for the retrieval of formatting
- * preferences.
- *
- * @return The preference keys for formatting
- */
- String[] getPreferenceKeys();
-
- /**
- * Retrieves the property <code>key</code> from the formatting context
- *
- * @param key
- * Key of the property to store in the context
- * @return The property <code>key</code> if available, <code>null</code>
- * otherwise
- */
- Object getProperty(Object key);
-
- /**
- * Is this preference key for a boolean preference?
- *
- * @param key
- * The preference key to query its type
- * @return <code>true</code> iff this key is for a boolean preference,
- * <code>false</code> otherwise.
- */
- boolean isBooleanPreference(String key);
-
- /**
- * Is this preference key for a double preference?
- *
- * @param key
- * The preference key to query its type
- * @return <code>true</code> iff this key is for a double preference,
- * <code>false</code> otherwise.
- */
- boolean isDoublePreference(String key);
-
- /**
- * Is this preference key for a float preference?
- *
- * @param key
- * The preference key to query its type
- * @return <code>true</code> iff this key is for a float preference,
- * <code>false</code> otherwise.
- */
- boolean isFloatPreference(String key);
-
- /**
- * Is this preference key for an integer preference?
- *
- * @param key
- * The preference key to query its type
- * @return <code>true</code> iff this key is for an integer preference,
- * <code>false</code> otherwise.
- */
- boolean isIntegerPreference(String key);
-
- /**
- * Is this preference key for a long preference?
- *
- * @param key
- * The preference key to query its type
- * @return <code>true</code> iff this key is for a long preference,
- * <code>false</code> otherwise.
- */
- boolean isLongPreference(String key);
-
- /**
- * Is this preference key for a string preference?
- *
- * @param key
- * The preference key to query its type
- * @return <code>true</code> iff this key is for a string preference,
- * <code>false</code> otherwise.
- */
- boolean isStringPreference(String key);
-
- /**
- * Stores the preferences from a map to a preference store.
- * <p>
- * Note that the preference keys returned by
- * {@link getPreferenceKeys()} must not be used in the preference store.
- * Otherwise the preferences are overwritten.
- * </p>
- *
- * @param map
- * Map to retrieve the preferences from
- * @param store
- * Preference store to store the preferences in
- */
- void mapToStore(Map map, IPreferenceStore store);
-
- /**
- * Stores the property <code>key</code> in the formatting context.
- *
- * @param key
- * Key of the property to store in the context
- * @param property
- * Property to store in the context. If already present, the new
- * property overwrites the present one.
- */
- void setProperty(Object key, Object property);
-
- /**
- * Retrieves the preferences from a preference store in a map.
- * <p>
- * Note that the preference keys returned by
- * {@link getPreferenceKeys()} must not be used in the map. Otherwise the
- * preferences are overwritten.
- * </p>
- *
- * @param store
- * Preference store to retrieve the preferences from
- * @param map
- * Map to store the preferences in
- * @param useDefault
- * <code>true</code> iff the default preferences should be
- * used, <code>false</code> otherwise
- */
- void storeToMap(IPreferenceStore store, Map map, boolean useDefault);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IFormattingStrategy.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IFormattingStrategy.java
deleted file mode 100644
index 892ec6488ab..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IFormattingStrategy.java
+++ /dev/null
@@ -1,55 +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.formatter;
-
-
-/**
- * An formatting strategy is assumed to be specialized on formatting text
- * of a particular content type. Each formatting process calls the strategy's
- * methods in the following sequence:
- * <ul>
- * <li><code>formatterStarts</code>
- * <li><code>format</code>
- * <li><code>formatterStops</code>
- * </ul>
- * This interface must be implemented by clients. Implementers should be registered with
- * a content formatter in order get involved in the formatting process.
- */
-public interface IFormattingStrategy {
-
- /**
- * Informs the strategy about the start of a formatting process in which it will
- * participate.
- *
- * @param initialIndentation the indent string of the first line at which the
- * overall formatting process starts.
- */
- void formatterStarts(String initialIndentation);
-
- /**
- * Formats the given string. During the formatting process this strategy must update
- * the given character positions according to the changes applied to the given string.
- *
- * @param content the initial string to be formatted
- * @param isLineStart indicates whether the beginning of content is a line start in its document
- * @param indentation the indentation string to be used
- * @param positions the character positions to be updated
- * @return the formatted string
- */
- String format(String content, boolean isLineStart, String indentation, int[] positions);
-
- /**
- * Informs the strategy that the formatting process in which it has participated
- * has been finished.
- */
- void formatterStops();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IFormattingStrategyExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IFormattingStrategyExtension.java
deleted file mode 100644
index a817c2d0735..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IFormattingStrategyExtension.java
+++ /dev/null
@@ -1,61 +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.formatter;
-
-/**
- * Extension interface for <code>IFormattingStrategy</code>.
- * <p>
- * Updates formatting strategies to be able to receive a more general <code>IFormattingContext</code>
- * object from its associated content formatters.
- * <p>
- * Each formatting process calls the strategy's methods in the following
- * sequence:
- * <ul>
- * <li><code>formatterStarts</code>
- * <li><code>format</code>
- * <li><code>formatterStops</code>
- * </ul>
- * <p>
- * Note that multiple calls to <code>formatterStarts</code> can be issued to
- * a strategy before launching the formatting process with <code>format</code>.
- * <p>
- * This interface must be implemented by clients. Implementers should be
- * registered with a content formatter in order get involved in the formatting
- * process.
- *
- * @see IFormattingContext
- * @since 3.0
- */
-public interface IFormattingStrategyExtension {
-
- /**
- * Formats the region with the properties indicated in the formatting
- * context previously supplied by <code>formatterStarts(IFormattingContext)</code>.
- */
- void format();
-
- /**
- * Informs the strategy about the start of a formatting process in which it
- * will participate.
- *
- * @param context
- * Formatting context used in the corresponding formatting
- * process.
- */
- void formatterStarts(IFormattingContext context);
-
- /**
- * Informs the strategy that the formatting process in which it has
- * participated has been finished.
- */
- void formatterStops();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/package.html b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/package.html
deleted file mode 100644
index 33f16a7de0c..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/package.html
+++ /dev/null
@@ -1,21 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="Author" content="IBM">
- <meta name="GENERATOR" content="Mozilla/4.51 [en] (WinNT; I) [Netscape]">
- <title>Package-level Javadoc</title>
-</head>
-<body>
-Provides a text formatter add-on for an <tt>ITextViewer</tt>.
-A text formatter changes the formatting of&nbsp; document region while
-preserving and correctly updating the positions of the document.
-<h2>
-Package Specification</h2>
-<tt>IContentFormatter</tt> defines the concept of a text formatter. It
-collaborates with content type specific formatting stratgies (<tt>IFormattingStrategy</tt>)
-which for a given document region format the subregion with the matching
-content type. The package contains a default implementation of <tt>IContentFormatter</tt>
-(<tt>ContentFormatter</tt>).
-</body>
-</html>
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/information/IInformationPresenter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/information/IInformationPresenter.java
deleted file mode 100644
index 489f4e85947..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/information/IInformationPresenter.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.information;
-
-
-import org.eclipse.jface.text.ITextViewer;
-
-
-/**
- * An information presenter shows information available at the text viewer's
- * current document position. An <code>IInformationPresenter</code> is a
- * <code>ITextViewer</code> add-on.<p>
- * An information presenters has a list of <code>IInformationProvider</code> objects
- * each of which is registered for a particular document content type.
- * The presenter uses the strategy objects to retrieve the information to present.<p>
- * The interface can be implemented by clients. By default, clients use
- * <code>InformationPresenter</code> as the standard implementer of this interface.
- *
- * @see ITextViewer
- * @see IInformationProvider
- * @since 2.0
- */
-public interface IInformationPresenter {
-
- /**
- * Installs the information presenter on the given text viewer. After this method has been
- * finished, the presenter is operational. I.e., the method <code>showInformation</code>
- * can be called until <code>uninstall</code> is called.
- *
- * @param textViewer the viewer on which the presenter is installed
- */
- void install(ITextViewer textViewer);
-
- /**
- * Removes the information presenter from the text viewer it has previously been
- * installed on.
- */
- void uninstall();
-
- /**
- * Shows information related to the cursor position of the text viewer
- * this information presenter is installed on.
- *
- * @return an optional error message if
- */
- void showInformation();
-
- /**
- * Returns the information provider to be used for the given content type.
- *
- * @param contentType the type of the content for which information will be requested
- * @return an information provider or
- * <code>null</code> if none exists for the specified content type
- */
- IInformationProvider getInformationProvider(String contentType);
-}
-
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/information/IInformationPresenterExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/information/IInformationPresenterExtension.java
deleted file mode 100644
index ebff080355a..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/information/IInformationPresenterExtension.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**********************************************************************
-Copyright (c) 2000, 2003 IBM Corp. 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 implementation
-**********************************************************************/
-package org.eclipse.jface.text.information;
-
-/**
- * Extension interface for <code>IInformationPresenter</code>.
- * Updates the information presenter to be aware of documents with multiple partitions.
- *
- * @since 3.0
- */
-public interface IInformationPresenterExtension {
-
- /**
- * Returns the document partitioning this information presenter is using.
- *
- * @return the document partitioning this information presenter is using
- */
- String getDocumentPartitioning();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/information/IInformationProvider.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/information/IInformationProvider.java
deleted file mode 100644
index 527aec4c37e..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/information/IInformationProvider.java
+++ /dev/null
@@ -1,54 +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.information;
-
-
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextViewer;
-
-
-/**
- * Provides information related to the content of a text viewer.<p>
- * Clients may implement this interface.
- *
- * @see ITextViewer
- * @since 2.0
- */
-public interface IInformationProvider {
-
- /**
- * Returns the region of the text viewer's document close to the given
- * offset that contains a subject about which information can be provided.<p>
- * For example, if information can be provided on a per code block basis,
- * the offset should be used to find the enclosing code block and the source
- * range of the block should be returned.
- *
- * @param textViewer the text viewer in which informationhas been requested
- * @param offset the offset at which information has been requested
- * @return the region of the text viewer's document containing the information subject
- */
- IRegion getSubject(ITextViewer textViewer, int offset);
-
- /**
- * Returns the information about the given subject or <code>null</code> if
- * no information is available. It depends on the concrete configuration in which
- * format the information is to be provided. For example, information presented
- * in an information control displaying HTML, should be provided in HTML.
- *
- * @param textViewer the viewer in whose document the subject is contained
- * @param subject the text region constituting the information subject
- * @return the information about the subject
- * @see IInformationPresenter
- * @deprecated As of 2.1, replaced by {@link IInformationProviderExtension#getInformation2(ITextViewer, IRegion)}
- */
- String getInformation(ITextViewer textViewer, IRegion subject);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/information/IInformationProviderExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/information/IInformationProviderExtension.java
deleted file mode 100644
index 077c9f15f7e..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/information/IInformationProviderExtension.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.information;
-
-
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextViewer;
-
-
-/**
- * Extension interface for <code>IInformationProvider</code> to provide
- * the element for a given subject.
- *
- * @see org.eclipse.jface.text.information.IInformationProvider
- * @since 2.1
- */
-public interface IInformationProviderExtension {
-
- /**
- * Returns the element for the given subject or <code>null</code> if
- * no element is available.
- * <p>
- * Implementers should ignore the text returned by <code>IInformationProvider.getInformation()</code>.
- * </p>
- *
- * @param textViewer the viewer in whose document the subject is contained
- * @param subject the text region constituting the information subject
- * @return the element for the subject
- *
- * @see IInformationProvider#getInformation(ITextViewer, IRegion)
- * @see org.eclipse.jface.text.ITextViewer
- */
- Object getInformation2(ITextViewer textViewer, IRegion subject);
-}
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
deleted file mode 100644
index eaa66233083..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/information/IInformationProviderExtension2.java
+++ /dev/null
@@ -1,31 +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.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 {
-
- /**
- * Returns the information control creator of this information provider.
- *
- * @return the information control creator
- */
- IInformationControlCreator getInformationPresenterControlCreator();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/information/InformationPresenter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/information/InformationPresenter.java
deleted file mode 100644
index fd8c6edfef9..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/information/InformationPresenter.java
+++ /dev/null
@@ -1,492 +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.information;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.ControlListener;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-
-import org.eclipse.jface.text.AbstractInformationControlManager;
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocumentExtension3;
-import org.eclipse.jface.text.IInformationControl;
-import org.eclipse.jface.text.IInformationControlCreator;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.ITextViewerExtension3;
-import org.eclipse.jface.text.IViewportListener;
-import org.eclipse.jface.text.IWidgetTokenKeeper;
-import org.eclipse.jface.text.IWidgetTokenKeeperExtension;
-import org.eclipse.jface.text.IWidgetTokenOwner;
-import org.eclipse.jface.text.IWidgetTokenOwnerExtension;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextUtilities;
-
-
-/**
- * Standard implementation of <code>IInformationPresenter</code>.
- * This implementation extends <code>AbstractInformationControlManager</code>.
- * The information control is made visible on request by calling
- * <code>showInformation</code>.<p>
- * Usually, clients instantiate this class and configure it before using it. The configuration
- * must be consistent: This means the used <code>IInformationControlCreator</code>
- * must create an information control expecting information in the same format the configured
- * <code>IInformationProvider</code>s use to encode the information they provide.
- *
- * @since 2.0
- */
-public class InformationPresenter extends AbstractInformationControlManager implements IInformationPresenter, IInformationPresenterExtension, IWidgetTokenKeeper, IWidgetTokenKeeperExtension {
-
-
- /**
- * Priority of the info controls managed by this information presenter.
- * Default value: <code>0</code>;
- * @since 3.0
- */
- public static final int WIDGET_PRIORITY= 0;
-
-
- /**
- * Internal information control closer. Listens to several events issued by its subject control
- * and closes the information control when necessary.
- */
- class Closer implements IInformationControlCloser, ControlListener, MouseListener, FocusListener, IViewportListener, KeyListener {
-
- /** The subject control */
- private Control fSubjectControl;
- /** The information control */
- private IInformationControl fInformationControl;
- /** Indicates whether this closer is active */
- private boolean fIsActive= false;
-
- /*
- * @see IInformationControlCloser#setSubjectControl(Control)
- */
- public void setSubjectControl(Control control) {
- fSubjectControl= control;
- }
-
- /*
- * @see IInformationControlCloser#setInformationControl(IInformationControl)
- */
- public void setInformationControl(IInformationControl control) {
- fInformationControl= control;
- }
-
- /*
- * @see IInformationControlCloser#start(Rectangle)
- */
- public void start(Rectangle informationArea) {
-
- if (fIsActive)
- return;
- fIsActive= true;
-
- if (fSubjectControl != null && ! fSubjectControl.isDisposed()) {
- fSubjectControl.addControlListener(this);
- fSubjectControl.addMouseListener(this);
- fSubjectControl.addFocusListener(this);
- fSubjectControl.addKeyListener(this);
- }
-
- if (fInformationControl != null)
- fInformationControl.addFocusListener(this);
-
- fTextViewer.addViewportListener(this);
- }
-
- /*
- * @see IInformationControlCloser#stop()
- */
- public void stop() {
-
- if (!fIsActive)
- return;
- fIsActive= false;
-
- fTextViewer.removeViewportListener(this);
-
- if (fInformationControl != null)
- fInformationControl.removeFocusListener(this);
-
- hideInformationControl();
-
- if (fSubjectControl != null && !fSubjectControl.isDisposed()) {
- fSubjectControl.removeControlListener(this);
- fSubjectControl.removeMouseListener(this);
- fSubjectControl.removeFocusListener(this);
- fSubjectControl.removeKeyListener(this);
- }
- }
-
- /*
- * @see ControlListener#controlResized(ControlEvent)
- */
- public void controlResized(ControlEvent e) {
- stop();
- }
-
- /*
- * @see ControlListener#controlMoved(ControlEvent)
- */
- public void controlMoved(ControlEvent e) {
- stop();
- }
-
- /*
- * @see MouseListener#mouseDown(MouseEvent)
- */
- public void mouseDown(MouseEvent e) {
- stop();
- }
-
- /*
- * @see MouseListener#mouseUp(MouseEvent)
- */
- public void mouseUp(MouseEvent e) {
- }
-
- /*
- * @see MouseListener#mouseDoubleClick(MouseEvent)
- */
- public void mouseDoubleClick(MouseEvent e) {
- stop();
- }
-
- /*
- * @see FocusListener#focusGained(FocusEvent)
- */
- public void focusGained(FocusEvent e) {
- }
-
- /*
- * @see FocusListener#focusLost(FocusEvent)
- */
- public void focusLost(FocusEvent e) {
- Display d= fSubjectControl.getDisplay();
- d.asyncExec(new Runnable() {
- public void run() {
- if (fInformationControl == null || !fInformationControl.isFocusControl())
- stop();
- }
- });
- }
-
- /*
- * @see IViewportListenerListener#viewportChanged(int)
- */
- public void viewportChanged(int topIndex) {
- stop();
- }
-
- /*
- * @see KeyListener#keyPressed(KeyEvent)
- */
- public void keyPressed(KeyEvent e) {
- stop();
- }
-
- /*
- * @see KeyListener#keyReleased(KeyEvent)
- */
- public void keyReleased(KeyEvent e) {
- }
- }
-
-
- /** The text viewer this information presenter works on */
- private ITextViewer fTextViewer;
- /** The map of <code>IInformationProvider</code> objects */
- private Map fProviders;
- /** The offset to override selection. */
- private int fOffset= -1;
- /**
- * The document partitioning for this information presenter.
- * @since 3.0
- */
- private String fPartitioning;
-
- /**
- * Creates a new information presenter that uses the given information control creator.
- * The presenter is not installed on any text viewer yet. By default, an information
- * control closer is set that closes the information control in the event of key strokes,
- * resizing, moves, focus changes, mouse clicks, and disposal - all of those applied to
- * the information control's parent control. Also, the setup ensures that the information
- * control when made visible will request thel focus. By default, the default document
- * partitioning <code>IDocumentExtension3.DEFAULT_PARTITIONING</code> is used.
- *
- * @param creator the information control creator to be used
- */
- public InformationPresenter(IInformationControlCreator creator) {
- super(creator);
- setCloser(new Closer());
- takesFocusWhenVisible(true);
- fPartitioning= IDocumentExtension3.DEFAULT_PARTITIONING;
- }
-
- /**
- * Sets the document partitioning to be used by this information presenter.
- *
- * @param partitioning the document partitioning to be used by this information presenter
- * @since 3.0
- */
- public void setDocumentPartitioning(String partitioning) {
- Assert.isNotNull(partitioning);
- fPartitioning= partitioning;
- }
-
- /*
- * @see org.eclipse.jface.text.information.IInformationPresenterExtension#getDocumentPartitioning()
- * @since 3.0
- */
- public String getDocumentPartitioning() {
- return fPartitioning;
- }
-
- /**
- * Registers a given information provider for a particular content type.
- * If there is already a provider registered for this type, the new provider
- * is registered instead of the old one.
- *
- * @param provider the information provider to register, or <code>null</code> to remove an existing one
- * @param contentType the content type under which to register
- */
- public void setInformationProvider(IInformationProvider provider, String contentType) {
-
- Assert.isNotNull(contentType);
-
- if (fProviders == null)
- fProviders= new HashMap();
-
- if (provider == null)
- fProviders.remove(contentType);
- else
- fProviders.put(contentType, provider);
- }
-
- /*
- * @see IInformationPresenter#getInformationProvider(String)
- */
- public IInformationProvider getInformationProvider(String contentType) {
- if (fProviders == null)
- return null;
-
- return (IInformationProvider) fProviders.get(contentType);
- }
-
- /**
- * Sets a offset to override the selection. Setting the value to <code>-1</code> will disable
- * overriding.
- *
- * @param offset the offset to override selection or <code>-1</code>
- */
- public void setOffset(int offset) {
- fOffset= offset;
- }
-
- /*
- * @see AbstractInformationControlManager#computeInformation()
- */
- protected void computeInformation() {
-
- int offset= fOffset < 0 ? fTextViewer.getSelectedRange().x : fOffset;
- if (offset == -1)
- return;
-
- fOffset= -1;
-
- IInformationProvider provider= null;
- try {
- String contentType= TextUtilities.getContentType(fTextViewer.getDocument(), getDocumentPartitioning(), offset);
- provider= getInformationProvider(contentType);
- } catch (BadLocationException x) {
- }
- if (provider == null)
- return;
-
- IRegion subject= provider.getSubject(fTextViewer, offset);
- if (subject == null)
- return;
-
- if (provider instanceof IInformationProviderExtension2)
- setCustomInformationControlCreator(((IInformationProviderExtension2) provider).getInformationPresenterControlCreator());
- else
- setCustomInformationControlCreator(null);
-
- if (provider instanceof IInformationProviderExtension) {
- IInformationProviderExtension extension= (IInformationProviderExtension) provider;
- setInformation(extension.getInformation2(fTextViewer, subject), computeArea(subject));
- } else
- setInformation(provider.getInformation(fTextViewer, subject), computeArea(subject));
- }
-
- /**
- * Determines the graphical area covered by the given text region.
- *
- * @param region the region whose graphical extend must be computed
- * @return the graphical extend of the given region
- */
- private Rectangle computeArea(IRegion region) {
-
- IRegion widgetRegion= modelRange2WidgetRange(region);
- int start= widgetRegion.getOffset();
- int end= widgetRegion.getOffset() + widgetRegion.getLength();
-
- StyledText styledText= fTextViewer.getTextWidget();
- Point upperLeft= styledText.getLocationAtOffset(start);
- Point lowerRight= new Point(upperLeft.x, upperLeft.y);
-
- for (int i= start +1; i < end; i++) {
-
- Point p= styledText.getLocationAtOffset(i);
-
- if (upperLeft.x > p.x)
- upperLeft.x= p.x;
-
- if (upperLeft.y > p.y)
- upperLeft.y= p.y;
-
- if (lowerRight.x < p.x)
- lowerRight.x= p.x;
-
- if (lowerRight.y < p.y)
- lowerRight.y= p.y;
- }
-
- GC gc= new GC(styledText);
- lowerRight.x += gc.getFontMetrics().getAverageCharWidth();
- lowerRight.y += styledText.getLineHeight();
- gc.dispose();
-
- int width= lowerRight.x - upperLeft.x;
- int height= lowerRight.y - upperLeft.y;
- return new Rectangle(upperLeft.x, upperLeft.y, width, height);
- }
-
- /**
- * Translated the given range in the viewer's document into the corresponding
- * range of the viewer's widget.
- *
- * @param region the range in the viewer's document
- * @return the corresponding widget range
- * @since 2.1
- */
- private IRegion modelRange2WidgetRange(IRegion region) {
- if (fTextViewer instanceof ITextViewerExtension3) {
- ITextViewerExtension3 extension= (ITextViewerExtension3) fTextViewer;
- return extension.modelRange2WidgetRange(region);
- }
-
- IRegion visibleRegion= fTextViewer.getVisibleRegion();
- int start= region.getOffset() - visibleRegion.getOffset();
- int end= start + region.getLength();
- if (end > visibleRegion.getLength())
- end= visibleRegion.getLength();
-
- return new Region(start, end - start);
- }
-
- /*
- * @see IInformationPresenter#install(ITextViewer)
- */
- public void install(ITextViewer textViewer) {
- fTextViewer= textViewer;
- install(fTextViewer.getTextWidget());
- }
-
- /*
- * @see IInformationPresenter#uninstall()
- */
- public void uninstall() {
- dispose();
- }
-
- /*
- * @see AbstractInformationControlManager#showInformationControl(Rectangle)
- */
- protected void showInformationControl(Rectangle subjectArea) {
- if (fTextViewer instanceof IWidgetTokenOwner) {
- IWidgetTokenOwner owner= (IWidgetTokenOwner) fTextViewer;
- if (owner.requestWidgetToken(this))
- super.showInformationControl(subjectArea);
-
- } else if (fTextViewer instanceof IWidgetTokenOwnerExtension) {
- IWidgetTokenOwnerExtension extension= (IWidgetTokenOwnerExtension) fTextViewer;
- if (extension.requestWidgetToken(this, WIDGET_PRIORITY))
- super.showInformationControl(subjectArea);
- }
- }
-
- /*
- * @see AbstractInformationControlManager#hideInformationControl()
- */
- protected void hideInformationControl() {
- try {
- super.hideInformationControl();
- } finally {
- if (fTextViewer instanceof IWidgetTokenOwner) {
- IWidgetTokenOwner owner= (IWidgetTokenOwner) fTextViewer;
- owner.releaseWidgetToken(this);
- }
- }
- }
-
- /*
- * @see AbstractInformationControlManager#handleInformationControlDisposed()
- */
- protected void handleInformationControlDisposed() {
- try {
- super.handleInformationControlDisposed();
- } finally {
- if (fTextViewer instanceof IWidgetTokenOwner) {
- IWidgetTokenOwner owner= (IWidgetTokenOwner) fTextViewer;
- owner.releaseWidgetToken(this);
- }
- }
- }
-
- /*
- * @see org.eclipse.jface.text.IWidgetTokenKeeper#requestWidgetToken(IWidgetTokenOwner)
- */
- public boolean requestWidgetToken(IWidgetTokenOwner owner) {
- return false;
- }
-
- /*
- * @see org.eclipse.jface.text.IWidgetTokenKeeperExtension#requestWidgetToken(org.eclipse.jface.text.IWidgetTokenOwner, int)
- */
- public boolean requestWidgetToken(IWidgetTokenOwner owner, int priority) {
- return false;
- }
-
- /*
- * @see org.eclipse.jface.text.IWidgetTokenKeeperExtension#setFocus(org.eclipse.jface.text.IWidgetTokenOwner)
- */
- public boolean setFocus(IWidgetTokenOwner owner) {
- return false;
- }
-}
-
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/information/package.html b/org.eclipse.jface.text/src/org/eclipse/jface/text/information/package.html
deleted file mode 100644
index 2c20da02084..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/information/package.html
+++ /dev/null
@@ -1,22 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="Author" content="IBM">
- <meta name="GENERATOR" content="Mozilla/4.76 [en] (Windows NT 5.0; U) [Netscape]">
- <title>Package-level Javadoc</title>
-</head>
-<body>
-Provides an information provider add-on for an <tt>ITextViewer</tt>.
-An information provider presents information for a certain subject in a
-specific information control. An information control usually is a floating
-window.
-<h2>
-Package Specification</h2>
-<tt>IInformationPresenter</tt> defines the concept of an information provider.
-It collaborates with content type specific information providers (<tt>IInformationProvider</tt>)
-which determine for a certain offset in a text viewer an information subject
-and the information available about this subject.. The package contains
-a default implementation of <tt>IInformationPresenter</tt> (<tt>InformationPresenter</tt>).
-</body>
-</html>
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/package.html b/org.eclipse.jface.text/src/org/eclipse/jface/text/package.html
deleted file mode 100644
index 5561c3748e5..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/package.html
+++ /dev/null
@@ -1,82 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="Author" content="IBM">
- <meta name="GENERATOR" content="Mozilla/4.51 [en] (WinNT; I) [Netscape]">
- <title>Package-level Javadoc</title>
-</head>
-<body>
-Provides a framework for creating, manipulating, displaying
-and editing text documents.
-<h2>
-Package Specification</h2>
-The packages is divided into two parts. The first part defines and implements
-the notion of text documents, whereas the second part defines and implements
-a viewer for text documents.
-<h3>
-Text Model</h3>
-<tt>IDocument</tt> is the major text model abstraction. It provides content
-management, position management using position categories, document partition
-management, searching, and change notification.&nbsp; In order to be notified
-about document changes, an object must implements <tt>IDocumentListener</tt>
-and must be registered with the document. Position updating in responds
-to a document change is performed by implementers of <tt>IDocumentPositionUpdater</tt>.
-Partition updating in responds to a document change is performed by implements
-of <tt>IDocumentPartitioner</tt>. In order to be notified about document
-partition changes, objects must implement <tt>IDocumentParititoningListener</tt>
-and must be registered with the document.
-<p>The package contains default implementations for document position updaters
-and for documents. <tt>AbstractDocument</tt> uses <tt>ITextStorage</tt>
-for storing and managing its content and <tt>ILineTracker</tt> to maintain
-a line structure of its content. As defaults a gap text implementation
-of <tt>ITextStore</tt> is provided, together with a line tracker understanding
-the three standard line delimiters ("\r", "\n", "\r\n") and a&nbsp; line
-tracker which can be freely configured to consider any given set of strings
-as valid line delimiters.
-<h3>
-Text Viewer</h3>
-<tt>ITextViewer</tt> defines the concept of a document based, editiable
-viewer. <tt>ITextViewer</tt> offers the following functionality:
-<ul>
-<li>
-present a document</li>
-
-<li>
-event consumption (<tt>IEventConsumer</tt>)</li>
-
-<li>
-viewport tracking and notification (<tt>IIViewportListener</tt>)</li>
-
-<li>
-change notification (<tt>ITextListener</tt>, <tt>ITextInputListener</tt>)</li>
-
-<li>
-listeners (combined view/model notification, input document)</li>
-
-<li>
-standard text editing functions plus text hover support</li>
-
-<li>
-visual region support</li>
-</ul>
-An ITextViewer supports the following plugins
-<ul>
-<li>
-<tt>IUndoManager</tt> for the undo/redo mechanism</li>
-
-<li>
-<tt>IDoubleClickStrategy</tt> for partition type specific behavior on mouse
-double click</li>
-
-<li>
-<tt>IAutoIndentStrategy</tt>&nbsp; for content type specific behavior on
-inserting a line break</li>
-
-<li>
-<tt>ITextHover</tt> for content type specific behavior when overing over
-text</li>
-</ul>
-The package provides default implementations for all these interfaces.
-</body>
-</html>
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/IPresentationDamager.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/IPresentationDamager.java
deleted file mode 100644
index fcd9560974e..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/IPresentationDamager.java
+++ /dev/null
@@ -1,60 +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.presentation;
-
-
-
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITypedRegion;
-
-
-/**
- * Presentation damagers are used by a presentation reconciler to determine the
- * region of the document's presentation which must be rebuilt because of the
- * occurrence of a document change. A presentation damager is assumed to be
- * specific for a particular document content type. A presentation damager is
- * expected to return a damage region which is a valid input for a presentation repairer.
- * I.e. having access to the damage region only the repairer must be able to derive
- * all the information neede to sucessfully repair this region.<p>
- * This interface must either be implemented by clients or clients use the rule-based
- * default implementation <code>RuleBasedDamagerRepairer</code>. Implementers should be
- * registered with a presentation reconciler in order get involved in the reconciling
- * process.
- *
- * @see IPresentationReconciler
- * @see IDocument
- * @see DocumentEvent
- * @see IPresentationRepairer
- */
-public interface IPresentationDamager {
-
- /**
- * Tells the presentation damager on which document it will work.
- *
- * @param document the damager's working document
- */
- void setDocument(IDocument document);
-
- /**
- * Returns the damage in the document's presentation caused by the given document change.
- * The damage is restricted to the specified partition for which the presentation damager is
- * responsible. The damage may also depend on whether the document change also caused changes
- * of the document's partitioning.
- *
- * @param partition the partition inside which the damage must be determined
- * @param event the event describing the change whose damage must be determined
- * @param documentPartitioningChange indicates whether the given change changed the document's partitioning
- * @return the computed damage
- */
- IRegion getDamageRegion(ITypedRegion partition, DocumentEvent event, boolean documentPartitioningChanged);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/IPresentationReconciler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/IPresentationReconciler.java
deleted file mode 100644
index fc926527073..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/IPresentationReconciler.java
+++ /dev/null
@@ -1,76 +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.presentation;
-
-
-import org.eclipse.jface.text.ITextViewer;
-
-
-/**
- * An <code>IPresentationReconciler</code> defines and maintains the representation of a
- * text viewer's document in the presence of changes applied to the document.
- * An <code>IPresentationReconciler</code> is a <code>ITextViewer</code> add-on.<p>
- * The presentation reconciler keeps track of changes applied to the text viewer. It sends
- * each change to presentation damagers which are registered for the content types of the
- * regions in which the change occurred. The presentation reconciler passes the computed
- * damage to presentation repairers which construct text presentations. Those text presentation
- * when applied to the presentation reconciler's text viewer bring the document's presentation
- * in sync with the document's content and thus repair the damage. A presentation damager
- * is expected to return damage which is a valid input for a presentation repairer registered
- * for the same content type as the damager.<p>
- * A presentation reconciler should always be configured with damager/repairer pairs. I.e.
- * for each damager there should be a corresponding repairer.<p>
- * The interface can be implemented by clients. By default, clients use
- * <code>PresentationReconciler</code> as the standard implementer of this interface.
- *
- * @see ITextViewer
- * @see IPresentationDamager
- * @see IPresentationRepairer
- * @see org.eclipse.jface.text.TextPresentation
- */
-public interface IPresentationReconciler {
-
- /**
- * Installs this presentation reconciler on the given text viewer. After
- * this method has been finished, the reconciler is operational. I.e., it
- * works without requesting further client actions until <code>uninstall</code>
- * is called.
- *
- * @param textViewer the viewer on which this presentation reconciler is installed
- */
- void install(ITextViewer viewer);
-
- /**
- * Removes the reconciler from the text viewer it has previously been
- * installed on.
- */
- void uninstall();
-
- /**
- * Returns the presentation damager registered with this presentation reconciler
- * for the specified content type.
- *
- * @param contentType the content type for which to determine the damager
- * @return the presentation damager registered for the given content type, or
- * <code>null</code> if there is no such strategy
- */
- IPresentationDamager getDamager(String contentType);
-
- /**
- * Returns the presentation repairer registered with this presentation reconciler
- * for the specified content type.
- *
- * @param contentType the content type for which to determine the repairer
- * @return the presentation repairer registered for the given content type, or
- * <code>null</code> if there is no such strategy
- */
- IPresentationRepairer getRepairer(String contentType);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/IPresentationReconcilerExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/IPresentationReconcilerExtension.java
deleted file mode 100644
index ab979c7a718..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/IPresentationReconcilerExtension.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**********************************************************************
-Copyright (c) 2000, 2003 IBM Corp. 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 implementation
-**********************************************************************/
-package org.eclipse.jface.text.presentation;
-
-/**
- * Extension interface for <code>IPresentationReconciler</code>.
- * Updates the presentation reconciler to be aware of documents with multiple partitions.
- *
- * @since 3.0
- */
-public interface IPresentationReconcilerExtension {
-
- /**
- * Returns the document partitioning this presentation reconciler is using.
- *
- * @return the document partitioning this presentation reconciler is using
- */
- String getDocumentPartitioning();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/IPresentationRepairer.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/IPresentationRepairer.java
deleted file mode 100644
index 571de0a5e5b..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/IPresentationRepairer.java
+++ /dev/null
@@ -1,56 +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.presentation;
-
-
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.TextPresentation;
-
-
-/**
- * Presentation repairers are used by a presentation reconciler
- * to rebuild a damaged region in a document's presentation. A presentation repairer
- * is assumed to be specific for a particular document content type. The presentation
- * repairer gets the region which it should repair and constructs a "repair description"
- * The presentation repairer adds the individual steps of this sequence into the
- * text presentation it gets passed in.<p>
- * This interface must either be implemented by clients or clients use the rule-based
- * default implementation <code>RuleBasedDamagerRepairer</code>. Implementers should be
- * registered with a presentation reconciler in order get involved in the reconciling
- * process.
- *
- * @see IPresentationReconciler
- * @see IDocument
- * @see org.eclipse.swt.custom.StyleRange
- * @see TextPresentation
- */
-public interface IPresentationRepairer {
-
-
- /**
- * Tells the presentation repairer on which document it will work.
- *
- * @param document the damager's working document
- */
- void setDocument(IDocument document);
-
- /**
- * Fills the given presentation with the style ranges which when applied to the
- * presentation reconciler's text viewer repair the presentational damage described by
- * the given region.
- *
- * @param presentation the text presentation to be filled by this repairer
- * @param damage the damage to be repaired
- */
- void createPresentation(TextPresentation presentation, ITypedRegion damage);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/PresentationReconciler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/PresentationReconciler.java
deleted file mode 100644
index c2254963455..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/PresentationReconciler.java
+++ /dev/null
@@ -1,557 +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.presentation;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.DefaultPositionUpdater;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.DocumentPartitioningChangedEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentExtension3;
-import org.eclipse.jface.text.IDocumentListener;
-import org.eclipse.jface.text.IDocumentPartitioningListener;
-import org.eclipse.jface.text.IDocumentPartitioningListenerExtension;
-import org.eclipse.jface.text.IDocumentPartitioningListenerExtension2;
-import org.eclipse.jface.text.IPositionUpdater;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextInputListener;
-import org.eclipse.jface.text.ITextListener;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.ITextViewerExtension3;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextEvent;
-import org.eclipse.jface.text.TextPresentation;
-import org.eclipse.jface.text.TextUtilities;
-import org.eclipse.jface.text.TypedPosition;
-
-
-
-/**
- * Standard implementation of <code>IPresentationReconciler</code>.
- * This implementation assumes that the tasks performed by its
- * presentation damagers and repairers are lightweight and of low cost.
- * This presentation reconciler runs in the UI thread and always repairs
- * the complete damage caused by a document change rather than just the
- * portion overlapping with the viewer's viewport.<p>
- * Usually, clients instantiate this class and configure it before using it.
- */
-public class PresentationReconciler implements IPresentationReconciler, IPresentationReconcilerExtension {
-
- /** Prefix of the name of the position category for tracking damage regions. */
- protected final static String TRACKED_PARTITION= "__reconciler_tracked_partition"; //$NON-NLS-1$
-
-
- /**
- * Internal listener class.
- */
- class InternalListener implements
- ITextInputListener, IDocumentListener, ITextListener,
- IDocumentPartitioningListener, IDocumentPartitioningListenerExtension, IDocumentPartitioningListenerExtension2 {
-
- /** Set to <code>true</code> if between a document about to be changed and a changed event. */
- private boolean fDocumentChanging= false;
- /** The cached redraw state of the text viewer */
- private boolean fCachedRedrawState= true;
-
- /*
- * @see ITextInputListener#inputDocumentAboutToBeChanged(IDocument, IDocument)
- */
- public void inputDocumentAboutToBeChanged(IDocument oldDocument, IDocument newDocument) {
- if (oldDocument != null) {
- try {
-
- fViewer.removeTextListener(this);
- oldDocument.removeDocumentListener(this);
- oldDocument.removeDocumentPartitioningListener(this);
-
- oldDocument.removePositionUpdater(fPositionUpdater);
- oldDocument.removePositionCategory(fPositionCategory);
-
- } catch (BadPositionCategoryException x) {
- // should not happend for former input documents;
- }
- }
- }
-
- /*
- * @see ITextInputListener#inputDocumenChanged(IDocument, IDocument)
- */
- public void inputDocumentChanged(IDocument oldDocument, IDocument newDocument) {
-
- fDocumentChanging= false;
- fCachedRedrawState= true;
-
- if (newDocument != null) {
-
- newDocument.addPositionCategory(fPositionCategory);
- newDocument.addPositionUpdater(fPositionUpdater);
-
- newDocument.addDocumentPartitioningListener(this);
- newDocument.addDocumentListener(this);
- fViewer.addTextListener(this);
-
- setDocumentToDamagers(newDocument);
- setDocumentToRepairers(newDocument);
- processDamage(new Region(0, newDocument.getLength()), newDocument);
- }
- }
-
- /*
- * @see IDocumentPartitioningListener#documentPartitioningChanged(IDocument)
- */
- public void documentPartitioningChanged(IDocument document) {
- if (!fDocumentChanging && fCachedRedrawState)
- processDamage(new Region(0, document.getLength()), document);
- else
- fDocumentPartitioningChanged= true;
- }
-
- /*
- * @see IDocumentPartitioningListenerExtension#documentPartitioningChanged(IDocument, IRegion)
- * @since 2.0
- */
- public void documentPartitioningChanged(IDocument document, IRegion changedRegion) {
- if (!fDocumentChanging && fCachedRedrawState) {
- processDamage(new Region(changedRegion.getOffset(), changedRegion.getLength()), document);
- } else {
- fDocumentPartitioningChanged= true;
- fChangedDocumentPartitions= changedRegion;
- }
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentPartitioningListenerExtension2#documentPartitioningChanged(org.eclipse.jface.text.DocumentPartitioningChangedEvent)
- */
- public void documentPartitioningChanged(DocumentPartitioningChangedEvent event) {
- IRegion changedRegion= event.getChangedRegion(getDocumentPartitioning());
- if (changedRegion != null)
- documentPartitioningChanged(event.getDocument(), changedRegion);
- }
-
- /*
- * @see IDocumentListener#documentAboutToBeChanged(DocumentEvent)
- */
- public void documentAboutToBeChanged(DocumentEvent e) {
-
- fDocumentChanging= true;
- if (fCachedRedrawState) {
- try {
- int offset= e.getOffset() + e.getLength();
- ITypedRegion region= getPartition(e.getDocument(), offset);
- fRememberedPosition= new TypedPosition(region);
- e.getDocument().addPosition(fPositionCategory, fRememberedPosition);
- } catch (BadLocationException x) {
- // can not happen
- } catch (BadPositionCategoryException x) {
- // should not happen on input elements
- }
- }
- }
-
- /*
- * @see IDocumentListener#documentChanged(DocumentEvent)
- */
- public void documentChanged(DocumentEvent e) {
- if (fCachedRedrawState) {
- try {
- e.getDocument().removePosition(fPositionCategory, fRememberedPosition);
- } catch (BadPositionCategoryException x) {
- // can not happen on input documents
- }
- }
- fDocumentChanging= false;
- }
-
- /*
- * @see ITextListener#textChanged(TextEvent)
- */
- public void textChanged(TextEvent e) {
-
- fCachedRedrawState= e.getViewerRedrawState();
- if (!fCachedRedrawState)
- return;
-
- IRegion damage= null;
- IDocument document= null;
-
- if (e.getDocumentEvent() == null) {
- document= fViewer.getDocument();
- if (document != null) {
- if (e.getOffset() == 0 && e.getLength() == 0 && e.getText() == null) {
- // redraw state change, damage the whole document
- damage= new Region(0, document.getLength());
- } else {
- IRegion region= widgetRegion2ModelRegion(e);
- try {
- String text= document.get(region.getOffset(), region.getLength());
- DocumentEvent de= new DocumentEvent(document, region.getOffset(), region.getLength(), text);
- damage= getDamage(de, false);
- } catch (BadLocationException x) {
- }
- }
- }
- } else {
- DocumentEvent de= e.getDocumentEvent();
- document= de.getDocument();
- damage= getDamage(de, true);
- }
-
- if (damage != null && document != null)
- processDamage(damage, document);
-
- fDocumentPartitioningChanged= false;
- fChangedDocumentPartitions= null;
- }
-
- /**
- * Translates the given text event into the corresponding range of the viewer's document.
- *
- * @param e the text event
- * @return the widget region corresponding the region of the given event
- * @since 2.1
- */
- protected IRegion widgetRegion2ModelRegion(TextEvent e) {
- if (fViewer instanceof ITextViewerExtension3) {
- ITextViewerExtension3 extension= (ITextViewerExtension3) fViewer;
- return extension.widgetRange2ModelRange(new Region(e.getOffset(), e.getLength()));
- }
-
- IRegion visible= fViewer.getVisibleRegion();
- IRegion region= new Region(e.getOffset() + visible.getOffset(), e.getLength());
- return region;
- }
- }
-
- /** The map of presentation damagers. */
- private Map fDamagers;
- /** The map of presentation repairers. */
- private Map fRepairers;
- /** The target viewer. */
- private ITextViewer fViewer;
- /** The internal listener. */
- private InternalListener fInternalListener= new InternalListener();
- /** The name of the position category to track damage regions. */
- private String fPositionCategory;
- /** The position updated for the damage regions' position category. */
- private IPositionUpdater fPositionUpdater;
- /** The positions representing the damage regions. */
- private TypedPosition fRememberedPosition;
- /** Flag indicating the receipt of a partitioning changed notification. */
- private boolean fDocumentPartitioningChanged= false;
- /** The range covering the changed parititoning. */
- private IRegion fChangedDocumentPartitions= null;
- /**
- * The partitioning used by this presentation reconciler.
- * @since 3.0
- */
- private String fPartitioning;
-
- /**
- * Creates a new presentation reconciler. There are no damagers or repairers
- * registered with this reconciler. The default partitioning
- * <code>IDocumentExtension3.DEFAULT_PARTITIONING</code> is used.
- */
- public PresentationReconciler() {
- super();
- fPartitioning= IDocumentExtension3.DEFAULT_PARTITIONING;
- fPositionCategory= TRACKED_PARTITION + hashCode();
- fPositionUpdater= new DefaultPositionUpdater(fPositionCategory);
- }
-
- /**
- * Sets the document partitioning for this presentation reconciler.
- *
- * @param partitioning the document partitioning for this presentation reconciler.
- * @since 3.0
- */
- public void setDocumentPartitioning(String partitioning) {
- Assert.isNotNull(partitioning);
- fPartitioning= partitioning;
- }
-
- /*
- * @see org.eclipse.jface.text.presentation.IPresentationReconcilerExtension#geDocumenttPartitioning()
- * @since 3.0
- */
- public String getDocumentPartitioning() {
- return fPartitioning;
- }
-
- /**
- * Registers a given presentation damager for a particular content type.
- * If there is already a damager registered for this type, the new damager
- * is registered instead of the old one.
- *
- * @param damager the presentation damager to register, or <code>null</code> to remove an existing one
- * @param contentType the content type under which to register
- */
- public void setDamager(IPresentationDamager damager, String contentType) {
-
- Assert.isNotNull(contentType);
-
- if (fDamagers == null)
- fDamagers= new HashMap();
-
- if (damager == null)
- fDamagers.remove(contentType);
- else
- fDamagers.put(contentType, damager);
- }
-
- /**
- * Registers a given presentation repairer for a particular content type.
- * If there is already a repairer registered for this type, the new repairer
- * is registered instead of the old one.
- *
- * @param repairer the presentation repairer to register, or <code>null</code> to remove an existing one
- * @param contentType the content type under which to register
- */
- public void setRepairer(IPresentationRepairer repairer, String contentType) {
-
- Assert.isNotNull(contentType);
-
- if (fRepairers == null)
- fRepairers= new HashMap();
-
- if (repairer == null)
- fRepairers.remove(contentType);
- else
- fRepairers.put(contentType, repairer);
- }
-
- /*
- * @see IPresentationReconciler#install(ITextViewer)
- */
- public void install(ITextViewer viewer) {
- Assert.isNotNull(viewer);
-
- fViewer= viewer;
- fViewer.addTextInputListener(fInternalListener);
- }
-
- /*
- * @see IPresentationReconciler#uninstall()
- */
- public void uninstall() {
- fViewer.removeTextInputListener(fInternalListener);
- }
-
- /*
- * @see IPresentationReconciler#getDamager(String)
- */
- public IPresentationDamager getDamager(String contentType) {
-
- if (fDamagers == null)
- return null;
-
- return (IPresentationDamager) fDamagers.get(contentType);
- }
-
- /*
- * @see IPresentationReconciler#getRepairer(String)
- */
- public IPresentationRepairer getRepairer(String contentType) {
-
- if (fRepairers == null)
- return null;
-
- return (IPresentationRepairer) fRepairers.get(contentType);
- }
-
- /**
- * Informs all registed damagers about the document on which they will work.
- *
- * @param document the document on which to work
- */
- private void setDocumentToDamagers(IDocument document) {
- if (fDamagers != null) {
- Iterator e= fDamagers.values().iterator();
- while (e.hasNext()) {
- IPresentationDamager damager= (IPresentationDamager) e.next();
- damager.setDocument(document);
- }
- }
- }
-
- /**
- * Informs all registed repairers about the document on which they will work.
- *
- * @param document the document on which to work
- */
- private void setDocumentToRepairers(IDocument document) {
- if (fRepairers != null) {
- Iterator e= fRepairers.values().iterator();
- while (e.hasNext()) {
- IPresentationRepairer repairer= (IPresentationRepairer) e.next();
- repairer.setDocument(document);
- }
- }
- }
-
- /**
- * Constructs a "repair description" for the given damage and returns
- * this description as a text presentation. For this, it queries the
- * partitioning of the damage region and asks for each partition an
- * appropriate presentation repairer to construct the "repair description"
- * for this partition.
- *
- * @param damage the damage to be repaired
- * @param document the document whose presentation must be repaired
- * @return the presentation repair descritption as text presentation
- */
- private TextPresentation createPresentation(IRegion damage, IDocument document) {
- try {
-
- TextPresentation presentation= new TextPresentation(1000);
-
- ITypedRegion[] partitioning= TextUtilities.computePartitioning(document, getDocumentPartitioning(), damage.getOffset(), damage.getLength());
- for (int i= 0; i < partitioning.length; i++) {
- ITypedRegion r= partitioning[i];
- IPresentationRepairer repairer= getRepairer(r.getType());
- if (repairer != null)
- repairer.createPresentation(presentation, r);
- }
-
- return presentation;
-
- } catch (BadLocationException x) {
- }
-
- return null;
- }
-
-
- /**
- * Checks for the first and the last affected partition and calls their damagers.
- * Invalidates everything from the start of the damage for the first partition
- * until the end of the damage for the last partition.
- *
- * @param e the event describing the document change
- * @param optimize <code>true</code> if partition changes should be considered for optimization
- * @return the damaged caused by the change
- */
- private IRegion getDamage(DocumentEvent e, boolean optimize) {
-
- IRegion damage= null;
-
- try {
-
- ITypedRegion partition= getPartition(e.getDocument(), e.getOffset());
- IPresentationDamager damager= getDamager(partition.getType());
- if (damager == null)
- return null;
-
- IRegion r= damager.getDamageRegion(partition, e, fDocumentPartitioningChanged);
-
- if (!fDocumentPartitioningChanged && optimize) {
- damage= r;
- } else {
-
- int damageEnd= getDamageEndOffset(e);
-
- int parititionDamageEnd= -1;
- if (fChangedDocumentPartitions != null)
- parititionDamageEnd= fChangedDocumentPartitions.getOffset() + fChangedDocumentPartitions.getLength();
-
- int end= Math.max(damageEnd, parititionDamageEnd);
-
- damage= end == -1 ? r : new Region(r.getOffset(), end - r.getOffset());
- }
-
- } catch (BadLocationException x) {
- }
-
- return damage;
- }
-
- /**
- * Returns the end offset of the damage. If a partition has been splitted by
- * the given document event also the second half of the original
- * partition must be considered. This is achieved by using the remembered
- * partition range.
- *
- * @param e the event describing the change
- * @return the damage end offset (excluding)
- * @exception BadLocationException if method accesses invalid offset
- */
- private int getDamageEndOffset(DocumentEvent e) throws BadLocationException {
-
- IDocument d= e.getDocument();
-
- int length= 0;
- if (e.getText() != null) {
- length= e.getText().length();
- if (length > 0)
- -- length;
- }
-
- ITypedRegion partition= getPartition(d, e.getOffset() + length);
- int endOffset= partition.getOffset() + partition.getLength();
- if (endOffset == e.getOffset())
- return -1;
-
- int end= fRememberedPosition == null ? -1 : fRememberedPosition.getOffset() + fRememberedPosition.getLength();
- if (endOffset < end)
- partition= getPartition(d, end);
-
- IPresentationDamager damager= getDamager(partition.getType());
- if (damager == null)
- return -1;
-
- IRegion r= damager.getDamageRegion(partition, e, fDocumentPartitioningChanged);
-
- return r.getOffset() + r.getLength();
- }
-
- /**
- * Processes the given damage.
- * @param damage the damage to be repaired
- * @param document the document whose presentation must be repaired
- */
- private void processDamage(IRegion damage, IDocument document) {
- if (damage != null && damage.getLength() > 0) {
- TextPresentation p= createPresentation(damage, document);
- if (p != null && !p.isEmpty())
- applyTextRegionCollection(p);
- }
- }
-
- /**
- * Applies the given text presentation to the text viewer the presentation
- * reconciler is installed on.
- *
- * @param presentation the text presentation to be applied to the text viewer
- */
- private void applyTextRegionCollection(TextPresentation presentation) {
- fViewer.changeTextPresentation(presentation, false);
- }
-
- /**
- * Returns the partition for the given offset in the given document.
- *
- * @param document the document
- * @param offset the offset
- * @return the partition
- * @throws BadLocationException if offset is invalid in the given document
- * @since 3.0
- */
- private ITypedRegion getPartition(IDocument document, int offset) throws BadLocationException {
- return TextUtilities.getPartition(document, getDocumentPartitioning(), offset);
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/package.html b/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/package.html
deleted file mode 100644
index 9574694de4e..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/package.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="Author" content="IBM">
- <meta name="GENERATOR" content="Mozilla/4.51 [en] (WinNT; I) [Netscape]">
- <title>Package-level Javadoc</title>
-</head>
-<body>
-Provides a presentation reconciler add-on for an <tt>ITextViewer</tt>.
-A presentation reconciler keep the presentation (styles and colors) in
-sync with the content of the document serving as the <tt>ITextViewer</tt>'s
-input.
-<h2>
-Package Specification</h2>
-<tt>IPresentationReconciler</tt> defines the concept of a presentation
-reconciler. It collaborates with content type specific presentation damagers
-(<tt>IPresentationDamager</tt>) which for a given document change determine
-the region of the presentation which must be rebuild, and content type
-specific presentation repairers (<tt>IPresentationRepairer</tt>) which
-construct for a given damage region the document presentation. The package
-contains a default implementation of <tt>IPresentationReconciler </tt>(<tt>PresentationReconciler</tt>).
-</body>
-</html>
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/AbstractReconcileStep.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/AbstractReconcileStep.java
deleted file mode 100644
index 0f6d4945629..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/AbstractReconcileStep.java
+++ /dev/null
@@ -1,169 +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 java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.reconciler.DirtyRegion;
-
-/**
- * Abstract implementation of a reconcile step.
- *
- * @see org.eclipse.jface.text.reconciler.IReconcileStep
- * @since 3.0
- */
-public abstract class AbstractReconcileStep implements IReconcileStep {
-
- private IReconcileStep fNextStep;
- private IReconcileStep fPreviousStep;
- private IProgressMonitor fProgressMonitor;
- protected IReconcilableModel fInputModel;
-
- /**
- * Creates an intermediate reconcile step which adds
- * the given step to the pipe.
- */
- public AbstractReconcileStep(IReconcileStep step) {
- Assert.isNotNull(step);
- fNextStep= step;
- fNextStep.setPreviousStep(this);
- }
-
- /**
- * Creates the last reconcile step of the pipe.
- */
- public AbstractReconcileStep() {
- }
-
- public boolean isLastStep() {
- return fNextStep == null;
- }
-
- public boolean isFirstStep() {
- return fPreviousStep == null;
- }
-
- /*
- * @see org.eclipse.text.reconcilerpipe.IReconcilerResultCollector#setProgressMonitor(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void setProgressMonitor(IProgressMonitor monitor) {
- fProgressMonitor= monitor;
-
- if (!isLastStep())
- fNextStep.setProgressMonitor(monitor);
- }
-
- /*
- * @see org.eclipse.jface.text.reconciler.IReconcileStep#getProgressMonitor()
- */
- public IProgressMonitor getProgressMonitor() {
- return fProgressMonitor;
- }
-
- /*
- * @see IReconcileStep#reconcile(IRegion)
- */
- public final IReconcileResult[] reconcile(IRegion partition) {
- IReconcileResult[] result= reconcileModel(null, partition);
- if (!isLastStep()) {
- fNextStep.setInputModel(getModel());
- IReconcileResult[] nextResult= fNextStep.reconcile(partition);
- return merge(result, convertToInputModel(nextResult));
- } else
- return result;
- }
-
- /*
- * @see IReconcileStep#reconcile(org.eclipse.jface.text.reconciler.DirtyRegion, org.eclipse.jface.text.IRegion)
- */
- public final IReconcileResult[] reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
- IReconcileResult[] result= reconcileModel(dirtyRegion, subRegion);
- if (!isLastStep()) {
- fNextStep.setInputModel(getModel());
- IReconcileResult[] nextResult= fNextStep.reconcile(dirtyRegion, subRegion);
- return merge(result, convertToInputModel(nextResult));
- } else
- return result;
- }
-
-
- /**
- * Reconciles the model of this reconcile step. The
- * result is based on the input model.
- *
- * @param dirtyRegion the document region which has been changed
- * @param subRegion the sub region in the dirty region which should be reconciled
- * @return an array with reconcile results
- */
- abstract protected IReconcileResult[] reconcileModel(DirtyRegion dirtyRegion, IRegion subRegion);
-
- protected IReconcileResult[] convertToInputModel(IReconcileResult[] inputResults) {
- return inputResults;
- }
-
- private IReconcileResult[] merge(IReconcileResult[] results1, IReconcileResult[] results2) {
- if (results1 == null)
- return results2;
-
- if (results2 == null)
- return results1;
-
- // XXX: not yet performance optimized
- Collection collection= new ArrayList(Arrays.asList(results1));
- collection.addAll(Arrays.asList(results2));
- return (IReconcileResult[])collection.toArray(new IReconcileResult[collection.size()]);
- }
-
- /*
- * @see IProgressMonitor#isCanceled()
- */
- protected final boolean isCanceled() {
- return fProgressMonitor != null && fProgressMonitor.isCanceled();
- }
-
- /*
- * @see IReconcileStep#setPreviousStep(IReconcileStep)
- */
- public void setPreviousStep(IReconcileStep step) {
- Assert.isNotNull(step);
- Assert.isTrue(fPreviousStep == null);
- fPreviousStep= step;
- }
-
- /*
- * @see IReconcileStep#setInputModel(Object)
- */
- public void setInputModel(IReconcilableModel inputModel) {
- fInputModel= inputModel;
-
- if (!isLastStep())
- fNextStep.setInputModel(getModel());
- }
-
- public IReconcilableModel getInputModel() {
- return fInputModel;
- }
-
- abstract public IReconcilableModel getModel();
-
- /*
- * @see IReconcileStep#initialReconcile()
- */
- public void initialReconcile() {
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/AbstractReconciler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/AbstractReconciler.java
deleted file mode 100644
index 283c0ed3a19..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/AbstractReconciler.java
+++ /dev/null
@@ -1,497 +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.Assert;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentListener;
-import org.eclipse.jface.text.ITextInputListener;
-import org.eclipse.jface.text.ITextViewer;
-
-
-
-
-/**
- * Abstract implementation of <code>IReconciler</code>. The reconciler
- * listens to input document changes as well as changes of
- * the input document of the text viewer it is installed on. Depending on
- * its configuration it manages the received change notifications in a
- * queue folding neighboring or overlapping changes together. The reconciler
- * processes the dirty regions as a background activity after having waited for further
- * changes for the configured duration of time. A reconciler is started using its
- * <code>install</code> method. As a first step <code>initialProcess</code> is
- * executed in the background. Then, the reconciling thread waits for changes that
- * need to be reconciled. A reconciler can be resumed by calling <code>forceReconciling</code>
- * independent from the existence of actual changes. This mechanism is for subclasses only.
- * It is the clients responsibility to stop a reconciler using its <code>uninstall</code>
- * method. Unstopped reconcilers do not free their resources.<p>
- * It is subclass responsibility to specify how dirty regions are processed.
- *
- * @see IReconciler
- * @see IDocumentListener
- * @see ITextInputListener
- * @see DirtyRegion
- * @since 2.0
- */
-abstract public class AbstractReconciler implements IReconciler {
-
-
- /**
- * Background thread for the reconciling activity.
- */
- class BackgroundThread extends Thread {
-
- /** Has the reconciler been canceled */
- private boolean fCanceled= false;
- /** Has the reconciler been reset */
- private boolean fReset= false;
- /** Has a change been applied */
- private boolean fIsDirty= false;
- /** Is a reconciling strategy active */
- private boolean fIsActive= false;
-
- /**
- * Creates a new background thread. The thread
- * runs with minimal priority.
- *
- * @param name the thread's name
- */
- public BackgroundThread(String name) {
- super(name);
- setPriority(Thread.MIN_PRIORITY);
- setDaemon(true);
- }
-
- /**
- * Returns whether a reconciling strategy is active right now.
- *
- * @return <code>true</code> if a activity is active
- */
- public boolean isActive() {
- return fIsActive;
- }
-
- /**
- * Cancels the background thread.
- */
- public void cancel() {
- fCanceled= true;
- synchronized (fDirtyRegionQueue) {
- fDirtyRegionQueue.notifyAll();
- }
- }
-
- /**
- * Suspends the caller of this method until this background thread has
- * emptied the dirty region queue.
- */
- public void suspendCallerWhileDirty() {
- while (fIsDirty) {
- synchronized (fDirtyRegionQueue) {
- if (fIsDirty) {
- try {
- fDirtyRegionQueue.wait();
- } catch (InterruptedException x) {
- }
- }
- }
- }
- }
-
- /**
- * Reset the background thread as the text viewer has been changed,
- */
- public void reset() {
-
- if (fDelay > 0) {
-
- synchronized (this) {
- fIsDirty= true;
- fReset= true;
- }
-
- } else {
-
- synchronized (this) {
- fIsDirty= true;
- }
-
- synchronized (fDirtyRegionQueue) {
- fDirtyRegionQueue.notifyAll();
- }
- }
-
- reconcilerReset();
- }
-
- /**
- * The background activity. Waits until there is something in the
- * queue managing the changes that have been applied to the text viewer.
- * Removes the first change from the queue and process it.<p>
- * Calls <code>initialProcess</code> on entrance.
- */
- public void run() {
-
- synchronized (fDirtyRegionQueue) {
- try {
- fDirtyRegionQueue.wait(fDelay);
- } catch (InterruptedException x) {
- }
- }
-
- initialProcess();
-
- while (!fCanceled) {
-
- synchronized (fDirtyRegionQueue) {
- try {
- fDirtyRegionQueue.wait(fDelay);
- } catch (InterruptedException x) {
- }
- }
-
- if (fCanceled)
- break;
-
- if (!fIsDirty)
- continue;
-
- if (fReset) {
- synchronized (this) {
- fReset= false;
- }
- continue;
- }
-
- DirtyRegion r= null;
- synchronized (fDirtyRegionQueue) {
- r= fDirtyRegionQueue.removeNextDirtyRegion();
- }
-
- fIsActive= true;
-
- if (fProgressMonitor != null)
- fProgressMonitor.setCanceled(false);
-
- process(r);
-
- synchronized (fDirtyRegionQueue) {
- if (0 == fDirtyRegionQueue.getSize()) {
- synchronized (this) {
- fIsDirty= fProgressMonitor != null ? fProgressMonitor.isCanceled() : false;
- }
- fDirtyRegionQueue.notifyAll();
- }
- }
-
- fIsActive= false;
- }
- }
- }
-
- /**
- * Internal document listener and text input listener.
- */
- class Listener implements IDocumentListener, ITextInputListener {
-
- /*
- * @see IDocumentListener#documentAboutToBeChanged(DocumentEvent)
- */
- public void documentAboutToBeChanged(DocumentEvent e) {
- }
-
- /*
- * @see IDocumentListener#documentChanged(DocumentEvent)
- */
- public void documentChanged(DocumentEvent e) {
-
- if (fProgressMonitor != null && fThread.isActive())
- fProgressMonitor.setCanceled(true);
-
- if (fIsIncrementalReconciler)
- createDirtyRegion(e);
-
- fThread.reset();
- }
-
- /*
- * @see ITextInputListener#inputDocumentAboutToBeChanged(IDocument, IDocument)
- */
- public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {
-
- if (oldInput == fDocument) {
-
- if (fDocument != null)
- fDocument.removeDocumentListener(this);
-
- if (fIsIncrementalReconciler) {
- fDirtyRegionQueue.purgeQueue();
- if (fDocument != null && fDocument.getLength() > 0) {
- DocumentEvent e= new DocumentEvent(fDocument, 0, fDocument.getLength(), null);
- createDirtyRegion(e);
- fThread.suspendCallerWhileDirty();
- }
- }
-
- fDocument= null;
- }
- }
-
- /*
- * @see ITextInputListener#inputDocumentChanged(IDocument, IDocument)
- */
- public void inputDocumentChanged(IDocument oldInput, IDocument newInput) {
-
- fDocument= newInput;
- if (fDocument == null)
- return;
-
-
- reconcilerDocumentChanged(fDocument);
-
- fDocument.addDocumentListener(this);
-
- if (fIsIncrementalReconciler) {
- DocumentEvent e= new DocumentEvent(fDocument, 0, 0, fDocument.get());
- createDirtyRegion(e);
- }
-
- startReconciling();
- }
- }
-
- /** Queue to manage the changes applied to the text viewer */
- private DirtyRegionQueue fDirtyRegionQueue;
- /** The background thread */
- private BackgroundThread fThread;
- /** Internal document and text input listener */
- private Listener fListener;
- /** The background thread delay */
- private int fDelay= 500;
- /** Are there incremental reconciling strategies? */
- private boolean fIsIncrementalReconciler= true;
- /** The progress monitor used by this reconciler */
- private IProgressMonitor fProgressMonitor;
-
- /** The text viewer's document */
- private IDocument fDocument;
- /** The text viewer */
- private ITextViewer fViewer;
-
-
- /**
- * Processes a dirty region. If the dirty region is <code>null</code> the whole
- * document is consider being dirty. The dirty region is partitioned by the
- * document and each partition is handed over to a reconciling strategy registered
- * for the partition's content type.
- *
- * @param dirtyRegion the dirty region to be processed
- */
- abstract protected void process(DirtyRegion dirtyRegion);
-
- /**
- * Hook called when the document whose contents should be reconciled
- * has been changed, i.e., the input document of the text viewer this
- * reconciler is installed on. Usually, subclasses use this hook to
- * inform all their reconciling strategies about the change.
- *
- * @param newDocument the new reconciler document
- */
- abstract protected void reconcilerDocumentChanged(IDocument newDocument);
-
-
- /**
- * Creates a new reconciler without configuring it.
- */
- protected AbstractReconciler() {
- super();
- }
-
- /**
- * Tells the reconciler how long it should wait for further text changes before
- * activating the appropriate reconciling strategies.
- *
- * @param delay the duration in milli seconds of a change collection period.
- */
- public void setDelay(int delay) {
- fDelay= delay;
- }
-
- /**
- * Tells the reconciler whether any of the available reconciling strategies
- * is interested in getting detailed dirty region information or just in the
- * fact the the document has been changed. In the second case, the reconciling
- * can not incrementally be pursued.
- *
- * @param isIncremental indicates whether this reconciler will be configured with
- * incremental reconciling strategies
- *
- * @see DirtyRegion
- * @see IReconcilingStrategy
- */
- public void setIsIncrementalReconciler(boolean isIncremental) {
- fIsIncrementalReconciler= isIncremental;
- }
-
- /**
- * Sets the progress monitor of this reconciler.
- *
- * @param monitor the monitor to be used
- */
- public void setProgressMonitor(IProgressMonitor monitor) {
- fProgressMonitor= monitor;
- }
-
- /**
- * Returns whether any of the reconciling strategies is interested in
- * detailed dirty region information.
- *
- * @return whether this reconciler is incremental
- *
- * @see IReconcilingStrategy
- */
- protected boolean isIncrementalReconciler() {
- return fIsIncrementalReconciler;
- }
-
- /**
- * Returns the input document of the text viewer this reconciler is installed on.
- *
- * @return the reconciler document
- */
- protected IDocument getDocument() {
- return fDocument;
- }
-
- /**
- * Returns the text viewer this reconciler is installed on.
- *
- * @return the text viewer this reconciler is installed on
- */
- protected ITextViewer getTextViewer() {
- return fViewer;
- }
-
- /**
- * Returns the progress monitor of this reconciler.
- *
- * @return the progress monitor of this reconciler
- */
- protected IProgressMonitor getProgressMonitor() {
- return fProgressMonitor;
- }
-
- /*
- * @see IReconciler#install(ITextViewer)
- */
- public void install(ITextViewer textViewer) {
-
- Assert.isNotNull(textViewer);
-
- fViewer= textViewer;
-
- fListener= new Listener();
- fViewer.addTextInputListener(fListener);
-
- fDirtyRegionQueue= new DirtyRegionQueue();
- fThread= new BackgroundThread(getClass().getName());
- }
-
- /*
- * @see IReconciler#uninstall()
- */
- public void uninstall() {
- if (fListener != null) {
-
- fViewer.removeTextInputListener(fListener);
- if (fDocument != null) fDocument.removeDocumentListener(fListener);
- fListener= null;
-
- synchronized (this) {
- // http://dev.eclipse.org/bugs/show_bug.cgi?id=19135
- BackgroundThread bt= fThread;
- fThread= null;
- bt.cancel();
- }
- }
- }
-
- /**
- * Creates a dirty region for a document event and adds it to the queue.
- *
- * @param e the document event for which to create a dirty region
- */
- private void createDirtyRegion(DocumentEvent e) {
-
- if (e.getLength() == 0 && e.getText() != null) {
- // Insert
- fDirtyRegionQueue.addDirtyRegion(new DirtyRegion(e.getOffset(), e.getText().length(), DirtyRegion.INSERT, e.getText()));
-
- } else if (e.getText() == null || e.getText().length() == 0) {
- // Remove
- fDirtyRegionQueue.addDirtyRegion(new DirtyRegion(e.getOffset(), e.getLength(), DirtyRegion.REMOVE, null));
-
- } else {
- // Replace (Remove + Insert)
- fDirtyRegionQueue.addDirtyRegion(new DirtyRegion(e.getOffset(), e.getLength(), DirtyRegion.REMOVE, null));
- fDirtyRegionQueue.addDirtyRegion(new DirtyRegion(e.getOffset(), e.getText().length(), DirtyRegion.INSERT, e.getText()));
- }
- }
-
- /**
- * This method is called on startup of the background activity. It is called only
- * once during the life time of the reconciler. Clients may reimplement this method.
- */
- protected void initialProcess() {
- }
-
- /**
- * Forces the reconciler to reconcile the structure of the whole document.
- * Clients may extend this method.
- */
- protected void forceReconciling() {
-
- if (fDocument != null) {
-
- if (fIsIncrementalReconciler) {
- DocumentEvent e= new DocumentEvent(fDocument, 0, fDocument.getLength(), fDocument.get());
- createDirtyRegion(e);
- }
-
- startReconciling();
- }
- }
-
- /**
- * Starts the reconciler to reconcile the queued dirty-regions.
- * Clients may extend this method.
- */
- protected synchronized void startReconciling() {
- if (fThread == null)
- return;
-
- if (!fThread.isAlive())
- fThread.start();
-
- fThread.reset();
- }
-
- /**
- * Hook that is called after the reconciler thread has been reset.
- */
- protected void reconcilerReset() {
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/DirtyRegion.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/DirtyRegion.java
deleted file mode 100644
index a35e0729dc0..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/DirtyRegion.java
+++ /dev/null
@@ -1,97 +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.ITypedRegion;
-
-/**
- * A dirty region describes a document range which has been changed.
- */
-public class DirtyRegion implements ITypedRegion {
-
- /**
- * Identifies an insert operation.
- */
- final static public String INSERT= "__insert"; //$NON-NLS-1$
- /**
- * Identifies a remove operation.
- */
- final static public String REMOVE= "__remove"; //$NON-NLS-1$
-
- /** The region's offset */
- private int fOffset;
- /** The region's length */
- private int fLength;
- /** Indicates the type of the applied change */
- private String fType;
- /** The text which has been inserted */
- private String fText;
-
- /**
- * Creates a new dirty region.
- *
- *
- * @param offset the offset within the document where the change occurred
- * @param length the length of the text within the document that changed
- * @param type the type of change that this region represents: <code>INSERT</code> or <code>REMOVE</code>
- * @param text the substitution text
- */
- public DirtyRegion(int offset, int length, String type, String text) {
- fOffset= offset;
- fLength= length;
- fType= type;
- fText= text;
- }
-
- /*
- * @see ITypedRegion#getOffset()
- */
- public int getOffset() {
- return fOffset;
- }
-
- /*
- * @see ITypedRegion#getLength()
- */
- public int getLength() {
- return fLength;
- }
-
- /*
- * @see ITypedRegion#getType
- */
- public String getType() {
- return fType;
- }
-
- /**
- * Returns the text that changed as part of the region change.
- *
- * @return the changed text
- */
- public String getText() {
- return fText;
- }
-
- /**
- * Modify the receiver so that it encompasses the region specified by the dirty region.
- *
- * @param dr the dirty region with which to merge
- */
- void mergeWith(DirtyRegion dr) {
- int start= Math.min(fOffset, dr.fOffset);
- int end= Math.max(fOffset + fLength, dr.fOffset + dr.fLength);
- fOffset= start;
- fLength= end - start;
- fText= (dr.fText == null ? fText : (fText == null) ? dr.fText : fText + dr.fText);
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/DirtyRegionQueue.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/DirtyRegionQueue.java
deleted file mode 100644
index c076bbf6770..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/DirtyRegionQueue.java
+++ /dev/null
@@ -1,104 +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 java.util.List;
-import java.util.ArrayList;
-
-
-/**
- * Queue used by <code>Reconciler</code> to manage dirty regions. When a dirty region
- * is inserted into the queue, the queue tries to fold it into the neighboring dirty region.
- *
- * @see Reconciler
- * @see DirtyRegion
- */
-class DirtyRegionQueue {
-
- /** The list of dirty regions */
- private List fDirtyRegions= new ArrayList();
-
- /**
- * Creates a new empty dirty region.
- */
- public DirtyRegionQueue() {
- super();
- }
-
- /**
- * Adds a dirty region to the end of the dirty-region queue.
- *
- * @param dr the dirty region to add
- */
- public void addDirtyRegion(DirtyRegion dr) {
- // If the dirty region being added is directly after the last dirty
- // region on the queue then merge the two dirty regions together.
- DirtyRegion lastDR= getLastDirtyRegion();
- boolean wasMerged= false;
- if (lastDR != null)
- if (lastDR.getType() == dr.getType())
- if (lastDR.getType() == DirtyRegion.INSERT) {
- if (lastDR.getOffset() + lastDR.getLength() == dr.getOffset()) {
- lastDR.mergeWith(dr);
- wasMerged= true;
- }
- } else if (lastDR.getType() == DirtyRegion.REMOVE) {
- if (dr.getOffset() + dr.getLength() == lastDR.getOffset()) {
- lastDR.mergeWith(dr);
- wasMerged= true;
- }
- }
-
- if (!wasMerged)
- // Don't merge- just add the new one onto the queue.
- fDirtyRegions.add(dr);
- }
-
- /**
- * Returns the last dirty region that was added to the queue.
- *
- * @return the last DirtyRegion on the queue
- */
- private DirtyRegion getLastDirtyRegion() {
- int size= fDirtyRegions.size();
- return (size == 0 ? null : (DirtyRegion) fDirtyRegions.get(size - 1));
- }
-
- /**
- * Returns the number of regions in the queue.
- *
- * @return the dirty-region queue-size
- */
- public int getSize() {
- return fDirtyRegions.size();
- }
-
- /**
- * Throws away all entries in the queue.
- */
- public void purgeQueue() {
- fDirtyRegions.clear();
- }
-
- /**
- * Removes and returns the first dirty region in the queue
- *
- * @return the next dirty region on the queue
- */
- public DirtyRegion removeNextDirtyRegion() {
- if (fDirtyRegions.size() == 0)
- return null;
- DirtyRegion dr= (DirtyRegion) fDirtyRegions.get(0);
- fDirtyRegions.remove(0);
- return dr;
- }
-}
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/reconciler/IReconcilableModel.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcilableModel.java
deleted file mode 100644
index 73e8b52daf3..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcilableModel.java
+++ /dev/null
@@ -1,21 +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;
-
-/**
- * Tagging interface for a reconcilable model.
- *
- * @since 3.0
- */
-public interface IReconcilableModel {
-
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcileResult.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcileResult.java
deleted file mode 100644
index 2abecd99ff2..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcileResult.java
+++ /dev/null
@@ -1,22 +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;
-
-/**
- * Tagging interface for the result reported by a reconcile step
- *
- * @see org.eclipse.jface.text.reconciler.IReconcileStep
- * @since 3.0
- */
-public interface IReconcileResult {
-
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcileStep.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcileStep.java
deleted file mode 100644
index 5aadcc53817..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcileStep.java
+++ /dev/null
@@ -1,100 +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.IRegion;
-import org.eclipse.jface.text.reconciler.DirtyRegion;
-
-/**
- * A reconcile step is one of n steps of a reconcile
- * strategy that consists of several steps.
- *
- * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy
- * @since 3.0
- */
-public interface IReconcileStep {
-
- /**
- * Returns whether this is the last reconcile step or not.
- *
- * @return <code>true</code> if this is the last reconcile step
- */
- boolean isLastStep();
-
- /**
- * Returns whether this is the first reconcile step or not.
- *
- * @return <code>true</code> if this is the last reconcile step
- */
- boolean isFirstStep();
-
- /**
- * Sets the step which is in front of this step in the pipe.
- * <p>
- * Note: This method must be called at most once per reconcile step.
- * </p>
- *
- * @param step the previous step
- * @exception org.eclipse.jface.text.Assert#AssertionFailedException if called more than once
- */
- void setPreviousStep(IReconcileStep step);
-
- /**
- * Activates incremental reconciling of the specified dirty region.
- * As a dirty region might span multiple content types, the segment of the
- * dirty region which should be investigated is also provided to this
- * reconciling strategy. The given regions refer to the document passed into
- * the most recent call of <code>setDocument</code>.
- *
- * @param dirtyRegion the document region which has been changed
- * @param subRegion the sub region in the dirty region which should be reconciled
- * @return an array with reconcile results
- */
- IReconcileResult[] reconcile(DirtyRegion dirtyRegion, IRegion subRegion);
-
- /**
- * Activates non-incremental reconciling. The reconciling strategy is just told
- * that there are changes and that it should reconcile the given partition of the
- * document most recently passed into <code>setDocument</code>.
- *
- * @param partition the document partition to be reconciled
- * @return an array with reconcile results
- */
- IReconcileResult[] reconcile(IRegion partition);
-
- /**
- * Sets the progress monitor to this reconcile step.
- *
- * @param monitor the progress monitor to be used
- */
- void setProgressMonitor(IProgressMonitor monitor);
-
- /**
- * Returns the progress monitor used to report progress.
- *
- * @return a progress monitor or null if no progress monitor is provided
- */
- public IProgressMonitor getProgressMonitor();
-
- /**
- * Tells this reconcile step on which model it will
- * work. This method will be called before any other method
- * and can be called multiple times. The regions passed to the
- * other methods always refer to the most recent document
- * passed into this method.
- *
- * @param inputModel the model on which this strategy will work
- */
- void setInputModel(IReconcilableModel inputModel);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconciler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconciler.java
deleted file mode 100644
index 36778f1d40e..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconciler.java
+++ /dev/null
@@ -1,62 +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.ITextViewer;
-
-
-
-/**
- * An <code>IReconciler</code> defines and maintains a model of the content
- * of the text viewer's document in the presence of changes applied to this
- * document. An <code>IReconciler</code> is a <code>ITextViewer</code> add-on.<p>
- * Reconcilers are assumed to be asynchronous, i.e. they allow a certain
- * temporal window of inconsistency between the document and the model of
- * the content of this document. <p>
- * Reconcilers have a list of <code>IReconcilingStrategy</code> objects
- * each of which is registered for a particular document content type.
- * The reconciler uses the strategy objects to react on the changes applied
- * to the text viewer's document.<p>
- * The interface can be implemented by clients. By default, clients use
- * <code>Reconciler</code> as the standard implementer of this interface.
- *
- * @see ITextViewer
- * @see IReconcilingStrategy
- */
-public interface IReconciler {
-
- /**
- * Installs the reconciler on the given text viewer. After this method has been
- * finished, the reconciler is operational. I.e., it works without requesting
- * further client actions until <code>uninstall</code> is called.
- *
- * @param textViewer the viewer on which the reconciler is installed
- */
- void install(ITextViewer textViewer);
-
- /**
- * Removes the reconciler from the text viewer it has previously been
- * installed on.
- */
- void uninstall();
-
- /**
- * Returns the reconciling strategy registered with the reconciler
- * for the specified content type.
- *
- * @param contentType the content type for which to determine the reconciling strategy
- * @return the reconciling strategy registered for the given content type, or
- * <code>null</code> if there is no such strategy
- */
- IReconcilingStrategy getReconcilingStrategy(String contentType);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcilerExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcilerExtension.java
deleted file mode 100644
index 53450ce708c..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcilerExtension.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**********************************************************************
-Copyright (c) 2000, 2003 IBM Corp. 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 implementation
-**********************************************************************/
-package org.eclipse.jface.text.reconciler;
-
-/**
- * Extension interface for <code>IReconciler</code>.
- * Updates the reconciler to be aware of documents with multiple partitions.
- *
- * @since 3.0
- */
-public interface IReconcilerExtension {
-
- /**
- * Returns the partitioning this reconciler is using.
- *
- * @return the partitioning this reconciler is using
- */
- String getDocumentPartitioning();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcilingStrategy.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcilingStrategy.java
deleted file mode 100644
index 55be9a316df..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcilingStrategy.java
+++ /dev/null
@@ -1,60 +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;
-import org.eclipse.jface.text.IRegion;
-
-
-/**
- * A reconciling strategy is used by an reconciler to reconcile a model
- * based on text of a particular content type. It provides methods for
- * incremental as well as non-incremental reconciling.<p>
- * This interface must be implemented by clients. Implementers should be
- * registered with a reconciler in order get involved in the reconciling
- * process.
- */
-public interface IReconcilingStrategy {
-
- /**
- * Tells this reconciling strategy on which document it will
- * work. This method will be called before any other method
- * and can be called multiple times. The regions passed to the
- * other methods always refer to the most recent document
- * passed into this method.
- *
- * @param document the document on which this strategy will work
- */
- void setDocument(IDocument document);
-
- /**
- * Activates incremental reconciling of the specified dirty region.
- * As a dirty region might span multiple content types, the segment of the
- * dirty region which should be investigated is also provided to this
- * reconciling strategy. The given regions refer to the document passed into
- * the most recent call of <code>setDocument</code>.
- *
- * @param dirtyRegion the document region which has been changed
- * @param subRegion the sub region in the dirty region which should be reconciled
- */
- void reconcile(DirtyRegion dirtyRegion, IRegion subRegion);
-
- /**
- * Activates non-incremental reconciling. The reconciling strategy is just told
- * that there are changes and that it should reconcile the given partition of the
- * document most recently passed into <code>setDocument</code>.
- *
- * @param partition the document partition to be reconciled
- */
- void reconcile(IRegion partition);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcilingStrategyExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcilingStrategyExtension.java
deleted file mode 100644
index 5dc7a3ce1d8..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcilingStrategyExtension.java
+++ /dev/null
@@ -1,45 +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;
-
-
-/**
- * Extension interface for <code>IReconcilingStrategy</code>.
- * The new functions are:
- * <ul>
- * <li> usage of a progress monitor
- * <li> initial reconciling step: If a reconciler runs as periodic activity in the background, this
- * methods offers the reconciler a chance for initializing its startegies and achieving a
- * reconciled state before the periodic activity starts.
- * </ul>
- *
- * @since 2.0
- */
-public interface IReconcilingStrategyExtension {
-
- /**
- * Tells this reconciling strategy with which progress monitor
- * it will work. This method will be called before any other
- * method and can be called multiple times.
- *
- * @param monitor the progress monitor with which this strategy will work
- */
- void setProgressMonitor(IProgressMonitor monitor);
-
- /**
- * Called only once in the life time of this reconciling strategy.
- */
- void initialReconcile();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/MonoReconciler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/MonoReconciler.java
deleted file mode 100644
index aafcead74eb..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/MonoReconciler.java
+++ /dev/null
@@ -1,107 +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.Assert;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.Region;
-
-
-/**
- * Standard implementation of <code>IReconciler</code>. The reconciler
- * is configured with a single <code>IReconcilingStrategy</code> that is
- * used independly from where a dirty region is located in the reconciler's
- * document. <p>
- * Usually, clients instantiate this class and configure it before using it.
- *
- * @see IReconciler
- * @see org.eclipse.jface.text.IDocumentListener
- * @see org.eclipse.jface.text.ITextInputListener
- * @see DirtyRegion
- * @since 2.0
- */
-public class MonoReconciler extends AbstractReconciler {
-
-
- /** The reconciling strategy */
- private IReconcilingStrategy fStrategy;
-
-
- /**
- * Creates a new reconciler that uses the same reconciling strategy to
- * reconcile its document independent of the type of the document's contents.
- *
- * @param strategy the reconciling strategy to be used
- * @param isIncremental the indication whether strategy is incremental or not
- */
- public MonoReconciler(IReconcilingStrategy strategy, boolean isIncremental) {
- super();
-
- Assert.isNotNull(strategy);
-
- fStrategy= strategy;
- setIsIncrementalReconciler(isIncremental);
- }
-
- /*
- * @see IReconciler#getReconcilingStrategy(String)
- */
- public IReconcilingStrategy getReconcilingStrategy(String contentType) {
- Assert.isNotNull(contentType);
- return fStrategy;
- }
-
- /*
- * @see AbstractReconciler#process(DirtyRegion)
- */
- protected void process(DirtyRegion dirtyRegion) {
-
- if(dirtyRegion != null)
- fStrategy.reconcile(dirtyRegion, dirtyRegion);
- else {
- IDocument document= getDocument();
- if (document != null)
- fStrategy.reconcile(new Region(0, document.getLength()));
- }
- }
-
- /*
- * @see AbstractReconciler#reconcilerDocumentChanged(IDocument)
- */
- protected void reconcilerDocumentChanged(IDocument document) {
- fStrategy.setDocument(document);
- }
-
- /*
- * @see AbstractReconciler#setProgressMonitor(IProgressMonitor)
- */
- public void setProgressMonitor(IProgressMonitor monitor) {
- super.setProgressMonitor(monitor);
- if (fStrategy instanceof IReconcilingStrategyExtension) {
- IReconcilingStrategyExtension extension= (IReconcilingStrategyExtension) fStrategy;
- extension.setProgressMonitor(monitor);
- }
- }
-
- /*
- * @see AbstractReconciler#initialProcess()
- */
- protected void initialProcess() {
- if (fStrategy instanceof IReconcilingStrategyExtension) {
- IReconcilingStrategyExtension extension= (IReconcilingStrategyExtension) fStrategy;
- extension.initialReconcile();
- }
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/Reconciler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/Reconciler.java
deleted file mode 100644
index 16932770be1..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/Reconciler.java
+++ /dev/null
@@ -1,219 +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 java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentExtension3;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextUtilities;
-import org.eclipse.jface.text.TypedRegion;
-
-/**
- * Standard implementation of <code>IReconciler</code>. The reconciler
- * is configured with a set of reconciling strategies each of which is
- * responsible for a particular content type. <p>
- * Usually, clients instantiate this class and configure it before using it.
- *
- * @see IReconciler
- * @see org.eclipse.jface.text.IDocumentListener
- * @see org.eclipse.jface.text.ITextInputListener
- * @see DirtyRegion
- */
-public class Reconciler extends AbstractReconciler implements IReconcilerExtension {
-
- /** The map of reconciling strategies */
- private Map fStrategies;
-
- /**
- * The partitioning this reconciler uses.
- *@since 3.0
- */
- private String fPartitioning;
-
- /**
- * Creates a new reconciler with the following configuration: it is
- * an incremental reconciler with a standard delay of 500 ms. There
- * are no predefined reconciling strategies. The partitioning it uses
- * is the default partitioning <code>IDocumentExtension3.DEFAULT_PARTITIONING</code>.
- */
- public Reconciler() {
- super();
- fPartitioning= IDocumentExtension3.DEFAULT_PARTITIONING;
- }
-
- /**
- * Sets the document partitioning for this reconciler.
- *
- * @param partitioning the document partitioning for this reconciler
- * @since 3.0
- */
- public void setDocumentPartitioning(String partitioning) {
- Assert.isNotNull(partitioning);
- fPartitioning= partitioning;
- }
-
- /*
- * @see org.eclipse.jface.text.reconciler.IReconcilerExtension#getDocumentPartitioning()
- * @since 3.0
- */
- public String getDocumentPartitioning() {
- return fPartitioning;
- }
-
- /**
- * Registers a given reconciling strategy for a particular content type.
- * If there is already a strategy registered for this type, the new strategy
- * is registered instead of the old one.
- *
- * @param strategy the reconciling strategy to register, or <code>null</code> to remove an existing one
- * @param contentType the content type under which to register
- */
- public void setReconcilingStrategy(IReconcilingStrategy strategy, String contentType) {
-
- Assert.isNotNull(contentType);
-
- if (fStrategies == null)
- fStrategies= new HashMap();
-
- if (strategy == null)
- fStrategies.remove(contentType);
- else {
- fStrategies.put(contentType, strategy);
- if (strategy instanceof IReconcilingStrategyExtension && getProgressMonitor() == null) {
- IReconcilingStrategyExtension extension= (IReconcilingStrategyExtension) strategy;
- extension.setProgressMonitor(getProgressMonitor());
- }
- }
- }
-
- /*
- * @see IReconciler#getReconcilingStrategy(String)
- */
- public IReconcilingStrategy getReconcilingStrategy(String contentType) {
-
- Assert.isNotNull(contentType);
-
- if (fStrategies == null)
- return null;
-
- return (IReconcilingStrategy) fStrategies.get(contentType);
- }
-
- /**
- * Processes a dirty region. If the dirty region is <code>null</code> the whole
- * document is consider being dirty. The dirty region is partitioned by the
- * document and each partition is handed over to a reconciling strategy registered
- * for the partition's content type.
- *
- * @param dirtyRegion the dirty region to be processed
- * @see AbstractReconciler#process(DirtyRegion)
- */
- protected void process(DirtyRegion dirtyRegion) {
-
- IRegion region= dirtyRegion;
-
- if (region == null)
- region= new Region(0, getDocument().getLength());
-
- ITypedRegion[] regions= computePartitioning(region.getOffset(), region.getLength());
-
- for (int i= 0; i < regions.length; i++) {
- ITypedRegion r= regions[i];
- IReconcilingStrategy s= getReconcilingStrategy(r.getType());
- if (s == null)
- continue;
-
- if(dirtyRegion != null)
- s.reconcile(dirtyRegion, r);
- else
- s.reconcile(r);
- }
- }
-
- /*
- * @see AbstractReconciler#reconcilerDocumentChanged(IDocument)
- * @since 2.0
- */
- protected void reconcilerDocumentChanged(IDocument document) {
- if (fStrategies != null) {
- Iterator e= fStrategies.values().iterator();
- while (e.hasNext()) {
- IReconcilingStrategy strategy= (IReconcilingStrategy) e.next();
- strategy.setDocument(document);
- }
- }
- }
-
- /*
- * @see AbstractReconciler#setProgressMonitor(IProgressMonitor)
- * @since 2.0
- */
- public void setProgressMonitor(IProgressMonitor monitor) {
- super.setProgressMonitor(monitor);
-
- if (fStrategies != null) {
- Iterator e= fStrategies.values().iterator();
- while (e.hasNext()) {
- IReconcilingStrategy strategy= (IReconcilingStrategy) e.next();
- if (strategy instanceof IReconcilingStrategyExtension) {
- IReconcilingStrategyExtension extension= (IReconcilingStrategyExtension) strategy;
- extension.setProgressMonitor(monitor);
- }
- }
- }
- }
-
- /*
- * @see AbstractReconciler#initialProcess()
- * @since 2.0
- */
- protected void initialProcess() {
- ITypedRegion[] regions= computePartitioning(0, getDocument().getLength());
- for (int i= 0; i < regions.length; i++) {
- ITypedRegion r= regions[i];
- IReconcilingStrategy s= getReconcilingStrategy(r.getType());
- if (s instanceof IReconcilingStrategyExtension) {
- IReconcilingStrategyExtension e= (IReconcilingStrategyExtension) s;
- e.initialReconcile();
- }
- }
- }
-
- /**
- * Computes and returns the partitioning for the given region of the input document
- * of the reconciler's connected text viewer.
- *
- * @param offset the region offset
- * @param length the region length
- * @return the computed partitioning
- * @since 3.0
- */
- private ITypedRegion[] computePartitioning(int offset, int length) {
- ITypedRegion[] regions= null;
- try {
- regions= TextUtilities.computePartitioning(getDocument(), getDocumentPartitioning(), offset, length);
- } catch (BadLocationException x) {
- regions= new TypedRegion[0];
- }
- return regions;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/package.html b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/package.html
deleted file mode 100644
index 8f46d6c7019..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/package.html
+++ /dev/null
@@ -1,25 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="Author" content="IBM">
- <meta name="GENERATOR" content="Mozilla/4.76 [en] (Windows NT 5.0; U) [Netscape]">
- <title>Package-level Javadoc</title>
-</head>
-<body>
-Provides a reconciler add-on for an <tt>ITextViewer</tt>.
-A&nbsp; reconciler provides generic synchronization support&nbsp; with
-the content of the document serving as the <tt>ITextViewer</tt>'s input.
-There is no explicit model of what is synchronized.
-<h2>
-Package Specification</h2>
-<tt>IReconciler</tt> defines the concept of a reconciler. It collaborates
-with content type specific reconciling strategies (<tt>IReconcilingStrategy</tt>)
-which perform the synchronization for a given dirty region. The package
-contains a default implementation of <tt>IReconciler</tt> (<tt>Reconciler</tt>).
-
-<tt>Reconciler</tt> and <tt>MonoReconciler</tt> implements reconciling
-as a periodic background activity and folds co-located changes while being
-inactive.
-</body>
-</html>
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/BufferedRuleBasedScanner.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/BufferedRuleBasedScanner.java
deleted file mode 100644
index 66ba10f0543..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/BufferedRuleBasedScanner.java
+++ /dev/null
@@ -1,133 +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.rules;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-
-/**
- * A buffered rule based scanner. The buffer always contains a section
- * of a fixed size of the document to be scanned. Completely adheres to
- * the contract of <code>RuleBasedScanner</code>.
- */
-public class BufferedRuleBasedScanner extends RuleBasedScanner {
-
- /** The default buffer size. Value = 500 */
- private final static int DEFAULT_BUFFER_SIZE= 500;
- /** The actual size of the buffer. Initially set to <code>DEFAULT_BUFFER_SIZE</code> */
- private int fBufferSize= DEFAULT_BUFFER_SIZE;
- /** The buffer */
- private char[] fBuffer= new char[DEFAULT_BUFFER_SIZE];
- /** The offset of the document at which the buffer starts */
- private int fStart;
- /** The offset of the document at which the buffer ends */
- private int fEnd;
- /** The cached length of the document */
- private int fDocumentLength;
-
-
- /**
- * Creates a new buffered rule based scanner which does
- * not have any rule and a default buffer size of 500 characters.
- */
- protected BufferedRuleBasedScanner() {
- super();
- }
-
- /**
- * Creates a new buffered rule based scanner which does
- * not have any rule. The buffer size is set to the given
- * number of characters.
- *
- * @param size the buffer size
- */
- public BufferedRuleBasedScanner(int size) {
- super();
- setBufferSize(size);
- }
-
- /**
- * Sets the buffer to the given number of characters.
- *
- * @param size the buffer size
- */
- protected void setBufferSize(int size) {
- Assert.isTrue(size > 0);
- fBufferSize= size;
- fBuffer= new char[size];
- }
-
- /**
- * Shifts the buffer so that the buffer starts at the
- * given document offset.
- *
- * @param offset the document offset at which the buffer starts
- */
- private void shiftBuffer(int offset) {
-
- fStart= offset;
- fEnd= fStart + fBufferSize;
- if (fEnd > fDocumentLength)
- fEnd= fDocumentLength;
-
- try {
-
- String content= fDocument.get(fStart, fEnd - fStart);
- content.getChars(0, fEnd - fStart, fBuffer, 0);
-
- } catch (BadLocationException x) {
- }
- }
-
- /*
- * @see RuleBasedScanner#setRange(IDocument, int, int)
- */
- public void setRange(IDocument document, int offset, int length) {
-
- super.setRange(document, offset, length);
-
- fDocumentLength= document.getLength();
- shiftBuffer(offset);
- }
-
- /*
- * @see RuleBasedScanner#read()
- */
- public int read() {
-
- if (fOffset >= fRangeEnd) {
- ++ fOffset;
- return EOF;
- }
-
- if (fOffset == fEnd)
- shiftBuffer(fEnd);
- else if (fOffset < fStart || fEnd < fOffset)
- shiftBuffer(fOffset);
-
- return fBuffer[fOffset++ - fStart];
- }
-
- /*
- * @see RuleBasedScanner#unread()
- */
- public void unread() {
-
- if (fOffset == fStart)
- shiftBuffer(Math.max(0, fStart - (fBufferSize / 2)));
-
- -- fOffset;
- }
-}
-
-
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/DefaultDamagerRepairer.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/DefaultDamagerRepairer.java
deleted file mode 100644
index edbd92d70ab..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/DefaultDamagerRepairer.java
+++ /dev/null
@@ -1,213 +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.rules;
-
-
-import org.eclipse.swt.custom.StyleRange;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextAttribute;
-import org.eclipse.jface.text.TextPresentation;
-import org.eclipse.jface.text.presentation.IPresentationDamager;
-import org.eclipse.jface.text.presentation.IPresentationRepairer;
-
-
-/**
- * A standard implementation of a syntax driven presentation damager
- * and presentation repairer. It uses a token scanner to scan
- * the document and to determine its damage and new text presentation.
- * The tokens returned by the scanner are supposed to return text attributes
- * as their data.
- *
- * @see ITokenScanner
- * @since 2.0
- */
-public class DefaultDamagerRepairer implements IPresentationDamager, IPresentationRepairer {
-
- /** The document this object works on */
- protected IDocument fDocument;
- /** The scanner it uses */
- protected ITokenScanner fScanner;
- /** The default text attribute if non is returned as data by the current token */
- protected TextAttribute fDefaultTextAttribute;
-
- /**
- * Creates a damager/repairer that uses the given scanner and returns the given default
- * text attribute if the current token does not carry a text attribute.
- *
- * @param scanner the token scanner to be used
- * @param defaultTextAttribute the text attribute to be returned if non is specified by the current token,
- * may not be <code>null</code>
- *
- * @deprecated use DefaultDamagerRepairer(ITokenScanner) instead
- */
- public DefaultDamagerRepairer(ITokenScanner scanner, TextAttribute defaultTextAttribute) {
-
- Assert.isNotNull(defaultTextAttribute);
-
- fScanner= scanner;
- fDefaultTextAttribute= defaultTextAttribute;
- }
-
- /**
- * Creates a damager/repairer that uses the given scanner. The scanner may not be <code>null</code>
- * and is assumed to return only token that carry text attributes.
- *
- * @param scanner the token scanner to be used, may not be <code>null</code>
- */
- public DefaultDamagerRepairer(ITokenScanner scanner) {
-
- Assert.isNotNull(scanner);
-
- fScanner= scanner;
- }
-
- /*
- * @see IPresentationDamager#setDocument(IDocument)
- * @see IPresentationRepairer#setDocument(IDocument)
- */
- public void setDocument(IDocument document) {
- fDocument= document;
- }
-
-
- //---- IPresentationDamager
-
- /**
- * Returns the end offset of the line that contains the specified offset or
- * if the offset is inside a line delimiter, the end offset of the next line.
- *
- * @param offset the offset whose line end offset must be computed
- * @return the line end offset for the given offset
- * @exception BadLocationException if offset is invalid in the current document
- */
- protected int endOfLineOf(int offset) throws BadLocationException {
-
- IRegion info= fDocument.getLineInformationOfOffset(offset);
- if (offset <= info.getOffset() + info.getLength())
- return info.getOffset() + info.getLength();
-
- int line= fDocument.getLineOfOffset(offset);
- try {
- info= fDocument.getLineInformation(line + 1);
- return info.getOffset() + info.getLength();
- } catch (BadLocationException x) {
- return fDocument.getLength();
- }
- }
-
- /*
- * @see IPresentationDamager#getDamageRegion(ITypedRegion, DocumentEvent, boolean)
- */
- public IRegion getDamageRegion(ITypedRegion partition, DocumentEvent e, boolean documentPartitioningChanged) {
-
- if (!documentPartitioningChanged) {
- try {
-
- IRegion info= fDocument.getLineInformationOfOffset(e.getOffset());
- int start= Math.max(partition.getOffset(), info.getOffset());
-
- int end= e.getOffset() + (e.getText() == null ? e.getLength() : e.getText().length());
-
- if (info.getOffset() <= end && end <= info.getOffset() + info.getLength()) {
- // optimize the case of the same line
- end= info.getOffset() + info.getLength();
- } else
- end= endOfLineOf(end);
-
- end= Math.min(partition.getOffset() + partition.getLength(), end);
- return new Region(start, end - start);
-
- } catch (BadLocationException x) {
- }
- }
-
- return partition;
- }
-
- //---- IPresentationRepairer
-
- /*
- * @see IPresentationRepairer#createPresentation(TextPresentation, ITypedRegion)
- */
- public void createPresentation(TextPresentation presentation, ITypedRegion region) {
-
- if (fScanner == null) {
- // will be removed if deprecated constructor will be removed
- addRange(presentation, region.getOffset(), region.getLength(), fDefaultTextAttribute);
- return;
- }
-
- int lastStart= region.getOffset();
- int length= 0;
- IToken lastToken= Token.UNDEFINED;
- TextAttribute lastAttribute= getTokenTextAttribute(lastToken);
-
- fScanner.setRange(fDocument, lastStart, region.getLength());
-
- while (true) {
- IToken token= fScanner.nextToken();
- if (token.isEOF())
- break;
-
- TextAttribute attribute= getTokenTextAttribute(token);
- if (lastAttribute != null && lastAttribute.equals(attribute)) {
- length += fScanner.getTokenLength();
- } else {
- addRange(presentation, lastStart, length, lastAttribute);
- lastToken= token;
- lastAttribute= attribute;
- lastStart= fScanner.getTokenOffset();
- length= fScanner.getTokenLength();
- }
- }
-
- addRange(presentation, lastStart, length, lastAttribute);
- }
-
- /**
- * Returns a text attribute encoded in the given token. If the token's
- * data is not <code>null</code> and a text attribute it is assumed that
- * it is the encoded text attribute. It returns the default text attribute
- * if there is no encoded text attribute found.
- *
- * @param token the token whose text attribute is to be determined
- * @return the token's text attribute
- */
- protected TextAttribute getTokenTextAttribute(IToken token) {
- Object data= token.getData();
- if (data instanceof TextAttribute)
- return (TextAttribute) data;
- return fDefaultTextAttribute;
- }
-
- /**
- * Adds style information to the given text presentation.
- *
- * @param presentation the text presentation to be extended
- * @param offset the offset of the range to be styled
- * @param length the length of the range to be styled
- * @param attr the attribute describing the style of the range to be styled
- */
- protected void addRange(TextPresentation presentation, int offset, int length, TextAttribute attr) {
- if (attr != null)
- presentation.addStyleRange(new StyleRange(offset, length, attr.getForeground(), attr.getBackground(), attr.getStyle()));
- }
-}
-
-
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/DefaultPartitioner.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/DefaultPartitioner.java
deleted file mode 100644
index 03335e4d4de..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/DefaultPartitioner.java
+++ /dev/null
@@ -1,543 +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.rules;
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.DefaultPositionUpdater;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.jface.text.IDocumentPartitionerExtension;
-import org.eclipse.jface.text.IDocumentPartitionerExtension2;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TypedPosition;
-import org.eclipse.jface.text.TypedRegion;
-
-
-
-/**
- * A standard implementation of a document partitioner.
- * It uses a partition token scanner to scan the document and to determine
- * the document's partitioning. The tokens returned by the
- * scanner are supposed to return the partition type
- * as their data. The partitoner remembers the document's partitions
- * in the document itself rather than maintaining its own data structure.
- *
- * @see IPartitionTokenScanner
- * @since 2.0
- */
-public class DefaultPartitioner implements IDocumentPartitioner, IDocumentPartitionerExtension, IDocumentPartitionerExtension2 {
-
- /**
- * The position category this partitioner uses to store the document's partitioning information.
- * @deprecated use <code>getManagingPositionCategories()</code>.
- */
- public final static String CONTENT_TYPES_CATEGORY= "__content_types_category"; //$NON-NLS-1$
-
-
- /** The partitioner's scanner */
- protected IPartitionTokenScanner fScanner;
- /** The legal content types of this partitioner */
- protected String[] fLegalContentTypes;
- /** The partitioner's document */
- protected IDocument fDocument;
- /** The document length before a document change occured */
- protected int fPreviousDocumentLength;
- /** The position updater used to for the default updating of partitions */
- protected DefaultPositionUpdater fPositionUpdater;
- /** The offset at which the first changed partition starts */
- protected int fStartOffset;
- /** The offset at which the last changed partition ends */
- protected int fEndOffset;
- /**The offset at which a partition has been deleted */
- protected int fDeleteOffset;
- /**
- * The position category this partitioner uses to store the document's partitioning information.
- * @since 3.0
- */
- private String fPositionCategory;
-
- /**
- * Creates a new partitioner that uses the given scanner and may return
- * partitions of the given legal content types.
- *
- * @param scanner the scanner this partitioner is supposed to use
- * @param legalContentTypes the legal content types of this partitioner
- */
- public DefaultPartitioner(IPartitionTokenScanner scanner, String[] legalContentTypes) {
- fScanner= scanner;
- fLegalContentTypes= legalContentTypes;
- fPositionCategory= CONTENT_TYPES_CATEGORY + hashCode();
- fPositionUpdater= new DefaultPositionUpdater(fPositionCategory);
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentPartitionerExtension2#getManagingPositionCategories()
- * @since 3.0
- */
- public String[] getManagingPositionCategories() {
- return new String[] { fPositionCategory };
- }
-
- /*
- * @see IDocumentPartitioner#connect(IDocument)
- */
- public void connect(IDocument document) {
- Assert.isNotNull(document);
- Assert.isTrue(!document.containsPositionCategory(fPositionCategory));
-
- fDocument= document;
- fDocument.addPositionCategory(fPositionCategory);
-
- initialize();
- }
-
- /**
- * Performs the initial partitioning of the partitioner's document.
- */
- protected void initialize() {
-
- fScanner.setRange(fDocument, 0, fDocument.getLength());
-
- try {
- IToken token= fScanner.nextToken();
- while (!token.isEOF()) {
-
- String contentType= getTokenContentType(token);
-
- if (isSupportedContentType(contentType)) {
- TypedPosition p= new TypedPosition(fScanner.getTokenOffset(), fScanner.getTokenLength(), contentType);
- fDocument.addPosition(fPositionCategory, p);
- }
-
- token= fScanner.nextToken();
- }
- } catch (BadLocationException x) {
- // cannot happen as offsets come from scanner
- } catch (BadPositionCategoryException x) {
- // cannot happen if document has been connected before
- }
- }
-
- /*
- * @see IDocumentPartitioner#disconnect()
- */
- public void disconnect() {
-
- Assert.isTrue(fDocument.containsPositionCategory(fPositionCategory));
-
- try {
- fDocument.removePositionCategory(fPositionCategory);
- } catch (BadPositionCategoryException x) {
- // can not happen because of Assert
- }
- }
-
- /*
- * @see IDocumentPartitioner#documentAboutToBeChanged(DocumentEvent)
- */
- public void documentAboutToBeChanged(DocumentEvent e) {
-
- Assert.isTrue(e.getDocument() == fDocument);
-
- fPreviousDocumentLength= e.getDocument().getLength();
- fStartOffset= -1;
- fEndOffset= -1;
- fDeleteOffset= -1;
- }
-
- /*
- * @see IDocumentPartitioner#documentChanged(DocumentEvent)
- */
- public boolean documentChanged(DocumentEvent e) {
- IRegion region= documentChanged2(e);
- return (region != null);
- }
-
- /**
- * Helper method for tracking the minimal region containg all partition changes.
- * If <code>offset</code> is smaller than the remembered offset, <code>offset</code>
- * will from now on be remembered. If <code>offset + length</code> is greater than
- * the remembered end offset, it will be remembered from now on.
- *
- * @param offset the offset
- * @param length the length
- */
- private void rememberRegion(int offset, int length) {
- // remember start offset
- if (fStartOffset == -1)
- fStartOffset= offset;
- else if (offset < fStartOffset)
- fStartOffset= offset;
-
- // remember end offset
- int endOffset= offset + length;
- if (fEndOffset == -1)
- fEndOffset= endOffset;
- else if (endOffset > fEndOffset)
- fEndOffset= endOffset;
- }
-
- /**
- * Remembers the given offset as the deletion offset.
- *
- * @param offset the offset
- */
- private void rememberDeletedOffset(int offset) {
- fDeleteOffset= offset;
- }
-
- /**
- * Creates the minimal region containing all partition changes using the
- * remembered offset, end offset, and deletion offset.
- *
- * @return the minimal region containing all the partition changes
- */
- private IRegion createRegion() {
- if (fDeleteOffset == -1) {
- if (fStartOffset == -1 || fEndOffset == -1)
- return null;
- return new Region(fStartOffset, fEndOffset - fStartOffset);
- } else if (fStartOffset == -1 || fEndOffset == -1) {
- return new Region(fDeleteOffset, 0);
- } else {
- int offset= Math.min(fDeleteOffset, fStartOffset);
- int endOffset= Math.max(fDeleteOffset, fEndOffset);
- return new Region(offset, endOffset - offset);
- }
- }
-
- /*
- * @see IDocumentPartitionerExtension#documentChanged2(DocumentEvent)
- * @since 2.0
- */
- public IRegion documentChanged2(DocumentEvent e) {
-
- try {
-
- IDocument d= e.getDocument();
- Position[] category= d.getPositions(fPositionCategory);
- IRegion line= d.getLineInformationOfOffset(e.getOffset());
- int reparseStart= line.getOffset();
- int partitionStart= -1;
- String contentType= null;
-
- int first= d.computeIndexInCategory(fPositionCategory, reparseStart);
- if (first > 0) {
- TypedPosition partition= (TypedPosition) category[first - 1];
- if (partition.includes(reparseStart)) {
- partitionStart= partition.getOffset();
- contentType= partition.getType();
- if (e.getOffset() == partition.getOffset() + partition.getLength())
- reparseStart= partitionStart;
- -- first;
- } else if (reparseStart == e.getOffset() && reparseStart == partition.getOffset() + partition.getLength()) {
- partitionStart= partition.getOffset();
- contentType= partition.getType();
- reparseStart= partitionStart;
- -- first;
- } else {
- partitionStart= partition.getOffset() + partition.getLength();
- contentType= IDocument.DEFAULT_CONTENT_TYPE;
- }
- }
-
- fPositionUpdater.update(e);
- for (int i= first; i < category.length; i++) {
- Position p= category[i];
- if (p.isDeleted) {
- rememberDeletedOffset(e.getOffset());
- break;
- }
- }
- category= d.getPositions(fPositionCategory);
-
- fScanner.setPartialRange(d, reparseStart, d.getLength() - reparseStart, contentType, partitionStart);
-
- int lastScannedPosition= reparseStart;
- IToken token= fScanner.nextToken();
-
- while (!token.isEOF()) {
-
- contentType= getTokenContentType(token);
-
- if (!isSupportedContentType(contentType)) {
- token= fScanner.nextToken();
- continue;
- }
-
- int start= fScanner.getTokenOffset();
- int length= fScanner.getTokenLength();
-
- lastScannedPosition= start + length - 1;
-
- // remove all affected positions
- while (first < category.length) {
- TypedPosition p= (TypedPosition) category[first];
- if (lastScannedPosition >= p.offset + p.length ||
- (p.overlapsWith(start, length) &&
- (!d.containsPosition(fPositionCategory, start, length) ||
- !contentType.equals(p.getType())))) {
-
- rememberRegion(p.offset, p.length);
- d.removePosition(fPositionCategory, p);
- ++ first;
-
- } else
- break;
- }
-
- // if position already exists we are done
- if (d.containsPosition(fPositionCategory, start, length)) {
- if (lastScannedPosition > e.getOffset())
- return createRegion();
- ++ first;
- } else {
- // insert the new type position
- try {
- d.addPosition(fPositionCategory, new TypedPosition(start, length, contentType));
- rememberRegion(start, length);
- } catch (BadPositionCategoryException x) {
- } catch (BadLocationException x) {
- }
- }
-
- token= fScanner.nextToken();
- }
-
-
- // remove all positions behind lastScannedPosition since there aren't any further types
- if (lastScannedPosition != reparseStart) {
- // if this condition is not met, nothing has been scanned because of a deletion
- ++ lastScannedPosition;
- }
- first= d.computeIndexInCategory(fPositionCategory, lastScannedPosition);
-
- TypedPosition p;
- while (first < category.length) {
- p= (TypedPosition) category[first++];
- d.removePosition(fPositionCategory, p);
- rememberRegion(p.offset, p.length);
- }
-
- } catch (BadPositionCategoryException x) {
- // should never happen on connected documents
- } catch (BadLocationException x) {
- }
-
- return createRegion();
- }
-
-
- /**
- * Returns the position in the partitoner's position category which is
- * close to the given offset. This is, the position has either an offset which
- * is the same as the given offset or an offset which is smaller than the given
- * offset. This method profits from the knowledge that a partitioning is
- * a ordered set of disjoint position.
- *
- * @param offset the offset for which to search the closest position
- * @return the closest position in the partitioner's category
- */
- protected TypedPosition findClosestPosition(int offset) {
-
- try {
-
- int index= fDocument.computeIndexInCategory(fPositionCategory, offset);
- Position[] category= fDocument.getPositions(fPositionCategory);
-
- if (category.length == 0)
- return null;
-
- if (index < category.length) {
- if (offset == category[index].offset)
- return (TypedPosition) category[index];
- }
-
- if (index > 0)
- index--;
-
- return (TypedPosition) category[index];
-
- } catch (BadPositionCategoryException x) {
- } catch (BadLocationException x) {
- }
-
- return null;
- }
-
-
- /*
- * @see IDocumentPartitioner#getContentType(int)
- */
- public String getContentType(int offset) {
-
- TypedPosition p= findClosestPosition(offset);
- if (p != null && p.includes(offset))
- return p.getType();
-
- return IDocument.DEFAULT_CONTENT_TYPE;
- }
-
- /*
- * @see IDocumentPartitioner#getPartition(int)
- */
- public ITypedRegion getPartition(int offset) {
-
- try {
-
- Position[] category = fDocument.getPositions(fPositionCategory);
-
- if (category == null || category.length == 0)
- return new TypedRegion(0, fDocument.getLength(), IDocument.DEFAULT_CONTENT_TYPE);
-
- int index= fDocument.computeIndexInCategory(fPositionCategory, offset);
-
- if (index < category.length) {
-
- TypedPosition next= (TypedPosition) category[index];
-
- if (offset == next.offset)
- return new TypedRegion(next.getOffset(), next.getLength(), next.getType());
-
- if (index == 0)
- return new TypedRegion(0, next.offset, IDocument.DEFAULT_CONTENT_TYPE);
-
- TypedPosition previous= (TypedPosition) category[index - 1];
- if (previous.includes(offset))
- return new TypedRegion(previous.getOffset(), previous.getLength(), previous.getType());
-
- int endOffset= previous.getOffset() + previous.getLength();
- return new TypedRegion(endOffset, next.getOffset() - endOffset, IDocument.DEFAULT_CONTENT_TYPE);
- }
-
- TypedPosition previous= (TypedPosition) category[category.length - 1];
- if (previous.includes(offset))
- return new TypedRegion(previous.getOffset(), previous.getLength(), previous.getType());
-
- int endOffset= previous.getOffset() + previous.getLength();
- return new TypedRegion(endOffset, fDocument.getLength() - endOffset, IDocument.DEFAULT_CONTENT_TYPE);
-
- } catch (BadPositionCategoryException x) {
- } catch (BadLocationException x) {
- }
-
- return new TypedRegion(0, fDocument.getLength(), IDocument.DEFAULT_CONTENT_TYPE);
- }
-
- /*
- * @see IDocumentPartitioner#computePartitioning(int, int)
- */
- public ITypedRegion[] computePartitioning(int offset, int length) {
-
- List list= new ArrayList();
-
- try {
-
- int endOffset= offset + length;
-
- Position[] category= fDocument.getPositions(fPositionCategory);
-
- TypedPosition previous= null, current= null;
- int start, end, gapOffset;
- Position gap= null;
-
- for (int i= 0; i < category.length; i++) {
-
- current= (TypedPosition) category[i];
-
- gapOffset= (previous != null) ? previous.getOffset() + previous.getLength() : 0;
- gap= new Position(gapOffset, current.getOffset() - gapOffset);
- if (gap.getLength() > 0 && gap.overlapsWith(offset, length)) {
- start= Math.max(offset, gapOffset);
- end= Math.min(endOffset, gap.getOffset() + gap.getLength());
- list.add(new TypedRegion(start, end - start, IDocument.DEFAULT_CONTENT_TYPE));
- }
-
- if (current.overlapsWith(offset, length)) {
- start= Math.max(offset, current.getOffset());
- end= Math.min(endOffset, current.getOffset() + current.getLength());
- list.add(new TypedRegion(start, end - start, current.getType()));
- }
-
- previous= current;
- }
-
- if (previous != null) {
- gapOffset= previous.getOffset() + previous.getLength();
- gap= new Position(gapOffset, fDocument.getLength() - gapOffset);
- if (gap.getLength() > 0 && gap.overlapsWith(offset, length)) {
- start= Math.max(offset, gapOffset);
- end= Math.min(endOffset, fDocument.getLength());
- list.add(new TypedRegion(start, end - start, IDocument.DEFAULT_CONTENT_TYPE));
- }
- }
-
- if (list.isEmpty())
- list.add(new TypedRegion(offset, length, IDocument.DEFAULT_CONTENT_TYPE));
-
- } catch (BadPositionCategoryException x) {
- }
-
- TypedRegion[] result= new TypedRegion[list.size()];
- list.toArray(result);
- return result;
- }
-
- /*
- * @see IDocumentPartitioner#getLegalContentTypes()
- */
- public String[] getLegalContentTypes() {
- return fLegalContentTypes;
- }
-
- /**
- * Returns whether the given type is one of the legal content types.
- *
- * @param contentType the content type to check
- * @return <code>true</code> if the content type is a legal content type
- */
- protected boolean isSupportedContentType(String contentType) {
- if (contentType != null) {
- for (int i= 0; i < fLegalContentTypes.length; i++) {
- if (fLegalContentTypes[i].equals(contentType))
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Returns a content type encoded in the given token. If the token's
- * data is not <code>null</code> and a string it is assumed that
- * it is the encoded content type.
- *
- * @param token the token whose content type is to be determined
- * @return the token's content type
- */
- protected String getTokenContentType(IToken token) {
- Object data= token.getData();
- if (data instanceof String)
- return (String) data;
- return null;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/EndOfLineRule.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/EndOfLineRule.java
deleted file mode 100644
index 7a5bb9f8223..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/EndOfLineRule.java
+++ /dev/null
@@ -1,45 +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.rules;
-
-
-/**
- * A specific configuration of a single line rule
- * whereby the pattern begins with a specific sequence but
- * is only ended by a line delimiter.
- */
-public class EndOfLineRule extends SingleLineRule {
-
- /**
- * Creates a rule for the given starting sequence
- * which, if detected, will return the specified token.
- *
- * @param startSequence the pattern's start sequence
- * @param token the token to be returned on success
- */
- public EndOfLineRule(String startSequence, IToken token) {
- this(startSequence, token, (char) 0);
- }
-
- /**
- * Creates a rule for the given starting sequence
- * which, if detected, will return the specified token.
- * Any character which follows the given escape character
- * will be ignored.
- *
- * @param startSequence the pattern's start sequence
- * @param token the token to be returned on success
- * @param escapeCharacter the escape character
- */
- public EndOfLineRule(String startSequence, IToken token, char escapeCharacter) {
- super(startSequence, null, token, escapeCharacter, true);
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/ICharacterScanner.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/ICharacterScanner.java
deleted file mode 100644
index 2edc15e21e2..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/ICharacterScanner.java
+++ /dev/null
@@ -1,51 +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.rules;
-
-
-/**
- * Defines the interface of a character scanner used by rules.
- * Rules may request the next character or ask the character
- * scanner to unread the last read character.
- */
-public interface ICharacterScanner {
-
- /**
- * The value returned when this scanner has read EOF.
- */
- public static final int EOF= -1;
-
- /**
- * Provides rules access to the legal line delimiters.
- *
- * @return the legal line delimiters
- */
- char[][] getLegalLineDelimiters();
-
- /**
- * Returns the column of the character scanner.
- *
- * @return the column of the character scanner
- */
- int getColumn();
-
- /**
- * Returns the next character or EOF if end of file has been reached
- *
- * @return the next character or EOF
- */
- int read();
-
- /**
- * Rewinds the scanner before the last read character.
- */
- void unread();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IPartitionTokenScanner.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IPartitionTokenScanner.java
deleted file mode 100644
index 420261fe869..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IPartitionTokenScanner.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.rules;
-
-
-import org.eclipse.jface.text.IDocument;
-
-
-/**
- * A partition token scanner returns tokens that represent partitions. For that reason,
- * a partition token scanner is vulnerable in respect to the document offset it starts
- * scanning. In a simple case, a partition token scanner must always start at a partition
- * boundary. A partition token scanner can also start in the middle of a partition,
- * if it knows the type of the partition.
- *
- * @since 2.0
- */
-public interface IPartitionTokenScanner extends ITokenScanner {
-
- /**
- * Configures the scanner by providing access to the document range that should be scanned.
- * The range may no only contain complete partitions but starts at the beginning of a line in the
- * middle of a partition of the given content type. This requires that a partition delimiter can not
- * contain a line delimiter.
- *
- * @param document the document to scan
- * @param offset the offset of the document range to scan
- * @param length the length of the document range to scan
- * @param contentType the content type at the given offset
- * @param partitionOffset the offset at which the partition of the given offset starts
- */
- void setPartialRange(IDocument document, int offset, int length, String contentType, int partitionOffset);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IPredicateRule.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IPredicateRule.java
deleted file mode 100644
index 8e4f99e5243..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IPredicateRule.java
+++ /dev/null
@@ -1,47 +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.rules;
-
-/**
- * Defines the interface for a rule used in the scanning of text for the purpose of
- * document partitioning or text styling. A predicate rule can only return one single
- * token after having successfully detected content. This token is called success token.
- * Also, it also returns a token indicating that this rule has not been successful.
- *
- * @see ICharacterScanner
- * @since 2.0
- */
-public interface IPredicateRule extends IRule {
-
- /**
- * Returns the success token of this predicate rule.
- *
- * @return the success token of this rule
- */
- IToken getSuccessToken();
-
- /**
- * Evaluates the rule by examining the characters available from
- * the provided character scanner. The token returned by this rule
- * returns <code>true</code> when calling <code>isUndefined</code>,
- * if the text the rule investigated does not match the rule's requirements. Otherwise,
- * this method returns this rule's success token. If this rules relies on a text pattern
- * comprising a opening and a closing character sequence this method can also be called
- * when the scanner is positioned already between the opening and the closing sequence.
- * In this case, <code>resume</code> must be set to <code>true</code>.
- *
- * @param scanner the character scanner to be used by this rule
- * @param resume indicates that the rule starts working between the opening and the closing character sequence
- * @return the token computed by the rule
- */
- IToken evaluate(ICharacterScanner scanner, boolean resume);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IRule.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IRule.java
deleted file mode 100644
index 4b5dce4ac87..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IRule.java
+++ /dev/null
@@ -1,33 +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.rules;
-
-
-/**
- * Defines the interface for a rule used in the
- * scanning of text for the purpose of document
- * partitioning or text styling.
- *
- * @see ICharacterScanner
- */
-public interface IRule {
-
- /**
- * Evaluates the rule by examining the characters available from
- * the provided character scanner. The token returned by this rule
- * returns <code>true</code> when calling <code>isUndefined</code>,
- * if the text the rule investigated does not match the rule's requirements.
- *
- * @param scanner the character scanner to be used by this rule
- * @return the token computed by the rule
- */
- IToken evaluate(ICharacterScanner scanner);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IToken.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IToken.java
deleted file mode 100644
index ad02d81034c..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IToken.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.rules;
-
-
-/**
- * A token to be returned by a rule.
- */
-public interface IToken {
-
- /**
- * Return whether this token is undefined.
- *
- * @return <code>true</code>if this token is undefined
- */
- boolean isUndefined();
-
- /**
- * Return whether this token represents a whitespace.
- *
- * @return <code>true</code>if this token represents a whitespace
- */
- boolean isWhitespace();
-
- /**
- * Return whether this token represents End Of File.
- *
- * @return <code>true</code>if this token represents EOF
- */
- boolean isEOF();
-
- /**
- * Return whether this token is neither undefined, nor whitespace, nor EOF.
- *
- * @return <code>true</code>if this token is not undefined, not a whitespace, and not EOF
- */
- boolean isOther();
-
- /**
- * Return a data attacted to this token. The semantics of this data kept undefined by this interface.
- *
- * @return the data attached to this token.
- */
- Object getData();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/ITokenScanner.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/ITokenScanner.java
deleted file mode 100644
index 0dab8dfe19c..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/ITokenScanner.java
+++ /dev/null
@@ -1,58 +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.rules;
-
-
-import org.eclipse.jface.text.IDocument;
-
-
-/**
- * A token scanner scans a range of a document and reports about the token it finds.
- * A scanner has state. When asked, the scanner returns the offset and the length of the
- * last found token.
- *
- * @see org.eclipse.jface.text.rules.IToken
- * @since 2.0
- */
-public interface ITokenScanner {
-
- /**
- * Configures the scanner by providing access to the document range that should
- * be scanned.
- *
- * @param document the document to scan
- * @param offset the offset of the document range to scan
- * @param length the length of the document range to scan
- */
- void setRange(IDocument document, int offset, int length);
-
- /**
- * Returns the next token in the document.
- *
- * @return the next token in the document
- */
- IToken nextToken();
-
- /**
- * Returns the offset of the last token read by this scanner.
- *
- * @return the offset of the last token read by this scanner
- */
- int getTokenOffset();
-
- /**
- * Returns the length of the last token read by this scanner.
- *
- * @return the length of the last token read by this scanner
- */
- int getTokenLength();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IWhitespaceDetector.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IWhitespaceDetector.java
deleted file mode 100644
index 0719ea0ec0d..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IWhitespaceDetector.java
+++ /dev/null
@@ -1,27 +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.rules;
-
-
-/**
- * Defines the interface by which <code>WhitespaceRule</code>
- * determines whether a given character is to be considered
- * whitespace in the current context.
- */
-public interface IWhitespaceDetector {
-
- /**
- * Returns whether the specified character is whitespace.
- *
- * @param c the character to be checked
- */
- boolean isWhitespace(char c);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IWordDetector.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IWordDetector.java
deleted file mode 100644
index 5b7db6f9679..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IWordDetector.java
+++ /dev/null
@@ -1,38 +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.rules;
-
-
-/**
- * Defines the interface by which <code>WordRule</code>
- * determines whether a given character is valid as part
- * of a word in the current context.
- */
-public interface IWordDetector {
-
- /**
- * Returns whether the specified character is
- * valid as the first character in a word.
- *
- * @param c the character to be checked
- * @return <code>true</code> is a valid first character in a word, <code>false</code> otherwise
- */
- boolean isWordStart(char c);
-
- /**
- * Returns whether the specified character is
- * valid as a subsequent character in a word.
- *
- * @param c the character to be checked
- * @return <code>true</code> if the character is a valid word part, <code>false</code> otherwise
- */
- boolean isWordPart(char c);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/MultiLineRule.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/MultiLineRule.java
deleted file mode 100644
index 9f35df2d08a..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/MultiLineRule.java
+++ /dev/null
@@ -1,63 +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.rules;
-
-
-/**
- * A rule for detecting patterns which begin with a given
- * sequence and may end with a given sequence thereby spanning
- * multiple lines.
- */
-public class MultiLineRule extends PatternRule {
-
- /**
- * Creates a rule for the given starting and ending sequence
- * which, if detected, will return the specified token.
- *
- * @param startSequence the pattern's start sequence
- * @param endSequence the pattern's end sequence
- * @param token the token to be returned on success
- */
- public MultiLineRule(String startSequence, String endSequence, IToken token) {
- this(startSequence, endSequence, token, (char) 0);
- }
-
- /**
- * Creates a rule for the given starting and ending sequence
- * which, if detected, will return the specific token.
- * Any character which follows the given escape character will be ignored.
- *
- * @param startSequence the pattern's start sequence
- * @param endSequence the pattern's end sequence
- * @param token the token to be returned on success
- * @param escapeCharacter the escape character
- */
- public MultiLineRule(String startSequence, String endSequence, IToken token, char escapeCharacter) {
- this(startSequence, endSequence, token, escapeCharacter, false);
- }
-
- /**
- * Creates a rule for the given starting and ending sequence
- * which, if detected, will return the specific token. Any character that follows the
- * given escape character will be ignored. <code>breakOnEOF</code> indicates whether
- * EOF is equivalent to detecting the <code>endSequence</code>.
- *
- * @param startSequence the pattern's start sequence
- * @param endSequence the pattern's end sequence
- * @param token the token to be returned on success
- * @param escapeCharacter the escape character
- * @param breaksOnEOF indicates whether the end of the file terminates this rule successfully
- * @since 2.1
- */
- public MultiLineRule(String startSequence, String endSequence, IToken token, char escapeCharacter, boolean breaksOnEOF) {
- super(startSequence, endSequence, token, escapeCharacter, false, breaksOnEOF);
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/NumberRule.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/NumberRule.java
deleted file mode 100644
index 42fb5c9e40f..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/NumberRule.java
+++ /dev/null
@@ -1,72 +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.rules;
-
-import org.eclipse.jface.text.Assert;
-
-
-/**
- * An implementation of <code>IRule</code> capable of detecting a numerical value.
- */
-public class NumberRule implements IRule {
-
- /** Internal setting for the uninitialized column constraint */
- protected static final int UNDEFINED= -1;
- /** The token to be returned when this rule is successful */
- protected IToken fToken;
- /** The column constraint */
- protected int fColumn= UNDEFINED;
-
- /**
- * Creates a rule which will return the specified
- * token when a numerical sequence is detected.
- *
- * @param token the token to be returned
- */
- public NumberRule(IToken token) {
- Assert.isNotNull(token);
- fToken= token;
- }
-
- /**
- * Sets a column constraint for this rule. If set, the rule's token
- * will only be returned if the pattern is detected starting at the
- * specified column. If the column is smaller then 0, the column
- * constraint is considered removed.
- *
- * @param column the column in which the pattern starts
- */
- public void setColumnConstraint(int column) {
- if (column < 0)
- column= UNDEFINED;
- fColumn= column;
- }
-
- /*
- * @see IRule#evaluate(ICharacterScanner)
- */
- public IToken evaluate(ICharacterScanner scanner) {
- int c= scanner.read();
- if (Character.isDigit((char)c)) {
- if (fColumn == UNDEFINED || (fColumn == scanner.getColumn() - 1)) {
- do {
- c= scanner.read();
- } while (Character.isDigit((char) c));
- scanner.unread();
- return fToken;
- }
- }
-
- scanner.unread();
- return Token.UNDEFINED;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/PatternRule.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/PatternRule.java
deleted file mode 100644
index 2b451d29dec..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/PatternRule.java
+++ /dev/null
@@ -1,239 +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.rules;
-
-import org.eclipse.jface.text.Assert;
-
-
-
-
-/**
- * Standard implementation of <code>IPredicateRule</code>.
- * Is is capable of detecting a pattern which begins with a given start
- * sequence and ends with a given end sequence. If the end sequence is
- * not specified, it can be either end of line, end or file, or both. Additionally,
- * the pattern can be constrained to begin in a certain column. The rule can also
- * be used to check whether the text to scan covers half of the pattern, i.e. contains
- * the end sequence required by the rule.
- */
-public class PatternRule implements IPredicateRule {
-
- /** Internal setting for the uninitialized column constraint */
- protected static final int UNDEFINED= -1;
-
- /** The token to be returned on success */
- protected IToken fToken;
- /** The pattern's start sequence */
- protected char[] fStartSequence;
- /** The pattern's end sequence */
- protected char[] fEndSequence;
- /** The pattern's column constrain */
- protected int fColumn= UNDEFINED;
- /** The pattern's escape character */
- protected char fEscapeCharacter;
- /** Indicates whether end of line terminates the pattern */
- protected boolean fBreaksOnEOL;
- /** Indicates whether end of file terminates the pattern */
- protected boolean fBreaksOnEOF;
-
- /**
- * Creates a rule for the given starting and ending sequence.
- * When these sequences are detected the rule will return the specified token.
- * Alternatively, the sequence can also be ended by the end of the line.
- * Any character which follows the given escapeCharacter will be ignored.
- *
- * @param startSequence the pattern's start sequence
- * @param endSequence the pattern's end sequence, <code>null</code> is a legal value
- * @param token the token which will be returned on success
- * @param escapeCharacter any character following this one will be ignored
- * @param breaksOnEOL indicates whether the end of the line also terminates the pattern
- */
- public PatternRule(String startSequence, String endSequence, IToken token, char escapeCharacter, boolean breaksOnEOL) {
- Assert.isTrue(startSequence != null && startSequence.length() > 0);
- Assert.isTrue(endSequence != null || breaksOnEOL);
- Assert.isNotNull(token);
-
- fStartSequence= startSequence.toCharArray();
- fEndSequence= (endSequence == null ? new char[0] : endSequence.toCharArray());
- fToken= token;
- fEscapeCharacter= escapeCharacter;
- fBreaksOnEOL= breaksOnEOL;
- }
-
- /**
- * Creates a rule for the given starting and ending sequence.
- * When these sequences are detected the rule will return the specified token.
- * Alternatively, the sequence can also be ended by the end of the line or the end of the file.
- * Any character which follows the given escapeCharacter will be ignored.
- *
- * @param startSequence the pattern's start sequence
- * @param endSequence the pattern's end sequence, <code>null</code> is a legal value
- * @param token the token which will be returned on success
- * @param escapeCharacter any character following this one will be ignored
- * @param breaksOnEOL indicates whether the end of the line also terminates the pattern
- * @param breaksOnEOF indicates whether the end of the file also terminates the pattern
- * @since 2.1
- */
- public PatternRule(String startSequence, String endSequence, IToken token, char escapeCharacter, boolean breaksOnEOL, boolean breaksOnEOF) {
- this(startSequence, endSequence, token, escapeCharacter, breaksOnEOL);
- fBreaksOnEOF= breaksOnEOF;
- }
-
- /**
- * Sets a column constraint for this rule. If set, the rule's token
- * will only be returned if the pattern is detected starting at the
- * specified column. If the column is smaller then 0, the column
- * constraint is considered removed.
- *
- * @param column the column in which the pattern starts
- */
- public void setColumnConstraint(int column) {
- if (column < 0)
- column= UNDEFINED;
- fColumn= column;
- }
-
-
- /**
- * Evaluates this rules without considering any column constraints.
- *
- * @param scanner the character scanner to be used
- * @return the token resulting from this evaluation
- */
- protected IToken doEvaluate(ICharacterScanner scanner) {
- return doEvaluate(scanner, false);
- }
-
- /**
- * Evaluates this rules without considering any column constraints. Resumes
- * detection, i.e. look sonly for the end sequence required by this rule if the
- * <code>resume</code> flag is set.
- *
- * @param scanner the character scanner to be used
- * @param resume <code>true</code> if detection should be resumed, <code>false</code> otherwise
- * @return the token resulting from this evaluation
- * @since 2.0
- */
- protected IToken doEvaluate(ICharacterScanner scanner, boolean resume) {
-
- if (resume) {
-
- if (endSequenceDetected(scanner))
- return fToken;
-
- } else {
-
- int c= scanner.read();
- if (c == fStartSequence[0]) {
- if (sequenceDetected(scanner, fStartSequence, false)) {
- if (endSequenceDetected(scanner))
- return fToken;
- }
- }
- }
-
- scanner.unread();
- return Token.UNDEFINED;
- }
-
- /*
- * @see IRule#evaluate(ICharacterScanner)
- */
- public IToken evaluate(ICharacterScanner scanner) {
- return evaluate(scanner, false);
- }
-
- /**
- * Returns whether the end sequence was detected. As the pattern can be considered
- * ended by a line delimiter, the result of this method is <code>true</code> if the
- * rule breaks on the end of the line, or if the EOF character is read.
- *
- * @param scanner the character scanner to be used
- * @return <code>true</code> if the end sequence has been detected
- */
- protected boolean endSequenceDetected(ICharacterScanner scanner) {
- int c;
- char[][] delimiters= scanner.getLegalLineDelimiters();
- while ((c= scanner.read()) != ICharacterScanner.EOF) {
- if (c == fEscapeCharacter) {
- // Skip the escaped character.
- scanner.read();
- } else if (fEndSequence.length > 0 && c == fEndSequence[0]) {
- // Check if the specified end sequence has been found.
- if (sequenceDetected(scanner, fEndSequence, true))
- return true;
- } else if (fBreaksOnEOL) {
- // Check for end of line since it can be used to terminate the pattern.
- for (int i= 0; i < delimiters.length; i++) {
- if (c == delimiters[i][0] && sequenceDetected(scanner, delimiters[i], true))
- return true;
- }
- }
- }
- if (fBreaksOnEOF) return true;
- scanner.unread();
- return false;
- }
-
- /**
- * Returns whether the next characters to be read by the character scanner
- * are an exact match with the given sequence. No escape characters are allowed
- * within the sequence. If specified the sequence is considered to be found
- * when reading the EOF character.
- *
- * @param scanner the character scanner to be used
- * @param sequence the sequence to be detected
- * @param eofAllowed indicated whether EOF terminates the pattern
- * @return <code>true</code> if the given sequence has been detected
- */
- protected boolean sequenceDetected(ICharacterScanner scanner, char[] sequence, boolean eofAllowed) {
- for (int i= 1; i < sequence.length; i++) {
- int c= scanner.read();
- if (c == ICharacterScanner.EOF && eofAllowed) {
- return true;
- } else if (c != sequence[i]) {
- // Non-matching character detected, rewind the scanner back to the start.
- // Do not unread the first character.
- scanner.unread();
- for (int j= i-1; j > 0; j--)
- scanner.unread();
- return false;
- }
- }
-
- return true;
- }
-
- /*
- * @see IPredicateRule#evaluate(ICharacterScanner, boolean)
- * @since 2.0
- */
- public IToken evaluate(ICharacterScanner scanner, boolean resume) {
- if (fColumn == UNDEFINED)
- return doEvaluate(scanner, resume);
-
- int c= scanner.read();
- scanner.unread();
- if (c == fStartSequence[0])
- return (fColumn == scanner.getColumn() ? doEvaluate(scanner, resume) : Token.UNDEFINED);
- else
- return Token.UNDEFINED;
- }
-
- /*
- * @see IPredicateRule#getSuccessToken()
- * @since 2.0
- */
- public IToken getSuccessToken() {
- return fToken;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedDamagerRepairer.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedDamagerRepairer.java
deleted file mode 100644
index 84f73ba8c3a..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedDamagerRepairer.java
+++ /dev/null
@@ -1,49 +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.rules;
-
-
-import org.eclipse.jface.text.TextAttribute;
-
-
-/**
- * @deprecated use <code>DefaultDamagerRepairer</code>
- */
-public class RuleBasedDamagerRepairer extends DefaultDamagerRepairer {
-
- /**
- * Creates a damager/repairer that uses the given scanner and returns the given default
- * text attribute if the current token does not carry a text attribute.
- *
- * @param scanner the rule based scanner to be used
- * @param defaultTextAttribute the text attribute to be returned if non is specified by the current token,
- * may not be <code>null</code>
- *
- * @deprecated use RuleBasedDamagerRepairer(RuleBasedScanner) instead
- */
- public RuleBasedDamagerRepairer(RuleBasedScanner scanner, TextAttribute defaultTextAttribute) {
- super(scanner, defaultTextAttribute);
- }
-
- /**
- * Creates a damager/repairer that uses the given scanner. The scanner may not be <code>null</code>
- * and is assumed to return only token that carry text attributes.
- *
- * @param scanner the rule based scanner to be used, may not be <code>null</code>
- * @since 2.0
- */
- public RuleBasedDamagerRepairer(RuleBasedScanner scanner) {
- super(scanner);
- }
-}
-
-
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedPartitionScanner.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedPartitionScanner.java
deleted file mode 100644
index 5ce40bc58a1..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedPartitionScanner.java
+++ /dev/null
@@ -1,106 +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.rules;
-
-
-import org.eclipse.jface.text.IDocument;
-
-
-/**
- * Scanner that exclusively uses predicate rules.
- * @since 2.0
- */
-public class RuleBasedPartitionScanner extends BufferedRuleBasedScanner implements IPartitionTokenScanner {
-
- /** The content type of the partition in which to resume scanning. */
- protected String fContentType;
- /** The offset of the partition inside which to resume. */
- protected int fPartitionOffset;
-
-
- /*
- * @see RuleBasedScanner#setRules(IRule[])
- */
- public void setRules(IRule[] rules) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * @see RuleBasedScanner#setRules(IRule[])
- */
- public void setPredicateRules(IPredicateRule[] rules) {
- super.setRules(rules);
- }
-
- /*
- * @see ITokenScanner#setRange(IDocument, int, int)
- */
- public void setRange(IDocument document, int offset, int length) {
- setPartialRange(document, offset, length, null, -1);
- }
-
- /*
- * @see IPartitionTokenScanner#setPartialRange(IDocument, int, int, String, int)
- */
- public void setPartialRange(IDocument document, int offset, int length, String contentType, int partitionOffset) {
- fContentType= contentType;
- fPartitionOffset= partitionOffset;
- if (partitionOffset > -1) {
- int delta= offset - partitionOffset;
- if (delta > 0) {
- super.setRange(document, partitionOffset, length + delta);
- fOffset= offset;
- return;
- }
- }
- super.setRange(document, offset, length);
- }
-
- /*
- * @see ITokenScanner#nextToken()
- */
- public IToken nextToken() {
-
-
- if (fContentType == null || fRules == null) {
- //don't try to resume
- return super.nextToken();
- }
-
- // inside a partition
-
- fColumn= UNDEFINED;
- boolean resume= (fPartitionOffset > -1 && fPartitionOffset < fOffset);
- fTokenOffset= resume ? fPartitionOffset : fOffset;
-
- IPredicateRule rule;
- IToken token;
-
- for (int i= 0; i < fRules.length; i++) {
- rule= (IPredicateRule) fRules[i];
- token= rule.getSuccessToken();
- if (fContentType.equals(token.getData())) {
- token= rule.evaluate(this, resume);
- if (!token.isUndefined()) {
- fContentType= null;
- return token;
- }
- }
- }
-
- // haven't found any rule for this type of partition
- fContentType= null;
- if (resume)
- fOffset= fPartitionOffset;
- return super.nextToken();
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedPartitioner.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedPartitioner.java
deleted file mode 100644
index 707a67f95de..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedPartitioner.java
+++ /dev/null
@@ -1,551 +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.rules;
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.DefaultPositionUpdater;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.jface.text.IDocumentPartitionerExtension;
-import org.eclipse.jface.text.IDocumentPartitionerExtension2;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TypedPosition;
-import org.eclipse.jface.text.TypedRegion;
-
-
-
-/**
- * A standard implementation of a syntax driven document partitioner.
- * It uses a rule based scanner to scan the document and to determine
- * the document's partitioning. The tokens returned by the rules the
- * scanner is configured with are supposed to return the partition type
- * as their data. The partitioner remembers the document's partitions
- * in the document itself rather than maintaining its own data structure.
- *
- * @see IRule
- * @see RuleBasedScanner
- *
- * @deprecated use <code>DefaultPartitioner</code> instead
- */
-public class RuleBasedPartitioner implements IDocumentPartitioner, IDocumentPartitionerExtension, IDocumentPartitionerExtension2 {
-
- /**
- * The position category this partitioner uses to store the document's partitioning information
- * @deprecated use <code>getManagingPositionCategories()</code>.
- */
- public final static String CONTENT_TYPES_CATEGORY= "__content_types_category"; //$NON-NLS-1$
-
-
- /** The partitioner's scanner */
- protected RuleBasedScanner fScanner;
- /** The legal content types of this partitioner */
- protected String[] fLegalContentTypes;
- /** The partitioner's document */
- protected IDocument fDocument;
- /** The document length before a document change occured */
- protected int fPreviousDocumentLength;
- /** The position updater used to for the default updating of partitions */
- protected DefaultPositionUpdater fPositionUpdater;
- /** The offset at which the first changed partition starts */
- protected int fStartOffset;
- /** The offset at which the last changed partition ends */
- protected int fEndOffset;
- /**The offset at which a partition has been deleted */
- protected int fDeleteOffset;
- /**
- * The position category for managing partitoning information.
- * @since 3.0
- */
- private String fPositionCategory;
-
-
- /**
- * Creates a new partitioner that uses the given scanner and may return
- * partitions of the given legal content types.
- *
- * @param scanner the scanner this partitioner is supposed to use
- * @param legalContentTypes the legal content types of this partitioner
- */
- public RuleBasedPartitioner(RuleBasedScanner scanner, String[] legalContentTypes) {
- fScanner= scanner;
- fLegalContentTypes= legalContentTypes;
- fPositionCategory= CONTENT_TYPES_CATEGORY + hashCode();
- fPositionUpdater= new DefaultPositionUpdater(fPositionCategory);
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentPartitionerExtension2#getManagingPositionCategories()
- * @since 3.0
- */
- public String[] getManagingPositionCategories() {
- return new String[] { fPositionCategory };
- }
-
- /*
- * @see IDocumentPartitioner#connect
- */
- public void connect(IDocument document) {
- Assert.isNotNull(document);
- Assert.isTrue(!document.containsPositionCategory(fPositionCategory));
-
- fDocument= document;
- fDocument.addPositionCategory(fPositionCategory);
-
- initialize();
- }
-
- /**
- * Performs the initial partitioning of the partitioner's document.
- */
- protected void initialize() {
-
- fScanner.setRange(fDocument, 0, fDocument.getLength());
-
- try {
- IToken token= fScanner.nextToken();
- while (!token.isEOF()) {
-
- String contentType= getTokenContentType(token);
-
- if (isSupportedContentType(contentType)) {
- TypedPosition p= new TypedPosition(fScanner.getTokenOffset(), fScanner.getTokenLength(), contentType);
- fDocument.addPosition(fPositionCategory, p);
- }
-
- token= fScanner.nextToken();
- }
- } catch (BadLocationException x) {
- // cannot happen as offsets come from scanner
- } catch (BadPositionCategoryException x) {
- // cannot happen if document has been connected before
- }
- }
-
- /*
- * @see IDocumentPartitioner#disconnect
- */
- public void disconnect() {
-
- Assert.isTrue(fDocument.containsPositionCategory(fPositionCategory));
-
- try {
- fDocument.removePositionCategory(fPositionCategory);
- } catch (BadPositionCategoryException x) {
- // can not happen because of Assert
- }
- }
-
- /*
- * @see IDocumentPartitioner#documentAboutToBeChanged
- */
- public void documentAboutToBeChanged(DocumentEvent e) {
-
- Assert.isTrue(e.getDocument() == fDocument);
-
- fPreviousDocumentLength= e.getDocument().getLength();
- fStartOffset= -1;
- fEndOffset= -1;
- fDeleteOffset= -1;
- }
-
- /*
- * @see IDocumentPartitioner#documentChanged
- */
- public boolean documentChanged(DocumentEvent e) {
- IRegion region= documentChanged2(e);
- return (region != null);
- }
-
- /**
- * Helper method for tracking the minimal region containg all partition changes.
- * If <code>offset</code> is smaller than the remembered offset, <code>offset</code>
- * will from now on be remembered. If <code>offset + length</code> is greater than
- * the remembered end offset, it will be remembered from now on.
- *
- * @param offset the offset
- * @param length the length
- */
- private void rememberRegion(int offset, int length) {
- // remember start offset
- if (fStartOffset == -1)
- fStartOffset= offset;
- else if (offset < fStartOffset)
- fStartOffset= offset;
-
- // remember end offset
- int endOffset= offset + length;
- if (fEndOffset == -1)
- fEndOffset= endOffset;
- else if (endOffset > fEndOffset)
- fEndOffset= endOffset;
- }
-
- /**
- * Remembers the given offset as the deletion offset.
- *
- * @param offset the offset
- */
- private void rememberDeletedOffset(int offset) {
- fDeleteOffset= offset;
- }
-
- /**
- * Creates the minimal region containing all partition changes using the
- * remembered offset, end offset, and deletion offset.
- * @return the minimal region containing all the partition changes
- */
- private IRegion createRegion() {
- if (fDeleteOffset == -1) {
- if (fStartOffset == -1 || fEndOffset == -1)
- return null;
- return new Region(fStartOffset, fEndOffset - fStartOffset);
- } else if (fStartOffset == -1 || fEndOffset == -1) {
- return new Region(fDeleteOffset, 0);
- } else {
- int offset= Math.min(fDeleteOffset, fStartOffset);
- int endOffset= Math.max(fDeleteOffset, fEndOffset);
- return new Region(offset, endOffset - offset);
- }
- }
-
- /*
- * @see IDocumentPartitionerExtension#documentChanged2(DocumentEvent)
- * @since 2.0
- */
- public IRegion documentChanged2(DocumentEvent e) {
-
- try {
-
- IDocument d= e.getDocument();
- Position[] category= d.getPositions(fPositionCategory);
- int first= 0;
- int reparseStart= 0;
- int originalSize= category.length;
-
- if (originalSize > 0) {
-
- /*
- * determine character position at which the scanner starts:
- * first position behind the last non-default partition the actual position is not involved with
- */
-
- first= d.computeIndexInCategory(fPositionCategory, e.getOffset());
-
- Position p= null;
- do {
- --first;
- if (first < 0)
- break;
-
- p= category[first];
-
- } while (p.overlapsWith(e.getOffset(), e.getLength()) ||
- (e.getOffset() == fPreviousDocumentLength &&
- (p.getOffset() + p.getLength() == fPreviousDocumentLength)));
-
- fPositionUpdater.update(e);
- for (int i= 0; i < category.length; i++) {
- p= category[i];
- if (p.isDeleted) {
- rememberDeletedOffset(e.getOffset());
- break;
- }
- }
- category= d.getPositions(fPositionCategory);
-
- if (first >= 0) {
- p= category[first];
- reparseStart= p.getOffset() + p.getLength();
- }
-
- ++first;
- }
-
- fScanner.setRange(d, reparseStart, d.getLength() - reparseStart);
-
- int lastScannedPosition= reparseStart;
- IToken token= fScanner.nextToken();
-
- while (!token.isEOF()) {
-
-
- String contentType= getTokenContentType(token);
-
- if (!isSupportedContentType(contentType)) {
- token= fScanner.nextToken();
- continue;
- }
-
- int start= fScanner.getTokenOffset();
- int length= fScanner.getTokenLength();
-
- lastScannedPosition= start + length - 1;
-
- // remove all affected positions
- while (first < category.length) {
- TypedPosition p= (TypedPosition) category[first];
- if (lastScannedPosition >= p.offset + p.length ||
- (p.overlapsWith(start, length) &&
- (!d.containsPosition(fPositionCategory, start, length) ||
- !contentType.equals(p.getType())))) {
-
- rememberRegion(p.offset, p.length);
- d.removePosition(fPositionCategory, p);
- ++ first;
-
- } else
- break;
- }
-
- // if position already exists we are done
- if (d.containsPosition(fPositionCategory, start, length))
- return createRegion();
-
- // insert the new type position
- try {
- d.addPosition(fPositionCategory, new TypedPosition(start, length, contentType));
- rememberRegion(start, length);
- } catch (BadPositionCategoryException x) {
- } catch (BadLocationException x) {
- }
-
- token= fScanner.nextToken();
- }
-
-
- // remove all positions behind lastScannedPosition since there aren't any further types
- if (lastScannedPosition != reparseStart) {
- // if this condition is not met, nothing has been scanned because of a delete
- ++ lastScannedPosition;
- }
- first= d.computeIndexInCategory(fPositionCategory, lastScannedPosition);
-
- TypedPosition p;
- while (first < category.length) {
- p= (TypedPosition) category[first++];
- d.removePosition(fPositionCategory, p);
- rememberRegion(p.offset, p.length);
- }
-
- } catch (BadPositionCategoryException x) {
- // should never happen on connected documents
- } catch (BadLocationException x) {
- }
-
- return createRegion();
- }
-
-
- /**
- * Returns the position in the partitoner's position category which is
- * close to the given offset. This is, the position has either an offset which
- * is the same as the given offset or an offset which is smaller than the given
- * offset. This method profits from the knowledge that a partitioning is
- * a ordered set of disjoint position.
- *
- * @param offset the offset for which to search the closest position
- * @return the closest position in the partitioner's category
- */
- protected TypedPosition findClosestPosition(int offset) {
-
- try {
-
- int index= fDocument.computeIndexInCategory(fPositionCategory, offset);
- Position[] category= fDocument.getPositions(fPositionCategory);
-
- if (category.length == 0)
- return null;
-
- if (index < category.length) {
- if (offset == category[index].offset)
- return (TypedPosition) category[index];
- }
-
- if (index > 0)
- index--;
-
- return (TypedPosition) category[index];
-
- } catch (BadPositionCategoryException x) {
- } catch (BadLocationException x) {
- }
-
- return null;
- }
-
-
- /*
- * @see IDocumentPartitioner#getContentType
- */
- public String getContentType(int offset) {
-
- TypedPosition p= findClosestPosition(offset);
- if (p != null && p.includes(offset))
- return p.getType();
-
- return IDocument.DEFAULT_CONTENT_TYPE;
- }
-
- /*
- * @see IDocumentPartitioner#getPartition
- */
- public ITypedRegion getPartition(int offset) {
-
- try {
-
- Position[] category = fDocument.getPositions(fPositionCategory);
-
- if (category == null || category.length == 0)
- return new TypedRegion(0, fDocument.getLength(), IDocument.DEFAULT_CONTENT_TYPE);
-
- int index= fDocument.computeIndexInCategory(fPositionCategory, offset);
-
- if (index < category.length) {
-
- TypedPosition next= (TypedPosition) category[index];
-
- if (offset == next.offset)
- return new TypedRegion(next.getOffset(), next.getLength(), next.getType());
-
- if (index == 0)
- return new TypedRegion(0, next.offset, IDocument.DEFAULT_CONTENT_TYPE);
-
- TypedPosition previous= (TypedPosition) category[index - 1];
- if (previous.includes(offset))
- return new TypedRegion(previous.getOffset(), previous.getLength(), previous.getType());
-
- int endOffset= previous.getOffset() + previous.getLength();
- return new TypedRegion(endOffset, next.getOffset() - endOffset, IDocument.DEFAULT_CONTENT_TYPE);
- }
-
- TypedPosition previous= (TypedPosition) category[category.length - 1];
- if (previous.includes(offset))
- return new TypedRegion(previous.getOffset(), previous.getLength(), previous.getType());
-
- int endOffset= previous.getOffset() + previous.getLength();
- return new TypedRegion(endOffset, fDocument.getLength() - endOffset, IDocument.DEFAULT_CONTENT_TYPE);
-
- } catch (BadPositionCategoryException x) {
- } catch (BadLocationException x) {
- }
-
- return new TypedRegion(0, fDocument.getLength(), IDocument.DEFAULT_CONTENT_TYPE);
- }
-
- /*
- * @see IDocumentPartitioner#computePartitioning
- */
- public ITypedRegion[] computePartitioning(int offset, int length) {
-
- List list= new ArrayList();
-
- try {
-
- int endOffset= offset + length;
-
- Position[] category= fDocument.getPositions(fPositionCategory);
-
- TypedPosition previous= null, current= null;
- int start, end, gapOffset;
- Position gap= null;
-
- for (int i= 0; i < category.length; i++) {
-
- current= (TypedPosition) category[i];
-
- gapOffset= (previous != null) ? previous.getOffset() + previous.getLength() : 0;
- gap= new Position(gapOffset, current.getOffset() - gapOffset);
- if (gap.getLength() > 0 && gap.overlapsWith(offset, length)) {
- start= Math.max(offset, gapOffset);
- end= Math.min(endOffset, gap.getOffset() + gap.getLength());
- list.add(new TypedRegion(start, end - start, IDocument.DEFAULT_CONTENT_TYPE));
- }
-
- if (current.overlapsWith(offset, length)) {
- start= Math.max(offset, current.getOffset());
- end= Math.min(endOffset, current.getOffset() + current.getLength());
- list.add(new TypedRegion(start, end - start, current.getType()));
- }
-
- previous= current;
- }
-
- if (previous != null) {
- gapOffset= previous.getOffset() + previous.getLength();
- gap= new Position(gapOffset, fDocument.getLength() - gapOffset);
- if (gap.getLength() > 0 && gap.overlapsWith(offset, length)) {
- start= Math.max(offset, gapOffset);
- end= Math.min(endOffset, fDocument.getLength());
- list.add(new TypedRegion(start, end - start, IDocument.DEFAULT_CONTENT_TYPE));
- }
- }
-
- if (list.isEmpty())
- list.add(new TypedRegion(offset, length, IDocument.DEFAULT_CONTENT_TYPE));
-
- } catch (BadPositionCategoryException x) {
- }
-
- TypedRegion[] result= new TypedRegion[list.size()];
- list.toArray(result);
- return result;
- }
-
- /*
- * @see IDocumentPartitioner#getLegalContentTypes
- */
- public String[] getLegalContentTypes() {
- return fLegalContentTypes;
- }
-
- /**
- * Returns whether the given type is one of the legal content types.
- *
- * @param contentType the content type to check
- * @return <code>true</code> if the content type is a legal content type
- */
- protected boolean isSupportedContentType(String contentType) {
- if (contentType != null) {
- for (int i= 0; i < fLegalContentTypes.length; i++) {
- if (fLegalContentTypes[i].equals(contentType))
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Returns a content type encoded in the given token. If the token's
- * data is not <code>null</code> and a string it is assumed that
- * it is the encoded content type.
- *
- * @param token the token whose content type is to be determined
- * @return the token's content type
- */
- protected String getTokenContentType(IToken token) {
- Object data= token.getData();
- if (data instanceof String)
- return (String) data;
- return null;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedScanner.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedScanner.java
deleted file mode 100644
index c477452ecf6..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedScanner.java
+++ /dev/null
@@ -1,196 +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.rules;
-
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-
-
-/**
- * A generic scanner which can be "programmed" with a sequence of rules.
- * The scanner is used to get the next token by evaluating its rule in sequence until
- * one is successful. If a rule returns a token which is undefined, the scanner will proceed to
- * the next rule. Otherwise the token provided by the rule will be returned by
- * the scanner. If no rule returned a defined token, this scanner returns a token
- * which returns <code>true</code> when calling <code>isOther</code>, unless the end
- * of the file is reached. In this case the token returns <code>true</code> when calling
- * <code>isEOF</code>.
- *
- * @see IRule
- */
-public class RuleBasedScanner implements ICharacterScanner, ITokenScanner {
-
- /** The list of rules of this scanner */
- protected IRule[] fRules;
- /** The token to be returned by default if no rule fires */
- protected IToken fDefaultReturnToken;
- /** The document to be scanned */
- protected IDocument fDocument;
- /** The cached legal line delimiters of the document */
- protected char[][] fDelimiters;
- /** The offset of the next character to be read */
- protected int fOffset;
- /** The end offset of the range to be scanned */
- protected int fRangeEnd;
- /** The offset of the last read token */
- protected int fTokenOffset;
- /** The cached column of the current scanner position */
- protected int fColumn;
- /** Internal setting for the uninitialized column cache. */
- protected static final int UNDEFINED= -1;
-
- /**
- * Creates a new rule based scanner which does not have any rule.
- */
- public RuleBasedScanner() {
- }
-
- /**
- * Configures the scanner with the given sequence of rules.
- *
- * @param rules the sequence of rules controlling this scanner
- */
- public void setRules(IRule[] rules) {
- fRules= rules;
- }
-
- /**
- * Configures the scanner's default return token. This is the token
- * which is returned when non of the rules fired and EOF has not been
- * reached.
- *
- * @param token the default return token
- * @since 2.0
- */
- public void setDefaultReturnToken(IToken defaultReturnToken) {
- Assert.isNotNull(defaultReturnToken.getData());
- fDefaultReturnToken= defaultReturnToken;
- }
-
- /*
- * @see ITokenScanner#setRange(IDocument, int, int)
- */
- public void setRange(IDocument document, int offset, int length) {
-
- fDocument= document;
- fOffset= offset;
- fRangeEnd= Math.min(fDocument.getLength(), offset + length);
-
- String[] delimiters= fDocument.getLegalLineDelimiters();
- fDelimiters= new char[delimiters.length][];
- for (int i= 0; i < delimiters.length; i++)
- fDelimiters[i]= delimiters[i].toCharArray();
-
- if (fDefaultReturnToken == null)
- fDefaultReturnToken= new Token(null);
- }
-
- /*
- * @see ITokenScanner#getTokenOffset()
- */
- public int getTokenOffset() {
- return fTokenOffset;
- }
-
- /*
- * @see ITokenScanner#getTokenLength()
- */
- public int getTokenLength() {
- if (fOffset < fRangeEnd)
- return fOffset - getTokenOffset();
- return fRangeEnd - getTokenOffset();
- }
-
-
- /*
- * @see ICharacterScanner#getColumn()
- */
- public int getColumn() {
- if (fColumn == UNDEFINED) {
- try {
- int line= fDocument.getLineOfOffset(fOffset);
- int start= fDocument.getLineOffset(line);
-
- fColumn= fOffset - start;
-
- } catch (BadLocationException ex) {
- }
- }
- return fColumn;
- }
-
- /*
- * @see ICharacterScanner#getLegalLineDelimiters()
- */
- public char[][] getLegalLineDelimiters() {
- return fDelimiters;
- }
-
- /*
- * @see ITokenScanner#nextToken()
- */
- public IToken nextToken() {
-
- IToken token;
-
- while (true) {
-
- fTokenOffset= fOffset;
- fColumn= UNDEFINED;
-
- if (fRules != null) {
- for (int i= 0; i < fRules.length; i++) {
- token= (fRules[i].evaluate(this));
- if (!token.isUndefined())
- return token;
- }
- }
-
- if (read() == EOF)
- return Token.EOF;
- else
- return fDefaultReturnToken;
- }
- }
-
- /*
- * @see ICharacterScanner#read()
- */
- public int read() {
-
- try {
-
- if (fOffset < fRangeEnd) {
- try {
- return fDocument.getChar(fOffset);
- } catch (BadLocationException e) {
- }
- }
-
- return EOF;
-
- } finally {
- ++ fOffset;
- }
- }
-
- /*
- * @see ICharacterScanner#unread()
- */
- public void unread() {
- --fOffset;
- }
-}
-
-
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/SingleLineRule.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/SingleLineRule.java
deleted file mode 100644
index 4d5bc14e55d..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/SingleLineRule.java
+++ /dev/null
@@ -1,65 +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.rules;
-
-
-/**
- * A specific configuration of pattern rule whereby
- * the pattern begins with a specific sequence and may
- * end with a specific sequence, but will not span more
- * than a single line.
- */
-public class SingleLineRule extends PatternRule {
-
- /**
- * Creates a rule for the given starting and ending sequence
- * which, if detected, will return the specified token.
- *
- * @param startSequence the pattern's start sequence
- * @param token the token to be returned on success
- */
- public SingleLineRule(String startSequence, String endSequence, IToken token) {
- this(startSequence, endSequence, token, (char) 0);
- }
-
- /**
- * Creates a rule for the given starting and ending sequence
- * which, if detected, will return the specified token.
- * Any character which follows the given escape character
- * will be ignored.
- *
- * @param startSequence the pattern's start sequence
- * @param endSequence the pattern's end sequence
- * @param token the token to be returned on success
- * @param escapeCharacter the escape character
- */
- public SingleLineRule(String startSequence, String endSequence, IToken token, char escapeCharacter) {
- this(startSequence, endSequence, token, escapeCharacter, false);
- }
-
- /**
- * Creates a rule for the given starting and ending sequence
- * which, if detected, will return the specified token. Alternatively, the
- * line can also be ended with the end of the file.
- * Any character which follows the given escape character
- * will be ignored.
- *
- * @param startSequence the pattern's start sequence
- * @param endSequence the pattern's end sequence
- * @param token the token to be returned on success
- * @param escapeCharacter the escape character
- * @param breaksOnEOF indicates whether the end of the file successfully terminates this rule
- * @since 2.1
- */
- public SingleLineRule(String startSequence, String endSequence, IToken token, char escapeCharacter, boolean breaksOnEOF) {
- super(startSequence, endSequence, token, escapeCharacter, true, breaksOnEOF);
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/Token.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/Token.java
deleted file mode 100644
index 1fd18cf65dd..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/Token.java
+++ /dev/null
@@ -1,125 +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.rules;
-
-import org.eclipse.jface.text.Assert;
-
-
-/**
- * Standard implementation of <code>IToken</code>.
- */
-public class Token implements IToken {
-
- /** Internal token type: Undefined */
- private static final int T_UNDEFINED= 0;
- /** Internal token type: EOF */
- private static final int T_EOF= 1;
- /** Internal token type: Whitespace */
- private static final int T_WHITESPACE= 2;
- /** Internal token type: Others */
- private static final int T_OTHER= 3;
-
-
- /**
- * Standard token: Undefined.
- */
- public static final IToken UNDEFINED= new Token(T_UNDEFINED);
- /**
- * Standard token: End Of File.
- */
- public static final IToken EOF= new Token(T_EOF);
- /**
- * Standard token: Whitespace.
- */
- public static final IToken WHITESPACE= new Token(T_WHITESPACE);
-
- /**
- * Standard token: Neither Undefine, Whitespace, nor End Of File.
- * @deprecated will be removed
- */
- public static final IToken OTHER= new Token(T_OTHER);
-
- /** The type of this token */
- private int fType;
- /** The data associated with this token */
- private Object fData;
-
- /**
- * Creates a new token according to the given specification which does not
- * have any data attached to it.
- *
- * @param type the type of the token
- * @since 2.0
- */
- private Token(int type) {
- fType= type;
- fData= null;
- }
-
- /**
- * Creates a new token which represents neither undefined, whitespace, nor EOF.
- * The newly created token has the given data attached to it.
- *
- * @param data the data attached to the newly created token
- */
- public Token(Object data) {
- fType= T_OTHER;
- fData= data;
- }
-
- /**
- * Reinitializes the data of this token. The token may not represent
- * undefined, whitepsace, or EOF.
- *
- * @param the data to be attached to the token
- * @since 2.0
- */
- public void setData(Object data) {
- Assert.isTrue(isOther());
- fData= data;
- }
-
- /*
- * @see IToken#getData()
- */
- public Object getData() {
- return fData;
- }
-
- /*
- * @see IToken#isOther()
- */
- public boolean isOther() {
- return (fType == T_OTHER);
- }
-
- /*
- * @see IToken#isEOF()
- */
- public boolean isEOF() {
- return (fType == T_EOF);
- }
-
- /*
- * @see IToken#isWhitespace()
- */
- public boolean isWhitespace() {
- return (fType == T_WHITESPACE);
- }
-
- /*
- * @see IToken#isUndefined()
- */
- public boolean isUndefined() {
- return (fType == T_UNDEFINED);
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/WhitespaceRule.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/WhitespaceRule.java
deleted file mode 100644
index 7fc02d353b6..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/WhitespaceRule.java
+++ /dev/null
@@ -1,58 +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.rules;
-
-
-import org.eclipse.jface.text.Assert;
-
-
-/**
- * An implementation of <code>IRule</code> capable of detecting whitespace.
- * A whitespace rule uses a whitespace detector in order to find out which
- * characters are whitespace characters.
- *
- * @see IWhitespaceDetector
- */
-public class WhitespaceRule implements IRule {
-
- /** The whitespace detector used by this rule */
- protected IWhitespaceDetector fDetector;
-
- /**
- * Creates a rule which, with the help of an
- * whitespace detector, will return a whitespace
- * token when a whitespace is detected.
- *
- * @param detector the rule's whitespace detector, may not be <code>null</code>
- */
- public WhitespaceRule(IWhitespaceDetector detector) {
- Assert.isNotNull(detector);
- fDetector= detector;
- }
-
- /*
- * @see IRule#evaluate(ICharacterScanner)
- */
- public IToken evaluate(ICharacterScanner scanner) {
- int c= scanner.read();
- if (fDetector.isWhitespace((char) c)) {
- do {
- c= scanner.read();
- } while (fDetector.isWhitespace((char) c));
- scanner.unread();
- return Token.WHITESPACE;
- } else {
- scanner.unread();
- return Token.UNDEFINED;
- }
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/WordPatternRule.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/WordPatternRule.java
deleted file mode 100644
index ee09cbe88f7..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/WordPatternRule.java
+++ /dev/null
@@ -1,108 +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.rules;
-
-
-import org.eclipse.jface.text.Assert;
-
-
-
-/**
- * A specific single line rule which stipulates that the start
- * and end sequence occur within a single word, as defined by a word detector.
- *
- * @see IWordDetector
- */
-public class WordPatternRule extends SingleLineRule {
-
- /** The word detector used by this rule */
- protected IWordDetector fDetector;
- /** The internal buffer used for pattern detection */
- private StringBuffer fBuffer= new StringBuffer();
-
- /**
- * Creates a rule for the given starting and ending word
- * pattern which, if detected, will return the specified token.
- * A word detector is used to identify words.
- *
- * @param detected the word detector to be used
- * @param startSequence the start sequence of the word pattern
- * @param endSequence the end sequence of the word pattern
- * @param token the token to be returned on success
- */
- public WordPatternRule(IWordDetector detector, String startSequence, String endSequence, IToken token) {
- this(detector, startSequence, endSequence, token, (char)0);
- }
-
- /**
- /**
- * Creates a rule for the given starting and ending word
- * pattern which, if detected, will return the specified token.
- * A word detector is used to identify words.
- * Any character which follows the given escapeCharacter will be ignored.
- *
- * @param detected the word detector to be used
- * @param startSequence the start sequence of the word pattern
- * @param endSequence the end sequence of the word pattern
- * @param token the token to be returned on success
- * @param escapeCharacter the escape character
- */
- public WordPatternRule(IWordDetector detector, String startSequence, String endSequence, IToken token, char escapeCharacter) {
- super(startSequence, endSequence, token, escapeCharacter);
- Assert.isNotNull(detector);
- fDetector= detector;
- }
-
- /**
- * Returns whether the end sequence was detected.
- * The rule acquires the rest of the word, using the
- * provided word detector, and tests to determine if
- * it ends with the end sequence.
- *
- * @param scanner the scanner to be used
- * @return <code>true</code> if the word ends on the given end sequence
- */
- protected boolean endSequenceDetected(ICharacterScanner scanner) {
- fBuffer.setLength(0);
- int c= scanner.read();
- while (fDetector.isWordPart((char) c)) {
- fBuffer.append((char) c);
- c= scanner.read();
- }
- scanner.unread();
-
- if (fBuffer.length() >= fEndSequence.length) {
- for (int i=fEndSequence.length - 1, j= fBuffer.length() - 1; i >= 0; i--, j--) {
- if (fEndSequence[i] != fBuffer.charAt(j)) {
- unreadBuffer(scanner);
- return false;
- }
- }
- return true;
- }
-
- unreadBuffer(scanner);
- return false;
- }
-
- /**
- * Returns the characters in the buffer to the scanner.
- * Note that the rule must also return the characters
- * read in as part of the start sequence expect the first one.
- *
- * @param scanner the scanner to be used
- */
- protected void unreadBuffer(ICharacterScanner scanner) {
- fBuffer.insert(0, fStartSequence);
- for (int i= fBuffer.length() - 1; i > 0; i--)
- scanner.unread();
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/WordRule.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/WordRule.java
deleted file mode 100644
index 6d162d2fda7..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/WordRule.java
+++ /dev/null
@@ -1,145 +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.rules;
-
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.jface.text.Assert;
-
-
-/**
- * An implementation of <code>IRule</code> capable of detecting words
- * Word rules also allow for the association of tokens with specific words.
- * That is, not only can the rule be used to provide tokens for exact matches,
- * but also for the generalized notion of a word in the context in which it is used.
- * A word rules uses a word detector to determine what a word is.
- *
- * @see IWordDetector
- */
-public class WordRule implements IRule {
-
- /** Internal setting for the uninitialized column constraint */
- protected static final int UNDEFINED= -1;
-
- /** The word detector used by this rule */
- protected IWordDetector fDetector;
- /** The default token to be returned on success and if nothing else has been specified. */
- protected IToken fDefaultToken;
- /** The column constraint */
- protected int fColumn= UNDEFINED;
- /** The table of predefined words and token for this rule */
- protected Map fWords= new HashMap();
- /** Buffer used for pattern detection */
- private StringBuffer fBuffer= new StringBuffer();
-
- /**
- * Creates a rule which, with the help of an word detector, will return the token
- * associated with the detected word. If no token has been associated, the scanner
- * will be rolled back and an undefined token will be returned in order to allow
- * any subsequent rules to analyze the characters.
- *
- * @param detector the word detector to be used by this rule, may not be <code>null</code>
- *
- * @see #addWord
- */
- public WordRule(IWordDetector detector) {
- this(detector, Token.UNDEFINED);
- }
-
- /**
- * Creates a rule which, with the help of an word detector, will return the token
- * associated with the detected word. If no token has been associated, the
- * specified default token will be returned.
- *
- * @param detector the word detector to be used by this rule, may not be <code>null</code>
- * @param defaultToken the default token to be returned on success
- * if nothing else is specified, may not be <code>null</code>
- *
- * @see #addWord
- */
- public WordRule(IWordDetector detector, IToken defaultToken) {
-
- Assert.isNotNull(detector);
- Assert.isNotNull(defaultToken);
-
- fDetector= detector;
- fDefaultToken= defaultToken;
- }
-
- /**
- * Adds a word and the token to be returned if it is detected.
- *
- * @param word the word this rule will search for, may not be <code>null</code>
- * @param token the token to be returned if the word has been found, may not be <code>null</code>
- */
- public void addWord(String word, IToken token) {
- Assert.isNotNull(word);
- Assert.isNotNull(token);
-
- fWords.put(word, token);
- }
-
- /**
- * Sets a column constraint for this rule. If set, the rule's token
- * will only be returned if the pattern is detected starting at the
- * specified column. If the column is smaller then 0, the column
- * constraint is considered removed.
- *
- * @param column the column in which the pattern starts
- */
- public void setColumnConstraint(int column) {
- if (column < 0)
- column= UNDEFINED;
- fColumn= column;
- }
-
- /*
- * @see IRule#evaluate(ICharacterScanner)
- */
- public IToken evaluate(ICharacterScanner scanner) {
- int c= scanner.read();
- if (fDetector.isWordStart((char) c)) {
- if (fColumn == UNDEFINED || (fColumn == scanner.getColumn() - 1)) {
-
- fBuffer.setLength(0);
- do {
- fBuffer.append((char) c);
- c= scanner.read();
- } while (c != ICharacterScanner.EOF && fDetector.isWordPart((char) c));
- scanner.unread();
-
- IToken token= (IToken) fWords.get(fBuffer.toString());
- if (token != null)
- return token;
-
- if (fDefaultToken.isUndefined())
- unreadBuffer(scanner);
-
- return fDefaultToken;
- }
- }
-
- scanner.unread();
- return Token.UNDEFINED;
- }
-
- /**
- * Returns the characters in the buffer to the scanner.
- *
- * @param scanner the scanner to be used
- */
- protected void unreadBuffer(ICharacterScanner scanner) {
- for (int i= fBuffer.length() - 1; i >= 0; i--)
- scanner.unread();
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/package.html b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/package.html
deleted file mode 100644
index 253c05333b5..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/package.html
+++ /dev/null
@@ -1,21 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="Author" content="IBM">
- <meta name="GENERATOR" content="Mozilla/4.51 [en] (WinNT; I) [Netscape]">
- <title>Package-level Javadoc</title>
-</head>
-<body>
-Provides a framework for rule based text scanning
-and uses the framework to provide rule-driven default implementations of
-<tt>IPresentationDamager</tt>, <tt>IPresentationRepairer</tt> and <tt>IDocumentPartitioner</tt>.
-<h2>
-Package Specification</h2>
-<tt>RuleBasedScanner</tt> is a document-based scanner controlled by <tt>IRule</tt>
-objects. When evaluated an <tt>IRule</tt> always returns an <tt>IToken</tt>.
-The package provides a set of rules whereby <tt>PatternRule</tt> is the
-most important one. <tt>PatternRule</tt> defines a pattern-configurable
-rule.
-</body>
-</html>
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/Annotation.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/Annotation.java
deleted file mode 100644
index d5215d5b53f..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/Annotation.java
+++ /dev/null
@@ -1,130 +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.FontMetrics;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Canvas;
-
-/**
- * Abstract annotation managed by an <code>IAnnotationModel</code>.
- * Annotations are considered being located at layers and are considered being painted
- * starting with layer 0 upwards. Thus an annotation of layer 5 will be drawn on top of
- * all co-located annotations at the layers 4 - 0. Subclasses must provide the annotations
- * paint method.
- *
- * @see IVerticalRuler
- */
-public abstract class Annotation {
-
- /** The layer of this annotation. */
- private int fLayer;
-
- /**
- * Creates a new annotation.
- */
- protected Annotation() {
- }
-
- /**
- * Sets the layer of this annotation.
- *
- * @param layer the layer of this annotation
- */
- protected void setLayer(int layer) {
- fLayer= layer;
- }
-
- /**
- * Convenience method for drawing an image aligned inside a rectangle.
- *
- * @param image the image to be drawn
- * @param GC the drawing GC
- * @param canvas the canvas on which to draw
- * @param r the clipping rectangle
- * @param halign the horizontal alignment of the image to be drawn
- * @param valign the vertical alignment of the image to be drawn
- */
- protected static void drawImage(Image image, GC gc, Canvas canvas, Rectangle r, int halign, int valign) {
- if (image != null) {
-
- Rectangle bounds= image.getBounds();
-
- int x= 0;
- switch(halign) {
- case SWT.LEFT:
- break;
- case SWT.CENTER:
- x= (r.width - bounds.width) / 2;
- break;
- case SWT.RIGHT:
- x= r.width - bounds.width;
- break;
- }
-
- int y= 0;
- switch (valign) {
- case SWT.TOP: {
- FontMetrics fontMetrics= gc.getFontMetrics();
- y= (fontMetrics.getHeight() - bounds.height)/2;
- break;
- }
- case SWT.CENTER:
- y= (r.height - bounds.height) / 2;
- break;
- case SWT.BOTTOM: {
- FontMetrics fontMetrics= gc.getFontMetrics();
- y= r.height - (fontMetrics.getHeight() + bounds.height)/2;
- break;
- }
- }
-
- gc.drawImage(image, r.x+x, r.y+y);
- }
- }
-
- /**
- * Convenience method for drawing an image aligned inside a rectangle.
- *
- * @param image the image to be drawn
- * @param GC the drawing GC
- * @param canvas the canvas on which to draw
- * @param r the clipping rectangle
- * @param align the alignment of the image to be drawn
- */
- protected static void drawImage(Image image, GC gc, Canvas canvas, Rectangle r, int align) {
- drawImage(image, gc, canvas, r, align, SWT.CENTER);
- }
-
- /**
- * Returns the annotations drawing layer.
- *
- * @return the annotations drawing layer
- */
- public int getLayer() {
- return fLayer;
- }
-
- /**
- * Implement this method to draw a graphical representation
- * of this annotation within the given bounds.
- *
- * @param GC the drawing GC
- * @param canvas the canvas to draw on
- * @param bounds the bounds inside the canvas to draw on
- */
- public abstract void paint(GC gc, Canvas canvas, Rectangle bounds);
-}
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
deleted file mode 100644
index df430b91f3c..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationBarHoverManager.java
+++ /dev/null
@@ -1,266 +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.MouseEvent;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Control;
-
-import org.eclipse.jface.text.AbstractHoverInformationControlManager;
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IInformationControl;
-import org.eclipse.jface.text.IInformationControlCreator;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.ITextViewerExtension3;
-
-
-/**
- * This manager controls the layout, content, and visibility of an information
- * control in reaction to mouse hover events issued by the vertical ruler of a
- * source viewer.
- * @since 2.0
- */
-public class AnnotationBarHoverManager extends AbstractHoverInformationControlManager {
-
- /** The source viewer the manager is connected to */
- private ISourceViewer fSourceViewer;
- /** The vertical ruler the manager is registered with */
- private IVerticalRulerInfo fVerticalRulerInfo;
- /** The annotation hover the manager uses to retrieve the information to display */
- private IAnnotationHover fAnnotationHover;
-
- /**
- * Creates an annotation hover manager with the given parameters. In addition,
- * the hovers anchor is RIGHT and the margin is 5 points to the right.
- *
- * @param sourceViewer the source viewer this manager connects to
- * @param ruler the vertical ruler this manager connects to
- * @param annotationHover the annotation hover providing the information to be displayed
- * @param creator the information control creator
- * @deprecated As of 2.1, replaced by {@link AnnotationBarHoverManager#AnnotationBarHoverManager(IVerticalRulerInfo, ISourceViewer, IAnnotationHover, IInformationControlCreator)}
- */
- public AnnotationBarHoverManager(ISourceViewer sourceViewer, IVerticalRuler ruler, IAnnotationHover annotationHover, IInformationControlCreator creator) {
- this(ruler, sourceViewer, annotationHover, creator);
- }
-
- /**
- * Creates an annotation hover manager with the given parameters. In addition,
- * the hovers anchor is RIGHT and the margin is 5 points to the right.
- *
- * @param ruler the vertical ruler this manager connects to
- * @param sourceViewer the source viewer this manager connects to
- * @param annotationHover the annotation hover providing the information to be displayed
- * @param creator the information control creator
- * @since 2.1
- */
- public AnnotationBarHoverManager(IVerticalRulerInfo rulerInfo, ISourceViewer sourceViewer, IAnnotationHover annotationHover, IInformationControlCreator creator) {
- super(creator);
-
- Assert.isNotNull(sourceViewer);
- Assert.isNotNull(annotationHover);
-
- fSourceViewer= sourceViewer;
- fVerticalRulerInfo= rulerInfo;
- fAnnotationHover= annotationHover;
-
- setAnchor(ANCHOR_RIGHT);
- setMargins(5, 0);
- }
-
- /*
- * @see AbstractHoverInformationControlManager#computeInformation()
- */
- protected void computeInformation() {
- MouseEvent event= getHoverEvent();
- IAnnotationHover hover= getHover(event);
-
- int line= getHoverLine(event);
- if (hover instanceof IAnnotationHoverExtension) {
- IAnnotationHoverExtension extension= (IAnnotationHoverExtension) hover;
- setCustomInformationControlCreator(extension.getInformationControlCreator());
- setInformation(extension.getHoverInfo(fSourceViewer, line, fSourceViewer.getTopIndex(), fSourceViewer.getBottomIndex()), computeArea(line));
- } else {
- setCustomInformationControlCreator(null);
- setInformation(hover.getHoverInfo(fSourceViewer, line), computeArea(line));
- }
-
- }
-
- /**
- * Determines the hover to be used to display information based on the source of the
- * mouse hover event. If <code>fVerticalRulerInfo</code> is not a composite ruler, the
- * standard hover is returned.
- *
- * @param source the source of the mouse hover event
- * @return the hover depending on <code>source</code>, or <code>fAnnotationHover</code> if none can be found.
- * @since 3.0
- */
- private IAnnotationHover getHover(MouseEvent event) {
- if (event == null || event.getSource() == null)
- return fAnnotationHover;
-
- if (fVerticalRulerInfo instanceof CompositeRuler) {
- CompositeRuler comp= (CompositeRuler) fVerticalRulerInfo;
- for (Iterator it= comp.getDecoratorIterator(); it.hasNext();) {
- Object o= it.next();
- if (o instanceof IVerticalRulerInfoExtension && o instanceof IVerticalRulerInfo) {
- if (((IVerticalRulerInfo) o).getControl() == event.getSource()) {
- IAnnotationHover hover= ((IVerticalRulerInfoExtension) o).getHover();
- if (hover != null)
- return hover;
- }
- }
- }
- }
- return fAnnotationHover;
- }
-
-
- /**
- * Returns the line of interest deduced from the mouse hover event.
- *
- * @param event a mouse hover event that triggered hovering
- * @return the document model line number on which the hover event occurred or <code>-1</code> if there is no event
- * @since 3.0
- */
- private int getHoverLine(MouseEvent event) {
- return event == null ? -1 : fVerticalRulerInfo.toDocumentLineNumber(event.y);
- }
-
- /**
- * Returns for the widget line number for the given document line number.
- *
- * @param line the absolute line number
- * @return the line number relative to the viewer's visible region
- * @throws BadLocationException if <code>line</code> is not valid in the viewer's document
- */
- private int getWidgetLineNumber(int line) throws BadLocationException {
- if (fSourceViewer instanceof ITextViewerExtension3) {
- ITextViewerExtension3 extension= (ITextViewerExtension3) fSourceViewer;
- return extension.modelLine2WidgetLine(line);
- }
-
- IRegion region= fSourceViewer.getVisibleRegion();
- int firstLine= fSourceViewer.getDocument().getLineOfOffset(region.getOffset());
- return line - firstLine;
- }
-
- /**
- * Determines graphical area covered by the given line.
- *
- * @param line the number of the line in the viewer whose graphical extend in the vertical ruler must be computed
- * @return the graphical extend of the given line
- */
- private Rectangle computeArea(int line) {
- try {
- StyledText text= fSourceViewer.getTextWidget();
- int lineHeight= text.getLineHeight();
- int y= getWidgetLineNumber(line) * lineHeight - text.getTopPixel();
- Point size= fVerticalRulerInfo.getControl().getSize();
- return new Rectangle(0, y, size.x, lineHeight);
- } catch (BadLocationException x) {
- }
- return null;
- }
-
- /**
- * Returns the annotation hover for this hover manager.
- *
- * @return the annotation hover for this hover manager
- * @since 2.1
- */
- protected IAnnotationHover getAnnotationHover() {
- return fAnnotationHover;
- }
-
- /**
- * Returns the source viewer for this hover manager.
- *
- * @return the source viewer for this hover manager
- * @since 2.1
- */
- protected ISourceViewer getSourceViewer() {
- return fSourceViewer;
- }
-
- /**
- * Returns the vertical ruler info for this hover manager
- *
- * @return the vertical ruler info for this hover manager
- * @since 2.1
- */
- protected IVerticalRulerInfo getVerticalRulerInfo() {
- return fVerticalRulerInfo;
- }
-
- /*
- * @see org.eclipse.jface.text.AbstractInformationControlManager#computeSizeConstraints(org.eclipse.swt.widgets.Control, org.eclipse.jface.text.IInformationControl)
- * @since 3.0
- */
- protected Point computeSizeConstraints(Control subjectControl, IInformationControl informationControl) {
- /* limit the hover to the size of the styled text's client area. */
- StyledText styledText= fSourceViewer.getTextWidget();
- if (styledText == null)
- return super.computeSizeConstraints(subjectControl, informationControl);
-
- Rectangle r= styledText.getClientArea();
- if (r == null)
- return super.computeSizeConstraints(subjectControl, informationControl);
- return new Point(r.width, r.height);
- }
-
- /*
- * @see org.eclipse.jface.text.AbstractInformationControlManager#computeInformationControlLocation(org.eclipse.swt.graphics.Rectangle, org.eclipse.swt.graphics.Point)
- * @since 3.0
- */
- protected Point computeInformationControlLocation(Rectangle subjectArea, Point controlSize) {
- MouseEvent event= getHoverEvent();
- IAnnotationHover hover= getHover(event);
-
- if (hover instanceof IAnnotationHoverExtension) {
- ITextSelection lineRange= ((IAnnotationHoverExtension) hover).getLineRange(fSourceViewer, getHoverLine(event), fSourceViewer.getTopIndex(), fSourceViewer.getBottomIndex());
- if (lineRange != null && !lineRange.isEmpty())
- return computeViewerRange(lineRange);
- }
- return super.computeInformationControlLocation(subjectArea, controlSize);
- }
-
- /**
- * Computes the hover location for the given line range.
- *
- * @param lineRange the first and last line covered by the hover, encoded as the <code>x</code> and <code>y</code> fields of a <code>Point</code>
- * @return a <code>Point</code>containing the display coordinates of the hover location
- * @since 3.0
- */
- private Point computeViewerRange(ITextSelection lineRange) {
- final int topLine= fSourceViewer.getTopIndex();
- // compute pixel offset taking in account partially visible lines.
- int lineDelta= lineRange.getStartLine() - topLine;
- StyledText textWidget= fSourceViewer.getTextWidget();
- int lineHeight= textWidget.getLineHeight();
- // note that this works independently of the widget2model mapping, since we just get the
- // pixels of the first paritally visible line, if there is one.
- int partial= (lineHeight - (textWidget.getTopPixel() % lineHeight)) % lineHeight;
- int y= lineDelta * lineHeight + partial;
- int x= 1; // avoids line overlay of the hover and the editor border.
-
- return textWidget.toDisplay(x, y);
- }
-}
-
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationColumn.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationColumn.java
deleted file mode 100644
index 176d66656a6..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationColumn.java
+++ /dev/null
@@ -1,30 +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;
-
-
-/**
- * @deprecated use <code>AnnotationRulerColumn</code> instead.
- * @since 2.0
- */
-public final class AnnotationColumn extends AnnotationRulerColumn {
-
- /**
- * Creates a new <code>AnnotationColumn</code> of the given width.
- *
- * @param width the width of this column
- * @deprecated
- */
- public AnnotationColumn(int width) {
- super(width);
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationModel.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationModel.java
deleted file mode 100644
index e813e89d094..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationModel.java
+++ /dev/null
@@ -1,475 +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.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.NoSuchElementException;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentListener;
-import org.eclipse.jface.text.Position;
-
-
-/**
- * Standard implementation of <code>IAnnotationModel</code>. This class can directly
- * be used by clients. Subclasses may adapt this annotation model to other exsisting
- * annotation mechanisms.
- */
-public class AnnotationModel implements IAnnotationModel, IAnnotationModelExtension {
-
- /** The list of managed annotations */
- protected Map fAnnotations;
- /** The list of annotation model listeners */
- protected ArrayList fAnnotationModelListeners;
- /** The document conntected with this model */
- protected IDocument fDocument;
- /** The number of open connections to the same document */
- private int fOpenConnections= 0;
- /** The document listener for tracking whether document positions might have been changed. */
- private IDocumentListener fDocumentListener;
- /** The flag indicating whether the document positions might have been changed. */
- private boolean fDocumentChanged= true;
- /**
- * The model's attachment.
- * @since 3.0
- */
- private Map fAttachments= new HashMap();
- /**
- * The annotation model listener on attached submodels.
- * @since 3.0
- */
- private IAnnotationModelListener fModelListener= new IAnnotationModelListener() {
- public void modelChanged(IAnnotationModel model) {
- AnnotationModel.this.fireModelChanged();
- }
- };
-
- /**
- * Creates a new annotation model. The annotation is empty, i.e. does not
- * manage any annotations and is not connected to any document.
- */
- public AnnotationModel() {
- fAnnotations= Collections.synchronizedMap(new HashMap(10));
- fAnnotationModelListeners= new ArrayList(2);
-
- fDocumentListener= new IDocumentListener() {
-
- public void documentAboutToBeChanged(DocumentEvent event) {
- }
-
- public void documentChanged(DocumentEvent event) {
- fDocumentChanged= true;
- }
- };
- }
-
- /*
- * @see IAnnotationModel#addAnnotation(Annotation, Position)
- */
- public void addAnnotation(Annotation annotation, Position position) {
- try {
- addAnnotation(annotation, position, true);
- } catch (BadLocationException e) {
- // ignore invalid position
- }
- }
-
- /**
- * Adds the given annotation to this model. Associates the
- * annotation with the given position. If requested, all annotation
- * model listeners are informed about this model change. If the annotation
- * is already managed by this model nothing happens.
- *
- * @param annotation the annotation to add
- * @param position the associate position
- * @param fireModelChange indicates whether to notify all model listeners
- * @throws BadLocationException if the position is not a valid document position
- */
- protected void addAnnotation(Annotation annotation, Position position, boolean fireModelChanged) throws BadLocationException {
- if (!fAnnotations.containsKey(annotation)) {
-
- addPosition(fDocument, position);
- fAnnotations.put(annotation, position);
-
- if (fireModelChanged)
- fireModelChanged();
- }
- }
-
- /*
- * @see IAnnotationModel#addAnnotationModelListener(IAnnotationModelListener)
- */
- public void addAnnotationModelListener(IAnnotationModelListener listener) {
- if (!fAnnotationModelListeners.contains(listener)) {
- fAnnotationModelListeners.add(listener);
- listener.modelChanged(this);
- }
- }
-
- /**
- * Adds the given position to the default position category of the
- * given document.
- *
- * @param document the document to which to add the position
- * @param position the position to add
- * @throws BadLocationException if the position is not a valid document position
- */
- protected void addPosition(IDocument document, Position position) throws BadLocationException {
- if (document != null)
- document.addPosition(position);
- }
-
- /*
- * @see IAnnotationModel#connect(IDocument)
- */
- public void connect(IDocument document) {
- Assert.isTrue(fDocument == null || fDocument == document);
-
- if (fDocument == null) {
- fDocument= document;
- Iterator e= fAnnotations.values().iterator();
- while (e.hasNext())
- try {
- addPosition(fDocument, (Position) e.next());
- } catch (BadLocationException x) {
- // ignore invalid position
- }
- }
-
- ++ fOpenConnections;
- if (fOpenConnections == 1) {
- fDocument.addDocumentListener(fDocumentListener);
- connected();
- }
-
- for (Iterator it= fAttachments.keySet().iterator(); it.hasNext();) {
- IAnnotationModel model= (IAnnotationModel) fAttachments.get(it.next());
- model.connect(document);
- }
- }
-
- /**
- * Hook method. Is called as soon as this model becomes connected to a document.
- * Subclasses may re-implement.
- */
- protected void connected() {
- }
-
- /**
- * Hook method. Is called as soon as this model becomes diconnected from its document.
- * Subclasses may re-implement.
- */
- protected void disconnected() {
- }
-
- /*
- * @see IAnnotationModel#disconnect(IDocument)
- */
- public void disconnect(IDocument document) {
-
- Assert.isTrue(fDocument == document);
-
- for (Iterator it= fAttachments.keySet().iterator(); it.hasNext();) {
- IAnnotationModel model= (IAnnotationModel) fAttachments.get(it.next());
- model.disconnect(document);
- }
-
- -- fOpenConnections;
- if (fOpenConnections == 0) {
-
- disconnected();
- fDocument.removeDocumentListener(fDocumentListener);
-
- if (fDocument != null) {
- Iterator e= fAnnotations.values().iterator();
- while (e.hasNext()) {
- Position p= (Position) e.next();
- fDocument.removePosition(p);
- }
- fDocument= null;
- }
- }
- }
-
- /**
- * Informs all annotation model listeners that this model has been changed.
- */
- protected void fireModelChanged() {
- fireModelChanged(new AnnotationModelEvent(this));
- }
-
- /**
- * Informs all annotation model listeners that this model has been changed
- * as described in the annotation model event. The event is sent out
- * to all listeners implementing <code>IAnnotationModelListenerExtension</code>.
- * All other listeners are notified by just calling <code>modelChanged(IAnnotationModel)</code>.
- *
- * @param event the event to be sent out to the listeners
- * @since 2.0
- */
- protected void fireModelChanged(AnnotationModelEvent event) {
- ArrayList v= new ArrayList(fAnnotationModelListeners);
- Iterator e= v.iterator();
- while (e.hasNext()) {
- IAnnotationModelListener l= (IAnnotationModelListener) e.next();
- if (l instanceof IAnnotationModelListenerExtension)
- ((IAnnotationModelListenerExtension) l).modelChanged(event);
- else
- l.modelChanged(this);
- }
- }
-
- /**
- * Removes the given annotations from this model. If requested all
- * annotation model listeners will be informed about this change.
- * <code>modelInitiated</code> indicates whether the deletion has
- * been initiated by this model or by one of its clients.
- *
- * @param annotations the annotations to be removed
- * @param fireModelChanged indicates whether to notify all model listeners
- * @param modelInitiated indicates whether this changes has been initiated by this model
- */
- protected void removeAnnotations(List annotations, boolean fireModelChanged, boolean modelInitiated) {
- if (annotations.size() > 0) {
- Iterator e= annotations.iterator();
- while (e.hasNext())
- removeAnnotation((Annotation) e.next(), false);
-
- if (fireModelChanged)
- fireModelChanged();
- }
- }
-
- /**
- * Removes all annotations from the model whose associated positions have been
- * deleted. If requested inform all model listeners about the change.
- *
- * @param fireModelChanged indicates whether to notify all model listeners
- */
- protected void cleanup(boolean fireModelChanged) {
- if (fDocumentChanged) {
- fDocumentChanged= false;
-
- ArrayList deleted= new ArrayList();
- Iterator e= new ArrayList(fAnnotations.keySet()).iterator();
- while (e.hasNext()) {
- Annotation a= (Annotation) e.next();
- Position p= (Position) fAnnotations.get(a);
- if (p == null || p.isDeleted())
- deleted.add(a);
- }
-
- removeAnnotations(deleted, fireModelChanged, false);
- }
- }
-
- /*
- * @see IAnnotationModel#getAnnotationsIterator()
- */
- public Iterator getAnnotationIterator() {
- return getAnnotationIterator(true, true);
- }
-
- /**
- * Returns all annotations managed by this model. <code>cleanup</code>
- * indicates whether all annotations whose associated positions are
- * deleted should previously be removed from the model. <code>recurse</code> indicates
- * whether annotations of attached submodels should also be returned.
- *
- * @param cleanup indicates whether annotations with deleted associated positions are removed
- * @param recurse whether to return annotations managed by submodels.
- * @return all annotations managed by this model
- * @since 3.0
- */
- private Iterator getAnnotationIterator(boolean cleanup, boolean recurse) {
-
- if (!recurse)
- return getAnnotationIterator(cleanup);
-
- List iterators= new ArrayList(fAttachments.size() + 1);
- iterators.add(getAnnotationIterator(cleanup));
- for (Iterator it= fAttachments.keySet().iterator(); it.hasNext();) {
- iterators.add(((IAnnotationModel)fAttachments.get(it.next())).getAnnotationIterator());
- }
-
- final Iterator iter= iterators.iterator();
-
- // Meta iterator...
- return new Iterator() {
-
- /** The current iterator. */
- private Iterator fCurrent= (Iterator) iter.next(); // there is at least one.
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- public boolean hasNext() {
- if (fCurrent.hasNext())
- return true;
- else if (iter.hasNext()) {
- fCurrent= (Iterator) iter.next();
- return hasNext();
- } else
- return false;
- }
-
- public Object next() {
- if (!hasNext())
- throw new NoSuchElementException();
- else
- return fCurrent.next();
- }
-
- };
- }
-
- /**
- * Returns all annotations managed by this model. <code>cleanup</code>
- * indicates whether all annotations whose associated positions are
- * deleted should previously be removed from the model.
- *
- * @param cleanup indicates whether annotations with deleted associated positions are removed
- * @return all annotations managed by this model
- */
- protected Iterator getAnnotationIterator(boolean cleanup) {
- if (cleanup)
- cleanup(false);
-
- synchronized (fAnnotations) {
- return new ArrayList(fAnnotations.keySet()).iterator();
- }
- }
-
- /*
- * @see IAnnotationModel#getPosition(Annotation)
- */
- public Position getPosition(Annotation annotation) {
- Position position= (Position) fAnnotations.get(annotation);
- Iterator it= fAttachments.values().iterator();
- while (position == null && it.hasNext())
- position= ((IAnnotationModel)it.next()).getPosition(annotation);
-
- return position;
- }
-
- /**
- * Removes all annotations from the annotation model and
- * informs all model listeners about this change.
- */
- public void removeAllAnnotations() {
- removeAllAnnotations(true);
- }
-
- /**
- * Removes all annotations from the annotation model. If requested
- * inform all model change listeners about this change.
- *
- * @param fireModelChanged indicates whether to notify all model listeners
- */
- protected void removeAllAnnotations(boolean fireModelChanged) {
-
- if (fDocument != null) {
- Iterator e= fAnnotations.values().iterator();
- while (e.hasNext()) {
- Position p= (Position) e.next();
- fDocument.removePosition(p);
- }
- }
-
- fAnnotations.clear();
-
- if (fireModelChanged)
- fireModelChanged();
- }
-
- /*
- * @see IAnnotationModel#removeAnnotation(Annotation)
- */
- public void removeAnnotation(Annotation annotation) {
- removeAnnotation(annotation, true);
- }
-
- /**
- * Removes the given annotation from the annotation model.
- * If requested inform all model change listeners about this change.
- *
- * @param annotation the annotation to be removed
- * @param fireModelChanged indicates whether to notify all model listeners
- */
- protected void removeAnnotation(Annotation annotation, boolean fireModelChanged) {
- if (fAnnotations.containsKey(annotation)) {
-
- if (fDocument != null) {
- Position p= (Position) fAnnotations.get(annotation);
- fDocument.removePosition(p);
- }
-
- fAnnotations.remove(annotation);
-
- if (fireModelChanged)
- fireModelChanged();
- }
- }
-
- /*
- * @see IAnnotationModel#removeAnnotationModelListener(IAnnotationModelListener)
- */
- public void removeAnnotationModelListener(IAnnotationModelListener listener) {
- fAnnotationModelListeners.remove(listener);
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationModelExtension#attach(java.lang.Object, java.lang.Object)
- * @since 3.0
- */
- public void addAnnotationModel(Object key, IAnnotationModel attachment) {
- Assert.isNotNull(attachment);
- if (!fAttachments.containsValue(attachment)) {
- fAttachments.put(key, attachment);
- for (int i= 0; i < fOpenConnections; i++)
- attachment.connect(fDocument);
- attachment.addAnnotationModelListener(fModelListener);
- }
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationModelExtension#get(java.lang.Object)
- * @since 3.0
- */
- public IAnnotationModel getAnnotationModel(Object key) {
- return (IAnnotationModel) fAttachments.get(key);
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationModelExtension#detach(java.lang.Object)
- * @since 3.0
- */
- public IAnnotationModel removeAnnotationModel(Object key) {
- IAnnotationModel ret= (IAnnotationModel) fAttachments.remove(key);
- if (ret != null) {
- for (int i= 0; i < fOpenConnections; i++)
- ret.disconnect(fDocument);
- ret.removeAnnotationModelListener(fModelListener);
- }
- return ret;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationModelEvent.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationModelEvent.java
deleted file mode 100644
index 855cca7e79c..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationModelEvent.java
+++ /dev/null
@@ -1,44 +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;
-
-/**
- * Specification of changes applied to annotation models.
- * The event carries the changed annotation model. <p>
- * Work in progress. Intented to also contain added, removed, and modified annotations.
- *
- * @see IAnnotationModel
- * @since 2.0
- */
-public class AnnotationModelEvent {
-
- /** The model this event refers to. For internal use only. */
- IAnnotationModel fAnnotationModel;
-
- /**
- * Creates a new annotation model event for the given model.
- *
- * @param model the model
- */
- public AnnotationModelEvent(IAnnotationModel model) {
- fAnnotationModel= model;
- }
-
- /**
- * Returns the model this event refers to.
- *
- * @return the model this events belongs to
- */
- public IAnnotationModel getAnnotationModel() {
- return fAnnotationModel;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationPainter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationPainter.java
deleted file mode 100644
index 99eb2a44edf..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationPainter.java
+++ /dev/null
@@ -1,647 +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.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.swt.custom.StyleRange;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Display;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IPaintPositionManager;
-import org.eclipse.jface.text.IPainter;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextViewerExtension3;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.Region;
-
-
-
-/**
- * Paints annotations provided by an annotation model as squiggly lines and/or
- * highlighted onto an associated source viewer.
- * Clients usually instantiate and configure objects of this class.
- *
- * @since 2.1
- */
-public class AnnotationPainter implements IPainter, PaintListener, IAnnotationModelListener {
-
- /**
- * The presentation information (decoration) for an annotation. Each such
- * object represents one squiggly.
- */
- private static class Decoration {
- /** The position of this decoration */
- Position fPosition;
- /** The color of this decoration */
- Color fColor;
- /** Indicates whether this decoration might span multiple lines */
- boolean fMultiLine;
- }
-
- /** Indicates whether this painter is active */
- private boolean fIsActive= false;
- /** Indicates whether this painter is managing decorations */
- private boolean fIsPainting= false;
- /** Indicates whether this painter is setting its annotation model */
- private boolean fIsSettingModel= false;
- /** The associated source viewer */
- private ISourceViewer fSourceViewer;
- /** The cached widget of the source viewer */
- private StyledText fTextWidget;
- /** The annotation model providing the annotations to be drawn */
- private IAnnotationModel fModel;
- /** The annotation access */
- private IAnnotationAccess fAnnotationAccess;
- /** The list of decorations */
- private List fDecorations= new ArrayList();
- /**
- * The list of highlighted decorations.
- * @since 3.0
- */
- private List fHighlightedDecorations= new ArrayList();
- /** The internal color table */
- private Map fColorTable= new HashMap();
- /** The list of types of annotations that are painted by this painter */
- private Set fAnnotationTypes= new HashSet();
- /**
- * The list of types of annotations that are highlighted by this painter.
- * @since 3.0
- */
- private Set fHighlightAnnotationTypes= new HashSet();
- /**
- * List of style ranges used to do background highlighting.
- * since 3.0
- */
- private ArrayList fStyleRanges= new ArrayList();
-
-// private int fBgRepairOffset= -1;
-// private int fBgRepairLength= -1;
-
- /**
- * Creates a new annotation painter for the given source viewer and with the given
- * annotation access. The painter is uninitialized, i.e. no annotation types are configured
- * to be painted.
- *
- * @param sourceViewer the source viewer for this painter
- * @param access the annotation access for this painter
- */
- public AnnotationPainter(ISourceViewer sourceViewer, IAnnotationAccess access) {
- fSourceViewer= sourceViewer;
- fAnnotationAccess= access;
- fTextWidget= sourceViewer.getTextWidget();
- }
-
- /**
- * Returns whether this painter has to draw any squiggle.
- *
- * @return <code>true</code> if there are squiggles to be drawn, <code>false</code> otherwise
- */
- private boolean hasDecorations() {
- return !fDecorations.isEmpty();
- }
-
- /**
- * Enables painting. This painter registers a paint listener with the
- * source viewer's widget.
- */
- private void enablePainting() {
- if (!fIsPainting && hasDecorations()) {
- fIsPainting= true;
- fTextWidget.addPaintListener(this);
- handleDrawRequest(null);
- }
- }
-
- /**
- * Disables painting, if is has previously been enabled. Removes
- * any paint listeners registered with the source viewer's widget.
- *
- * @param redraw <code>true</code> if the widget should be redrawn after disabling
- */
- private void disablePainting(boolean redraw) {
- if (fIsPainting) {
- fIsPainting= false;
- fTextWidget.removePaintListener(this);
- if (redraw && hasDecorations())
- handleDrawRequest(null);
- }
- }
-
- /**
- * Sets the annotation model for this painter. Registers this painter
- * as listener of the give model, if the model is not <code>null</code>.
- *
- * @param model the annotation model
- */
- private void setModel(IAnnotationModel model) {
- if (fModel != model) {
- if (fModel != null)
- fModel.removeAnnotationModelListener(this);
- fModel= model;
- if (fModel != null) {
- try {
- fIsSettingModel= true;
- fModel.addAnnotationModelListener(this);
- } finally {
- fIsSettingModel= false;
- }
- }
- }
- }
-
- /**
- * Updates the set of decorations based on the current state of
- * the painter's annotation model.
- */
- private void catchupWithModel() {
- if (fDecorations != null && fHighlightAnnotationTypes != null) {
- fDecorations.clear();
- fHighlightedDecorations.clear();
- if (fModel != null) {
-
- Iterator e= fModel.getAnnotationIterator();
- while (e.hasNext()) {
-
- Annotation annotation= (Annotation) e.next();
- Object annotationType= fAnnotationAccess.getType(annotation);
- if (annotationType == null)
- continue;
-
- Color color= null;
- boolean isHighlighting= fHighlightAnnotationTypes.contains(annotationType);
- boolean isDrawingSquiggles= fAnnotationTypes.contains(annotationType);
- if (isDrawingSquiggles || isHighlighting)
- color= (Color) fColorTable.get(annotationType);
-
- if (color != null) {
- Position position= fModel.getPosition(annotation);
- if (position == null || position.isDeleted())
- continue;
-
- Decoration pp= new Decoration();
- pp.fPosition= position;
- pp.fColor= color;
- pp.fMultiLine= fAnnotationAccess.isMultiLine(annotation);
-
- if (isDrawingSquiggles)
- fDecorations.add(pp);
- if (isHighlighting)
- fHighlightedDecorations.add(pp);
- }
- }
- }
- }
- }
-
- /**
- * Recomputes the squiggles to be drawn and redraws them.
- */
- private void updatePainting() {
- disablePainting(true);
-
- // remove background from style ranges
- applyBackground(false); // faster than invalidateTextPresentation();
-
- catchupWithModel();
-
- // add background to style ranges
- applyBackground(true);
-
- enablePainting();
- }
-
- private void applyBackground(boolean highlight) {
- for (Iterator iter= fHighlightedDecorations.iterator(); iter.hasNext();) {
-
- Decoration pp = (Decoration)iter.next();
- Position p= pp.fPosition;
- if (!fSourceViewer.overlapsWithVisibleRegion(p.offset, p.length))
- continue;
-
- IRegion r= getWidgetRange(p);
- if (r != null) {
-// fBgRepairOffset= Math.min(fBgRepairOffset, r.getOffset());
-// fBgRepairLength= Math.max(fBgRepairLength, r.getOffset() + r.getLength() - fBgRepairOffset);
- StyleRange[] styleRanges= fTextWidget.getStyleRanges(r.getOffset(), r.getLength());
- ArrayList newStyleRanges= new ArrayList(styleRanges.length + 10);
- int offset= r.getOffset();
- for (int j= 0, length= styleRanges.length; j < length; j++) {
- StyleRange sr= styleRanges[j];
- Color bgColor= highlight ? pp.fColor : null;
- if (offset < sr.start) {
- // Unstyled range
- StyleRange usr= new StyleRange(offset, sr.start - offset, null, bgColor);
- fStyleRanges.add(usr);
- newStyleRanges.add(usr);
- }
- offset= sr.start + sr.length;
- sr.background= bgColor;
- fStyleRanges.add(sr);
- newStyleRanges.add(sr);
- }
- int endOffset= r.getOffset() + r.getLength();
- if (offset < endOffset) {
- // Last unstyled range
- StyleRange usr= new StyleRange(offset, endOffset - offset, null, pp.fColor);
- fStyleRanges.add(usr);
- newStyleRanges.add(usr);
- }
- styleRanges= (StyleRange[])newStyleRanges.toArray(new StyleRange[newStyleRanges.size()]);
- fTextWidget.replaceStyleRanges(r.getOffset(), r.getLength(), styleRanges);
- }
- }
- }
-
- /*
- * @see org.eclipse.jface.text.ITextViewer#invalidateTextPresentation()
- */
-// private void invalidateTextPresentation() {
-// if (fBgRepairOffset == Integer.MAX_VALUE)
-// return;
-//
-// if (fSourceViewer instanceof ITextViewerExtension2 && fBgRepairOffset > -1 && fBgRepairLength > -1) {
-// System.out.println("invalidating: " + fBgRepairOffset + ", " + fBgRepairLength);
-// ((ITextViewerExtension2)fSourceViewer).invalidateTextPresentation(fBgRepairOffset, fBgRepairLength);
-// } else
-// fSourceViewer.invalidateTextPresentation();
-//
-// fBgRepairOffset= Integer.MAX_VALUE;
-// fBgRepairLength= -1;
-// }
-
- /*
- * @see IAnnotationModelListener#modelChanged(IAnnotationModel)
- */
- public void modelChanged(final IAnnotationModel model) {
- if (fTextWidget != null && !fTextWidget.isDisposed()) {
- if (fIsSettingModel) {
- // inside the ui thread -> no need for posting
- updatePainting();
- } else {
- Display d= fTextWidget.getDisplay();
- if (d != null) {
- d.asyncExec(new Runnable() {
- public void run() {
- if (fTextWidget != null && !fTextWidget.isDisposed())
- updatePainting();
- }
- });
- }
- }
- }
- }
-
- /**
- * Sets the color in which the squiggly for the given annotation type should be drawn.
- *
- * @param annotationType the annotation type
- * @param color the color
- */
- public void setAnnotationTypeColor(Object annotationType, Color color) {
- if (color != null)
- fColorTable.put(annotationType, color);
- else
- fColorTable.remove(annotationType);
- }
-
- /**
- * Adds the given annotation type to the list of annotation types whose
- * annotations should be painted by this painter. If the annotation type
- * is already in this list, this method is without effect.
- *
- * @param annotationType the annotation type
- */
- public void addAnnotationType(Object annotationType) {
- fAnnotationTypes.add(annotationType);
- }
-
- /**
- * Adds the given annotation type to the list of annotation types whose
- * annotations should be highlighted this painter. If the annotation type
- * is already in this list, this method is without effect.
- *
- * @param annotationType the annotation type
- * @since 3.0
- */
- public void addHighlightAnnotationType(Object annotationType) {
- fHighlightAnnotationTypes.add(annotationType);
-
- }
-
- /**
- * Removes the given annotation type from the list of annotation types whose
- * annotations are painted by this painter. If the annotation type is not
- * in this list, this method is wihtout effect.
- *
- * @param annotationType the annotation type
- */
- public void removeAnnotationType(Object annotationType) {
- fAnnotationTypes.remove(annotationType);
- }
-
- /**
- * Removes the given annotation type from the list of annotation types whose
- * annotations are highlighted by this painter. If the annotation type is not
- * in this list, this method is wihtout effect.
- *
- * @param annotationType the annotation type
- * @since 3.0
- */
- public void removeHighlightAnnotationType(Object annotationType) {
- fHighlightAnnotationTypes.remove(annotationType);
- }
-
- /**
- * Clears the list of annotation types whose annotations are
- * painted by this painter.
- */
- public void removeAllAnnotationTypes() {
- fAnnotationTypes.clear();
- fHighlightAnnotationTypes.clear();
- }
-
- /**
- * Returns whether the list of annotation types whose annotations are painted
- * by this painter contains at least on element.
- *
- * @return <code>true</code> if there is an annotation type whose annotations are painted
- */
- public boolean isPaintingAnnotations() {
- return !fAnnotationTypes.isEmpty() || !fHighlightAnnotationTypes.isEmpty();
- }
-
- /*
- * @see IPainter#dispose()
- */
- public void dispose() {
-
- if (fColorTable != null)
- fColorTable.clear();
- fColorTable= null;
-
- if (fAnnotationTypes != null)
- fAnnotationTypes.clear();
- fAnnotationTypes= null;
-
- if (fHighlightAnnotationTypes != null)
- fHighlightAnnotationTypes.clear();
- fHighlightAnnotationTypes= null;
-
- fTextWidget= null;
- fSourceViewer= null;
- fAnnotationAccess= null;
- fModel= null;
- fDecorations= null;
- fHighlightedDecorations= null;
- }
-
- /**
- * Returns the document offset of the upper left corner of the source viewer's viewport,
- * possibly including partially visible lines.
- *
- * @return the document offset if the upper left corner of the viewport
- */
- private int getInclusiveTopIndexStartOffset() {
-
- if (fTextWidget != null && !fTextWidget.isDisposed()) {
- int top= fSourceViewer.getTopIndex();
- if ((fTextWidget.getTopPixel() % fTextWidget.getLineHeight()) != 0)
- top--;
- try {
- IDocument document= fSourceViewer.getDocument();
- return document.getLineOffset(top);
- } catch (BadLocationException ex) {
- }
- }
-
- return -1;
- }
-
- /*
- * @see PaintListener#paintControl(PaintEvent)
- */
- public void paintControl(PaintEvent event) {
- if (fTextWidget != null)
- handleDrawRequest(event.gc);
- }
-
- /**
- * Handles the request to draw the annotations using the given gaphical context.
- *
- * @param gc the graphical context
- */
- private void handleDrawRequest(GC gc) {
-
- if (fTextWidget == null) {
- // is already disposed
- return;
- }
-
- int vOffset= getInclusiveTopIndexStartOffset();
- // http://bugs.eclipse.org/bugs/show_bug.cgi?id=17147
- int vLength= fSourceViewer.getBottomIndexEndOffset() + 1;
-
- for (Iterator e = fDecorations.iterator(); e.hasNext();) {
- Decoration pp = (Decoration) e.next();
- Position p= pp.fPosition;
- if (p.overlapsWith(vOffset, vLength)) {
-
- if (!pp.fMultiLine) {
-
- IRegion widgetRange= getWidgetRange(p);
- if (widgetRange != null)
- draw(gc, widgetRange.getOffset(), widgetRange.getLength(), pp.fColor);
-
- } else {
-
- IDocument document= fSourceViewer.getDocument();
- try {
-
- int startLine= document.getLineOfOffset(p.getOffset());
- int lastInclusive= Math.max(p.getOffset(), p.getOffset() + p.getLength() - 1);
- int endLine= document.getLineOfOffset(lastInclusive);
-
- for (int i= startLine; i <= endLine; i++) {
- IRegion line= document.getLineInformation(i);
- int paintStart= Math.max(line.getOffset(), p.getOffset());
- int paintEnd= Math.min(line.getOffset() + line.getLength(), p.getOffset() + p.getLength());
- if (paintEnd > paintStart) {
- // otherwise inside a line delimiter
- IRegion widgetRange= getWidgetRange(new Position(paintStart, paintEnd - paintStart));
- if (widgetRange != null)
- draw(gc, widgetRange.getOffset(), widgetRange.getLength(), pp.fColor);
- }
- }
-
- } catch (BadLocationException x) {
- }
- }
- }
- }
- }
-
- /**
- * Returns the widget region that corresponds to the given region in the
- * viewer's document.
- *
- * @param p the region in the viewer's document
- * @return the corresponding widget region
- */
- private IRegion getWidgetRange(Position p) {
- if (fSourceViewer instanceof ITextViewerExtension3) {
-
- ITextViewerExtension3 extension= (ITextViewerExtension3) fSourceViewer;
- return extension.modelRange2WidgetRange(new Region(p.getOffset(), p.getLength()));
-
- } else {
-
- IRegion region= fSourceViewer.getVisibleRegion();
- int offset= region.getOffset();
- int length= region.getLength();
-
- if (p.overlapsWith(offset , length)) {
- int p1= Math.max(offset, p.getOffset());
- int p2= Math.min(offset + length, p.getOffset() + p.getLength());
- return new Region(p1 - offset, p2 - p1);
- }
- }
-
- return null;
- }
-
- /**
- * Computes an array of alternating x and y values which are the corners of the squiggly line of the
- * given height between the given end points.
- *
- * @param left the left end point
- * @param right the right end point
- * @param height the height of the squiggly line
- * @return the array of alternating x and y values which are the corners of the squiggly line
- */
- private int[] computePolyline(Point left, Point right, int height) {
-
- final int WIDTH= 4; // must be even
- final int HEIGHT= 2; // can be any number
-// final int MINPEEKS= 2; // minimal number of peeks
-
- int peeks= (right.x - left.x) / WIDTH;
-// if (peeks < MINPEEKS) {
-// int missing= (MINPEEKS - peeks) * WIDTH;
-// left.x= Math.max(0, left.x - missing/2);
-// peeks= MINPEEKS;
-// }
-
- int leftX= left.x;
-
- // compute (number of point) * 2
- int length= ((2 * peeks) + 1) * 2;
- if (length < 0)
- return new int[0];
-
- int[] coordinates= new int[length];
-
- // cache peeks' y-coordinates
- int bottom= left.y + height - 1;
- int top= bottom - HEIGHT;
-
- // populate array with peek coordinates
- for (int i= 0; i < peeks; i++) {
- int index= 4 * i;
- coordinates[index]= leftX + (WIDTH * i);
- coordinates[index+1]= bottom;
- coordinates[index+2]= coordinates[index] + WIDTH/2;
- coordinates[index+3]= top;
- }
-
- // the last down flank is missing
- coordinates[length-2]= left.x + (WIDTH * peeks);
- coordinates[length-1]= bottom;
-
- return coordinates;
- }
-
- /**
- * Draws a squiggly line of the given length start at the given offset in the
- * given color.
- *
- * @param gc the grahical context
- * @param offset the offset of the line
- * @param length the length of the line
- * @param color the color of the line
- */
- private void draw(GC gc, int offset, int length, Color color) {
- if (gc != null) {
-
- Point left= fTextWidget.getLocationAtOffset(offset);
- Point right= fTextWidget.getLocationAtOffset(offset + length);
-
- gc.setForeground(color);
- int[] polyline= computePolyline(left, right, gc.getFontMetrics().getHeight());
- gc.drawPolyline(polyline);
-
- } else {
- fTextWidget.redrawRange(offset, length, true);
- }
- }
-
- /*
- * @see IPainter#deactivate(boolean)
- */
- public void deactivate(boolean redraw) {
- if (fIsActive) {
- fIsActive= false;
- disablePainting(redraw);
- setModel(null);
- catchupWithModel();
- }
- }
-
- /*
- * @see IPainter#paint(int)
- */
- public void paint(int reason) {
- if (fSourceViewer.getDocument() == null) {
- deactivate(false);
- return;
- }
-
- if (!fIsActive) {
- IAnnotationModel model= fSourceViewer.getAnnotationModel();
- if (model != null) {
- fIsActive= true;
- setModel(fSourceViewer.getAnnotationModel());
- }
- } else if (CONFIGURATION == reason || INTERNAL == reason)
- updatePainting();
- }
-
- /*
- * @see org.eclipse.jface.text.IPainter#setPositionManager(org.eclipse.jface.text.IPaintPositionManager)
- */
- public void setPositionManager(IPaintPositionManager manager) {
- }
-}
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
deleted file mode 100644
index 96df8901980..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationRulerColumn.java
+++ /dev/null
@@ -1,602 +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.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Canvas;
-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.IRegion;
-import org.eclipse.jface.text.ITextListener;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.ITextViewerExtension3;
-import org.eclipse.jface.text.IViewportListener;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextEvent;
-import org.eclipse.jface.text.TextViewer;
-
-
-/**
- * A vertical ruler column showing graphical representations of annotations.
- * Will become final. Do not subclass.
- * @since 2.0
- */
-public class AnnotationRulerColumn implements IVerticalRulerColumn {
-
- /**
- * Internal listener class.
- */
- class InternalListener implements IViewportListener, IAnnotationModelListener, ITextListener {
-
- /*
- * @see IViewportListener#viewportChanged(int)
- */
- public void viewportChanged(int verticalPosition) {
- if (verticalPosition != fScrollPos)
- redraw();
- }
-
- /*
- * @see IAnnotationModelListener#modelChanged(IAnnotationModel)
- */
- public void modelChanged(IAnnotationModel model) {
- postRedraw();
- }
-
- /*
- * @see ITextListener#textChanged(TextEvent)
- */
- public void textChanged(TextEvent e) {
- if (e.getViewerRedrawState())
- postRedraw();
- }
- }
-
-
- /** This column's parent ruler */
- private CompositeRuler fParentRuler;
- /** The cached text viewer */
- private ITextViewer fCachedTextViewer;
- /** The cached text widget */
- private StyledText fCachedTextWidget;
- /** The ruler's canvas */
- private Canvas fCanvas;
- /** The vertical ruler's model */
- private IAnnotationModel fModel;
- /** Cache for the actual scroll position in pixels */
- private int fScrollPos;
- /** The drawable for double buffering */
- private Image fBuffer;
- /** The internal listener */
- private InternalListener fInternalListener= new InternalListener();
- /** The width of this vertical ruler */
- private int fWidth;
- /** Switch for enabling/disabling the setModel method. */
- private boolean fAllowSetModel= true;
- /**
- * The list of annotation types to be shown in this ruler.
- * @since 3.0
- */
- private Set fAnnotationTypes= new HashSet();
- /**
- * The annotation access.
- * @since 3.0
- */
- private IAnnotationAccess fAnnotationAccess;
-
-
- /**
- * Constructs this column with the given arguments.
- *
- * @param width the width of the vertical ruler
- * @param annotationAccess the annotation access
- * @since 3.0
- */
- public AnnotationRulerColumn(IAnnotationModel model, int width, IAnnotationAccess annotationAccess) {
- fWidth= width;
- fAllowSetModel= false;
- fModel= model;
- fModel.addAnnotationModelListener(fInternalListener);
- fAnnotationAccess= annotationAccess;
- }
-
- /**
- * Constructs this column with the given arguments.
- *
- * @param width the width of the vertical ruler
- * @param annotationAccess the annotation access
- * @since 3.0
- */
- public AnnotationRulerColumn(int width, IAnnotationAccess annotationAccess) {
- fWidth= width;
- fAnnotationAccess= annotationAccess;
- }
-
- /**
- * Constructs this column with the given arguments.
- *
- * @param width the width of the vertical ruler
- */
- public AnnotationRulerColumn(IAnnotationModel model, int width) {
- fWidth= width;
- fAllowSetModel= false;
- fModel= model;
- fModel.addAnnotationModelListener(fInternalListener);
- }
-
- /**
- * Constructs this column with the given width.
- *
- * @param width the width of the vertical ruler
- */
- public AnnotationRulerColumn(int width) {
- fWidth= width;
- }
-
- /*
- * @see IVerticalRulerColumn#getControl()
- */
- public Control getControl() {
- return fCanvas;
- }
-
- /*
- * @see IVerticalRulerColumn#getWidth()
- */
- public int getWidth() {
- return fWidth;
- }
-
- /*
- * @see IVerticalRulerColumn#createControl(CompositeRuler, Composite)
- */
- public Control createControl(CompositeRuler parentRuler, Composite parentControl) {
-
- fParentRuler= parentRuler;
- fCachedTextViewer= parentRuler.getTextViewer();
- fCachedTextWidget= fCachedTextViewer.getTextWidget();
-
- fCanvas= new Canvas(parentControl, SWT.NO_BACKGROUND);
-
- fCanvas.addPaintListener(new PaintListener() {
- public void paintControl(PaintEvent event) {
- if (fCachedTextViewer != null)
- doubleBufferPaint(event.gc);
- }
- });
-
- fCanvas.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- handleDispose();
- fCachedTextViewer= null;
- fCachedTextWidget= null;
- }
- });
-
- fCanvas.addMouseListener(new MouseListener() {
- public void mouseUp(MouseEvent event) {
- }
-
- public void mouseDown(MouseEvent event) {
- fParentRuler.setLocationOfLastMouseButtonActivity(event.x, event.y);
- }
-
- public void mouseDoubleClick(MouseEvent event) {
- fParentRuler.setLocationOfLastMouseButtonActivity(event.x, event.y);
- mouseDoubleClicked(fParentRuler.getLineOfLastMouseButtonActivity());
- }
- });
-
- if (fCachedTextViewer != null) {
- fCachedTextViewer.addViewportListener(fInternalListener);
- fCachedTextViewer.addTextListener(fInternalListener);
- }
-
- return fCanvas;
- }
-
- /**
- * Hook method for a mouse double click event on the given ruler line.
- *
- * @param rulerLine the ruler line
- */
- protected void mouseDoubleClicked(int rulerLine) {
- }
-
- /**
- * Disposes the ruler's resources.
- */
- private void handleDispose() {
-
- if (fCachedTextViewer != null) {
- fCachedTextViewer.removeViewportListener(fInternalListener);
- fCachedTextViewer.removeTextListener(fInternalListener);
- }
-
- if (fModel != null)
- fModel.removeAnnotationModelListener(fInternalListener);
-
- if (fBuffer != null) {
- fBuffer.dispose();
- fBuffer= null;
- }
-
- fAnnotationTypes.clear();
- fAnnotationAccess= null;
- }
-
- /**
- * Double buffer drawing.
- *
- * @param dest the gc to draw into
- */
- private void doubleBufferPaint(GC dest) {
-
- Point size= fCanvas.getSize();
-
- if (size.x <= 0 || size.y <= 0)
- return;
-
- if (fBuffer != null) {
- Rectangle r= fBuffer.getBounds();
- if (r.width != size.x || r.height != size.y) {
- fBuffer.dispose();
- fBuffer= null;
- }
- }
- if (fBuffer == null)
- fBuffer= new Image(fCanvas.getDisplay(), size.x, size.y);
-
- GC gc= new GC(fBuffer);
- gc.setFont(fCachedTextWidget.getFont());
- try {
- gc.setBackground(fCanvas.getBackground());
- gc.fillRectangle(0, 0, size.x, size.y);
-
- if (fCachedTextViewer instanceof ITextViewerExtension3)
- doPaint1(gc);
- else
- doPaint(gc);
- } finally {
- gc.dispose();
- }
-
- dest.drawImage(fBuffer, 0, 0);
- }
-
- /**
- * Returns the document offset of the upper left corner of the source viewer's
- * viewport, possibly including partially visible lines.
- *
- * @return document offset of the upper left corner including partially visible lines
- */
- protected int getInclusiveTopIndexStartOffset() {
-
- if (fCachedTextWidget != null && !fCachedTextWidget.isDisposed()) {
- int top= fCachedTextViewer.getTopIndex();
- if ((fCachedTextWidget.getTopPixel() % fCachedTextWidget.getLineHeight()) != 0)
- top--;
- try {
- IDocument document= fCachedTextViewer.getDocument();
- return document.getLineOffset(top);
- } catch (BadLocationException ex) {
- }
- }
-
- return -1;
- }
-
- /**
- * Draws the vertical ruler w/o drawing the Canvas background.
- *
- * @param gc the gc to draw into
- */
- protected void doPaint(GC gc) {
-
- if (fModel == null || fCachedTextViewer == null)
- return;
-
- int topLeft= getInclusiveTopIndexStartOffset();
- int bottomRight;
-
- if (fCachedTextViewer instanceof ITextViewerExtension3) {
- ITextViewerExtension3 extension= (ITextViewerExtension3) fCachedTextViewer;
- IRegion coverage= extension.getModelCoverage();
- bottomRight= coverage.getOffset() + coverage.getLength();
- } else if (fCachedTextViewer instanceof TextViewer) {
- // TODO remove once TextViewer implements ITextViewerExtension3
- TextViewer extension= (TextViewer) fCachedTextViewer;
- IRegion coverage= extension.getModelCoverage();
- bottomRight= coverage.getOffset() + coverage.getLength();
- } else {
- // http://dev.eclipse.org/bugs/show_bug.cgi?id=14938
- // http://dev.eclipse.org/bugs/show_bug.cgi?id=22487
- // add 1 as getBottomIndexEndOffset returns the inclusive offset, but we want the exclusive offset (right after the last character)
- bottomRight= fCachedTextViewer.getBottomIndexEndOffset() + 1;
- }
- int viewPort= bottomRight - topLeft;
-
- fScrollPos= fCachedTextWidget.getTopPixel();
- int lineheight= fCachedTextWidget.getLineHeight();
- Point dimension= fCanvas.getSize();
- int shift= fCachedTextViewer.getTopInset();
-
- IDocument doc= fCachedTextViewer.getDocument();
-
- int topLine= -1, bottomLine= -1;
- try {
- IRegion region= fCachedTextViewer.getVisibleRegion();
- topLine= doc.getLineOfOffset(region.getOffset());
- bottomLine= doc.getLineOfOffset(region.getOffset() + region.getLength());
- } catch (BadLocationException x) {
- return;
- }
-
- // draw Annotations
- Rectangle r= new Rectangle(0, 0, 0, 0);
- int maxLayer= 1; // loop at least once thru layers.
-
- for (int layer= 0; layer < maxLayer; layer++) {
- Iterator iter= fModel.getAnnotationIterator();
- while (iter.hasNext()) {
- Annotation annotation= (Annotation) iter.next();
-
- if (fAnnotationAccess != null && skip(fAnnotationAccess.getType(annotation)))
- continue;
-
- int lay= annotation.getLayer();
- maxLayer= Math.max(maxLayer, lay+1); // dynamically update layer maximum
- if (lay != layer) // wrong layer: skip annotation
- continue;
-
- Position position= fModel.getPosition(annotation);
- if (position == null)
- continue;
-
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=20284
- // Position.overlapsWith returns false if the position just starts at the end
- // of the specified range. If the position has zero length, we want to include it anyhow
- int viewPortSize= position.getLength() == 0 ? viewPort + 1 : viewPort;
- if (!position.overlapsWith(topLeft, viewPortSize))
- continue;
-
- try {
-
- int offset= position.getOffset();
- int length= position.getLength();
-
- int startLine= doc.getLineOfOffset(offset);
- if (startLine < topLine)
- startLine= topLine;
-
- int endLine= startLine;
- if (length > 0)
- endLine= doc.getLineOfOffset(offset + length - 1);
- if (endLine > bottomLine)
- endLine= bottomLine;
-
- startLine -= topLine;
- endLine -= topLine;
-
- r.x= 0;
- r.y= (startLine * lineheight) - fScrollPos + shift;
- r.width= dimension.x;
- int lines= endLine - startLine;
- if (lines < 0)
- lines= -lines;
- r.height= (lines+1) * lineheight;
-
- if (r.y < dimension.y) // annotation within visible area
- annotation.paint(gc, fCanvas, r);
-
- } catch (BadLocationException e) {
- }
- }
- }
- }
-
- /**
- * Draws the vertical ruler w/o drawing the Canvas background. Implementation based
- * on <code>ITextViewerExtension3</code>. Will replace <code>doPaint(GC)</code>.
- *
- * @param gc the gc to draw into
- */
- protected void doPaint1(GC gc) {
-
- if (fModel == null || fCachedTextViewer == null)
- return;
-
- ITextViewerExtension3 extension= (ITextViewerExtension3) fCachedTextViewer;
-
- fScrollPos= fCachedTextWidget.getTopPixel();
- int lineheight= fCachedTextWidget.getLineHeight();
- Point dimension= fCanvas.getSize();
- int shift= fCachedTextViewer.getTopInset();
-
- // draw Annotations
- Rectangle r= new Rectangle(0, 0, 0, 0);
- int maxLayer= 1; // loop at least once thru layers.
-
- for (int layer= 0; layer < maxLayer; layer++) {
- Iterator iter= fModel.getAnnotationIterator();
- while (iter.hasNext()) {
-
- Annotation annotation= (Annotation) iter.next();
-
- if (fAnnotationAccess != null && skip(fAnnotationAccess.getType(annotation)))
- continue;
-
- int lay= annotation.getLayer();
- maxLayer= Math.max(maxLayer, lay+1); // dynamically update layer maximum
- if (lay != layer) // wrong layer: skip annotation
- continue;
-
- Position position= fModel.getPosition(annotation);
- if (position == null)
- continue;
-
- IRegion widgetRegion= extension.modelRange2WidgetRange(new Region(position.getOffset(), position.getLength()));
- if (widgetRegion == null)
- continue;
-
- int startLine= extension.widgetLineOfWidgetOffset(widgetRegion.getOffset());
- if (startLine == -1)
- continue;
-
- int endLine= extension.widgetLineOfWidgetOffset(widgetRegion.getOffset() + Math.max(widgetRegion.getLength() -1, 0));
- if (endLine == -1)
- continue;
-
- r.x= 0;
- r.y= (startLine * lineheight) - fScrollPos + shift;
- r.width= dimension.x;
- int lines= endLine - startLine;
- if (lines < 0)
- lines= -lines;
- r.height= (lines+1) * lineheight;
-
- if (r.y < dimension.y) // annotation within visible area
- annotation.paint(gc, fCanvas, r);
- }
- }
- }
-
-
- /**
- * Post a redraw request for this column into the UI thread.
- */
- private void postRedraw() {
- if (fCanvas != null && !fCanvas.isDisposed()) {
- Display d= fCanvas.getDisplay();
- if (d != null) {
- d.asyncExec(new Runnable() {
- public void run() {
- redraw();
- }
- });
- }
- }
- }
-
- /*
- * @see IVerticalRulerColumn#redraw()
- */
- public void redraw() {
- if (fCanvas != null && !fCanvas.isDisposed()) {
- GC gc= new GC(fCanvas);
- doubleBufferPaint(gc);
- gc.dispose();
- }
- }
-
- /*
- * @see IVerticalRulerColumn#setModel
- */
- public void setModel(IAnnotationModel model) {
- if (fAllowSetModel && model != fModel) {
-
- if (fModel != null)
- fModel.removeAnnotationModelListener(fInternalListener);
-
- fModel= model;
-
- if (fModel != null)
- fModel.addAnnotationModelListener(fInternalListener);
-
- postRedraw();
- }
- }
-
- /*
- * @see IVerticalRulerColumn#setFont(Font)
- */
- public void setFont(Font font) {
- }
-
- /**
- * Returns the cached text viewer.
- *
- * @return the cached text viewer
- */
- protected ITextViewer getCachedTextViewer() {
- return fCachedTextViewer;
- }
-
- /**
- * Returns this column's annotation model.
- *
- * @return this column's annotation model
- */
- protected IAnnotationModel getModel() {
- return fModel;
- }
-
- /**
- * Adds the given annotation type to this annotation ruler column. Starting
- * with this call, annotations of the given type are shown in this annotation
- * ruler column.
- *
- * @param annotationType the annotation type
- * @since 3.0
- */
- public void addAnnotationType(Object annotationType) {
- fAnnotationTypes.add(annotationType);
- }
-
- /**
- * Removes the given annotation type from this annotation ruler column.
- * Annotations of the given type are no longer shown in this annotation
- * ruler column.
- *
- * @param annotationType the annotation type
- * @since 3.0
- */
- public void removeAnnotationType(Object annotationType) {
- fAnnotationTypes.remove(annotationType);
- }
-
- /**
- * Returns whether annotation of the given annotation type should be skipped
- * by the drawing routine.
- *
- * @param annotationType the annotation type
- * @return <code>true</code> if annotation of the given type should be skipped
- * @since 3.0
- */
- private boolean skip(Object annotationType) {
- if (annotationType == null)
- return false;
- return !fAnnotationTypes.contains(annotationType);
- }
-}
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
deleted file mode 100644
index f159c45bdb1..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ChangeRulerColumn.java
+++ /dev/null
@@ -1,676 +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.custom.StyledText;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.MouseMoveListener;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Cursor;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextListener;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.ITextViewerExtension3;
-import org.eclipse.jface.text.IViewportListener;
-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.
- *
- * @since 3.0
- */
-public final class ChangeRulerColumn implements IVerticalRulerColumn, IVerticalRulerInfo, IVerticalRulerInfoExtension, IChangeRulerColumn {
-
- /**
- * Handles all the mouse interaction in this line number ruler column.
- */
- class MouseHandler implements MouseListener, MouseMoveListener {
-
- /*
- * @see org.eclipse.swt.events.MouseListener#mouseUp(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseUp(MouseEvent event) {
- }
-
- /*
- * @see org.eclipse.swt.events.MouseListener#mouseDown(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseDown(MouseEvent event) {
- fParentRuler.setLocationOfLastMouseButtonActivity(event.x, event.y);
- }
-
- /*
- * @see org.eclipse.swt.events.MouseListener#mouseDoubleClick(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseDoubleClick(MouseEvent event) {
- fParentRuler.setLocationOfLastMouseButtonActivity(event.x, event.y);
- }
-
- /*
- * @see org.eclipse.swt.events.MouseMoveListener#mouseMove(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseMove(MouseEvent e) {
- if (fCachedTextViewer!= null) {
- int line= toDocumentLineNumber(e.y);
- ILineDiffInfo info= getDiffInfo(line);
- Cursor cursor;
- if (info != null && info.hasChanges())
- cursor= fHitDetectionCursor;
- else
- cursor= null;
- if (cursor != fLastCursor) {
- fCanvas.setCursor(cursor);
- fLastCursor= cursor;
- }
- }
-
- }
-
- }
-
- /**
- * Internal listener class.
- */
- class InternalListener implements IViewportListener, ITextListener {
-
- /*
- * @see IViewportListener#viewportChanged(int)
- */
- public void viewportChanged(int verticalPosition) {
- if (verticalPosition != fScrollPos)
- redraw();
- }
-
- /*
- * @see ITextListener#textChanged(TextEvent)
- */
- public void textChanged(TextEvent event) {
-
- if (!event.getViewerRedrawState())
- return;
-
- if (fSensitiveToTextChanges || event.getDocumentEvent() == null)
- postRedraw();
-
- }
- }
-
- /**
- * Internal listener class that will update the ruler when the underlying model changes.
- */
- class AnnotationListener implements IAnnotationModelListener {
- /*
- * @see org.eclipse.jface.text.source.IAnnotationModelListener#modelChanged(org.eclipse.jface.text.source.IAnnotationModel)
- */
- public void modelChanged(IAnnotationModel model) {
- postRedraw();
- }
- }
-
- /** This column's parent ruler */
- private CompositeRuler fParentRuler;
- /** Cached text viewer */
- private ITextViewer fCachedTextViewer;
- /** Cached text widget */
- private StyledText fCachedTextWidget;
- /** The columns canvas */
- private Canvas fCanvas;
- /** Cache for the actual scroll position in pixels */
- private int fScrollPos;
- /** The drawable for double buffering */
- private Image fBuffer;
- /** The internal listener */
- private InternalListener fInternalListener= new InternalListener();
- /** Indicates whether this column reacts on text change events */
- private boolean fSensitiveToTextChanges= false;
- /** The foreground color */
- private Color fForeground;
- /** The background color */
- private Color fBackground;
- /** Color for changed lines */
- private Color fAddedColor;
- /** Color for added lines */
- private Color fChangedColor;
- /** Color for the deleted line indicator */
- private Color fDeletedColor;
- /** The ruler's annotation model. */
- private IAnnotationModel fAnnotationModel;
- /** The ruler's hover */
- private IAnnotationHover fHover;
- /** The internal listener */
- private AnnotationListener fAnnotationListener= new AnnotationListener();
- /** The width of the change ruler column. */
- private int fWidth= 5;
- /** The hand cursor that will show when hovering over a change. */
- Cursor fHitDetectionCursor;
- /** The last used cursor. */
- Cursor fLastCursor;
-
-
- /**
- * Returns the System background color for list widgets.
- *
- * @param display the display the drawing occurs on
- * @return the System background color for list widgets
- */
- protected Color getBackground(Display display) {
- if (fBackground == null)
- return display.getSystemColor(SWT.COLOR_LIST_BACKGROUND);
- return fBackground;
- }
-
- /*
- * @see IVerticalRulerColumn#createControl(CompositeRuler, Composite)
- */
- public Control createControl(CompositeRuler parentRuler, Composite parentControl) {
-
- fParentRuler= parentRuler;
- fCachedTextViewer= parentRuler.getTextViewer();
- fCachedTextWidget= fCachedTextViewer.getTextWidget();
-
- fCanvas= new Canvas(parentControl, SWT.NONE);
- fCanvas.setBackground(getBackground(fCanvas.getDisplay()));
- fCanvas.setForeground(fForeground);
-
- fHitDetectionCursor= new Cursor(parentControl.getDisplay(), SWT.CURSOR_HAND);
-
- fCanvas.addPaintListener(new PaintListener() {
- public void paintControl(PaintEvent event) {
- if (fCachedTextViewer != null)
- doubleBufferPaint(event.gc);
- }
- });
-
- fCanvas.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- handleDispose();
- fCachedTextViewer= null;
- fCachedTextWidget= null;
- }
- });
-
- MouseHandler mouseHandler= new MouseHandler();
-
- fCanvas.addMouseListener(mouseHandler);
-
- fCanvas.addMouseMoveListener(mouseHandler);
-
- if (fCachedTextViewer != null) {
-
- fCachedTextViewer.addViewportListener(fInternalListener);
- fCachedTextViewer.addTextListener(fInternalListener);
- }
-
- return fCanvas;
- }
-
- /**
- * Disposes the column's resources.
- */
- protected void handleDispose() {
-
- if (fAnnotationModel != null) {
- fAnnotationModel.removeAnnotationModelListener(fAnnotationListener);
- fAnnotationModel= null;
- }
-
- if (fCachedTextViewer != null) {
- fCachedTextViewer.removeViewportListener(fInternalListener);
- fCachedTextViewer.removeTextListener(fInternalListener);
- }
-
- if (fHitDetectionCursor != null) {
- fHitDetectionCursor.dispose();
- fHitDetectionCursor= null;
- }
-
- if (fBuffer != null) {
- fBuffer.dispose();
- fBuffer= null;
- }
- }
-
- /**
- * Double buffer drawing.
- *
- * @param dest the gc to draw into
- */
- private void doubleBufferPaint(GC dest) {
-
- Point size= fCanvas.getSize();
-
- if (size.x <= 0 || size.y <= 0)
- return;
-
- if (fBuffer != null) {
- Rectangle r= fBuffer.getBounds();
- if (r.width != size.x || r.height != size.y) {
- fBuffer.dispose();
- fBuffer= null;
- }
- }
- if (fBuffer == null)
- fBuffer= new Image(fCanvas.getDisplay(), size.x, size.y);
-
- GC gc= new GC(fBuffer);
- gc.setFont(fCanvas.getFont());
- if (fForeground != null)
- gc.setForeground(fForeground);
-
- try {
- gc.setBackground(getBackground(fCanvas.getDisplay()));
- gc.fillRectangle(0, 0, size.x, size.y);
-
- if (fCachedTextViewer instanceof ITextViewerExtension3)
- doPaint1(gc);
- else
- doPaint(gc);
-
- } finally {
- gc.dispose();
- }
-
- dest.drawImage(fBuffer, 0, 0);
- }
-
- /**
- * Returns the viewport height in lines.
- *
- * @return the viewport height in lines
- */
- protected int getVisibleLinesInViewport() {
- Rectangle clArea= fCachedTextWidget.getClientArea();
- if (!clArea.isEmpty())
- return clArea.height / fCachedTextWidget.getLineHeight();
- return -1;
- }
-
- /**
- * Draws the ruler column.
- *
- * @param gc the gc to draw into
- */
- private void doPaint(GC gc) {
-
- if (fCachedTextViewer == null)
- return;
-
- if (fCachedTextWidget == null)
- return;
-
-
- int firstLine= 0;
-
- int topLine= fCachedTextViewer.getTopIndex() -1;
- int bottomLine= fCachedTextViewer.getBottomIndex() + 1;
-
- try {
-
- IRegion region= fCachedTextViewer.getVisibleRegion();
- IDocument doc= fCachedTextViewer.getDocument();
-
- if (doc == null)
- return;
-
- firstLine= doc.getLineOfOffset(region.getOffset());
- if (firstLine > topLine)
- topLine= firstLine;
-
- int lastLine= doc.getLineOfOffset(region.getOffset() + region.getLength());
- if (lastLine < bottomLine)
- bottomLine= lastLine;
-
- } catch (BadLocationException x) {
- return;
- }
-
- fSensitiveToTextChanges= bottomLine - topLine < getVisibleLinesInViewport();
-
- int lineheight= fCachedTextWidget.getLineHeight();
- fScrollPos= fCachedTextWidget.getTopPixel();
- int canvasheight= fCanvas.getSize().y;
-
- int y= ((topLine - firstLine) * lineheight) - fScrollPos + fCachedTextViewer.getTopInset();
- for (int line= topLine; line <= bottomLine; line++, y+= lineheight) {
-
- if (y >= canvasheight)
- break;
-
- paintLine(line, y, lineheight, gc, fCachedTextWidget.getDisplay());
- }
- }
-
- /**
- * Draws the ruler column. Uses <code>ITextViewerExtension3</code> for the
- * implementation. Will replace <code>doPinat(GC)</code>.
- *
- * @param gc the gc to draw into
- */
- private void doPaint1(GC gc) {
-
- if (fCachedTextViewer == null)
- return;
-
- ITextViewerExtension3 extension= (ITextViewerExtension3) fCachedTextViewer;
-
- int firstLine= 0;
-
-
- int widgetTopLine= fCachedTextWidget.getTopIndex();
- if (widgetTopLine > 0)
- -- widgetTopLine;
-
- int topLine= extension.widgetlLine2ModelLine(widgetTopLine);
- int bottomLine= fCachedTextViewer.getBottomIndex();
- if (bottomLine >= 0)
- ++ bottomLine;
-
- try {
-
- IRegion region= extension.getModelCoverage();
- IDocument doc= fCachedTextViewer.getDocument();
-
- if (doc == null)
- return;
-
- firstLine= doc.getLineOfOffset(region.getOffset());
- if (firstLine > topLine || topLine == -1)
- topLine= firstLine;
-
- int lastLine= doc.getLineOfOffset(region.getOffset() + region.getLength());
- if (lastLine < bottomLine || bottomLine == -1)
- bottomLine= lastLine;
-
- } catch (BadLocationException x) {
- return;
- }
-
- fSensitiveToTextChanges= bottomLine - topLine < getVisibleLinesInViewport();
-
- int lineheight= fCachedTextWidget.getLineHeight();
- fScrollPos= fCachedTextWidget.getTopPixel();
- int canvasheight= fCanvas.getSize().y;
-
- int y= (widgetTopLine * lineheight) - fScrollPos + fCachedTextViewer.getTopInset();
- for (int modelLine= topLine; modelLine <= bottomLine; modelLine++) {
-
- if (y >= canvasheight)
- break;
-
- int widgetLine= extension.modelLine2WidgetLine(modelLine);
- if (widgetLine == -1)
- continue;
-
- paintLine(modelLine, y, lineheight, gc, fCachedTextWidget.getDisplay());
-
- y+= lineheight;
- }
- }
-
- /*
- * @see IVerticalRulerColumn#redraw()
- */
- public void redraw() {
-
- if (fCanvas != null && !fCanvas.isDisposed()) {
- GC gc= new GC(fCanvas);
- doubleBufferPaint(gc);
- gc.dispose();
- }
- }
-
- /*
- * @see IVerticalRulerColumn#setFont(Font)
- */
- public void setFont(Font font) {
- }
-
- /**
- * Returns the parent (composite) ruler of this ruler column.
- *
- * @return the parent ruler
- * @since 3.0
- */
- protected CompositeRuler getParentRuler() {
- return fParentRuler;
- }
-
- /*
- * @see org.eclipse.jface.text.source.LineNumberRulerColumn#paintLineHook(int, int, int, org.eclipse.swt.graphics.GC)
- */
- protected void paintLine(int line, int y, int lineheight, GC gc, Display display) {
- ILineDiffInfo info= getDiffInfo(line);
-
- if (info != null) {
- // width of the column
- int width= getWidth();
-
- // draw background color if special
- if (hasSpecialColor(info)) {
- gc.setBackground(getColor(info, display));
- gc.fillRectangle(0, y, width, lineheight);
- }
-
- /* Deletion Indicator: Simply a horizontal line */
- int delBefore= info.getRemovedLinesAbove();
- int delBelow= info.getRemovedLinesBelow();
- if (delBefore > 0 || delBelow > 0) {
- Color deletionColor= getDeletionColor(display);
- gc.setForeground(deletionColor);
-
- if (delBefore > 0) {
- gc.drawLine(0, y, width, y);
- }
-
- if (delBelow > 0) {
- gc.drawLine(0, y + lineheight - 1, width, y + lineheight - 1);
- }
- }
- }
- }
-
- /**
- * Returns whether the line background differs from the default.
- *
- * @param info the info being queried
- * @return <code>true</code> if <code>info</code> describes either a changed or an added line.
- */
- private boolean hasSpecialColor(ILineDiffInfo info) {
- return info.getType() == ILineDiffInfo.ADDED || info.getType() == ILineDiffInfo.CHANGED;
- }
-
- /**
- * Retrieves the <code>ILineDiffInfo</code> for <code>line</code> from the model.
- * There are optimizations for direct access and sequential access patterns.
- *
- * @param line the line we want the info for.
- * @return the <code>ILineDiffInfo</code> for <code>line</code>, or <code>null</code>.
- */
- private ILineDiffInfo getDiffInfo(int line) {
- if (fAnnotationModel == null)
- return null;
-
- // assume direct access
- if (fAnnotationModel instanceof ILineDiffer) {
- ILineDiffer differ= (ILineDiffer)fAnnotationModel;
- return differ.getLineInfo(line);
- }
-
- return null;
- }
-
- /**
- * Returns the color for deleted lines.
- *
- * @return the color to be used for the deletion indicator
- */
- private Color getDeletionColor(Display display) {
- return fDeletedColor == null ? getBackground(display) : fDeletedColor;
- }
-
- /**
- * Returns the color for the given line diff info.
- *
- * @param info the <code>ILineDiffInfo</code> being queried
- * @param display the display that the drawing occurs on
- * @return the correct background color for the line type being described by <code>info</code>
- */
- private Color getColor(ILineDiffInfo info, Display display) {
- Assert.isTrue(info != null && info.getType() != ILineDiffInfo.UNCHANGED);
- Color ret= null;
- switch (info.getType()) {
- case ILineDiffInfo.CHANGED :
- ret= fChangedColor;
- break;
- case ILineDiffInfo.ADDED :
- ret= fAddedColor;
- break;
- }
- return ret == null ? getBackground(display) : ret;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerInfo#getLineOfLastMouseButtonActivity()
- */
- public int getLineOfLastMouseButtonActivity() {
- return getParentRuler().getLineOfLastMouseButtonActivity();
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerInfo#toDocumentLineNumber(int)
- */
- public int toDocumentLineNumber(int y_coordinate) {
- return getParentRuler().toDocumentLineNumber(y_coordinate);
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#getHover()
- */
- public IAnnotationHover getHover() {
- return fHover;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IChangeRulerColumn#setHover(org.eclipse.jface.text.source.IAnnotationHover)
- */
- public void setHover(IAnnotationHover hover) {
- fHover= hover;
- }
-
- /*
- * @see IVerticalRulerColumn#setModel(IAnnotationModel)
- */
- public void setModel(IAnnotationModel model) {
- IAnnotationModel newModel;
- if (model instanceof IAnnotationModelExtension) {
- newModel= ((IAnnotationModelExtension)model).getAnnotationModel(QUICK_DIFF_MODEL_ID);
- } else {
- newModel= model;
- }
- if (fAnnotationModel != newModel) {
- if (fAnnotationModel != null) {
- fAnnotationModel.removeAnnotationModelListener(fAnnotationListener);
- }
- fAnnotationModel= newModel;
- if (fAnnotationModel != null) {
- fAnnotationModel.addAnnotationModelListener(fAnnotationListener);
- }
- redraw();
- }
- }
-
- /*
- * @see org.eclipse.jface.text.source.IChangeRulerColumn#setBackground(org.eclipse.swt.graphics.Color)
- */
- public void setBackground(Color background) {
- fBackground= background;
- if (fCanvas != null && !fCanvas.isDisposed())
- fCanvas.setBackground(getBackground(fCanvas.getDisplay()));
- }
-
- /*
- * @see org.eclipse.jface.text.source.IChangeRulerColumn#setAddedColor(org.eclipse.swt.graphics.Color)
- */
- public void setAddedColor(Color addedColor) {
- fAddedColor= addedColor;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IChangeRulerColumn#setChangedColor(org.eclipse.swt.graphics.Color)
- */
- public void setChangedColor(Color changedColor) {
- fChangedColor= changedColor;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IChangeRulerColumn#setDeletedColor(org.eclipse.swt.graphics.Color)
- */
- public void setDeletedColor(Color deletedColor) {
- fDeletedColor= deletedColor;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#getModel()
- */
- public IAnnotationModel getModel() {
- return fAnnotationModel;
- }
-
- /*
- * @see IVerticalRulerColumn#getControl()
- */
- public Control getControl() {
- return fCanvas;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerInfo#getWidth()
- */
- public int getWidth() {
- return fWidth;
- }
-
- /**
- * Triggers a redraw in the display thread.
- */
- protected final void postRedraw() {
- if (fCanvas != null && !fCanvas.isDisposed()) {
- Display d= fCanvas.getDisplay();
- if (d != null) {
- d.asyncExec(new Runnable() {
- public void run() {
- redraw();
- }
- });
- }
- }
- }
-}
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
deleted file mode 100644
index 03bc668781a..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/CompositeRuler.java
+++ /dev/null
@@ -1,774 +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.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.ControlListener;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.HelpListener;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.MouseMoveListener;
-import org.eclipse.swt.events.MouseTrackListener;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.events.TraverseListener;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.internal.SWTEventListener;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Layout;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Menu;
-
-import org.eclipse.jface.text.Assert;
-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.ITextViewerExtension;
-import org.eclipse.jface.text.ITextViewerExtension3;
-
-
-/**
- * Standard implementation of <code>IVerticalRuler</code>. This ruler does not have a
- * a visual representation of its own. The presentation comes from the configurable list
- * of decorators. Decorators must implement the <code>IVerticalRulerColumn</code>
- * interface.<p>
- * Clients may instantiate and configure this class.
- *
- * @see IVerticalRulerColumn
- * @see ITextViewer
- * @since 2.0
- */
-public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension {
-
-
- /**
- * Layout of the composite vertical ruler. Arranges the list of decorators.
- */
- class RulerLayout extends Layout {
-
- /**
- * Creates the new ruler layout.
- */
- protected RulerLayout() {
- }
-
- /*
- * @see Layout#computeSize(Composite, int, int, boolean)
- */
- protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) {
- Control[] children= composite.getChildren();
- Point size= new Point(0, 0);
- for (int i= 0; i < children.length; i++) {
- Point s= children[i].computeSize(SWT.DEFAULT, SWT.DEFAULT, flushCache);
- size.x += s.x;
- size.y= Math.max(size.y, s.y);
- }
- size.x += (Math.max(0, children.length -1) * fGap);
- return size;
- }
-
- /*
- * @see Layout#layout(Composite, boolean)
- */
- protected void layout(Composite composite, boolean flushCache) {
- Rectangle clArea= composite.getClientArea();
- int rulerHeight= clArea.height;
-
- int x= 0;
- Iterator e= fDecorators.iterator();
- while (e.hasNext()) {
- IVerticalRulerColumn column= (IVerticalRulerColumn) e.next();
- int columnWidth= column.getWidth();
- column.getControl().setBounds(x, 0, columnWidth, rulerHeight);
- x += (columnWidth + fGap);
- }
- }
- }
-
- /**
- * A canvas that adds listeners to all its children. Used by the implementation of the
- * vertical ruler to propagate listener additions and removals to the ruler's columns.
- */
- static class CompositeRulerCanvas extends Canvas {
-
- /**
- * Keeps the information for which event type a listener object has been added.
- */
- static class ListenerInfo {
- Class fClass;
- SWTEventListener fListener;
- }
-
- /** The list of listeners added to this canvas. */
- private List fCachedListeners= new ArrayList();
- /** Internal listener for opening the context menu. */
- private Listener fMenuDetectListener;
-
- /**
- * Creates a new composite ruler canvas.
- *
- * @param parent the parent composite
- * @param style the SWT styles
- */
- public CompositeRulerCanvas(Composite parent, int style) {
- super(parent, style);
- fMenuDetectListener= new Listener() {
- public void handleEvent(Event event) {
- if (event.type == SWT.MenuDetect) {
- Menu menu= getMenu();
- if (menu != null) {
- menu.setLocation(event.x, event.y);
- menu.setVisible(true);
- }
- }
- }
- };
- super.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- if (fCachedListeners != null) {
- fCachedListeners.clear();
- fCachedListeners= null;
- }
- }
- });
- }
-
- /**
- * Adds the given listener object as listner of the given type (<code>clazz</code>) to
- * the given control.
- *
- * @param clazz the listener type
- * @param control the control to add the listener to
- * @param listener the listener to be added
- */
- private void addListener(Class clazz, Control control, SWTEventListener listener) {
- if (ControlListener.class.equals(clazz)) {
- control. addControlListener((ControlListener) listener);
- return;
- }
- if (FocusListener.class.equals(clazz)) {
- control. addFocusListener((FocusListener) listener);
- return;
- }
- if (HelpListener.class.equals(clazz)) {
- control. addHelpListener((HelpListener) listener);
- return;
- }
- if (KeyListener.class.equals(clazz)) {
- control. addKeyListener((KeyListener) listener);
- return;
- }
- if (MouseListener.class.equals(clazz)) {
- control. addMouseListener((MouseListener) listener);
- return;
- }
- if (MouseMoveListener.class.equals(clazz)) {
- control. addMouseMoveListener((MouseMoveListener) listener);
- return;
- }
- if (MouseTrackListener.class.equals(clazz)) {
- control. addMouseTrackListener((MouseTrackListener) listener);
- return;
- }
- if (PaintListener.class.equals(clazz)) {
- control. addPaintListener((PaintListener) listener);
- return;
- }
- if (TraverseListener.class.equals(clazz)) {
- control. addTraverseListener((TraverseListener) listener);
- return;
- }
- if (DisposeListener.class.equals(clazz)) {
- control. addDisposeListener((DisposeListener) listener);
- return;
- }
- }
-
- /**
- * Removes the given listener object as listner of the given type (<code>clazz</code>) from
- * the given control.
- *
- * @param clazz the listener type
- * @param control the control to remove the listener from
- * @param listener the listener to be removed
- */
- private void removeListener(Class clazz, Control control, SWTEventListener listener) {
- if (ControlListener.class.equals(clazz)) {
- control. removeControlListener((ControlListener) listener);
- return;
- }
- if (FocusListener.class.equals(clazz)) {
- control. removeFocusListener((FocusListener) listener);
- return;
- }
- if (HelpListener.class.equals(clazz)) {
- control. removeHelpListener((HelpListener) listener);
- return;
- }
- if (KeyListener.class.equals(clazz)) {
- control. removeKeyListener((KeyListener) listener);
- return;
- }
- if (MouseListener.class.equals(clazz)) {
- control. removeMouseListener((MouseListener) listener);
- return;
- }
- if (MouseMoveListener.class.equals(clazz)) {
- control. removeMouseMoveListener((MouseMoveListener) listener);
- return;
- }
- if (MouseTrackListener.class.equals(clazz)) {
- control. removeMouseTrackListener((MouseTrackListener) listener);
- return;
- }
- if (PaintListener.class.equals(clazz)) {
- control. removePaintListener((PaintListener) listener);
- return;
- }
- if (TraverseListener.class.equals(clazz)) {
- control. removeTraverseListener((TraverseListener) listener);
- return;
- }
- if (DisposeListener.class.equals(clazz)) {
- control. removeDisposeListener((DisposeListener) listener);
- return;
- }
- }
-
- /**
- * Adds the given listener object to the internal book keeping under
- * the given listener type (<code>clazz</code>).
- *
- * @param clazz the listener type
- * @param listener the listener object
- */
- private void addListener(Class clazz, SWTEventListener listener) {
- Control[] children= getChildren();
- for (int i= 0; i < children.length; i++) {
- if (children[i] != null && !children[i].isDisposed())
- addListener(clazz, children[i], listener);
- }
-
- ListenerInfo info= new ListenerInfo();
- info.fClass= clazz;
- info.fListener= listener;
- fCachedListeners.add(info);
- }
-
- /**
- * Removes the given listener object from the internal book keeping under
- * the given listener type (<code>clazz</code>).
- *
- * @param clazz the listener type
- * @param listener the listener object
- */
- private void removeListener(Class clazz, SWTEventListener listener) {
- int length= fCachedListeners.size();
- for (int i= 0; i < length; i++) {
- ListenerInfo info= (ListenerInfo) fCachedListeners.get(i);
- if (listener == info.fListener && clazz.equals(info.fClass)) {
- fCachedListeners.remove(i);
- break;
- }
- }
-
- Control[] children= getChildren();
- for (int i= 0; i < children.length; i++) {
- if (children[i] != null && !children[i].isDisposed())
- removeListener(clazz, children[i], listener);
- }
- }
-
- /**
- * Tells this canvas that a child has been added.
- *
- * @param child the child
- */
- public void childAdded(Control child) {
- if (child != null && !child.isDisposed()) {
- int length= fCachedListeners.size();
- for (int i= 0; i < length; i++) {
- ListenerInfo info= (ListenerInfo) fCachedListeners.get(i);
- addListener(info.fClass, child, info.fListener);
- }
- child.addListener(SWT.MenuDetect, fMenuDetectListener);
- }
- }
-
- /**
- * Tells this canvas that a child has been removed.
- *
- * @param child the child
- */
- public void childRemoved(Control child) {
- if (child != null && !child.isDisposed()) {
- int length= fCachedListeners.size();
- for (int i= 0; i < length; i++) {
- ListenerInfo info= (ListenerInfo) fCachedListeners.get(i);
- removeListener(info.fClass, child, info.fListener);
- }
- child.removeListener(SWT.MenuDetect, fMenuDetectListener);
- }
- }
-
- /*
- * @see Control#removeControlListener(ControlListener)
- */
- public void removeControlListener(ControlListener listener) {
- removeListener(ControlListener.class, listener);
- super.removeControlListener(listener);
- }
-
- /*
- * @see Control#removeFocusListener(FocusListener)
- */
- public void removeFocusListener(FocusListener listener) {
- removeListener(FocusListener.class, listener);
- super.removeFocusListener(listener);
- }
-
- /*
- * @see Control#removeHelpListener(HelpListener)
- */
- public void removeHelpListener(HelpListener listener) {
- removeListener(HelpListener.class, listener);
- super.removeHelpListener(listener);
- }
-
- /*
- * @see Control#removeKeyListener(KeyListener)
- */
- public void removeKeyListener(KeyListener listener) {
- removeListener(KeyListener.class, listener);
- super.removeKeyListener(listener);
- }
-
- /*
- * @see Control#removeMouseListener(MouseListener)
- */
- public void removeMouseListener(MouseListener listener) {
- removeListener(MouseListener.class, listener);
- super.removeMouseListener(listener);
- }
-
- /*
- * @see Control#removeMouseMoveListener(MouseMoveListener)
- */
- public void removeMouseMoveListener(MouseMoveListener listener) {
- removeListener(MouseMoveListener.class, listener);
- super.removeMouseMoveListener(listener);
- }
-
- /*
- * @see Control#removeMouseTrackListener(MouseTrackListener)
- */
- public void removeMouseTrackListener(MouseTrackListener listener) {
- removeListener(MouseTrackListener.class, listener);
- super.removeMouseTrackListener(listener);
- }
-
- /*
- * @see Control#removePaintListener(PaintListener)
- */
- public void removePaintListener(PaintListener listener) {
- removeListener(PaintListener.class, listener);
- super.removePaintListener(listener);
- }
-
- /*
- * @see Control#removeTraverseListener(TraverseListener)
- */
- public void removeTraverseListener(TraverseListener listener) {
- removeListener(TraverseListener.class, listener);
- super.removeTraverseListener(listener);
- }
-
- /*
- * @see Widget#removeDisposeListener(DisposeListener)
- */
- public void removeDisposeListener(DisposeListener listener) {
- removeListener(DisposeListener.class, listener);
- super.removeDisposeListener(listener);
- }
-
- /*
- * @seeControl#addControlListener(ControlListener)
- */
- public void addControlListener(ControlListener listener) {
- super.addControlListener(listener);
- addListener(ControlListener.class, listener);
- }
-
- /*
- * @see Control#addFocusListener(FocusListener)
- */
- public void addFocusListener(FocusListener listener) {
- super.addFocusListener(listener);
- addListener(FocusListener.class, listener);
- }
-
- /*
- * @see Control#addHelpListener(HelpListener)
- */
- public void addHelpListener(HelpListener listener) {
- super.addHelpListener(listener);
- addListener(HelpListener.class, listener);
- }
-
- /*
- * @see Control#addKeyListener(KeyListener)
- */
- public void addKeyListener(KeyListener listener) {
- super.addKeyListener(listener);
- addListener(KeyListener.class, listener);
- }
-
- /*
- * @see Control#addMouseListener(MouseListener)
- */
- public void addMouseListener(MouseListener listener) {
- super.addMouseListener(listener);
- addListener(MouseListener.class, listener);
- }
-
- /*
- * @see Control#addMouseMoveListener(MouseMoveListener)
- */
- public void addMouseMoveListener(MouseMoveListener listener) {
- super.addMouseMoveListener(listener);
- addListener(MouseMoveListener.class, listener);
- }
-
- /*
- * @see Control#addMouseTrackListener(MouseTrackListener)
- */
- public void addMouseTrackListener(MouseTrackListener listener) {
- super.addMouseTrackListener(listener);
- addListener(MouseTrackListener.class, listener);
- }
-
- /*
- * @seeControl#addPaintListener(PaintListener)
- */
- public void addPaintListener(PaintListener listener) {
- super.addPaintListener(listener);
- addListener(PaintListener.class, listener);
- }
-
- /*
- * @see Control#addTraverseListener(TraverseListener)
- */
- public void addTraverseListener(TraverseListener listener) {
- super.addTraverseListener(listener);
- addListener(TraverseListener.class, listener);
- }
-
- /*
- * @see Widget#addDisposeListener(DisposeListener)
- */
- public void addDisposeListener(DisposeListener listener) {
- super.addDisposeListener(listener);
- addListener(DisposeListener.class, listener);
- }
- }
-
- /** The ruler's viewer */
- private ITextViewer fTextViewer;
- /** The ruler's canvas to which to add the ruler columns */
- private CompositeRulerCanvas fComposite;
- /** The ruler's annotation model */
- private IAnnotationModel fModel;
- /** The list of decorators */
- private List fDecorators= new ArrayList(2);
- /** The cached location of the last mouse button activity */
- private Point fLocation= new Point(-1, -1);
- /** The cached line of the list mouse button activity */
- private int fLastMouseButtonActivityLine= -1;
- /** The gap between the individual columns of this composite ruler */
- private int fGap;
-
-
- /**
- * Constructs a new composite vertical ruler.
- */
- public CompositeRuler() {
- this(0);
- }
-
- /**
- * Constructs a new composite ruler with the given gap between its columns.
- *
- * @param gap
- */
- public CompositeRuler(int gap) {
- fGap= gap;
- }
-
- /**
- * Inserts the given decorator at the specfied slot to this composite ruler.
- * Decorators are counted from left to right.
- *
- * @param index the index
- * @param rulerColumn the decorator to be inserted
- */
- public void addDecorator(int index, IVerticalRulerColumn rulerColumn) {
- if (index > fDecorators.size())
- fDecorators.add(rulerColumn);
- else
- fDecorators.add(index, rulerColumn);
-
- if (fComposite != null && !fComposite.isDisposed()) {
- rulerColumn.createControl(this, fComposite);
- fComposite.childAdded(rulerColumn.getControl());
- layoutTextViewer();
- }
- }
-
- /**
- * Removes the decorator in the specified slot from this composite ruler.
- *
- * @param index the index
- */
- public void removeDecorator(int index) {
- IVerticalRulerColumn rulerColumn= (IVerticalRulerColumn) fDecorators.get(index);
- removeDecorator(rulerColumn);
- }
-
- /**
- * Removes the given decorator from the composite ruler.
- *
- * @param rulerColumn the ruler column to be removed
- * @since 3.0
- */
- public void removeDecorator(IVerticalRulerColumn rulerColumn) {
- fDecorators.remove(rulerColumn);
- if (rulerColumn != null) {
- Control cc= rulerColumn.getControl();
- if (cc != null && !cc.isDisposed()) {
- fComposite.childRemoved(cc);
- cc.dispose();
- }
- }
- layoutTextViewer();
- }
-
- /**
- * Relayouts the text viewer. This also causes this ruler to get
- * relayouted.
- */
- private void layoutTextViewer() {
-
- Control parent= fTextViewer.getTextWidget();
-
- if (fTextViewer instanceof ITextViewerExtension) {
- ITextViewerExtension extension= (ITextViewerExtension) fTextViewer;
- parent= extension.getControl();
- }
-
- if (parent instanceof Composite && !parent.isDisposed())
- ((Composite) parent).layout(true);
- }
-
- /*
- * @see IVerticalRuler#getControl()
- */
- public Control getControl() {
- return fComposite;
- }
-
- /*
- * @see IVerticalRuler#createControl(Composite, ITextViewer)
- */
- public Control createControl(Composite parent, ITextViewer textViewer) {
-
- fTextViewer= textViewer;
-
- fComposite= new CompositeRulerCanvas(parent, SWT.NONE);
- fComposite.setLayout(new RulerLayout());
-
- Iterator iter= fDecorators.iterator();
- while (iter.hasNext()) {
- IVerticalRulerColumn column= (IVerticalRulerColumn) iter.next();
- column.createControl(this, fComposite);
- fComposite.childAdded(column.getControl());
- }
-
- parent.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- fTextViewer= null;
- fComposite= null;
- fModel= null;
- fDecorators.clear();
- }
- });
-
- return fComposite;
- }
-
- /*
- * @see IVerticalRuler#setModel(IAnnotationModel)
- */
- public void setModel(IAnnotationModel model) {
-
- fModel= model;
-
- Iterator e= fDecorators.iterator();
- while (e.hasNext()) {
- IVerticalRulerColumn column= (IVerticalRulerColumn) e.next();
- column.setModel(model);
- }
- }
-
- /*
- * @see IVerticalRuler#getModel()
- */
- public IAnnotationModel getModel() {
- return fModel;
- }
-
- /*
- * @see IVerticalRuler#update()
- */
- public void update() {
- if (fComposite != null && !fComposite.isDisposed()) {
- Display d= fComposite.getDisplay();
- if (d != null) {
- d.asyncExec(new Runnable() {
- public void run() {
- Iterator e= fDecorators.iterator();
- while (e.hasNext()) {
- IVerticalRulerColumn column= (IVerticalRulerColumn) e.next();
- column.redraw();
- }
- }
- });
- }
- }
- }
-
- /*
- * @see IVerticalRulerExtension#setFont(Font)
- */
- public void setFont(Font font) {
- Iterator e= fDecorators.iterator();
- while (e.hasNext()) {
- IVerticalRulerColumn column= (IVerticalRulerColumn) e.next();
- column.setFont(font);
- }
- }
-
- /*
- * @see IVerticalRulerInfo#getWidth()
- */
- public int getWidth() {
- int width= 0;
- Iterator e= fDecorators.iterator();
- while (e.hasNext()) {
- IVerticalRulerColumn column= (IVerticalRulerColumn) e.next();
- width += (column.getWidth() + fGap);
- }
- return Math.max(0, width - fGap);
- }
-
- /*
- * @see IVerticalRulerInfo#getLineOfLastMouseButtonActivity()
- */
- public int getLineOfLastMouseButtonActivity() {
- if (fLastMouseButtonActivityLine == -1)
- fLastMouseButtonActivityLine= toDocumentLineNumber(fLocation.y);
- return fLastMouseButtonActivityLine;
- }
-
- /*
- * @see IVerticalRulerInfo#toDocumentLineNumber(int)
- */
- public int toDocumentLineNumber(int y_coordinate) {
-
- if (fTextViewer == null || y_coordinate == -1)
- return -1;
-
- StyledText text= fTextViewer.getTextWidget();
- int line= ((y_coordinate + text.getTopPixel()) / text.getLineHeight());
- return widgetLine2ModelLine(fTextViewer, line);
- }
-
- /**
- * Returns the line in the given viewer's document that correspond to the given
- * line of the viewer's widget.
- *
- * @param viewer the viewer
- * @param widgetLine the widget line
- * @return the corresponding line the viewer's document
- * @since 2.1
- */
- protected final static int widgetLine2ModelLine(ITextViewer viewer, int widgetLine) {
-
- if (viewer instanceof ITextViewerExtension3) {
- ITextViewerExtension3 extension= (ITextViewerExtension3) viewer;
- return extension.widgetlLine2ModelLine(widgetLine);
- }
-
- try {
- IRegion r= viewer.getVisibleRegion();
- IDocument d= viewer.getDocument();
- return widgetLine += d.getLineOfOffset(r.getOffset());
- } catch (BadLocationException x) {
- }
- return widgetLine;
- }
-
- /**
- * Returns this ruler's text viewer.
- *
- * @return this ruler's text viewer
- */
- public ITextViewer getTextViewer() {
- return fTextViewer;
- }
-
- /*
- * @see IVerticalRulerExtension#setLocationOfLastMouseButtonActivity(int, int)
- */
- public void setLocationOfLastMouseButtonActivity(int x, int y) {
- fLocation.x= x;
- fLocation.y= y;
- fLastMouseButtonActivityLine= -1;
- }
-
- /**
- * Returns an iterator over the <code>IVerticalRulerColumns</code> that make up this
- * composite column.
- *
- * @return an iterator over the contained columns.
- * @since 3.0
- */
- public Iterator getDecoratorIterator() {
- Assert.isNotNull(fDecorators, "fDecorators must be initialized"); //$NON-NLS-1$
- return fDecorators.iterator();
- }
-
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationAccess.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationAccess.java
deleted file mode 100644
index a1f8f0c37eb..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationAccess.java
+++ /dev/null
@@ -1,47 +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;
-
-/**
- * An annotation access provides access to information that is not available via the
- * API of <code>Annotation</code>. Clients usually implement this interface.
- *
- * @see org.eclipse.jface.text.source.Annotation
- * @since 2.1
- */
-public interface IAnnotationAccess {
-
- /**
- * Returns the type of the given annotation.
- *
- * @param annotation the annotation
- * @return the type of the given annotation or <code>null</code> if it has none.
- */
- Object getType(Annotation annotation);
-
- /**
- * Returns whether the given annotation spans multiple lines.
- *
- * @param annotation the annotation
- * @return <code>true</code> if the annotation spans multiple lines,
- * <code>false</code> otherwise
- */
- boolean isMultiLine(Annotation annotation);
-
- /**
- * Returns whether the given annotation is temporary rather than persistent.
- *
- * @param annotation the annotation
- * @return <code>true</code> if the annotation is temporary,
- * <code>false</code> otherwise
- */
- boolean isTemporary(Annotation annotation);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationAccessExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationAccessExtension.java
deleted file mode 100644
index b304ed73680..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationAccessExtension.java
+++ /dev/null
@@ -1,30 +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;
-
-/**
- * Extension interface for <code>IAnnotationAccess</code>.
- * Allows to get a label for the annotation's type.
- * </code>.
- *
- * @since 3.0
- */
-public interface IAnnotationAccessExtension {
-
- /**
- * Returns the label for the given annotation's type.
- *
- * @param annotation the annotation
- * @return the label the given annotation's type or <code>null</code> if no such label exists
- */
- String getTypeLabel(Annotation annotation);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationHover.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationHover.java
deleted file mode 100644
index c2e51af3f27..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationHover.java
+++ /dev/null
@@ -1,33 +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;
-
-
-
-
-/**
- * Provides the information to be displayed in a hover popup window
- * which appears over the presentation area of annotations. Clients
- * may implement this interface.
- */
-public interface IAnnotationHover {
-
- /**
- * Returns the text which should be presented in the a
- * hover popup window. This information is requested based on
- * the specified line number.
- *
- * @param sourceViewer the source viewer this hover is registered with
- * @param lineNumber the line number for which information is requested
- * @return the requested information or <code>null</code> if no such information exists
- */
- String getHoverInfo(ISourceViewer sourceViewer, int lineNumber);
-}
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
deleted file mode 100644
index e4d422feed8..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationHoverExtension.java
+++ /dev/null
@@ -1,61 +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.jface.text.IInformationControlCreator;
-import org.eclipse.jface.text.ITextSelection;
-
-/**
- * Extension to <code>IAnnotationHover</code> for
- * <ul>
- * <li>providing its own information control creator</li>
- * <li>providing the range of lines for which the hover for a given line is valid
- * </ul>
- *
- * @see org.eclipse.jface.text.IInformationControlCreator
- * @see org.eclipse.jface.text.source.IAnnotationHover
- * @since 3.0
- */
-public interface IAnnotationHoverExtension {
-
- /**
- * Returns the information control creator of this annotation hover.
- *
- * @return the information control creator
- */
- IInformationControlCreator getInformationControlCreator();
-
- /**
- * Returns the text which should be presented in the a
- * hover popup window. This information is requested based on
- * the specified line number.
- *
- * @param sourceViewer the source viewer this hover is registered with
- * @param lineNumber the line number for which information is requested
- * @param first the first line in <code>viewer</code>'s document to consider
- * @param number the number of lines in <code>viewer</code>'s document to consider
- * @return the requested information or <code>null</code> if no such information exists
- */
- String getHoverInfo(ISourceViewer sourceViewer, int lineNumber, int first, int number);
-
- /**
- * Returns the range of lines that are covered by this hover for the given
- * <code>ISourceViewer</code> at model line <code>line</code>.
- *
- * @param viewer the viewer which the hover is queried for
- * @param line the line which a hover is displayed for
- * @param first the first line in <code>viewer</code>'s document to consider
- * @param number the number of lines in <code>viewer</code>'s document to consider
- * @return the selection in the document displayed in <code>viewer</code> containing <code>line</code>
- * that is covered by the hover information returned by the receiver.
- */
- ITextSelection getLineRange(ISourceViewer viewer, int line, int first, int number);
-} \ No newline at end of file
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModel.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModel.java
deleted file mode 100644
index 3b7bf48aba4..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModel.java
+++ /dev/null
@@ -1,124 +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.jface.text.IDocument;
-import org.eclipse.jface.text.Position;
-
-
-/**
- * This interface defines the model for managing annotations attached to a document.
- * The model maintains a set of annotations for a given document and notifies registered annotation
- * model listeners about annotation model changes. It also provides methods
- * for inquerying the current offset and length of an annotation managed
- * by this model.<p>
- * Clients may implement this interface or use the default implementation provided
- * by <code>AnnotationModel</code>.
- *
- * @see Annotation
- * @see IAnnotationModelListener
- */
-public interface IAnnotationModel {
-
- /**
- * Registers the annotation model listener with this annotation model.
- * After registration listener is informed about each change of this model.
- * If the listener is already registered nothing happens.
- *
- * @param listener the listener to be registered, may not be <code>null</code>
- */
- void addAnnotationModelListener(IAnnotationModelListener listener);
-
- /**
- * Removes the listener from the model's list of annotation model listeners.
- * If the listener is not registered with the model nothing happens.
- *
- * @param listener the listener to be removed, may not be <code>null</code>
- */
- void removeAnnotationModelListener(IAnnotationModelListener listener);
-
- /**
- * Connects the annotation model to a document. The annotations managed
- * by this model must subsequently update according to the changes applied
- * to the document. Once an annotation model is connected to a document,
- * all further <code>connect</code> calls must mention the document the
- * model is already connected to. An annotation model primarily uses
- * <code>connect</code> and <code>disconnect</code> for reference counting
- * the document. Reference counting frees the clients from keeping tracker
- * whether a model has already been connected to a document.
- *
- * @param document the document the model gets connected to,
- * may not be <code>null</code>
- *
- * @see #disconnect
- */
- void connect(IDocument document);
-
- /**
- * Disconnects this model from a document. After that, document changes no longer matter.
- * An annotation model may only be disconnected from a document to which it has been
- * connected before. If the model reference counts the connections to a document,
- * the connection to the document may only be terminated if the reference count does
- * down to 0.
- *
- * @param document the document the model gets disconnected from,
- * may not be <code>null</code>
- *
- * @see #connect for further specification details
- */
- void disconnect(IDocument document);
-
- /**
- * Adds a annotation to this annotation model. The annotation is associated with
- * with the given position which describes the range covered by the annotation.
- * All registered annotation model listeners are informed about the change.
- * If the model is connected to a document, the position is automatically
- * updated on document changes. If the annotation is already managed by
- * this annotation model or is not a valid position in the connected nothing happens.
- *
- * @param annotation the annotation to add, may not be <code>null</code>
- * @param position the position describing the range covered by this annotation,
- * may not be <code>null</code>
- */
- void addAnnotation(Annotation annotation, Position position);
-
- /**
- * Removes the given annotation from the model. I.e. the annotation is no
- * longer managed by this model. The position associated with the annotation
- * is no longer updated on document changes. If the annotation is not
- * managed by this model, nothing happens.
- *
- * @param annotation the annotation to be removed from this model,
- * may not be <code>null</code>
- */
- void removeAnnotation(Annotation annotation);
-
- /**
- * Returns all annotations managed by this model.
- *
- * @return all annotations managed by this model
- */
- Iterator getAnnotationIterator();
-
- /**
- * Returns the position associated with the given annotation.
- *
- * @param annotation the annotation whose position should be returned
- * @return the position of the given annotation or <code>null</code> if no
- * associated annotation exists
- */
- Position getPosition(Annotation annotation);
-}
-
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModelExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModelExtension.java
deleted file mode 100644
index 389083374b2..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModelExtension.java
+++ /dev/null
@@ -1,48 +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;
-
-
-/**
- * Extends <code>IAnnotationModel</code> with the ability to attach additional annotation models to it.
- *
- * @since 3.0
- */
-public interface IAnnotationModelExtension {
-
- /**
- * Attaches <code>attachment</code> to the receiver. Connects <code>attachment</code> to
- * the currently connected document. If <code>attachment</code> is already attached (even)
- * under a different key), it is not attached again.
- *
- * @param key the key through which the attachment is identified.
- * @param attachment the attached <code>IAnnotationModel</code>
- */
- void addAnnotationModel(Object key, IAnnotationModel attachment);
-
- /**
- * Returns the attached <code>IAnnotationModel</code> for <code>key</code>, or <code>null</code>
- * if none is attached for <code>key</code>.
- *
- * @param key the key through which the attachment is identified.
- * @return an <code>IAnnotationModel</code> attached under <code>key</code>, or <code>null</code>
- */
- IAnnotationModel getAnnotationModel(Object key);
-
- /**
- * Removes and returns the attached <code>IAnnotationModel</code> for <code>key</code>.
- *
- * @param key the key through which the attachment is identified.
- * @return an <code>IAnnotationModel</code> attached under <code>key</code>, or <code>null</code>
- */
- IAnnotationModel removeAnnotationModel(Object key);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModelListener.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModelListener.java
deleted file mode 100644
index db9708baaca..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModelListener.java
+++ /dev/null
@@ -1,31 +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;
-
-
-
-/**
- * Interface for objects interested in getting informed about
- * annotation model changes. Changes are the addition or removal
- * of annotations managed by the model. Clients may implement
- * this interface.
- *
- * @see IAnnotationModel
- */
-public interface IAnnotationModelListener {
-
- /**
- * Called if a model change occurred on the given model.
- *
- * @param model the changed annotation model
- */
- void modelChanged(IAnnotationModel model);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModelListenerExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModelListenerExtension.java
deleted file mode 100644
index 6e3042fbe19..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModelListenerExtension.java
+++ /dev/null
@@ -1,30 +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;
-
-/**
- * Extension interface for <code>IAnnotationModelListener</code>. Introduces a
- * notification mechanism that notifies the user by means of <code>AnnotationModelEvent</code>s.
- * Thus, more detailed information can be sent to the listener. Will replace the original notification
- * mechanism of <code>IAnnotationModelListener</code>.
- *
- * @since 2.0
- */
-public interface IAnnotationModelListenerExtension {
-
- /**
- * Called if a model change occurred on the given model.
- *
- * @param event the event to be sent out
- */
- void modelChanged(AnnotationModelEvent event);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IChangeRulerColumn.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IChangeRulerColumn.java
deleted file mode 100644
index c8f16012d15..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IChangeRulerColumn.java
+++ /dev/null
@@ -1,63 +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.graphics.Color;
-
-/**
- * An <code>IChangeRulerColumn</code> can display quick diff information.
- *
- * @since 3.0
- */
-public interface IChangeRulerColumn extends IVerticalRulerColumn, IVerticalRulerInfoExtension {
-
- /** The ID under which the quick diff model is registered with a document's annotation model. */
- public static final String QUICK_DIFF_MODEL_ID= "diff"; //$NON-NLS-1$
-
- /**
- * Sets the hover of this ruler column.
- *
- * @param hover the hover that will produce hover information text for this ruler column
- */
- public abstract void setHover(IAnnotationHover hover);
-
- /**
- * Sets the background color for normal lines. The color has to be disposed of by the caller when
- * the receiver is no longer used.
- *
- * @param addedColor the new color to be used as standard line background
- */
- public abstract void setBackground(Color addedColor);
-
- /**
- * Sets the background color for added lines. The color has to be disposed of by the caller when
- * the receiver is no longer used.
- *
- * @param addedColor the new color to be used for the added lines background
- */
- public abstract void setAddedColor(Color addedColor);
-
- /**
- * Sets the background color for changed lines. The color has to be disposed of by the caller when
- * the receiver is no longer used.
- *
- * @param changedColor the new color to be used for the changed lines background
- */
- public abstract void setChangedColor(Color changedColor);
-
- /**
- * Sets the color for the deleted lines indicator. The color has to be disposed of by the caller when
- * the receiver is no longer used.
- *
- * @param deletedColor the new color to be used for the deleted lines indicator.
- */
- public abstract void setDeletedColor(Color deletedColor);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ICharacterPairMatcher.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ICharacterPairMatcher.java
deleted file mode 100644
index e6269516837..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ICharacterPairMatcher.java
+++ /dev/null
@@ -1,70 +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.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-
-/**
- * A character pair matcher finds to a character at a certain document offset the matching peer character.
- * It is the matchers responsibility to define the concepts of "matching" and "peer". The matching process
- * starts at a given offset. Starting of this offset, the matcher chooses a character close to this offset. The
- * anchor defines whether the chosen character is left or right of the initial offset. The matcher then searches
- * for the matching peer character of the chosen character and if it finds one, delivers the minimal region of
- * the document that contains both characters.
- *
- * @since 2.1
- */
-public interface ICharacterPairMatcher {
-
- /**
- * Indicates the anchor value "right".
- */
- int RIGHT= 0;
- /**
- * Indicates the anchor value "left".
- */
- int LEFT= 1;
-
-
- /**
- * Disposes this pair matcher.
- */
- void dispose();
-
- /**
- * Clears this pair matcher. I.e. the matcher throws away all state it might
- * remember and prepares itself for a new call of the <code>match</code>
- * method.
- */
- void clear();
-
- /**
- * Starting at the given offset, the matcher chooses a character close to this offset.
- * The matcher then searches for the matching peer character of the chosen character
- * and if it finds one, returns the minimal region of the document that contains both characters.
- * It returns <code>null</code> if there is no peer character.
- *
- * @param iDocument the document to work on
- * @param i the start offset
- * @return the minimal region containg the peer characters
- */
- IRegion match(IDocument iDocument, int i);
-
- /**
- * Returns the anchor for the region of the matching peer characters. The anchor
- * says whether the character that has been chosen to search for its peer character
- * has been left or right of the initial offset.
- *
- * @return <code>RIGHT</code> or <code>LEFT</code>
- */
- int getAnchor();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ILineDiffInfo.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ILineDiffInfo.java
deleted file mode 100644
index c106d4cffd6..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ILineDiffInfo.java
+++ /dev/null
@@ -1,70 +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;
-
-
-/**
- * Describes the change state of one line, which consists of the state of the line itself, which
- * can be <code>UNCHANGED</code>, <code>CHANGED</code> or <code>ADDED</code>, and the number of
- * deleted lines before and after this line.
- *
- * @since 3.0
- */
-public interface ILineDiffInfo {
-
- /** Denotes an unchanged line. */
- static final int UNCHANGED= 0;
-
- /** Denotes an added line. */
- static final int ADDED= 1;
-
- /** Denotes a changed line. */
- static final int CHANGED= 2;
-
- /**
- * Returns the number of deleted lines after this line.
- *
- * @return the number of lines after this line.
- */
- int getRemovedLinesBelow();
-
- /**
- * Returns the number of deleted lines before this line.
- *
- * @return the number of lines before this line.
- */
- int getRemovedLinesAbove();
-
- /**
- * Returns the type of this line, one out of <code>UNCHANGED</code>, <code>CHANGED</code> or
- * <code>ADDED</code>.
- *
- * @return the type of this line.
- */
- int getType();
-
- /**
- * Returns whether this line has any changes (to itself, or any deletions before or after it).
- *
- * @return <code>true</code>, if the line's state (as returned by <code>getType</code>) is
- * either <code>CHANGED</code> or <code>ADDED</code> or either of <code>getRemovedLinesBelow</code>
- * and <code>getRemovedLinesAbove</code> would return a number &gt; 0
- */
- boolean hasChanges();
-
- /**
- * Returns the original text of this changed region
- *
- * @return the original text of this changed region, including any deleted lines. The returned
- * value and its elements may not be <code>null/code>, it may however be of zero length
- */
- String[] getOriginalText();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ILineDiffer.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ILineDiffer.java
deleted file mode 100644
index 55dcdc3a1a1..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ILineDiffer.java
+++ /dev/null
@@ -1,70 +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.jface.text.BadLocationException;
-
-
-/**
- * Protocol that allows direct access to line information. Usually, implementations will also
- * implement <code>IAnnotationModel</code>, which only allows <code>Iterator</code> based access
- * to annotations.
- *
- * @since 3.0
- */
-public interface ILineDiffer {
-
- /**
- * Determines the line state for line <code>line</code> in the targeted document.
- *
- * @param line
- * @return the line information object for <code>line</code>.
- */
- ILineDiffInfo getLineInfo(int line);
-
- /**
- * Reverts a single changed line to its original state, not touching any lines that
- * are deleted at its borders.
- *
- * @param line the line number of the line to be restored.
- * @throws BadLocationException if <code>line</code> is out of bounds.
- */
- void revertLine(int line) throws BadLocationException;
-
- /**
- * Reverts a block of modified / added lines to their original state, including any deleted
- * lines inside the block or at its borders. A block is considered to be a range of modified
- * (e.g. changed, or added) lines.
- *
- * @param line any line in the block to be reverted.
- * @throws BadLocationException if <code>line</code> is out of bounds.
- */
- void revertBlock(int line) throws BadLocationException;
-
- /**
- * Reverts a range of lines to their original state, including any deleted
- * lines inside the block or at its borders.
- *
- * @param line any line in the block to be reverted.
- * @param nLines the number of lines to be reverted, must be &gt; 0.
- * @throws BadLocationException if <code>line</code> is out of bounds.
- */
- void revertSelection(int line, int nLines) throws BadLocationException;
-
- /**
- * Restores the deleted lines after <code>line</code>.
- *
- * @param line the deleted lines following this line number are restored.
- * @return the number of restored lines.
- * @throws BadLocationException if <code>line</code> is out of bounds.
- */
- int restoreAfterLine(int line) throws BadLocationException;
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IOverviewRuler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IOverviewRuler.java
deleted file mode 100644
index f19c7521b21..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IOverviewRuler.java
+++ /dev/null
@@ -1,116 +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.graphics.Color;
-import org.eclipse.swt.widgets.Control;
-
-/**
- * This interface defines a visual component which may serve
- * text viewers as an overview annotation presentation area. This means,
- * presentation of annotations is independent from the actual viewport of
- * the text viewer. The annotations of the viewer's whole document are
- * visible in the overview ruler.
- *
- * This interfaces comprises three contracts:
- * <ul>
- * <li> The overview ruler retrieves the annotations it presents from an annotation model.
- * <li> The ruler is a visual component which must be integrated in a hierarchy of SWT controls.
- * <li> The ruler provides interested clients with mapping and
- * interaction information. This covers the mapping between
- * coordinates of the ruler's control and line numbers based
- * on the connected text viewer's document (<code>IVerticalRulerInfo</code>).
- * </ul>
- * Clients may implement this interface or use the default implementation provided
- * by <code>OverviewlRuler</code>.
- *
- * @see org.eclipse.jface.text.ITextViewer
- * @since 2.1
- */
-public interface IOverviewRuler extends IVerticalRuler {
-
- /**
- * Returns whether there is an annotation an the given y coordinate. This
- * method takes the compression factor of the overview ruler into account.
- *
- * @param y the y-coordinate
- * @return <code>true</code> if there is an annotation, <code>false</code> otherwise
- */
- boolean hasAnnotation(int y);
-
- /**
- * Returns the height of the visual presentation of an annotation in this
- * overview ruler. Assumes that all annotations are represented using the
- * same height.
- *
- * @return int the visual height of an annotation
- */
- int getAnnotationHeight();
-
- /**
- * Sets the color for the given annotation type in this overview ruler.
- *
- * @param annotationType the annotation type
- * @param color the color
- */
- void setAnnotationTypeColor(Object annotationType, Color color);
-
- /**
- * Sets the drawing layer for the given annotation type in this overview ruler.
- *
- * @param annotationType the annotation type
- * @param layer the drawing layer
- */
- void setAnnotationTypeLayer(Object annotationType, int layer);
-
- /**
- * Adds the given annotation type to this overview ruler. Starting with this
- * call, annotations of the given type are shown in the overview ruler.
- *
- * @param annotationType the annotation type
- */
- void addAnnotationType(Object annotationType);
-
- /**
- * Removes the given annotation type from this overview ruler. Annotations
- * of the given type are no longer shown in the overview ruler.
- *
- * @param annotationType the annotation type
- */
- void removeAnnotationType(Object annotationType);
-
- /**
- * Adds the given annotation type to the header of this ruler. Starting with
- * this call, the presence of annotations is tracked and the header is drawn
- * in the configured color.
- *
- * @param annotationType the annotation type to be tracked
- */
- void addHeaderAnnotationType(Object annotationType);
-
- /**
- * Removes the given annotation type from the header of this ruler. The
- * presence of annotations of the given type is no longer tracked and the
- * header is drawn in the default color, depending on the other configured
- * configured annotation types.
- *
- * @param annotationType the annotation type to be removed
- */
- void removeHeaderAnnotationType(Object annotationType);
-
- /**
- * Returns this rulers header control. This is the little area between the
- * top of the text widget and the top of this overview ruler.
- *
- * @return the header control of this overview ruler.
- */
- Control getHeaderControl();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ISharedTextColors.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ISharedTextColors.java
deleted file mode 100644
index 4f1cf9825d3..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ISharedTextColors.java
+++ /dev/null
@@ -1,39 +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.graphics.Color;
-import org.eclipse.swt.graphics.RGB;
-
-
-/**
- * Manages SWT color objects. Until the <code>dispose</code> method is called,
- * the same color object is returned for equal <code>RGB</code> values.
- * <p> This interface may be implemented by clients. </p>
- *
- * @since 2.1
- */
-public interface ISharedTextColors {
-
- /**
- * Returns the color object for the value represented by the given
- * <code>RGB</code> object.
- *
- * @param rgb the rgb color specification
- * @return the color object for the given rgb value
- */
- Color getColor(RGB rgb);
-
- /**
- * Tells this object to dispose all its managed colors.
- */
- void dispose();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ISourceViewer.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ISourceViewer.java
deleted file mode 100644
index 0fc6338e1e6..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ISourceViewer.java
+++ /dev/null
@@ -1,162 +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.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextOperationTarget;
-import org.eclipse.jface.text.ITextViewer;
-
-
-/**
- * In addition to the text viewer functionality a source viewer supports:
- * <ul>
- * <li> visual annotations based on an annotation model
- * <li> visual range indication
- * <li> management of text viewer add-ons
- * <li> explicit configuration
- * </ul>
- * It is assumed that range indication and visual annotations are shown
- * inside the same presentation area. There are no assumptions about
- * whether this area is different from the viewer's text widget.<p>
- * As the visibility of visual annotations can dynamically be changed,
- * it is assumed that the annotation presentation area can dynamically
- * be hidden if it is different from the text widget.<p>
- * Clients may implement this interface or use the default implementation provided
- * by <code>SourceViewer</code>.
- */
-public interface ISourceViewer extends ITextViewer {
-
- /**
- * Text operation code for requesting content assist to show completetion
- * proposals for the current insert position.
- */
- static final int CONTENTASSIST_PROPOSALS= ITextOperationTarget.STRIP_PREFIX + 1;
-
- /**
- * Text operation code for requesting content assist to show
- * the content information for the current insert position.
- */
- static final int CONTENTASSIST_CONTEXT_INFORMATION= ITextOperationTarget.STRIP_PREFIX + 2;
-
- /**
- * Text operation code for formatting the selected text or complete document
- * of this viewer if the selection is empty.
- */
- static final int FORMAT= ITextOperationTarget.STRIP_PREFIX + 3;
-
- /**
- * Text operation code for requesting information at the current insertion position.
- * @since 2.0
- */
- static final int INFORMATION= ITextOperationTarget.STRIP_PREFIX + 4;
-
- /**
- * Configures the source viewer using the given configuration.
- *
- * @param configuration the source viewer configuration to be used
- */
- void configure(SourceViewerConfiguration configuration);
-
- /**
- * Sets the annotation hover of this source viewer. The annotation hover
- * provides the information to be displayed in a hover popup window
- * if requested over the annotation presentation area. The annotation
- * hover is assumed to be line oriented.
- *
- * @param annotationHover the hover to be used, <code>null</code> is a valid argument
- */
- void setAnnotationHover(IAnnotationHover annotationHover);
-
- /**
- * Sets the given document as this viewer's text model and the
- * given annotation model as the model for this viewer's visual
- * annotations. The presentation is accordingly updated. An approriate
- * <code>TextEvent</code> is issued. This text event does not carry
- * a related document event.
- *
- * @param document the viewer's new input document
- * @param annotationModel the model for the viewer's visual annotations
- *
- * @see ITextViewer#setDocument(IDocument)
- */
- void setDocument(IDocument document, IAnnotationModel annotationModel);
-
- /**
- * Sets the given document as this viewer's text model and the
- * given annotation model as the model for this viewer's visual
- * annotations. The presentation is accordingly updated whereby
- * only the specified region is made visible. An approriate
- * <code>TextEvent</code> is issued. The text event does not carry a
- * related document event. This method is a convenience method for
- * <code>setDocument(document, annotationModel);setVisibleRegion(offset, length)</code>.
- *
- * @param document the new input document
- * @param annotationModel the model of the viewer's visual annotations
- * @param visibleRegionOffset the offset of the visible region
- * @param visibleRegionLength the length of the visible region
- *
- * @see ITextViewer#setDocument(IDocument, int, int)
- */
- void setDocument(IDocument document, IAnnotationModel annotationModel, int visibleRegionOffset, int visibleRegionLength);
-
- /**
- * Returns this viewer's annotation model.
- *
- * @return this viewer's annotation model
- */
- IAnnotationModel getAnnotationModel();
-
- /**
- * Sets the annotation used by this viewer as range indicator. The
- * range covered by this annotation is referred to as range indication.
- *
- * @param rangeIndicator the annotation to be used as this viewer's range indicator
- */
- void setRangeIndicator(Annotation rangeIndicator);
-
- /**
- * Sets the viewers's range indication to the specified range. Its is indicated
- * whether the cursor should also be moved to the beginning of the specified range.
- *
- * @param offset the offset of the range
- * @param length the length of the range
- * @param moveCursor indicates whether the cursor should be moved to the given offset
- */
- void setRangeIndication(int offset, int length, boolean moveCursor);
-
- /**
- * Returns the viewer's range indication.
- *
- * @return the viewer's range indication.
- */
- IRegion getRangeIndication();
-
- /**
- * Removes the viewer's range indication. There is no visible range indication
- * after this method completed.
- *
- * @return the viewer's range indication
- */
- void removeRangeIndication();
-
- /**
- * Controls the visibility of annotations and in the case of separate
- * presentation areas of text and annotations, the visibility of the
- * annotation's presentation area.<p>
- * By default, annotations and their presentation area are visible.
- *
- * @param show indicates the visibility of annotations
- */
- void showAnnotations(boolean show);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ISourceViewerExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ISourceViewerExtension.java
deleted file mode 100644
index 008399a0e4c..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ISourceViewerExtension.java
+++ /dev/null
@@ -1,37 +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;
-
-/**
- * Extension interface for <code>ISourceViewer</code>.
- * Extends the source viewer with the concept of an annotation overview.
- * The annotation overview differs from the annotation presentation in that it is
- * independent from the viewer's viewport, i.e. the annotations of the
- * whole document are visible. There are no assumptions about
- * the area in which the annotation overview is shown.<p>
- * As the visibility of annotation overview can dynamically be changed,
- * it is assumed that the presentation area can dynamically
- * be hidden if it is different from the text widget.<p>
- * Clients may implement this interface or use the default implementation provided
- * by <code>SourceViewer</code>.
- *
- * @since 2.1
- */
-public interface ISourceViewerExtension {
-
- /**
- * Shows/hides an overview representation of the annotations of the whole document of this viewer.
- *
- * @param show <code>true</code> if annotation overview should be visible, <code>false</code> otherwise
- */
- void showAnnotationsOverview(boolean show);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ITagHandler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ITagHandler.java
deleted file mode 100644
index 720ef039963..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ITagHandler.java
+++ /dev/null
@@ -1,92 +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.io.IOException;
-
-
-/**
- * A tag handler is responsible to
- * - handle the attributes for the tags it supports
- * - translate the tag sequence including attributes to another language
- * - back-translate relative line offsets.
- * <p>
- * Tag handlers are used by translators via tag handler factories.</p>
- * <p>
- * XXX: This is work in progress and can change anytime until API for 3.0 is frozen.
- * </p>
- * @see org.eclipse.jface.text.source.ITranslator
- * @see org.eclipse.jface.text.source.ITagHandlerFactory
- * @since 3.0
- */
-public interface ITagHandler {
-
- /**
- * Tells whether this handler can handle the given tag.
- *
- * @param tag the tag to check
- * @return <code>true</code> if this handler handles the given tag
- */
- boolean canHandleTag(String tag);
-
- /**
- * Tells whether this handler can handle the given text. Most
- * likely the handler will check if the text contains a tag
- * that he can handle.
- *
- * @param tag the text to check
- * @return <code>true</code> if this handler handles the given text
- */
- boolean canHandleText(String text);
-
- /**
- * Adds an attribute to this tag handler.
- *
- * @param name the name of the attribute
- * @param value the attribute value
- * @param sourceLineNumber the line number of the attribute in the source or <code>-1</code> if unknown
- */
- void addAttribute(String name, String value, int sourceLineNumber);
-
- /**
- * Resets this handler and sets the current tag to the given tag.
- * A handler can handle more than one tag but only one tag at a time.
- * <p>
- * Resetting the handler clears the attributes.</p>
- *
- * @param tag the tag to check
- * @return <code>true</code> if this handler handles the given tag
- */
- void reset(String tag);
-
- /**
- * Writes the tag and line mapping information to the
- * given translator result collector.
- *
- * @param resultCollector the translator's result collector
- * @param sourceLineNumber the line number of the attribute in the source or <code>-1</code> if unknown
- * @throws IOException
- */
- void processEndTag(ITranslatorResultCollector resultCollector, int sourceLineNumber) throws IOException;
-
- /**
- * Computes the offset in the source line that corresponds
- * to the given offset in the translated line.
- *
- * @param sourceLineLine the source line
- * @param translatedLine the translated line
- * @param offsetInTranslatedLine the offset in the translated line
- * @return the offset in the source line or <code>-1</code> if
- * it was not possible to compute the offset
- */
- int backTranslateOffsetInLine(String sourceLine, String translatedLine, int offsetInTranslatedLine);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ITagHandlerFactory.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ITagHandlerFactory.java
deleted file mode 100644
index 6de442d4d3b..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ITagHandlerFactory.java
+++ /dev/null
@@ -1,49 +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;
-
-/**
- * A tag handler factory provides access to tag
- * handlers.
- * <p>
- * XXX: This is work in progress and can change anytime until API for 3.0 is frozen.
- * </p>
- * @since 3.0
- */
-public interface ITagHandlerFactory {
-
- /**
- * Returns a handler that can handle the
- * given tag.
- * <p>
- * Depending on the used handler the factory might
- * return a new or a shared instance.</p>
- *
- * @param tag the tag for which to return the handler
- * @return a tag handler or <code>null</code> if no handler
- * is available
- */
- public ITagHandler getHandler(String tag);
-
- /**
- * Finds and returns a handler that can handle
- * the given text snippet.
- * <p>
- * Depending on the used handler the factory might
- * return a new or a shared instance.</p>
- *
- * @param text the text for which to find a handler
- * @return a tag handler or <code>null</code> if no handler
- * is available
- */
- public ITagHandler findHandler(String text);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ITranslator.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ITranslator.java
deleted file mode 100644
index d7fea53136c..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ITranslator.java
+++ /dev/null
@@ -1,76 +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.io.IOException;
-import java.io.Reader;
-
-/**
- * A translator translates a given file into another language.
- * The translator is also responsible to provide line mapping
- * information for the translation and to compute which offset
- * in an original line corresponds to a given offset in a
- * target line.
- * <p>
- * XXX: This is work in progress and can change anytime until API for 3.0 is frozen.
- * </p>
- * @since 3.0
- */
-public interface ITranslator {
-
- /**
- * Reads the source from the given reader and creates
- * translates it into another language. The translated
- * source might be given the optional name.
- *
- * @param reader the reader to access the source
- * @param name the name of the translated source or <code>null</code> if none
- * @return
- * @throws IOException
- */
- String translate(Reader reader, String name) throws IOException;
-
- /**
- * Returns the line mapping information.
- *
- * @return an int array where the index corresponds to line
- * numbers in the translation and the value is a
- * source line number
- */
- int[] getLineMapping();
-
- /**
- * Assigns an optional tag handler factory to this translator.
- * <p>
- * A translator can delegate the handling of individual tags
- * to tag handlers. The factory is responsible to provide
- * the correct tag handlers.</p>
- *
- * @param tagHandlerFactory a tag handler factory or <code>null</code>
- * if this translator does all work itself
- */
- void setTagHandlerFactory(ITagHandlerFactory tagHandlerFactory);
-
- /**
- * Computes the offset in the source line that corresponds
- * to the given offset in the translated line.
- *
- * @param sourceLineLine the source line
- * @param translatedLine the translated line
- * @param offsetInTranslatedLine the offset in the translated line
- * @param tag the tag to which the source line belongs or
- * <code>null</code> if the tag is not known
- * @return the offset in the source line or <code>-1</code> if
- * it was not possible to compute the offset
- */
- int backTranslateOffsetInLine(String sourceLine, String translatedLine, int offsetInTranslatedLine, String tag);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ITranslatorResultCollector.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ITranslatorResultCollector.java
deleted file mode 100644
index d2b8b81e05c..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ITranslatorResultCollector.java
+++ /dev/null
@@ -1,21 +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;
-
-/**
- * Tagging interface for a translator result collector.
- *
- * @since 3.0
- */
-public interface ITranslatorResultCollector {
-
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRuler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRuler.java
deleted file mode 100644
index 5e7c9b91370..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRuler.java
+++ /dev/null
@@ -1,75 +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.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-
-import org.eclipse.jface.text.ITextViewer;
-
-
-/**
- * This interface defines a visual component which may serve text viewers as an annotation presentation
- * area. Implementers of this interface have to define the presentation modus. This can either depend
- * on the connected viewer's view port or not. If the modus is view port dependent the ruler only shows
- * those annotations that are attached to document regions that are visible in the view port. If independent,
- * the presented annotations can also be attached to invisible document regions.
- *
- * This interfaces comprises three contracts:
- * <ul>
- * <li> The vertical ruler retrieves the annotations it presents from an annotation model.
- * <li> The ruler is a visual component which must be integrated in a hierarchy of SWT controls.
- * <li> The ruler provides interested clients with mapping and
- * interaction information. This covers the mapping between
- * coordinates of the ruler's control and line numbers based
- * on the connected text viewer's document (<code>IVerticalRulerInfo</code>).
- * </ul>
- * Clients may implement this interface or use the default implementation provided
- * by <code>CompositeRuler</code> and <code>VerticalRuler</code>.
- *
- * @see ITextViewer
- * @see IVerticalRulerInfo
- */
-public interface IVerticalRuler extends IVerticalRulerInfo {
-
- /**
- * Associates an annotation model with this ruler.
- * A value <code>null</code> is acceptable and clears the ruler.
- *
- * @param model the new annotation model, may be <code>null</code>
- */
- void setModel(IAnnotationModel model);
-
- /**
- * Returns the current annotation model of this ruler or <code>null</code>
- * if the ruler has no model.
- *
- * @return this ruler's annotation model or <code>null</code> if there is no model
- */
- IAnnotationModel getModel();
-
- /**
- * Forces the vertical ruler to synchronize itself with its
- * annotation model and its viewer's viewport.
- */
- void update();
-
- /**
- * Creates the ruler's SWT control.
- *
- * @param parent the parent control of the ruler's control
- * @param textViewer the text viewer to which this ruler belongs
- * @return the ruler's SWT control
- */
- Control createControl(Composite parent, ITextViewer textViewer);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRulerColumn.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRulerColumn.java
deleted file mode 100644
index 2c442e6933f..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRulerColumn.java
+++ /dev/null
@@ -1,74 +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.graphics.Font;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-
-
-/**
- * A <code>IVerticalRulerColumn</code> is an element that can be added
- * to a composite vertical ruler. A composite vertical ruler is a vertical ruler
- * with a dynamically changing appearance and behavior depending on its
- * actual arrangement of ruler columns. A vertical ruler column supports a
- * subset of the contract of a vertical ruler.
- *
- * @see org.eclipse.jface.text.source.CompositeRuler
- * @since 2.0
- */
-public interface IVerticalRulerColumn {
-
- /**
- * Associates an annotation model with this ruler column.
- * A value <code>null</code> is acceptable and clears the ruler.
- *
- * @param model the new annotation model, may be <code>null</code>
- */
- void setModel(IAnnotationModel model);
-
- /**
- * Redraws this column.
- */
- void redraw();
-
- /**
- * Creates the column's SWT control.
- *
- * @param parentRuler the parent ruler of this column
- * @param parentControl the control of the parent ruler
- * @return the column's SWT control
- */
- Control createControl(CompositeRuler parentRuler, Composite parentControl);
-
- /**
- * Returns the column's SWT control.
- *
- * @return the column's SWT control
- */
- Control getControl();
-
- /**
- * Returns the width of this column's control.
- *
- * @return the width of this column's control
- */
- int getWidth();
-
- /**
- * Sets the font of this ruler column.
- *
- * @param font the new font of the ruler column
- */
- void setFont(Font font);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRulerExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRulerExtension.java
deleted file mode 100644
index 7e0f3bfbef8..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRulerExtension.java
+++ /dev/null
@@ -1,41 +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.graphics.Font;
-
-
-/**
- * Extension interface for <code>IVerticalRuler</code>. Allows to set the font of the
- * vertical ruler and to set the location of the last mouse button activity.
- *
- * @since 2.0
- */
-public interface IVerticalRulerExtension {
-
- /**
- * Sets the font of this vertical ruler.
- *
- * @param font the new font of the vertical ruler
- */
- void setFont(Font font);
-
- /**
- * Sets the location of the last mouse button activity. This method is used for
- * example by external mouse listeners.
- *
- * @param x the x-coordinate
- * @param y the y-coordinate
- */
- void setLocationOfLastMouseButtonActivity(int x, int y);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRulerInfo.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRulerInfo.java
deleted file mode 100644
index ed180c37761..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRulerInfo.java
+++ /dev/null
@@ -1,63 +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.widgets.Control;
-
-
-/**
- * A vertical ruler is a visual component which may serve
- * text viewers as an annotation presentation
- * area. The vertical ruler info provides interested clients with the
- * mapping and interaction aspect of the vertical ruler. This
- * covers the mapping between coordinates of the ruler's
- * control and line numbers based on the connected text viewer's
- * document.
- *
- * @since 2.0
- */
-public interface IVerticalRulerInfo {
-
- /**
- * Returns the ruler's SWT control.
- *
- * @return the ruler's SWT control
- */
- Control getControl();
-
- /**
- * Returns the line number of the last mouse button activity.
- * Based on the input document of the connected text viewer.
- * The smallest possible line number is <code>0</code>.
- *
- * @return the line number of the last mouse button activity
- */
- int getLineOfLastMouseButtonActivity();
-
- /**
- * Translates a y-coordinate of the ruler's SWT control into
- * the according line number of the document of the connected text viewer.
- *
- * @param y_coordinate a y-coordinate of the ruler's SWT control
- * @return the line number of that coordinate or <code>-1</code> if that
- * coordinate does not correspond to a valid document line
- */
- int toDocumentLineNumber(int y_coordinate);
-
- /**
- * Returns the width of this ruler's control.
- *
- * @return the width of this ruler's control
- */
- int getWidth();
-}
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
deleted file mode 100644
index a221803e524..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRulerInfoExtension.java
+++ /dev/null
@@ -1,31 +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;
-
-/**
- * Extends <code>IVerticalRulerInfo</code> with the ability to define a custom hover to be used
- * when hovering over the <code>IVerticalRuler</code> described by this info instance, and to
- * specify the <code>IAnnotationModel</code> used by it.
- * @since 3.0
- */
-public interface IVerticalRulerInfoExtension {
- /**
- * Returns the hover for this vertical ruler (column).
- * @return the hover for this column
- */
- IAnnotationHover getHover();
-
- /**
- * Returns the model currently used by the receiver.
- * @return the model of the receiver, or <code>null</code> if no model is installed.
- */
- IAnnotationModel getModel();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/JFaceTextMessages.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/JFaceTextMessages.java
deleted file mode 100644
index 144851fa52e..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/JFaceTextMessages.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.source;
-
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-/**
- * Accessor for the <code>JFaceTextMessages.properties</code> file in
- * package <code>org.eclipse.jface.text</code>.
- * @since 2.0
- */
-class JFaceTextMessages {
-
- /** The resource bundle name. */
- private static final String RESOURCE_BUNDLE= "org.eclipse.jface.text.JFaceTextMessages";//$NON-NLS-1$
-
- /** The resource bundle. */
- private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
-
- /**
- * Prohibits the creation of accessor objects.
- */
- private JFaceTextMessages() {
- }
-
- /**
- * Returns the string found in the resource bundle under the given key or a place holder string.
- *
- * @param key the look up key
- * @return the value found under the given key
- */
- public static String getString(String key) {
- try {
- return fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- }
-
- /**
- * Gets a string from the resource bundle and formats it with the argument
- *
- * @param key the string used to get the bundle value, must not be null
- * @since 3.0
- */
- public static String getFormattedString(String key, Object[] args) {
- String format= null;
- try {
- format= fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- return MessageFormat.format(format, args);
- }
-}
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
deleted file mode 100644
index b977cfa8743..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineChangeHover.java
+++ /dev/null
@@ -1,319 +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 java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.swt.graphics.Point;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IInformationControlCreator;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.TextSelection;
-
-
-/**
- * A hover for line oriented diffs. It determines the text to show as hover for a certain line in the
- * document.
- *
- * @since 3.0
- */
-public class LineChangeHover implements IAnnotationHover, IAnnotationHoverExtension {
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationHoverExtension#getHoverInfo(org.eclipse.jface.text.source.ISourceViewer, int, int, int)
- */
- public String getHoverInfo(ISourceViewer sourceViewer, int lineNumber, int first, int number) {
- int last= first + number - 1;
- String content= computeContent(sourceViewer, lineNumber, first, last);
- return formatSource(content);
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationHover#getHoverInfo(org.eclipse.jface.text.source.ISourceViewer, int)
- */
- public String getHoverInfo(ISourceViewer sourceViewer, int lineNumber) {
- return getHoverInfo(sourceViewer, lineNumber, 0, Integer.MAX_VALUE);
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationHoverExtension#getLineRange(org.eclipse.jface.text.source.ISourceViewer, int, int, int)
- */
- public ITextSelection getLineRange(ISourceViewer viewer, int line, int first, int number) {
- int last= first + number - 1;
- Point lineRange= computeLineRange(viewer, line, first, last);
- if (viewer != null && lineRange != null && lineRange.x != -1 && lineRange.y != -1) {
- try {
- IDocument document= viewer.getDocument();
- if (document != null) {
- int offset= document.getLineOffset(lineRange.x);
- // make sure that content shifts due to deleted lines are shifted one down
- IRegion endLine= document.getLineInformation(Math.max(lineRange.x, lineRange.y));
- int endOffset= endLine.getOffset() + endLine.getLength();
- // consider add one to comprise last line
- int length= endOffset - offset + 1;
- return new TextSelection(document, offset, length);
- }
- } catch (BadLocationException e) {
- }
- }
- return new TextSelection(0, 0);
- }
-
- /**
- * Formats the source w/ syntax coloring etc. This implementation replaces tabs with spaces.
- * May be overridden by subclasses.
- *
- * @param content the hover content
- * @return <code>content</code> reformatted
- */
- protected String formatSource(String content) {
- if (content != null) {
- StringBuffer sb= new StringBuffer(content);
- final String tabReplacement= getTabReplacement();
- for (int pos= 0; pos < sb.length(); pos++) {
- if (sb.charAt(pos) == '\t')
- sb.replace(pos, pos + 1, tabReplacement);
- }
- return sb.toString();
- }
- return content;
- }
-
- /**
- * Consults the preferences for the number of spaces a tab should be displayed as.
- *
- * @return a String consisting of spaces that will replace one tab character in the
- * displayed source.
- */
- protected String getTabReplacement() {
- return " "; //$NON-NLS-1$
- }
-
- /**
- * Computes the content of the hover for the document contained in <code>viewer</code> on
- * line <code>line</code>.
- *
- * @param viewer the connected viewer
- * @param line the line for which to compute the hover info
- * @param first the first line in <code>viewer</code>'s document to consider
- * @param last the last line in <code>viewer</code>'s document to consider
- * @return The hover content corresponding to the parameters
- * @see #getHoverInfo()
- */
- private String computeContent(ISourceViewer viewer, int line, int first, int last) {
- Point contentRange= computeContentRange(viewer, line, first, last);
- if (contentRange == null)
- return null;
- ILineDiffer differ= getDiffer(viewer);
- if (differ == null)
- return null;
- // sanity test line argument
- if (line > contentRange.y + 1 || line < contentRange.x - 1)
- return null;
-
- final List lines= new LinkedList();
- for (int l= contentRange.x; l <= contentRange.y; l++) {
- lines.add(differ.getLineInfo(l));
- }
- final int max= viewer.getBottomIndex();
- return decorateText(lines, max - contentRange.x + 1);
- }
-
- /**
- * Takes a list of <code>ILineDiffInfo</code>s and computes a hover of at most <code>maxLines</code>.
- * Added lines are prefixed with a <code>'+'</code>, changed lines with <code>'>'</code> and
- * deleted lines with <code>'-'</code>.
- * <p>Deleted and added lines can even each other out, so that a number of deleted lines get
- * displayed where - in the current document - the added lines are.
- *
- * @param diffInfos a <code>List</code> of <code>ILineDiffInfo</code>
- * @param maxLines the maximum number of lines. Note that adding up all annotations might give
- * more than that due to deleted lines.
- * @return a <code>String</code> suitable for hover display
- */
- protected String decorateText(List diffInfos, int maxLines) {
- /* maxLines controls the size of the hover (not more than what fits into the display are of
- * the viewer).
- * added controls how many lines are added - added lines are
- */
- String text= new String();
- int added= 0;
- for (Iterator it= diffInfos.iterator(); it.hasNext();) {
- ILineDiffInfo info= (ILineDiffInfo)it.next();
- String[] original= info.getOriginalText();
- int type= info.getType();
- int i= 0;
- if (type == ILineDiffInfo.ADDED)
- added++; //$NON-NLS-1$
- else if (type == ILineDiffInfo.CHANGED) {
- text += "> " + (original.length > 0 ? original[i++] : ""); //$NON-NLS-1$ //$NON-NLS-2$
- maxLines--;
- } else if (type == ILineDiffInfo.UNCHANGED) {
- maxLines++;
- }
- if (maxLines == 0)
- return trimTrailing(text);
- for (; i < original.length; i++) {
- text += "- " + original[i]; //$NON-NLS-1$
- added--;
- if (--maxLines == 0)
- return trimTrailing(text);
- }
- }
- text= text.trim();
- if (text.length() == 0 && added-- > 0 && maxLines-- > 0)
- text += "+ "; //$NON-NLS-1$
- while (added-- > 0 && maxLines-- > 0)
- text += "\n+ "; //$NON-NLS-1$
- return text;
- }
-
- /**
- * Trims trailing spaces
- *
- * @param text a <code>String</code>
- * @return a copy of <code>text</code> with trailing spaces removed
- */
- private String trimTrailing(String text) {
- int pos= text.length() - 1;
- while (pos >= 0 && Character.isWhitespace(text.charAt(pos))) {
- pos--;
- }
- return text.substring(0, pos + 1);
- }
-
- /**
- * Extracts the line differ - if any - from the viewer's document's annotation model.
- * @param viewer the viewer
- * @return a line differ for the document displayed in viewer, or <code>null</code>.
- */
- private ILineDiffer getDiffer(ISourceViewer viewer) {
- // return the upper left corner of the first hover line
- IAnnotationModel model= viewer.getAnnotationModel();
-
- if (model == null)
- return null;
- if (model instanceof IAnnotationModelExtension) {
- IAnnotationModel diffModel= ((IAnnotationModelExtension)model).getAnnotationModel(IChangeRulerColumn.QUICK_DIFF_MODEL_ID);
- if (diffModel != null)
- model= diffModel;
- }
- if (model instanceof ILineDiffer)
- return (ILineDiffer)model;
- else
- return null;
- }
-
- /**
- * Computes the content range, which is either equal to the line range or the line range plus
- * one line at the start (due to <code>ILineDiffInfo</code> implementation).
- *
- * @param viewer the connected viewer
- * @param line the achor line
- * @param first the first line in <code>viewer</code>'s document to consider
- * @param last the last line in <code>viewer</code>'s document to consider
- * @return the computed content range
- */
- private Point computeContentRange(ISourceViewer viewer, int line, int first, int last) {
- ILineDiffer differ= getDiffer(viewer);
- if (differ == null)
- return null;
-
- Point lineRange= computeLineRange(viewer, line, first, last);
- if (lineRange == null)
- return null;
-
- // here comes the hack: since we only get deleted lines *after* a line, we decrease one further if conditions met
- int l= lineRange.x - 1;
- ILineDiffInfo info= differ.getLineInfo(l);
- if (l >= first - 1 && info != null && info.getType() == ILineDiffInfo.UNCHANGED && info.getRemovedLinesBelow() > 0)
- return new Point(l, lineRange.y);
- else
- return lineRange;
- }
-
- /**
- * Computes the block of lines which form a contiguous block of changes covering <code>line</code>.
- *
- * @param viewer the source viewer showing
- * @param line the line which a hover is displayed for
- * @param min the first line in <code>viewer</code>'s document to consider
- * @param max the last line in <code>viewer</code>'s document to consider
- * @return the selection in the document displayed in <code>viewer</code> containing <code>line</code>
- * that is covered by the hover information returned by the receiver.
- */
- protected Point computeLineRange(ISourceViewer viewer, int line, int min, int max) {
- /* Algorithm:
- * All lines that have changes to themselves (added, changed) are taken that form a
- * contiguous block of lines that includes <code>line</code>.
- *
- * If <code>line</code> is itself unchanged, if there is a deleted line either above or
- * below, or both, the lines +/- 1 from <code>line</code> are included in the search as well,
- * without applying this last rule to them, though. (I.e., if <code>line</code> is unchanged,
- * but has a deleted line above, this one is taken in. If the line above has changes, the block
- * is extended from there. If the line has no changes itself, the search stops).
- *
- * The block never extends the visible line range of the viewer.
- */
-
- ILineDiffer differ= getDiffer(viewer);
- if (differ == null)
- return null;
-
- // backward search
-
- int l= line;
- ILineDiffInfo info= differ.getLineInfo(l);
- // if this is a special case, we'll start the search one above line
- if (l >= min && info != null && info.getType() == ILineDiffInfo.UNCHANGED && info.getRemovedLinesAbove() > 0) {
- info= differ.getLineInfo(--l);
- }
-
- // search backwards until a line has no changes to itself
- while (l >= min && info != null && (info.getType() == ILineDiffInfo.CHANGED || info.getType() == ILineDiffInfo.ADDED)) {
- info= differ.getLineInfo(--l);
- }
-
- // correct overrun
-// int first= l < line ? l + 1 : l;
- int first= l + 1;
-
- // forward search
-
- l= line;
- info= differ.getLineInfo(l);
- // if this is a special case, we'll start the search one below line
- if (l <= max && info != null && info.getType() == ILineDiffInfo.UNCHANGED && info.getRemovedLinesBelow() > 0) {
- info= differ.getLineInfo(++l);
- }
- // search forward until a line has no changes to itself
- while (l <= max && info != null && (info.getType() == ILineDiffInfo.CHANGED || info.getType() == ILineDiffInfo.ADDED)) {
- info= differ.getLineInfo(++l);
- }
-
- // correct overrun
- int last= l - 1;
-
- return new Point(first, last);
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationHoverExtension#getInformationControlCreator()
- */
- public IInformationControlCreator getInformationControlCreator() {
- 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
deleted file mode 100644
index d25f5ec0cea..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberChangeRulerColumn.java
+++ /dev/null
@@ -1,414 +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.graphics.Color;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Display;
-
-import org.eclipse.jface.text.Assert;
-
-/**
- * A vertical ruler column displaying line numbers and serving as a UI for quick diff.
- * Clients usually instantiate and configure object of this class.
- *
- * @since 3.0
- */
-public final class LineNumberChangeRulerColumn extends LineNumberRulerColumn implements IVerticalRulerInfo, IVerticalRulerInfoExtension, IChangeRulerColumn {
-
- /** Width of the triangle displayed for deleted lines. */
- private final static int fTriangleWidth= 7;
- /** The height of the triangle displayed for deleted lines. */
- private final static int fTriangleHeight= 3;
-
- /**
- * Internal listener class that will update the ruler when the underlying model changes.
- */
- class AnnotationListener implements IAnnotationModelListener {
- /*
- * @see org.eclipse.jface.text.source.IAnnotationModelListener#modelChanged(org.eclipse.jface.text.source.IAnnotationModel)
- */
- public void modelChanged(IAnnotationModel model) {
- postRedraw();
- }
- }
-
- /**
- * Returns a specification of a color that lies between the given
- * foreground and background color using the given scale factor.
- *
- * @param fg the foreground color
- * @param bg the background color
- * @param scale the scale factor
- * @return the interpolated color
- */
- private static RGB interpolate(RGB fg, RGB bg, double scale) {
- return new RGB(
- (int) ((1.0-scale) * fg.red + scale * bg.red),
- (int) ((1.0-scale) * fg.green + scale * bg.green),
- (int) ((1.0-scale) * fg.blue + scale * bg.blue)
- );
- }
-
- /**
- * Returns the grey value in which the given color would be drawn in grey-scale.
- *
- * @param rgb the color
- * @return the grey-scale value
- */
- private static double greyLevel(RGB rgb) {
- if (rgb.red == rgb.green && rgb.green == rgb.blue)
- return rgb.red;
- return (0.299 * rgb.red + 0.587 * rgb.green + 0.114 * rgb.blue + 0.5);
- }
-
- /**
- * Returns whether the given color is dark or light depending on the colors grey-scale level.
- *
- * @param rgb the color
- * @return <code>true</code> if the color is dark, <code>false</code> if it is light
- */
- private static boolean isDark(RGB rgb) {
- return greyLevel(rgb) > 128;
- }
-
- /** Color for changed lines. */
- private Color fAddedColor;
- /** Color for added lines. */
- private Color fChangedColor;
- /** Color for the deleted line indicator. */
- private Color fDeletedColor;
- /** The ruler's annotation model. */
- IAnnotationModel fAnnotationModel;
- /** The ruler's hover. */
- private IAnnotationHover fHover;
- /** The internal listener. */
- private AnnotationListener fAnnotationListener= new AnnotationListener();
- /** <code>true</code> if changes should be displayed using character indications instead of background colors. */
- private boolean fCharacterDisplay;
- /** The shared text colors. */
- private ISharedTextColors fSharedColors;
-
- public LineNumberChangeRulerColumn(ISharedTextColors sharedColors) {
- Assert.isNotNull(sharedColors);
- fSharedColors= sharedColors;
- }
-
- /*
- * @see org.eclipse.jface.text.source.LineNumberRulerColumn#handleDispose()
- */
- protected void handleDispose() {
- if (fAnnotationModel != null) {
- fAnnotationModel.removeAnnotationModelListener(fAnnotationListener);
- fAnnotationModel= null;
- }
- super.handleDispose();
- }
-
- /*
- * @see org.eclipse.jface.text.source.LineNumberRulerColumn#paintLine(int, int, int, org.eclipse.swt.graphics.GC, org.eclipse.swt.widgets.Display)
- */
- protected void paintLine(int line, int y, int lineheight, GC gc, Display display) {
- ILineDiffInfo info= getDiffInfo(line);
-
- if (info != null) {
- // width of the column
- int width= getWidth();
-
- // draw background color if special
- if (hasSpecialColor(info)) {
- gc.setBackground(getColor(info, display));
- gc.fillRectangle(0, y, width, lineheight);
- }
-
- /* Deletion Indicator
- * It consists of a line across the column and a triangle as shown for a deleted
- * line below the line 50:
- * ('x' means its colored)
- *
- * 1, 2, 3 show the points of the triangle painted.
- *
- * 0 width
- * | |
- * --------------------- - y
- * | --- -- |
- * | | | | 1_
- * | -- | | x| ^
- * | | | | xxx| | fTriangleHeight / 2
- * | --- -- xxxxx| |
- * xxxxxxxxxxxx0xxxxxxx2_ v _ y + lineheight
- * | |
- * <------>
- * fTriangleWidth
- */
- int delBefore= info.getRemovedLinesAbove();
- int delBelow= info.getRemovedLinesBelow();
- if (delBefore > 0 || delBelow > 0) {
- Color deletionColor= getDeletionColor(display);
- gc.setBackground(deletionColor);
- gc.setForeground(deletionColor);
-
- int[] triangle= new int[6];
- triangle[0]= width - fTriangleWidth;
- triangle[1]= y;
- triangle[2]= width;
- triangle[3]= y - fTriangleHeight;
- triangle[4]= width;
- triangle[5]= y + fTriangleHeight;
-
- if (delBefore > 0) {
- gc.drawLine(0, y, width, y);
- gc.fillPolygon(triangle);
- }
-
- if (delBelow > 0) {
- triangle[1] += lineheight;
- triangle[3] += lineheight;
- triangle[5] += lineheight;
-
- gc.drawLine(0, y + lineheight, width, y + lineheight);
- gc.fillPolygon(triangle);
- }
- gc.setForeground(getForeground());
- }
- }
- }
-
- /**
- * Returns whether the line background differs from the default.
- *
- * @param info the info being queried
- * @return <code>true</code> if <code>info</code> describes either a changed or an added line.
- */
- private boolean hasSpecialColor(ILineDiffInfo info) {
- return info.getType() == ILineDiffInfo.ADDED || info.getType() == ILineDiffInfo.CHANGED;
- }
-
- /**
- * Retrieves the <code>ILineDiffInfo</code> for <code>line</code> from the model.
- * There are optimizations for direct access and sequential access patterns.
- *
- * @param line the line we want the info for.
- * @return the <code>ILineDiffInfo</code> for <code>line</code>, or <code>null</code>.
- */
- private ILineDiffInfo getDiffInfo(int line) {
- if (fAnnotationModel == null)
- return null;
-
- // assume direct access
- if (fAnnotationModel instanceof ILineDiffer) {
- ILineDiffer differ= (ILineDiffer)fAnnotationModel;
- return differ.getLineInfo(line);
- }
-
- return null;
- }
-
- /**
- * Returns the color for deleted lines.
- *
- * @param display the display that the drawing occurs on
- * @return the color to be used for the deletion indicator
- */
- private Color getDeletionColor(Display display) {
- return fDeletedColor == null ? getBackground(display) : fDeletedColor;
- }
-
- /**
- * Returns the color for the given line diff info.
- *
- * @param info the <code>ILineDiffInfo</code> being queried
- * @param display the display that the drawing occurs on
- * @return the correct background color for the line type being described by <code>info</code>
- */
- private Color getColor(ILineDiffInfo info, Display display) {
- Assert.isTrue(info != null && info.getType() != ILineDiffInfo.UNCHANGED);
- Color ret= null;
- switch (info.getType()) {
- case ILineDiffInfo.CHANGED :
- ret= getShadedColor(fChangedColor, display);
- break;
- case ILineDiffInfo.ADDED :
- ret= getShadedColor(fAddedColor, display);
- break;
- }
- return ret == null ? getBackground(display) : ret;
- }
-
- /**
- * Returns the character to display in character display mode for the given <code>ILineDiffInfo</code>
- *
- * @param info the <code>ILineDiffInfo</code> being queried
- * @return the character indication for <code>info</code>
- */
- private String getDisplayCharacter(ILineDiffInfo info) {
- if (info == null)
- return ""; //$NON-NLS-1$
- switch (info.getType()) {
- case ILineDiffInfo.CHANGED :
- return "~"; //$NON-NLS-1$
- case ILineDiffInfo.ADDED :
- return "+"; //$NON-NLS-1$
- }
- return " "; //$NON-NLS-1$
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerInfo#getLineOfLastMouseButtonActivity()
- */
- public int getLineOfLastMouseButtonActivity() {
- return getParentRuler().getLineOfLastMouseButtonActivity();
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerInfo#toDocumentLineNumber(int)
- */
- public int toDocumentLineNumber(int y_coordinate) {
- return getParentRuler().toDocumentLineNumber(y_coordinate);
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#getHover()
- */
- public IAnnotationHover getHover() {
- return fHover;
- }
-
- /**
- * Sets the hover of this ruler column.
- * @param hover the hover that will produce hover information text for this ruler column
- */
- public void setHover(IAnnotationHover hover) {
- fHover= hover;
- }
-
- /*
- * @see IVerticalRulerColumn#setModel(IAnnotationModel)
- */
- public void setModel(IAnnotationModel model) {
- IAnnotationModel newModel;
- if (model instanceof IAnnotationModelExtension) {
- newModel= ((IAnnotationModelExtension)model).getAnnotationModel(QUICK_DIFF_MODEL_ID);
- } else {
- newModel= model;
- }
- if (fAnnotationModel != newModel) {
- if (fAnnotationModel != null) {
- fAnnotationModel.removeAnnotationModelListener(fAnnotationListener);
- }
- fAnnotationModel= newModel;
- if (fAnnotationModel != null) {
- fAnnotationModel.addAnnotationModelListener(fAnnotationListener);
- }
- updateNumberOfDigits();
- computeIndentations();
- layout(true);
- postRedraw();
- }
- }
-
- /**
- * Sets the background color for added lines. The color has to be disposed of by the caller when
- * the receiver is no longer used.
- *
- * @param addedColor the new color to be used for the added lines background
- */
- public void setAddedColor(Color addedColor) {
- fAddedColor= addedColor;
- }
-
- /**
- * Sets the background color for changed lines. The color has to be disposed of by the caller when
- * the receiver is no longer used.
- *
- * @param changedColor the new color to be used for the changed lines background
- */
- public void setChangedColor(Color changedColor) {
- fChangedColor= changedColor;
- }
-
- /**
- * Sets the background color for changed lines. The color has to be disposed of by the caller when
- * the receiver is no longer used.
- *
- * @param changedColor the new color to be used for the changed lines background
- */
- private Color getShadedColor(Color color, Display display) {
- if (color == null)
- return null;
-
- RGB baseRGB= color.getRGB();
- RGB background= getBackground(display).getRGB();
-
- boolean darkBase= isDark(baseRGB);
- boolean darkBackground= isDark(background);
- if (darkBase && darkBackground)
- background= new RGB(255, 255, 255);
- else if (!darkBase && !darkBackground)
- background= new RGB(0, 0, 0);
-
- return fSharedColors.getColor(interpolate(baseRGB, background, 0.6));
- }
-
- /**
- * Sets the color for the deleted lines indicator. The color has to be disposed of by the caller when
- * the receiver is no longer used.
- *
- * @param deletedColor the new color to be used for the deleted lines indicator.
- */
- public void setDeletedColor(Color deletedColor) {
- fDeletedColor= deletedColor;
- }
-
- /**
- * Sets the the display mode of the ruler. If character mode is set to <code>true</code>, diff
- * information will be displayed textually on the line number ruler.
- *
- * @param characterMode <code>true</code> if diff information is to be displayed textually.
- */
- public void setDisplayMode(boolean characterMode) {
- if (characterMode != fCharacterDisplay) {
- fCharacterDisplay= characterMode;
- updateNumberOfDigits();
- computeIndentations();
- layout(true);
- }
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#getModel()
- */
- public IAnnotationModel getModel() {
- return fAnnotationModel;
- }
-
- /*
- * @see org.eclipse.jface.text.source.LineNumberRulerColumn#createDisplayString(int)
- */
- protected String createDisplayString(int line) {
- if (fCharacterDisplay && getModel() != null)
- return super.createDisplayString(line) + getDisplayCharacter(getDiffInfo(line));
- else
- return super.createDisplayString(line);
- }
-
- /*
- * @see org.eclipse.jface.text.source.LineNumberRulerColumn#computeNumberOfDigits()
- */
- protected int computeNumberOfDigits() {
- if (fCharacterDisplay && getModel() != null)
- return super.computeNumberOfDigits() + 1;
- else
- return super.computeNumberOfDigits();
- }
-
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberRulerColumn.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberRulerColumn.java
deleted file mode 100644
index e32dd1f8687..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberRulerColumn.java
+++ /dev/null
@@ -1,826 +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.custom.StyledText;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.MouseMoveListener;
-import org.eclipse.swt.events.MouseTrackListener;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Canvas;
-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.IRegion;
-import org.eclipse.jface.text.ITextListener;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.ITextViewerExtension;
-import org.eclipse.jface.text.ITextViewerExtension3;
-import org.eclipse.jface.text.IViewportListener;
-import org.eclipse.jface.text.TextEvent;
-
-
-/**
- * A vertical ruler column displaying line numbers.
- * Clients usually instantiate and configure object of this class.
- *
- * @since 2.0
- */
-public class LineNumberRulerColumn implements IVerticalRulerColumn {
-
- /**
- * Internal listener class.
- */
- class InternalListener implements IViewportListener, ITextListener {
-
- /*
- * @see IViewportListener#viewportChanged(int)
- */
- public void viewportChanged(int verticalPosition) {
- if (verticalPosition != fScrollPos)
- redraw();
- }
-
- /*
- * @see ITextListener#textChanged(TextEvent)
- */
- public void textChanged(TextEvent event) {
-
- if (updateNumberOfDigits()) {
- computeIndentations();
- layout(event.getViewerRedrawState());
- return;
- }
-
- if (!event.getViewerRedrawState())
- return;
-
- if (fSensitiveToTextChanges || event.getDocumentEvent() == null)
- postRedraw();
-
- }
- }
-
- /**
- * Handles all the mouse interaction in this line number ruler column.
- */
- class MouseHandler implements MouseListener, MouseMoveListener, MouseTrackListener {
-
- /** The cached view port size */
- private int fCachedViewportSize;
- /** The area of the line at which line selection started */
- private IRegion fStartLine;
- /** The number of the line at which line selection started */
- private int fStartLineNumber;
- /** The auto scroll direction */
- private int fAutoScrollDirection;
-
- /*
- * @see org.eclipse.swt.events.MouseListener#mouseUp(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseUp(MouseEvent event) {
- stopSelecting();
- stopAutoScroll();
- }
-
- /*
- * @see org.eclipse.swt.events.MouseListener#mouseDown(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseDown(MouseEvent event) {
- fParentRuler.setLocationOfLastMouseButtonActivity(event.x, event.y);
- startSelecting();
- }
-
- /*
- * @see org.eclipse.swt.events.MouseListener#mouseDoubleClick(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseDoubleClick(MouseEvent event) {
- fParentRuler.setLocationOfLastMouseButtonActivity(event.x, event.y);
- stopSelecting();
- stopAutoScroll();
- }
-
- /*
- * @see org.eclipse.swt.events.MouseMoveListener#mouseMove(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseMove(MouseEvent event) {
- if (!autoScroll(event)) {
- int newLine= fParentRuler.toDocumentLineNumber(event.y);
- expandSelection(newLine);
- }
- }
-
- /*
- * @see org.eclipse.swt.events.MouseTrackListener#mouseEnter(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseEnter(MouseEvent event) {
- }
-
- /*
- * @see org.eclipse.swt.events.MouseTrackListener#mouseExit(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseExit(MouseEvent event) {
- }
-
- /*
- * @see org.eclipse.swt.events.MouseTrackListener#mouseHover(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseHover(MouseEvent event) {
- }
-
- /**
- * Called when line drag selection started. Adds mouse move and track
- * listeners to this column's control.
- */
- private void startSelecting() {
- try {
-
- // select line
- IDocument document= fCachedTextViewer.getDocument();
- fStartLineNumber= fParentRuler.getLineOfLastMouseButtonActivity();
- fStartLine= document.getLineInformation(fStartLineNumber);
- fCachedTextViewer.setSelectedRange(fStartLine.getOffset(), fStartLine.getLength());
- fCachedViewportSize= getVisibleLinesInViewport();
-
- // prepare for drag selection
- fCanvas.addMouseMoveListener(this);
- fCanvas.addMouseTrackListener(this);
-
- } catch (BadLocationException x) {
- }
- }
-
- /**
- * Called when line drag selection stopped. Removes all previously
- * installed listeners from this column's control.
- */
- private void stopSelecting() {
- // drag selection stopped
- fCanvas.removeMouseMoveListener(this);
- fCanvas.removeMouseTrackListener(this);
- }
-
- /**
- * Expands the line selection from the remembered start line to the
- * given line.
- *
- * @param lineNumber the line to which to expand the selection
- */
- private void expandSelection(int lineNumber) {
- try {
-
- IDocument document= fCachedTextViewer.getDocument();
- IRegion lineInfo= document.getLineInformation(lineNumber);
-
- int start= Math.min(fStartLine.getOffset(), lineInfo.getOffset());
- int end= Math.max(fStartLine.getOffset() + fStartLine.getLength(), lineInfo.getOffset() + lineInfo.getLength());
-
- if (lineNumber < fStartLineNumber)
- fCachedTextViewer.setSelectedRange(end, start - end);
- else
- fCachedTextViewer.setSelectedRange(start, end - start);
-
- } catch (BadLocationException x) {
- }
- }
-
- /**
- * Called when auto scrolling stopped. Clears the auto scroll direction.
- */
- private void stopAutoScroll() {
- fAutoScrollDirection= SWT.NULL;
- }
-
- /**
- * Called on drag selection.
- *
- * @param event the mouse event caught by the mouse move listener
- * @return <code>true</code> if scrolling happend, <code>false</code> otherwise
- */
- private boolean autoScroll(MouseEvent event) {
- Rectangle area= fCanvas.getClientArea();
-
- if (event.y > area.height) {
- autoScroll(SWT.DOWN);
- return true;
- }
-
- if (event.y < 0) {
- autoScroll(SWT.UP);
- return true;
- }
-
- stopAutoScroll();
- return false;
- }
-
- /**
- * Scrolls the viewer into the given direction.
- *
- * @param direction the scroll direction
- */
- private void autoScroll(int direction) {
-
- if (fAutoScrollDirection == direction)
- return;
-
- final int TIMER_INTERVAL= 5;
- final Display display = fCanvas.getDisplay();
- Runnable timer= null;
- switch (direction) {
- case SWT.UP:
- timer= new Runnable() {
- public void run() {
- if (fAutoScrollDirection == SWT.UP) {
- int top= getInclusiveTopIndex();
- if (top > 0) {
- fCachedTextViewer.setTopIndex(top -1);
- expandSelection(top -1);
- display.timerExec(TIMER_INTERVAL, this);
- }
- }
- }
- };
- break;
- case SWT.DOWN:
- timer = new Runnable() {
- public void run() {
- if (fAutoScrollDirection == SWT.DOWN) {
- int top= getInclusiveTopIndex();
- fCachedTextViewer.setTopIndex(top +1);
- expandSelection(top +1 + fCachedViewportSize);
- display.timerExec(TIMER_INTERVAL, this);
- }
- }
- };
- break;
- }
-
- if (timer != null) {
- fAutoScrollDirection= direction;
- display.timerExec(TIMER_INTERVAL, timer);
- }
- }
-
- /**
- * Returns the viewer's first visible line, even if only partially visible.
- *
- * @return the viewer's first visible line
- */
- private int getInclusiveTopIndex() {
- if (fCachedTextWidget != null && !fCachedTextWidget.isDisposed()) {
- int top= fCachedTextViewer.getTopIndex();
- if ((fCachedTextWidget.getTopPixel() % fCachedTextWidget.getLineHeight()) != 0)
- -- top;
- return top;
- }
- return -1;
- }
- }
-
- /** This column's parent ruler */
- private CompositeRuler fParentRuler;
- /** Cached text viewer */
- private ITextViewer fCachedTextViewer;
- /** Cached text widget */
- private StyledText fCachedTextWidget;
- /** The columns canvas */
- private Canvas fCanvas;
- /** Cache for the actual scroll position in pixels */
- private int fScrollPos;
- /** The drawable for double buffering */
- private Image fBuffer;
- /** The internal listener */
- private InternalListener fInternalListener= new InternalListener();
- /** The font of this column */
- private Font fFont;
- /** The indentation cache */
- private int[] fIndentation;
- /** Indicates whether this column reacts on text change events */
- private boolean fSensitiveToTextChanges= false;
- /** The foreground color */
- private Color fForeground;
- /** The background color */
- private Color fBackground;
- /** Cached number of displayed digits */
- private int fCachedNumberOfDigits= -1;
- /** Flag indicating whether a relayout is required */
- private boolean fRelayoutRequired= false;
-
-
- /**
- * Constructs a new vertical ruler column.
- */
- public LineNumberRulerColumn() {
- }
-
- /**
- * Sets the foreground color of this column.
- *
- * @param foreground the foreground color
- */
- public void setForeground(Color foreground) {
- fForeground= foreground;
- }
-
- /**
- * Returns the foreground color being used to print the line numbers.
- *
- * @return the configured foreground color
- * @since 3.0
- */
- protected Color getForeground() {
- return fForeground;
- }
-
- /**
- * Sets the background color of this column.
- *
- * @param background the background color
- */
- public void setBackground(Color background) {
- fBackground= background;
- if (fCanvas != null && !fCanvas.isDisposed())
- fCanvas.setBackground(getBackground(fCanvas.getDisplay()));
- }
-
- /**
- * Returns the System background color for list widgets.
- *
- * @param display the display
- * @return the System background color for list widgets
- */
- protected Color getBackground(Display display) {
- if (fBackground == null)
- return display.getSystemColor(SWT.COLOR_LIST_BACKGROUND);
- return fBackground;
- }
-
- /*
- * @see IVerticalRulerColumn#getControl()
- */
- public Control getControl() {
- return fCanvas;
- }
-
- /*
- * @see IVerticalRuleColumnr#getWidth
- */
- public int getWidth() {
- return fIndentation[0];
- }
-
- /**
- * Computes the number of digits to be displayed. Returns
- * <code>true</code> if the number of digits changed compared
- * to the previous call of this method. If the method is called
- * for the first time, the return value is also <code>true</code>.
- *
- * @return whether the number of digits has been changed
- */
- protected boolean updateNumberOfDigits() {
- if (fCachedTextViewer == null)
- return false;
-
- int digits= computeNumberOfDigits();
-
- if (fCachedNumberOfDigits != digits) {
- fCachedNumberOfDigits= digits;
- return true;
- }
-
- return false;
- }
-
- /**
- * Does the real computation of the number of digits. Subclasses may override this method if
- * they need extra space on the line number ruler.
- *
- * @return the number of digits to be displayed on the line number ruler.
- */
- protected int computeNumberOfDigits() {
- IDocument document= fCachedTextViewer.getDocument();
- int lines= document == null ? 0 : document.getNumberOfLines();
-
- int digits= 2;
- while (lines > Math.pow(10, digits) -1) {
- ++digits;
- }
- return digits;
- }
-
- /**
- * Layouts the enclosing viewer to adapt the layout to changes of the
- * size of the individual components.
- *
- * @param redraw <code>true</code> if this column can be redrawn
- */
- protected void layout(boolean redraw) {
- if (!redraw) {
- fRelayoutRequired= true;
- return;
- }
-
- fRelayoutRequired= false;
- if (fCachedTextViewer instanceof ITextViewerExtension) {
- ITextViewerExtension extension= (ITextViewerExtension) fCachedTextViewer;
- Control control= extension.getControl();
- if (control instanceof Composite && !control.isDisposed()) {
- Composite composite= (Composite) control;
- composite.layout(true);
- }
- }
- }
-
- /**
- * Computes the indentations for the given font and stores them in
- * <code>fIndentation</code>.
- */
- protected void computeIndentations() {
- if (fCanvas == null)
- return;
-
- GC gc= new GC(fCanvas);
- try {
-
- gc.setFont(fCanvas.getFont());
-
- fIndentation= new int[fCachedNumberOfDigits + 1];
-
- Float number= new Float(Math.pow(10, fCachedNumberOfDigits) - 1);
- Point p= gc.stringExtent(Integer.toString(number.intValue()));
- fIndentation[0]= p.x;
-
- for (int i= 1; i <= fCachedNumberOfDigits; i++) {
- number= new Float(Math.pow(10, i) - 1);
- p= gc.stringExtent(Integer.toString(number.intValue()));
- fIndentation[i]= fIndentation[0] - p.x;
- }
-
- } finally {
- gc.dispose();
- }
- }
-
- /*
- * @see IVerticalRulerColumn#createControl(CompositeRuler, Composite)
- */
- public Control createControl(CompositeRuler parentRuler, Composite parentControl) {
-
- fParentRuler= parentRuler;
- fCachedTextViewer= parentRuler.getTextViewer();
- fCachedTextWidget= fCachedTextViewer.getTextWidget();
-
- fCanvas= new Canvas(parentControl, SWT.NONE);
- fCanvas.setBackground(getBackground(fCanvas.getDisplay()));
- fCanvas.setForeground(fForeground);
-
- fCanvas.addPaintListener(new PaintListener() {
- public void paintControl(PaintEvent event) {
- if (fCachedTextViewer != null)
- doubleBufferPaint(event.gc);
- }
- });
-
- fCanvas.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- handleDispose();
- fCachedTextViewer= null;
- fCachedTextWidget= null;
- }
- });
-
- fCanvas.addMouseListener(new MouseHandler());
-
- if (fCachedTextViewer != null) {
-
- fCachedTextViewer.addViewportListener(fInternalListener);
- fCachedTextViewer.addTextListener(fInternalListener);
-
- if (fFont == null) {
- if (fCachedTextWidget != null && !fCachedTextWidget.isDisposed())
- fFont= fCachedTextWidget.getFont();
- }
- }
-
- if (fFont != null)
- fCanvas.setFont(fFont);
-
- updateNumberOfDigits();
- computeIndentations();
- return fCanvas;
- }
-
- /**
- * Disposes the column's resources.
- */
- protected void handleDispose() {
-
- if (fCachedTextViewer != null) {
- fCachedTextViewer.removeViewportListener(fInternalListener);
- fCachedTextViewer.removeTextListener(fInternalListener);
- }
-
- if (fBuffer != null) {
- fBuffer.dispose();
- fBuffer= null;
- }
- }
-
- /**
- * Double buffer drawing.
- *
- * @param dest the gc to draw into
- */
- private void doubleBufferPaint(GC dest) {
-
- Point size= fCanvas.getSize();
-
- if (size.x <= 0 || size.y <= 0)
- return;
-
- if (fBuffer != null) {
- Rectangle r= fBuffer.getBounds();
- if (r.width != size.x || r.height != size.y) {
- fBuffer.dispose();
- fBuffer= null;
- }
- }
- if (fBuffer == null)
- fBuffer= new Image(fCanvas.getDisplay(), size.x, size.y);
-
- GC gc= new GC(fBuffer);
- gc.setFont(fCanvas.getFont());
- if (fForeground != null)
- gc.setForeground(fForeground);
-
- try {
- gc.setBackground(getBackground(fCanvas.getDisplay()));
- gc.fillRectangle(0, 0, size.x, size.y);
-
- if (fCachedTextViewer instanceof ITextViewerExtension3)
- doPaint1(gc);
- else
- doPaint(gc);
-
- } finally {
- gc.dispose();
- }
-
- dest.drawImage(fBuffer, 0, 0);
- }
-
- /**
- * Returns the viewport height in lines.
- *
- * @return the viewport height in lines
- */
- protected int getVisibleLinesInViewport() {
- Rectangle clArea= fCachedTextWidget.getClientArea();
- if (!clArea.isEmpty())
- return clArea.height / fCachedTextWidget.getLineHeight();
- return -1;
- }
-
- /**
- * Draws the ruler column.
- *
- * @param gc the gc to draw into
- */
- private void doPaint(GC gc) {
-
- if (fCachedTextViewer == null)
- return;
-
- if (fCachedTextWidget == null)
- return;
-
-
- int firstLine= 0;
-
- int topLine= fCachedTextViewer.getTopIndex() -1;
- int bottomLine= fCachedTextViewer.getBottomIndex() + 1;
-
- try {
-
- IRegion region= fCachedTextViewer.getVisibleRegion();
- IDocument doc= fCachedTextViewer.getDocument();
-
- if (doc == null)
- return;
-
- firstLine= doc.getLineOfOffset(region.getOffset());
- if (firstLine > topLine)
- topLine= firstLine;
-
- int lastLine= doc.getLineOfOffset(region.getOffset() + region.getLength());
- if (lastLine < bottomLine)
- bottomLine= lastLine;
-
- } catch (BadLocationException x) {
- return;
- }
-
- fSensitiveToTextChanges= bottomLine - topLine < getVisibleLinesInViewport();
-
- int lineheight= fCachedTextWidget.getLineHeight();
- fScrollPos= fCachedTextWidget.getTopPixel();
- int canvasheight= fCanvas.getSize().y;
-
- int y= ((topLine - firstLine) * lineheight) - fScrollPos + fCachedTextViewer.getTopInset();
- for (int line= topLine; line <= bottomLine; line++, y+= lineheight) {
-
- if (y >= canvasheight)
- break;
-
- paintLine(line, y, lineheight, gc, fCachedTextWidget.getDisplay());
-
- String s= createDisplayString(line);
- int indentation= fIndentation[s.length()];
- gc.drawString(s, indentation, y, true);
- }
- }
-
- /**
- * Computes the string to be printed for <code>line</code>. The default implementation returns
- * <code>Integer.toString(line + 1)</code>.
- *
- * @param line the line number for which the line number string is generated
- * @return the string to be printed on the line number bar for <code>line</code>
- */
- protected String createDisplayString(int line) {
- return Integer.toString(line + 1);
- }
-
- /**
- * Draws the ruler column. Uses <code>ITextViewerExtension3</code> for the
- * implementation. Will replace <code>doPinat(GC)</code>.
- *
- * @param gc the gc to draw into
- */
- private void doPaint1(GC gc) {
-
- if (fCachedTextViewer == null)
- return;
-
- ITextViewerExtension3 extension= (ITextViewerExtension3) fCachedTextViewer;
-
- int firstLine= 0;
-
-
- int widgetTopLine= fCachedTextWidget.getTopIndex();
- if (widgetTopLine > 0)
- -- widgetTopLine;
-
- int topLine= extension.widgetlLine2ModelLine(widgetTopLine);
- int bottomLine= fCachedTextViewer.getBottomIndex();
- if (bottomLine >= 0)
- ++ bottomLine;
-
- try {
-
- IRegion region= extension.getModelCoverage();
- IDocument doc= fCachedTextViewer.getDocument();
-
- if (doc == null)
- return;
-
- firstLine= doc.getLineOfOffset(region.getOffset());
- if (firstLine > topLine || topLine == -1)
- topLine= firstLine;
-
- int lastLine= doc.getLineOfOffset(region.getOffset() + region.getLength());
- if (lastLine < bottomLine || bottomLine == -1)
- bottomLine= lastLine;
-
- } catch (BadLocationException x) {
- return;
- }
-
- fSensitiveToTextChanges= bottomLine - topLine < getVisibleLinesInViewport();
-
- int lineheight= fCachedTextWidget.getLineHeight();
- fScrollPos= fCachedTextWidget.getTopPixel();
- int canvasheight= fCanvas.getSize().y;
-
- int y= (widgetTopLine * lineheight) - fScrollPos + fCachedTextViewer.getTopInset();
- for (int modelLine= topLine; modelLine <= bottomLine; modelLine++) {
-
- if (y >= canvasheight)
- break;
-
- int widgetLine= extension.modelLine2WidgetLine(modelLine);
- if (widgetLine == -1)
- continue;
-
- paintLine(modelLine, y, lineheight, gc, fCachedTextWidget.getDisplay());
-
- String s= createDisplayString(modelLine);
- int indentation= fIndentation[s.length()];
- gc.drawString(s, indentation, y, true);
- y+= lineheight;
- }
- }
-
- /**
- * Paints the line. After this method is called the line numbers are painted on top
- * of the result of this method.
- * <p>This default implementation does nothing.</p>
- *
- * @param line the line of the document which the ruler is painted for
- * @param y the y-coordinate of the box being painted for <code>line</code>, relative to <code>gc</code>
- * @param lineheight the height of one line (and therefore of the box being painted)
- * @param gc the drawing context the client may choose to draw on.
- * @param display the display the drawing occurs on
- * @since 3.0
- */
- protected void paintLine(int line, int y, int lineheight, GC gc, Display display) {
- }
-
- /**
- * Triggers a redraw in the display thread.
- *
- * @since 3.0
- */
- protected final void postRedraw() {
- if (fCanvas != null && !fCanvas.isDisposed()) {
- Display d= fCanvas.getDisplay();
- if (d != null) {
- d.asyncExec(new Runnable() {
- public void run() {
- redraw();
- }
- });
- }
- }
- }
-
- /*
- * @see IVerticalRulerColumn#redraw()
- */
- public void redraw() {
-
- if (fRelayoutRequired) {
- layout(true);
- return;
- }
-
- if (fCanvas != null && !fCanvas.isDisposed()) {
- GC gc= new GC(fCanvas);
- doubleBufferPaint(gc);
- gc.dispose();
- }
- }
-
- /*
- * @see IVerticalRulerColumn#setModel(IAnnotationModel)
- */
- public void setModel(IAnnotationModel model) {
- }
-
- /*
- * @see IVerticalRulerColumn#setFont(Font)
- */
- public void setFont(Font font) {
- fFont= font;
- if (fCanvas != null && !fCanvas.isDisposed()) {
- fCanvas.setFont(fFont);
- updateNumberOfDigits();
- computeIndentations();
- }
- }
-
- /**
- * Returns the parent (composite) ruler of this ruler column.
- *
- * @return the parent ruler
- * @since 3.0
- */
- protected CompositeRuler getParentRuler() {
- return fParentRuler;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/MatchingCharacterPainter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/MatchingCharacterPainter.java
deleted file mode 100644
index 0520a7b950d..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/MatchingCharacterPainter.java
+++ /dev/null
@@ -1,240 +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.custom.StyledText;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Point;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IPaintPositionManager;
-import org.eclipse.jface.text.IPainter;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextViewerExtension3;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.Region;
-
-/**
- * Highlights the peer character matching the character near the caret position. This
- * painter can be configured with an <code>ICharacterPairMatcher</code>.
- * Clients instantiate and configure object of this class.
- *
- * @since 2.1
- */
-public final class MatchingCharacterPainter implements IPainter, PaintListener {
-
- /** Indicates whether this painter is active */
- private boolean fIsActive= false;
- /** The source viewer this painter is associated with */
- private ISourceViewer fSourceViewer;
- /** The viewer's widget */
- private StyledText fTextWidget;
- /** The color in which to highlight the peer character */
- private Color fColor;
- /** The paint position manager */
- private IPaintPositionManager fPaintPositionManager;
- /** The startegy for finding matching characters */
- private ICharacterPairMatcher fMatcher;
- /** The position tracking the matching characters */
- private Position fPairPosition= new Position(0, 0);
- /** The anchor indicating whether the character is left or right of the caret */
- private int fAnchor;
-
-
- /**
- * Creates a new MatchingCharacterPainter for the given source viewer using
- * the given character pair matcher. The character matcher is not adopted by
- * this painter. Thus, it is not disposed. However, this painter requires
- * exlucsive access to the given pair matcher.
- *
- * @param sourceViewer
- * @param matcher
- */
- public MatchingCharacterPainter(ISourceViewer sourceViewer, ICharacterPairMatcher matcher) {
- fSourceViewer= sourceViewer;
- fMatcher= matcher;
- fTextWidget= sourceViewer.getTextWidget();
- }
-
- /**
- * Sets the color in which to highlight the match character.
- *
- * @param color the color
- */
- public void setColor(Color color) {
- fColor= color;
- }
-
- /*
- * @see org.eclipse.jface.text.IPainter#dispose()
- */
- public void dispose() {
- if (fMatcher != null) {
- fMatcher.clear();
- fMatcher= null;
- }
-
- fColor= null;
- fTextWidget= null;
- }
-
- /*
- * @see org.eclipse.jface.text.IPainter#deactivate(boolean)
- */
- public void deactivate(boolean redraw) {
- if (fIsActive) {
- fIsActive= false;
- fTextWidget.removePaintListener(this);
- if (fPaintPositionManager != null)
- fPaintPositionManager.unmanagePosition(fPairPosition);
- if (redraw)
- handleDrawRequest(null);
- }
- }
-
- /*
- * @see org.eclipse.swt.events.PaintListener#paintControl(org.eclipse.swt.events.PaintEvent)
- */
- public void paintControl(PaintEvent event) {
- if (fTextWidget != null)
- handleDrawRequest(event.gc);
- }
-
- /**
- * Handles a redraw request.
- *
- * @param gc the gc to draw into.
- */
- private void handleDrawRequest(GC gc) {
-
- if (fPairPosition.isDeleted)
- return;
-
- int offset= fPairPosition.getOffset();
- int length= fPairPosition.getLength();
- if (length < 1)
- return;
-
- if (fSourceViewer instanceof ITextViewerExtension3) {
- ITextViewerExtension3 extension= (ITextViewerExtension3) fSourceViewer;
- IRegion widgetRange= extension.modelRange2WidgetRange(new Region(offset, length));
- if (widgetRange == null)
- return;
-
- offset= widgetRange.getOffset();
- length= widgetRange.getLength();
-
- } else {
- IRegion region= fSourceViewer.getVisibleRegion();
- if (region.getOffset() > offset || region.getOffset() + region.getLength() < offset + length)
- return;
- offset -= region.getOffset();
- }
-
- if (ICharacterPairMatcher.RIGHT == fAnchor)
- draw(gc, offset, 1);
- else
- draw(gc, offset + length -1, 1);
- }
-
- /**
- * Highlights the given widget region.
- *
- * @param gc the gc to draw into
- * @param offset the offset of the widget region
- * @param length the length of the widget region
- */
- private void draw(GC gc, int offset, int length) {
- if (gc != null) {
- Point left= fTextWidget.getLocationAtOffset(offset);
- Point right= fTextWidget.getLocationAtOffset(offset + length);
-
- gc.setForeground(fColor);
- gc.drawRectangle(left.x, left.y, right.x - left.x - 1, gc.getFontMetrics().getHeight() - 1);
-
- } else {
- fTextWidget.redrawRange(offset, length, true);
- }
- }
-
- /*
- * @see org.eclipse.jface.text.IPainter#paint(int)
- */
- public void paint(int reason) {
-
- IDocument document= fSourceViewer.getDocument();
- if (document == null) {
- deactivate(false);
- return;
- }
-
- Point selection= fSourceViewer.getSelectedRange();
- if (selection.y > 0) {
- deactivate(true);
- return;
- }
-
- IRegion pair= fMatcher.match(document, selection.x);
- if (pair == null) {
- deactivate(true);
- return;
- }
-
- if (fIsActive) {
-
- if (IPainter.CONFIGURATION == reason) {
-
- // redraw current highlighting
- handleDrawRequest(null);
-
- } else if (pair.getOffset() != fPairPosition.getOffset() ||
- pair.getLength() != fPairPosition.getLength() ||
- fMatcher.getAnchor() != fAnchor) {
-
- // otherwise only do something if position is different
-
- // remove old highlighting
- handleDrawRequest(null);
- // update position
- fPairPosition.isDeleted= false;
- fPairPosition.offset= pair.getOffset();
- fPairPosition.length= pair.getLength();
- fAnchor= fMatcher.getAnchor();
- // apply new highlighting
- handleDrawRequest(null);
-
- }
- } else {
-
- fIsActive= true;
-
- fPairPosition.isDeleted= false;
- fPairPosition.offset= pair.getOffset();
- fPairPosition.length= pair.getLength();
- fAnchor= fMatcher.getAnchor();
-
- fTextWidget.addPaintListener(this);
- fPaintPositionManager.managePosition(fPairPosition);
- handleDrawRequest(null);
- }
- }
-
- /*
- * @see org.eclipse.jface.text.IPainter#setPositionManager(org.eclipse.jface.text.IPaintPositionManager)
- */
- public void setPositionManager(IPaintPositionManager manager) {
- fPaintPositionManager= manager;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRuler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRuler.java
deleted file mode 100644
index 790468ed153..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRuler.java
+++ /dev/null
@@ -1,1086 +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.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.custom.ViewForm;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseMoveListener;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Cursor;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Canvas;
-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.IRegion;
-import org.eclipse.jface.text.ITextListener;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.ITextViewerExtension3;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextEvent;
-
-
-
-/**
- * Ruler presented next to a source viewer showing all annotations of the
- * viewer's annotation model in a compact format. The ruler has the same height
- * as the source viewer.<p>
- * Clients usually instantiate and configure objects of this class.
- *
- * @since 2.1
- */
-public class OverviewRuler implements IOverviewRuler {
-
- /**
- * Internal listener class.
- */
- class InternalListener implements ITextListener, IAnnotationModelListener {
-
- /*
- * @see ITextListener#textChanged
- */
- public void textChanged(TextEvent e) {
- if (fTextViewer != null && e.getDocumentEvent() == null && e.getViewerRedrawState()) {
- // handle only changes of visible document
- redraw();
- }
- }
-
- /*
- * @see IAnnotationModelListener#modelChanged(IAnnotationModel)
- */
- public void modelChanged(IAnnotationModel model) {
- update();
- }
- }
-
- /**
- * Enumerates the annotations of a specified type and characteristics
- * of the associated annotation model.
- */
- class FilterIterator implements Iterator {
-
- private final static int IGNORE= 0;
- private final static int TEMPORARY= 1;
- private final static int PERSISTENT= 2;
-
- private Iterator fIterator;
- private Object fType;
- private Annotation fNext;
- private int fTemporary;
-
- public FilterIterator() {
- this(null, IGNORE);
- }
-
- public FilterIterator(Object annotationType) {
- this(annotationType, IGNORE);
- }
-
- public FilterIterator(Object annotationType, boolean temporary) {
- this(annotationType, temporary ? TEMPORARY : PERSISTENT);
- }
-
- private FilterIterator(Object annotationType, int temporary) {
- fType= annotationType;
- fTemporary= temporary;
- if (fModel != null) {
- fIterator= fModel.getAnnotationIterator();
- skip();
- }
- }
-
- private void skip() {
- while (fIterator.hasNext()) {
- Annotation next= (Annotation) fIterator.next();
- Object annotationType= fAnnotationAccess.getType(next);
- if (annotationType == null)
- continue;
-
- fNext= next;
- if (fType == null || fType.equals(annotationType)) {
- if (fTemporary == IGNORE) return;
- boolean temporary= fAnnotationAccess.isTemporary(fNext);
- if (fTemporary == TEMPORARY && temporary) return;
- if (fTemporary == PERSISTENT && !temporary) return;
- }
- }
- fNext= null;
- }
-
- /*
- * @see Iterator#hasNext()
- */
- public boolean hasNext() {
- return fNext != null;
- }
- /*
- * @see Iterator#next()
- */
- public Object next() {
- try {
- return fNext;
- } finally {
- if (fModel != null)
- skip();
- }
- }
- /*
- * @see Iterator#remove()
- */
- public void remove() {
- throw new UnsupportedOperationException();
- }
- }
-
- /**
- * The painter of the overview ruler's header.
- */
- class HeaderPainter implements PaintListener {
-
- private Color fIndicatorColor;
- private Color fSeparatorColor;
-
- public HeaderPainter() {
- fSeparatorColor= fSharedTextColors.getColor(ViewForm.borderInsideRGB);
- }
-
- public void setColor(Color color) {
- fIndicatorColor= color;
- }
-
- private void drawBevelRect(GC gc, int x, int y, int w, int h, Color topLeft, Color bottomRight) {
- gc.setForeground(topLeft == null ? fSeparatorColor : topLeft);
- gc.drawLine(x, y, x + w -1, y);
- gc.drawLine(x, y, x, y + h -1);
-
- gc.setForeground(bottomRight == null ? fSeparatorColor : bottomRight);
- gc.drawLine(x + w, y, x + w, y + h);
- gc.drawLine(x, y + h, x + w, y + h);
- }
-
- public void paintControl(PaintEvent e) {
-
- Point s= fHeader.getSize();
-
- if (fIndicatorColor != null) {
- e.gc.setBackground(fIndicatorColor);
- Rectangle r= new Rectangle(INSET, (s.y - (2*ANNOTATION_HEIGHT)) / 2, s.x - (2*INSET), 2*ANNOTATION_HEIGHT);
- e.gc.fillRectangle(r);
- Display d= fHeader.getDisplay();
- if (d != null)
-// drawBevelRect(e.gc, r.x, r.y, r.width -1, r.height -1, d.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW), d.getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW));
- drawBevelRect(e.gc, r.x, r.y, r.width -1, r.height -1, null, null);
- }
-
- e.gc.setForeground(fSeparatorColor);
- e.gc.setLineWidth(1);
- e.gc.drawLine(0, s.y -1, s.x -1, s.y -1);
- }
- }
-
- private static final int INSET= 2;
- private static final int ANNOTATION_HEIGHT= 4;
- private static boolean ANNOTATION_HEIGHT_SCALABLE= true;
-
-
- /** The model of the overview ruler */
- private IAnnotationModel fModel;
- /** The view to which this ruler is connected */
- private ITextViewer fTextViewer;
- /** The ruler's canvas */
- private Canvas fCanvas;
- /** The ruler's header */
- private Canvas fHeader;
- /** The drawable for double buffering */
- private Image fBuffer;
- /** The internal listener */
- private InternalListener fInternalListener= new InternalListener();
- /** The width of this vertical ruler */
- private int fWidth;
- /** The hit detection cursor */
- private Cursor fHitDetectionCursor;
- /** The last cursor */
- private Cursor fLastCursor;
- /** The line of the last mouse button activity */
- private int fLastMouseButtonActivityLine= -1;
- /** The actual annotation height */
- private int fAnnotationHeight= -1;
- /** The annotation access */
- private IAnnotationAccess fAnnotationAccess;
- /** The header painter */
- private HeaderPainter fHeaderPainter;
- /** The list of annotation types to be shown in this ruler */
- private Set fAnnotationTypes= new HashSet();
- /** The list of annotation types to be shown in the header of this ruler */
- private Set fHeaderAnnotationTypes= new HashSet();
- /** The mapping between annotation types and colors */
- private Map fAnnotationTypes2Colors= new HashMap();
- /** The color manager */
- private ISharedTextColors fSharedTextColors;
- /**
- * All available annotation types sorted by layer.
- *
- * @since 3.0
- */
- private List fAnnotationsSortedByLayer= new ArrayList();
- /**
- * All available layers sorted by layer.
- * This list may contain duplicates.
- *
- * @since 3.0
- */
- private List fLayersSortedByLayer= new ArrayList();
-
-
- /**
- * Constructs a overview ruler of the given width using the given annotation access and the given
- * color manager.
- *
- * @param annotationAccess the annotation access
- * @param width the width of the vertical ruler
- * @param sharedColors the color manager
- */
- public OverviewRuler(IAnnotationAccess annotationAccess, int width, ISharedTextColors sharedColors) {
- fAnnotationAccess= annotationAccess;
- fWidth= width;
- fSharedTextColors= sharedColors;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerInfo#getControl()
- */
- public Control getControl() {
- return fCanvas;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerInfo#getWidth()
- */
- public int getWidth() {
- return fWidth;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRuler#setModel(org.eclipse.jface.text.source.IAnnotationModel)
- */
- public void setModel(IAnnotationModel model) {
- if (model != fModel || model != null) {
-
- if (fModel != null)
- fModel.removeAnnotationModelListener(fInternalListener);
-
- fModel= model;
-
- if (fModel != null)
- fModel.addAnnotationModelListener(fInternalListener);
-
- update();
- }
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRuler#createControl(org.eclipse.swt.widgets.Composite, org.eclipse.jface.text.ITextViewer)
- */
- public Control createControl(Composite parent, ITextViewer textViewer) {
-
- fTextViewer= textViewer;
-
- fHitDetectionCursor= new Cursor(parent.getDisplay(), SWT.CURSOR_HAND);
-
- fHeader= new Canvas(parent, SWT.NONE);
-
- fCanvas= new Canvas(parent, SWT.NO_BACKGROUND);
-
- fCanvas.addPaintListener(new PaintListener() {
- public void paintControl(PaintEvent event) {
- if (fTextViewer != null)
- doubleBufferPaint(event.gc);
- }
- });
-
- fCanvas.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent event) {
- handleDispose();
- fTextViewer= null;
- }
- });
-
- fCanvas.addMouseListener(new MouseAdapter() {
- public void mouseDown(MouseEvent event) {
- handleMouseDown(event);
- }
- });
-
- fCanvas.addMouseMoveListener(new MouseMoveListener() {
- public void mouseMove(MouseEvent event) {
- handleMouseMove(event);
- }
- });
-
- if (fTextViewer != null)
- fTextViewer.addTextListener(fInternalListener);
-
- return fCanvas;
- }
-
- /**
- * Disposes the ruler's resources.
- */
- private void handleDispose() {
-
- if (fTextViewer != null) {
- fTextViewer.removeTextListener(fInternalListener);
- fTextViewer= null;
- }
-
- if (fModel != null)
- fModel.removeAnnotationModelListener(fInternalListener);
-
- if (fBuffer != null) {
- fBuffer.dispose();
- fBuffer= null;
- }
-
- if (fHitDetectionCursor != null) {
- fHitDetectionCursor.dispose();
- fHitDetectionCursor= null;
- }
-
- fAnnotationTypes.clear();
- fHeaderAnnotationTypes.clear();
- fAnnotationTypes2Colors.clear();
- fAnnotationsSortedByLayer.clear();
- fLayersSortedByLayer.clear();
- }
-
- /**
- * Double buffer drawing.
- *
- * @param dest the gc to draw into
- */
- private void doubleBufferPaint(GC dest) {
-
- Point size= fCanvas.getSize();
-
- if (size.x <= 0 || size.y <= 0)
- return;
-
- if (fBuffer != null) {
- Rectangle r= fBuffer.getBounds();
- if (r.width != size.x || r.height != size.y) {
- fBuffer.dispose();
- fBuffer= null;
- }
- }
- if (fBuffer == null)
- fBuffer= new Image(fCanvas.getDisplay(), size.x, size.y);
-
- GC gc= new GC(fBuffer);
- try {
- gc.setBackground(fCanvas.getBackground());
- gc.fillRectangle(0, 0, size.x, size.y);
-
- if (fTextViewer instanceof ITextViewerExtension3)
- doPaint1(gc);
- else
- doPaint(gc);
-
- } finally {
- gc.dispose();
- }
-
- dest.drawImage(fBuffer, 0, 0);
- }
-
- /**
- * Draws this overview ruler.
- *
- * @param gc the gc to draw into
- */
- private void doPaint(GC gc) {
-
- if (fTextViewer == null)
- return;
-
- Rectangle r= new Rectangle(0, 0, 0, 0);
- int yy, hh= ANNOTATION_HEIGHT;
-
-
- IDocument document= fTextViewer.getDocument();
- IRegion visible= fTextViewer.getVisibleRegion();
-
- StyledText textWidget= fTextViewer.getTextWidget();
- int maxLines= textWidget.getLineCount();
-
- Point size= fCanvas.getSize();
- int writable= maxLines * textWidget.getLineHeight();
- if (size.y > writable)
- size.y= Math.max(writable - fHeader.getSize().y, 0);
-
- for (Iterator iterator= fAnnotationsSortedByLayer.iterator(); iterator.hasNext();) {
- Object annotationType= iterator.next();
-
- if (skip(annotationType))
- continue;
-
- boolean[] temporary= new boolean[] { false, true };
- for (int t=0; t < temporary.length; t++) {
-
- Iterator e= new FilterIterator(annotationType, temporary[t]);
- Color fill= getFillColor(annotationType, temporary[t]);
- Color stroke= getStrokeColor(annotationType, temporary[t]);
-
- for (int i= 0; e.hasNext(); i++) {
-
- Annotation a= (Annotation) e.next();
- Position p= fModel.getPosition(a);
-
- if (p == null || !p.overlapsWith(visible.getOffset(), visible.getLength()))
- continue;
-
- int annotationOffset= Math.max(p.getOffset(), visible.getOffset());
- int annotationEnd= Math.min(p.getOffset() + p.getLength(), visible.getOffset() + visible.getLength());
- int annotationLength= annotationEnd - annotationOffset;
-
- try {
- if (ANNOTATION_HEIGHT_SCALABLE) {
- int numbersOfLines= document.getNumberOfLines(annotationOffset, annotationLength);
- // don't count empty trailing lines
- IRegion lastLine= document.getLineInformationOfOffset(annotationOffset + annotationLength);
- if (lastLine.getOffset() == annotationOffset + annotationLength) {
- numbersOfLines -= 2;
- hh= (numbersOfLines * size.y) / maxLines + ANNOTATION_HEIGHT;
- if (hh < ANNOTATION_HEIGHT)
- hh= ANNOTATION_HEIGHT;
- } else
- hh= ANNOTATION_HEIGHT;
- }
- fAnnotationHeight= hh;
-
- int startLine= textWidget.getLineAtOffset(annotationOffset - visible.getOffset());
- yy= Math.min((startLine * size.y) / maxLines, size.y - hh);
-
- if (fill != null) {
- gc.setBackground(fill);
- gc.fillRectangle(INSET, yy, size.x-(2*INSET), hh);
- }
-
- if (stroke != null) {
- gc.setForeground(stroke);
- r.x= INSET;
- r.y= yy;
- r.width= size.x - (2 * INSET) - 1;
- r.height= hh;
- gc.setLineWidth(1);
- gc.drawRectangle(r);
- }
- } catch (BadLocationException x) {
- }
- }
- }
- }
- }
-
- /**
- * Draws this overview ruler. Uses <code>ITextViewerExtension3</code> for
- * its implementation. Will replace <code>doPaint(GC)</code>.
- *
- * @param gc the gc to draw into
- */
- private void doPaint1(GC gc) {
-
- if (fTextViewer == null)
- return;
-
- Rectangle r= new Rectangle(0, 0, 0, 0);
- int yy, hh= ANNOTATION_HEIGHT;
-
- ITextViewerExtension3 extension= (ITextViewerExtension3) fTextViewer;
- IDocument document= fTextViewer.getDocument();
- StyledText textWidget= fTextViewer.getTextWidget();
-
- int maxLines= textWidget.getLineCount();
- Point size= fCanvas.getSize();
- int writable= maxLines * textWidget.getLineHeight();
- if (size.y > writable)
- size.y= Math.max(writable - fHeader.getSize().y, 0);
-
- for (Iterator iterator= fAnnotationsSortedByLayer.iterator(); iterator.hasNext();) {
- Object annotationType= iterator.next();
-
- if (skip(annotationType))
- continue;
-
- boolean[] temporary= new boolean[] { false, true };
- for (int t=0; t < temporary.length; t++) {
-
- Iterator e= new FilterIterator(annotationType, temporary[t]);
- Color fill= getFillColor(annotationType, temporary[t]);
- Color stroke= getStrokeColor(annotationType, temporary[t]);
-
- for (int i= 0; e.hasNext(); i++) {
-
- Annotation a= (Annotation) e.next();
- Position p= fModel.getPosition(a);
-
- if (p == null)
- continue;
-
- IRegion widgetRegion= extension.modelRange2WidgetRange(new Region(p.getOffset(), p.getLength()));
- if (widgetRegion == null)
- continue;
-
- try {
- if (ANNOTATION_HEIGHT_SCALABLE) {
- int numbersOfLines= document.getNumberOfLines(p.getOffset(), p.getLength());
- // don't count empty trailing lines
- IRegion lastLine= document.getLineInformationOfOffset(p.getOffset() + p.getLength());
- if (lastLine.getOffset() == p.getOffset() + p.getLength()) {
- numbersOfLines -= 2;
- hh= (numbersOfLines * size.y) / maxLines + ANNOTATION_HEIGHT;
- if (hh < ANNOTATION_HEIGHT)
- hh= ANNOTATION_HEIGHT;
- } else
- hh= ANNOTATION_HEIGHT;
- }
- fAnnotationHeight= hh;
-
- int startLine= textWidget.getLineAtOffset(widgetRegion.getOffset());
- yy= Math.min(startLine * (size.y / maxLines), size.y - hh);
-
- if (fill != null) {
- gc.setBackground(fill);
- gc.fillRectangle(INSET, yy, size.x-(2*INSET), hh);
- }
-
- if (stroke != null) {
- gc.setForeground(stroke);
- r.x= INSET;
- r.y= yy;
- r.width= size.x - (2 * INSET) - 1;
- r.height= hh;
- gc.setLineWidth(1);
- gc.drawRectangle(r);
- }
- } catch (BadLocationException x) {
- }
- }
- }
- }
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRuler#update()
- */
- public void update() {
- if (fCanvas != null && !fCanvas.isDisposed()) {
- Display d= fCanvas.getDisplay();
- if (d != null) {
- d.asyncExec(new Runnable() {
- public void run() {
- redraw();
- updateHeader();
- }
- });
- }
- }
- }
-
- /**
- * Redraws the overview ruler.
- */
- private void redraw() {
- if (fCanvas != null && !fCanvas.isDisposed()) {
- GC gc= new GC(fCanvas);
- doubleBufferPaint(gc);
- gc.dispose();
- }
- }
-
- /**
- * Translates a given y-coordinate of this ruler into the corresponding
- * document lines. The number of lines depends on the concrete scaling
- * given as the ration between the height of this ruler and the length
- * of the document.
- *
- * @param y_coordinate the y-coordinate
- * @return the corresponding document lines
- */
- private int[] toLineNumbers(int y_coordinate) {
-
- StyledText textWidget= fTextViewer.getTextWidget();
- int maxLines= textWidget.getContent().getLineCount();
-
- int rulerLength= fCanvas.getSize().y;
- int writable= maxLines * textWidget.getLineHeight();
-
- if (rulerLength > writable)
- rulerLength= Math.max(writable - fHeader.getSize().y, 0);
-
- if (y_coordinate >= writable || y_coordinate >= rulerLength)
- return new int[] {-1, -1};
-
- int[] lines= new int[2];
-
- int pixel= Math.max(y_coordinate - 1, 0);
- lines[0]= (pixel * maxLines) / rulerLength;
-
- pixel= Math.min(rulerLength, y_coordinate + 1);
- lines[1]= (pixel * maxLines) / rulerLength;
-
- if (fTextViewer instanceof ITextViewerExtension3) {
- ITextViewerExtension3 extension= (ITextViewerExtension3) fTextViewer;
- lines[0]= extension.widgetlLine2ModelLine(lines[0]);
- lines[1]= extension.widgetlLine2ModelLine(lines[1]);
- } else {
- try {
- IRegion visible= fTextViewer.getVisibleRegion();
- int lineNumber= fTextViewer.getDocument().getLineOfOffset(visible.getOffset());
- lines[0] += lineNumber;
- lines[1] += lineNumber;
- } catch (BadLocationException x) {
- }
- }
-
- return lines;
- }
-
- /**
- * Returns the position of the first annotation found in the given line range.
- *
- * @param lineNumbers the line range
- * @param ignoreSelectedAnnotation whether to ignore the current selection
- * @return the position of the first found annotation
- */
- private Position getAnnotationPosition(int[] lineNumbers, boolean ignoreSelectedAnnotation) {
- if (lineNumbers[0] == -1)
- return null;
-
- Position found= null;
-
- try {
- IDocument d= fTextViewer.getDocument();
- IRegion line= d.getLineInformation(lineNumbers[0]);
-
- Point currentSelection= fTextViewer.getSelectedRange();
-
- int start= line.getOffset();
-
- line= d.getLineInformation(lineNumbers[lineNumbers.length - 1]);
- int end= line.getOffset() + line.getLength();
-
- for (int i= fAnnotationsSortedByLayer.size() -1; i >= 0; i--) {
-
- Object annotationType= fAnnotationsSortedByLayer.get(i);
-
- Iterator e= new FilterIterator(annotationType);
- while (e.hasNext() && found == null) {
- Annotation a= (Annotation) e.next();
-
- if (skip(fAnnotationAccess.getType(a)))
- continue;
-
- Position p= fModel.getPosition(a);
- if (p == null)
- continue;
-
- int posOffset= p.getOffset();
- int posEnd= posOffset + p.getLength();
- IRegion region= d.getLineInformationOfOffset(posEnd);
- // trailing empty lines don't count
- if (posEnd > posOffset && region.getOffset() == posEnd) {
- posEnd--;
- region= d.getLineInformationOfOffset(posEnd);
- }
-
- if (posOffset <= end && posEnd >= start) {
- if ((found == null || posOffset < found.getOffset()) && (ignoreSelectedAnnotation || currentSelection.x != posOffset || currentSelection.y != p.getLength()))
- found= p;
- }
- }
- }
- } catch (BadLocationException x) {
- }
-
- return found;
- }
-
- /**
- * Returns the line which corresponds best to one of
- * the underlying annotations at the given y-coordinate.
- *
- * @return the best matching line or <code>-1</code> if no such line can be found
- */
- private int findBestMatchingLineNumber(int[] lineNumbers) {
- if (lineNumbers == null || lineNumbers.length < 1)
- return -1;
-
- try {
- Position pos= getAnnotationPosition(lineNumbers, true);
- if (pos == null)
- return -1;
- return fTextViewer.getDocument().getLineOfOffset(pos.getOffset());
- } catch (BadLocationException ex) {
- return -1;
- }
- }
-
- /**
- * Handles mouse clicks.
- *
- * @param event the mouse button down event
- */
- private void handleMouseDown(MouseEvent event) {
- if (fTextViewer != null) {
- int[] lines= toLineNumbers(event.y);
- Position p= getAnnotationPosition(lines, false);
- if (p != null) {
- fTextViewer.revealRange(p.getOffset(), p.getLength());
- fTextViewer.setSelectedRange(p.getOffset(), p.getLength());
- }
- fTextViewer.getTextWidget().setFocus();
- }
- fLastMouseButtonActivityLine= toDocumentLineNumber(event.y);
- }
-
- /**
- * Handles mouse moves.
- *
- * @param event the mouse move event
- */
- private void handleMouseMove(MouseEvent event) {
- if (fTextViewer != null) {
- int[] lines= toLineNumbers(event.y);
- Position p= getAnnotationPosition(lines, true);
- Cursor cursor= (p != null ? fHitDetectionCursor : null);
- if (cursor != fLastCursor) {
- fCanvas.setCursor(cursor);
- fLastCursor= cursor;
- }
- }
- }
-
- /*
- * @see org.eclipse.jface.text.source.IOverviewRuler#addAnnotationType(java.lang.Object)
- */
- public void addAnnotationType(Object annotationType) {
- fAnnotationTypes.add(annotationType);
- }
-
- /*
- * @see org.eclipse.jface.text.source.IOverviewRuler#removeAnnotationType(java.lang.Object)
- */
- public void removeAnnotationType(Object annotationType) {
- fAnnotationTypes.remove(annotationType);
- }
-
- /*
- * @see org.eclipse.jface.text.source.IOverviewRuler#setAnnotationTypeLayer(java.lang.Object, int)
- */
- public void setAnnotationTypeLayer(Object annotationType, int layer) {
- Integer layerObj= new Integer(layer);
- if (fAnnotationsSortedByLayer.remove(annotationType))
- fLayersSortedByLayer.remove(layerObj);
-
- if (layer >= 0) {
- int i= 0;
- int size= fLayersSortedByLayer.size();
- while (i < size && layer >= ((Integer)fLayersSortedByLayer.get(i)).intValue())
- i++;
- fLayersSortedByLayer.add(i, layerObj);
- fAnnotationsSortedByLayer.add(i, annotationType);
- }
- }
-
- /*
- * @see org.eclipse.jface.text.source.IOverviewRuler#setAnnotationTypeColor(java.lang.Object, org.eclipse.swt.graphics.Color)
- */
- public void setAnnotationTypeColor(Object annotationType, Color color) {
- if (color != null)
- fAnnotationTypes2Colors.put(annotationType, color);
- else
- fAnnotationTypes2Colors.remove(annotationType);
- }
-
- /**
- * Returns whether annotation of the given annotation type should be skipped by the drawing routine.
- *
- * @param annotationType the annotation type
- * @return <code>true</code> if annotation of the given type should be skipped
- */
- private boolean skip(Object annotationType) {
- return !fAnnotationTypes.contains(annotationType);
- }
-
- /**
- * Returns a specification of a color that lies between the given
- * foreground and background color using the given scale factor.
- *
- * @param fg the foreground color
- * @param bg the background color
- * @param scale the scale factor
- * @return the interpolated color
- */
- private static RGB interpolate(RGB fg, RGB bg, double scale) {
- return new RGB(
- (int) ((1.0-scale) * fg.red + scale * bg.red),
- (int) ((1.0-scale) * fg.green + scale * bg.green),
- (int) ((1.0-scale) * fg.blue + scale * bg.blue)
- );
- }
-
- /**
- * Returns the grey value in which the given color would be drawn in grey-scale.
- *
- * @param rgb the color
- * @return the grey-scale value
- */
- private static double greyLevel(RGB rgb) {
- if (rgb.red == rgb.green && rgb.green == rgb.blue)
- return rgb.red;
- return (0.299 * rgb.red + 0.587 * rgb.green + 0.114 * rgb.blue + 0.5);
- }
-
- /**
- * Returns whether the given color is dark or light depending on the colors grey-scale level.
- *
- * @param rgb the color
- * @return <code>true</code> if the color is dark, <code>false</code> if it is light
- */
- private static boolean isDark(RGB rgb) {
- return greyLevel(rgb) > 128;
- }
-
- /**
- * Returns a color based on the color configured for the given annotation type and the given scale factor.
- *
- * @param annotationType the annotation type
- * @param scale the scale factor
- * @return the computed color
- */
- private Color getColor(Object annotationType, double scale) {
- Color base= (Color) fAnnotationTypes2Colors.get(annotationType);
- if (base == null)
- return null;
-
- RGB baseRGB= base.getRGB();
- RGB background= fCanvas.getBackground().getRGB();
-
- boolean darkBase= isDark(baseRGB);
- boolean darkBackground= isDark(background);
- if (darkBase && darkBackground)
- background= new RGB(255, 255, 255);
- else if (!darkBase && !darkBackground)
- background= new RGB(0, 0, 0);
-
- return fSharedTextColors.getColor(interpolate(baseRGB, background, scale));
- }
-
- /**
- * Returns the stroke color for the given annotation type and characteristics.
- *
- * @param annotationType the annotation type
- * @param temporary <code>true</code> if for temporary annotations
- * @return the stroke color
- */
- private Color getStrokeColor(Object annotationType, boolean temporary) {
- return getColor(annotationType, temporary ? 0.5 : 0.2);
- }
-
- /**
- * Returns the fill color for the given annotation type and characteristics.
- *
- * @param annotationType the annotation type
- * @param temporary <code>true</code> if for temporary annotations
- * @return the fill color
- */
- private Color getFillColor(Object annotationType, boolean temporary) {
- return getColor(annotationType, temporary ? 0.9 : 0.6);
- }
-
- /*
- * @see IVerticalRulerInfo#getLineOfLastMouseButtonActivity()
- */
- public int getLineOfLastMouseButtonActivity() {
- return fLastMouseButtonActivityLine;
- }
-
- /*
- * @see IVerticalRulerInfo#toDocumentLineNumber(int)
- */
- public int toDocumentLineNumber(int y_coordinate) {
-
- if (fTextViewer == null || y_coordinate == -1)
- return -1;
-
- int[] lineNumbers= toLineNumbers(y_coordinate);
- int bestLine= findBestMatchingLineNumber(lineNumbers);
- if (bestLine == -1 && lineNumbers.length > 0)
- return lineNumbers[0];
- return bestLine;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRuler#getModel()
- */
- public IAnnotationModel getModel() {
- return fModel;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IOverviewRuler#getAnnotationHeight()
- */
- public int getAnnotationHeight() {
- return fAnnotationHeight;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IOverviewRuler#hasAnnotation(int)
- */
- public boolean hasAnnotation(int y) {
- return findBestMatchingLineNumber(toLineNumbers(y)) != -1;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IOverviewRuler#getHeaderControl()
- */
- public Control getHeaderControl() {
- return fHeader;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IOverviewRuler#addHeaderAnnotationType(java.lang.Object)
- */
- public void addHeaderAnnotationType(Object annotationType) {
- fHeaderAnnotationTypes.add(annotationType);
- }
-
- /*
- * @see org.eclipse.jface.text.source.IOverviewRuler#removeHeaderAnnotationType(java.lang.Object)
- */
- public void removeHeaderAnnotationType(Object annotationType) {
- fHeaderAnnotationTypes.remove(annotationType);
- }
-
- /**
- * Updates the header of this ruler.
- */
- private void updateHeader() {
-
- if (fHeader == null || fHeader.isDisposed())
- return;
-
- Object colorType= null;
- outer: for (int i= fAnnotationsSortedByLayer.size() -1; i >= 0; i--) {
-
- Object annotationType= fAnnotationsSortedByLayer.get(i);
-
- if (!fHeaderAnnotationTypes.contains(annotationType) || !fAnnotationTypes.contains(annotationType))
- continue;
-
- for (Iterator e= new FilterIterator(annotationType); e.hasNext();) {
- if (e.next() != null) {
- colorType= annotationType;
- break outer;
- }
- }
- }
-
- Color color= null;
- if (colorType != null)
- color= (Color) fAnnotationTypes2Colors.get(colorType);
-
- if (color == null) {
- if (fHeaderPainter != null)
- fHeaderPainter.setColor(null);
- } else {
- if (fHeaderPainter == null) {
- fHeaderPainter= new HeaderPainter();
- fHeader.addPaintListener(fHeaderPainter);
- }
- fHeaderPainter.setColor(color);
- }
-
- fHeader.redraw();
- updateHeaderToolTipText();
- }
-
- /**
- * Updates the tool tip text of the header of this ruler.
- *
- * @since 3.0
- */
- private void updateHeaderToolTipText() {
-
- if (fHeader == null || fHeader.isDisposed())
- return;
-
- fHeader.setToolTipText(null);
-
- if (!(fAnnotationAccess instanceof IAnnotationAccessExtension))
- return;
-
- String overview= ""; //$NON-NLS-1$
-
- for (int i= fAnnotationsSortedByLayer.size() -1; i >= 0; i--) {
-
- Object annotationType= fAnnotationsSortedByLayer.get(i);
-
- if (!fHeaderAnnotationTypes.contains(annotationType) || !fAnnotationTypes.contains(annotationType))
- continue;
-
- int count= 0;
- String annotationTypeLabel= null;
-
- for (Iterator e= new FilterIterator(annotationType); e.hasNext();) {
- Annotation annotation= (Annotation)e.next();
- if (annotation != null) {
- if (annotationTypeLabel == null)
- annotationTypeLabel= ((IAnnotationAccessExtension)fAnnotationAccess).getTypeLabel(annotation);
- count++;
- }
- }
-
- if (annotationTypeLabel != null) {
- if (overview.length() > 0)
- overview += "\n"; //$NON-NLS-1$
- overview += JFaceTextMessages.getFormattedString("OverviewRulerHeader.toolTipTextEntry", new Object[] {annotationTypeLabel, new Integer(count)}); //$NON-NLS-1$
- }
- }
- if (overview.length() > 0)
- fHeader.setToolTipText(overview);
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRulerHoverManager.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRulerHoverManager.java
deleted file mode 100644
index cab1f914372..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRulerHoverManager.java
+++ /dev/null
@@ -1,77 +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.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-
-import org.eclipse.jface.text.IInformationControlCreator;
-import org.eclipse.jface.text.source.AnnotationBarHoverManager;
-import org.eclipse.jface.text.source.IAnnotationHover;
-import org.eclipse.jface.text.source.ISourceViewer;
-
-/**
- * This manager controls the layout, content, and visibility of an information
- * control in reaction to mouse hover events issued by the overview ruler of a
- * source viewer.
- *
- * @since 2.1
- */
-class OverviewRulerHoverManager extends AnnotationBarHoverManager {
-
- /**
- * Creates an overview hover manager with the given parameters. In addition,
- * the hovers anchor is RIGHT and the margin is 5 points to the right.
- *
- * @param ruler the overview ruler this manager connects to
- * @param sourceViewer the source viewer this manager connects to
- * @param annotationHover the annotation hover providing the information to be displayed
- * @param creator the information control creator
- */
- public OverviewRulerHoverManager(IOverviewRuler ruler, ISourceViewer sourceViewer, IAnnotationHover annotationHover, IInformationControlCreator creator) {
- super(ruler, sourceViewer, annotationHover, creator);
- setAnchor(ANCHOR_LEFT);
- }
-
- /*
- * @see AbstractHoverInformationControlManager#computeInformation()
- */
- protected void computeInformation() {
- Point location= getHoverEventLocation();
- int line= getVerticalRulerInfo().toDocumentLineNumber(location.y);
- setInformation(getAnnotationHover().getHoverInfo(getSourceViewer(), line), computeArea(location.y));
- }
-
- /**
- * Determines graphical area covered for which the hover is valid.
- *
- * @param y-coordinate in the vertical ruler
- * @return the graphical extend where the hover is valid
- */
- private Rectangle computeArea(int y) {
- // This is ok (see constructor)
- IOverviewRuler overviewRuler= (IOverviewRuler) getVerticalRulerInfo();
-
- int hover_height= overviewRuler.getAnnotationHeight();
- int hover_width= getVerticalRulerInfo().getControl().getSize().x;
-
- // Calculate y-coordinate for hover
- int hover_y= y;
- boolean hasAnnotation= true;
- while (hasAnnotation && hover_y > y - hover_height) {
- hover_y--;
- hasAnnotation= overviewRuler.hasAnnotation(hover_y);
- }
- hover_y++;
-
- return new Rectangle(0, hover_y, hover_width, hover_height);
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java
deleted file mode 100644
index f242dc8c7fc..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java
+++ /dev/null
@@ -1,789 +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.Stack;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Layout;
-
-import org.eclipse.jface.text.AbstractHoverInformationControlManager;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.DefaultPositionUpdater;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IPositionUpdater;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.IRewriteTarget;
-import org.eclipse.jface.text.ITextViewerExtension2;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextViewer;
-import org.eclipse.jface.text.contentassist.IContentAssistant;
-import org.eclipse.jface.text.formatter.FormattingContext;
-import org.eclipse.jface.text.formatter.FormattingContextProperties;
-import org.eclipse.jface.text.formatter.IContentFormatter;
-import org.eclipse.jface.text.formatter.IContentFormatterExtension2;
-import org.eclipse.jface.text.formatter.IFormattingContext;
-import org.eclipse.jface.text.information.IInformationPresenter;
-import org.eclipse.jface.text.presentation.IPresentationReconciler;
-import org.eclipse.jface.text.reconciler.IReconciler;
-
-/**
- * SWT based implementation of <code>ISourceViewer</code>. The same rules apply
- * as for <code>TextViewer</code>. A source viewer uses an <code>IVerticalRuler</code>
- * as its annotation presentation area. The vertical ruler is a small strip shown left
- * of the viewer's text widget. A source viewer uses an <code>IOverviewRuler</code>
- * as its presentation area for the annotation overview. The overview ruler is a small strip
- * shown right of the viewer's text widget.<p>
- * Clients are supposed to instantiate a source viewer and subsequently to communicate
- * with it exclusively using the <code>ISourceViewer</code> interface. Clients should not
- * subclass this class as it is rather likely that subclasses will be broken by future releases.
- */
-public class SourceViewer extends TextViewer implements ISourceViewer, ISourceViewerExtension {
-
-
- /**
- * Layout of a source viewer. Vertical ruler, text widget, and overview ruler are shown side by side.
- */
- class RulerLayout extends Layout {
-
- /** The gap between the text viewer and the vertical ruler. */
- protected int fGap;
-
- /**
- * Creates a new ruler layout with the given gap between text viewer and vertical ruler.
- *
- * @param gap the gap between text viewer and vertical ruler
- */
- protected RulerLayout(int gap) {
- fGap= gap;
- }
-
- /*
- * @see Layout#computeSize(Composite, int, int, boolean)
- */
- protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) {
- Control[] children= composite.getChildren();
- Point s= children[children.length - 1].computeSize(SWT.DEFAULT, SWT.DEFAULT, flushCache);
- if (fVerticalRuler != null && fIsVerticalRulerVisible)
- s.x += fVerticalRuler.getWidth() + fGap;
- return s;
- }
-
- /*
- * @see Layout#layout(Composite, boolean)
- */
- protected void layout(Composite composite, boolean flushCache) {
- Rectangle clArea= composite.getClientArea();
- if (fVerticalRuler != null && fIsVerticalRulerVisible) {
-
- Rectangle trim= getTextWidget().computeTrim(0, 0, 0, 0);
- int scrollbarHeight= trim.height;
-
- int verticalRulerWidth= fVerticalRuler.getWidth();
- int overviewRulerWidth= 0;
- if (fOverviewRuler != null && fIsOverviewRulerVisible) {
- overviewRulerWidth= fOverviewRuler.getWidth();
- fOverviewRuler.getControl().setBounds(clArea.width - overviewRulerWidth -1, scrollbarHeight, overviewRulerWidth, clArea.height - 3*scrollbarHeight);
- fOverviewRuler.getHeaderControl().setBounds(clArea.width - overviewRulerWidth -1, 0, overviewRulerWidth, scrollbarHeight);
- }
-
- getTextWidget().setBounds(verticalRulerWidth + fGap, 0, clArea.width - verticalRulerWidth - overviewRulerWidth - 2*fGap, clArea.height);
- fVerticalRuler.getControl().setBounds(0, 0, verticalRulerWidth, clArea.height - scrollbarHeight);
-
- } else
- getTextWidget().setBounds(0, 0, clArea.width, clArea.height);
- }
- }
-
- /**
- * Partial name of the position category to manage remembered selections.
- * @since 3.0
- */
- protected final static String _SELECTION_POSITION_CATEGORY= "__selection_category"; //$NON-NLS-1$
-
-
- /** The viewer's content assistant */
- protected IContentAssistant fContentAssistant;
- /**
- * Flag indicating whether the viewer's content assistant is installed
- * @since 2.0
- */
- protected boolean fContentAssistantInstalled;
- /** The viewer's content formatter */
- protected IContentFormatter fContentFormatter;
- /** The viewer's model reconciler */
- protected IReconciler fReconciler;
- /** The viewer's presentation reconciler */
- protected IPresentationReconciler fPresentationReconciler;
- /** The viewer's annotation hover */
- protected IAnnotationHover fAnnotationHover;
- /**
- * Stack of saved selections in the underlying document
- * @since 3.0
- */
- protected final Stack fSelections= new Stack();
- /**
- * Position updater for saved selections
- * @since 3.0
- */
- protected IPositionUpdater fSelectionUpdater= null;
- /**
- * Position category used by the selection updater
- * @since 3.0
- */
- protected String fSelectionCategory;
- /**
- * The viewer's overview ruler annotation hover
- * @since 3.0
- */
- protected IAnnotationHover fOverviewRulerAnnotationHover;
- /**
- * The viewer's information presenter
- * @since 2.0
- */
- protected IInformationPresenter fInformationPresenter;
-
- /** Visual vertical ruler */
- private IVerticalRuler fVerticalRuler;
- /** Visibility of vertical ruler */
- private boolean fIsVerticalRulerVisible;
- /** The SWT widget used when supporting a vertical ruler */
- private Composite fComposite;
- /** The vertical ruler's annotation model */
- private VisualAnnotationModel fVisualAnnotationModel;
- /** The viewer's range indicator to be shown in the vertical ruler */
- private Annotation fRangeIndicator;
- /** The viewer's vertical ruler hovering controller */
- private AbstractHoverInformationControlManager fVerticalRulerHoveringController;
- /**
- * The viewer's overview ruler hovering controller
- * @since 2.1
- */
- private AbstractHoverInformationControlManager fOverviewRulerHoveringController;
-
- /**
- * The overview ruler.
- * @since 2.1
- */
- private IOverviewRuler fOverviewRuler;
- /**
- * The visibility of the overview ruler
- * @since 2.1
- */
- private boolean fIsOverviewRulerVisible;
-
-
- /** The size of the gap between the vertical ruler and the text widget */
- protected final static int GAP_SIZE= 2;
-
-
- /**
- * Constructs a new source viewer. The vertical ruler is initially visible.
- * The viewer has not yet been initialized with a source viewer configuration.
- *
- * @param parent the parent of the viewer's control
- * @param ruler the vertical ruler used by this source viewer
- * @param styles the SWT style bits
- */
- public SourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
- this(parent, ruler, null, false, styles);
- }
-
- /**
- * Constructs a new source viewer. The vertical ruler is initially visible.
- * The overview ruler visibility is controlled by the value of <code>showAnnotationsOverview</code>.
- * The viewer has not yet been initialized with a source viewer configuration.
- *
- * @param parent the parent of the viewer's control
- * @param verticalRuler the vertical ruler used by this source viewer
- * @param overviewRuler the overview ruler
- * @param showAnnotationsOverview <code>true</code> if the overview ruler should be visible, <code>false</code> otherwise
- * @param styles the SWT style bits
- * @since 2.1
- */
- public SourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler, boolean showAnnotationsOverview, int styles) {
- super();
-
- fVerticalRuler= verticalRuler;
- fIsVerticalRulerVisible= (verticalRuler != null);
- fOverviewRuler= overviewRuler;
- fIsOverviewRulerVisible= (showAnnotationsOverview && overviewRuler != null);
-
- createControl(parent, styles);
- }
-
- /*
- * @see TextViewer#createControl(Composite, int)
- */
- protected void createControl(Composite parent, int styles) {
-
- if (fVerticalRuler != null || fOverviewRuler != null) {
- styles= (styles & ~SWT.BORDER);
- fComposite= new Canvas(parent, SWT.NONE);
- fComposite.setLayout(new RulerLayout(GAP_SIZE));
- parent= fComposite;
- }
-
- super.createControl(parent, styles);
-
- if (fVerticalRuler != null)
- fVerticalRuler.createControl(fComposite, this);
- if (fOverviewRuler != null)
- fOverviewRuler.createControl(fComposite, this);
- }
-
- /*
- * @see TextViewer#getControl()
- */
- public Control getControl() {
- if (fComposite != null)
- return fComposite;
- return super.getControl();
- }
-
- /*
- * @see ISourceViewer#setAnnotationHover(IAnnotationHover)
- */
- public void setAnnotationHover(IAnnotationHover annotationHover) {
- fAnnotationHover= annotationHover;
- }
-
- /**
- * Sets the overview ruler's annotation hover of this source viewer.
- * The annotation hover provides the information to be displayed in a hover
- * popup window if requested over the overview rulers area. The annotation
- * hover is assumed to be line oriented.
- *
- * @param annotationHover the hover to be used, <code>null</code> is a valid argument
- * @since 3.0
- */
- public void setOverviewRulerAnnotationHover(IAnnotationHover annotationHover) {
- fOverviewRulerAnnotationHover= annotationHover;
- }
-
- /*
- * @see ISourceViewer#configure(SourceViewerConfiguration)
- */
- public void configure(SourceViewerConfiguration configuration) {
-
- if (getTextWidget() == null)
- return;
-
- setDocumentPartitioning(configuration.getConfiguredDocumentPartitioning(this));
-
- // install content type independent plugins
- fPresentationReconciler= configuration.getPresentationReconciler(this);
- if (fPresentationReconciler != null)
- fPresentationReconciler.install(this);
-
- fReconciler= configuration.getReconciler(this);
- if (fReconciler != null)
- fReconciler.install(this);
-
- fContentAssistant= configuration.getContentAssistant(this);
- if (fContentAssistant != null) {
- fContentAssistant.install(this);
- fContentAssistantInstalled= true;
- }
-
- fContentFormatter= configuration.getContentFormatter(this);
-
- fInformationPresenter= configuration.getInformationPresenter(this);
- if (fInformationPresenter != null)
- fInformationPresenter.install(this);
-
- setUndoManager(configuration.getUndoManager(this));
-
- getTextWidget().setTabs(configuration.getTabWidth(this));
-
- setAnnotationHover(configuration.getAnnotationHover(this));
- setOverviewRulerAnnotationHover(configuration.getOverviewRulerAnnotationHover(this));
-
- setHoverControlCreator(configuration.getInformationControlCreator(this));
-
- // install content type specific plugins
- String[] types= configuration.getConfiguredContentTypes(this);
- for (int i= 0; i < types.length; i++) {
-
- String t= types[i];
-
- setAutoIndentStrategy(configuration.getAutoIndentStrategy(this, t), t);
- setTextDoubleClickStrategy(configuration.getDoubleClickStrategy(this, t), t);
-
- int[] stateMasks= configuration.getConfiguredTextHoverStateMasks(this, t);
- if (stateMasks != null) {
- for (int j= 0; j < stateMasks.length; j++) {
- int stateMask= stateMasks[j];
- setTextHover(configuration.getTextHover(this, t, stateMask), t, stateMask);
- }
- } else {
- setTextHover(configuration.getTextHover(this, t), t, ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK);
- }
-
- String[] prefixes= configuration.getIndentPrefixes(this, t);
- if (prefixes != null && prefixes.length > 0)
- setIndentPrefixes(prefixes, t);
-
- prefixes= configuration.getDefaultPrefixes(this, t);
- if (prefixes != null && prefixes.length > 0)
- setDefaultPrefixes(prefixes, t);
- }
-
- activatePlugins();
- }
-
- /**
- * After this method has been executed the caller knows that any installed annotation hover has been installed.
- */
- protected void ensureAnnotationHoverManagerInstalled() {
- if (fVerticalRuler != null && fAnnotationHover != null && fVerticalRulerHoveringController == null && fHoverControlCreator != null) {
- fVerticalRulerHoveringController= new AnnotationBarHoverManager(fVerticalRuler, this, fAnnotationHover, fHoverControlCreator);
- fVerticalRulerHoveringController.install(fVerticalRuler.getControl());
- }
- }
-
- /**
- * After this method has been executed the caller knows that any installed overview hover has been installed.
- */
- protected void ensureOverviewHoverManagerInstalled() {
- if (fOverviewRuler != null && fOverviewRulerAnnotationHover != null && fOverviewRulerHoveringController == null && fHoverControlCreator != null) {
- fOverviewRulerHoveringController= new OverviewRulerHoverManager(fOverviewRuler, this, fOverviewRulerAnnotationHover, fHoverControlCreator);
- fOverviewRulerHoveringController.install(fOverviewRuler.getControl());
- }
- }
-
- /*
- * @see TextViewer#activatePlugins()
- */
- public void activatePlugins() {
- ensureAnnotationHoverManagerInstalled();
- ensureOverviewHoverManagerInstalled();
- super.activatePlugins();
- }
-
- /*
- * @see ISourceViewer#setDocument(IDocument, IAnnotationModel)
- */
- public void setDocument(IDocument document) {
- setDocument(document, null, -1, -1);
- }
-
- /*
- * @see ISourceViewer#setDocument(IDocument, IAnnotationModel, int, int)
- */
- public void setDocument(IDocument document, int visibleRegionOffset, int visibleRegionLength) {
- setDocument(document, null, visibleRegionOffset, visibleRegionLength);
- }
-
- /*
- * @see ISourceViewer#setDocument(IDocument, IAnnotationModel)
- */
- public void setDocument(IDocument document, IAnnotationModel annotationModel) {
- setDocument(document, annotationModel, -1, -1);
- }
-
- /*
- * @see ISourceViewer#setDocument(IDocument, IAnnotationModel, int, int)
- */
- public void setDocument(IDocument document, IAnnotationModel annotationModel, int visibleRegionOffset, int visibleRegionLength) {
-
- if (fVerticalRuler == null && fOverviewRuler == null) {
-
- if (visibleRegionOffset == -1 && visibleRegionLength == -1)
- super.setDocument(document);
- else
- super.setDocument(document, visibleRegionOffset, visibleRegionLength);
-
- } else {
-
- if (fVisualAnnotationModel != null && getDocument() != null)
- fVisualAnnotationModel.disconnect(getDocument());
-
- if (annotationModel != null && document != null) {
- fVisualAnnotationModel= new VisualAnnotationModel(annotationModel);
- fVisualAnnotationModel.connect(document);
- } else {
- fVisualAnnotationModel= null;
- }
-
- if (visibleRegionOffset == -1 && visibleRegionLength == -1)
- super.setDocument(document);
- else
- super.setDocument(document, visibleRegionOffset, visibleRegionLength);
-
- if (fVerticalRuler != null)
- fVerticalRuler.setModel(fVisualAnnotationModel);
-
- if (fOverviewRuler != null)
- fOverviewRuler.setModel(fVisualAnnotationModel);
- }
- }
-
- /*
- * @see ISourceViewer#getAnnotationModel()
- */
- public IAnnotationModel getAnnotationModel() {
- if (fVisualAnnotationModel != null)
- return fVisualAnnotationModel.getModelAnnotationModel();
- return null;
- }
-
- /*
- * @see TextViewer#handleDispose()
- */
- protected void handleDispose() {
-
- clearRememberedSelection();
-
- if (fPresentationReconciler != null) {
- fPresentationReconciler.uninstall();
- fPresentationReconciler= null;
- }
-
- if (fReconciler != null) {
- fReconciler.uninstall();
- fReconciler= null;
- }
-
- if (fContentAssistant != null) {
- fContentAssistant.uninstall();
- fContentAssistantInstalled= false;
- fContentAssistant= null;
- }
-
- fContentFormatter= null;
-
- if (fInformationPresenter != null) {
- fInformationPresenter.uninstall();
- fInformationPresenter= null;
- }
-
- if (fVisualAnnotationModel != null && getDocument() != null) {
- fVisualAnnotationModel.disconnect(getDocument());
- fVisualAnnotationModel= null;
- }
-
- fVerticalRuler= null;
-
- if (fVerticalRulerHoveringController != null) {
- fVerticalRulerHoveringController.dispose();
- fVerticalRulerHoveringController= null;
- }
-
- fOverviewRuler= null;
-
- if (fOverviewRulerHoveringController != null) {
- fOverviewRulerHoveringController.dispose();
- fOverviewRulerHoveringController= null;
- }
-
- // http://dev.eclipse.org/bugs/show_bug.cgi?id=15300
- fComposite= null;
-
- super.handleDispose();
- }
-
- /*
- * @see ITextOperationTarget#canDoOperation(int)
- */
- public boolean canDoOperation(int operation) {
-
- if (getTextWidget() == null || (!redraws() && operation != FORMAT))
- return false;
-
- if (operation == CONTENTASSIST_PROPOSALS)
- return fContentAssistant != null && fContentAssistantInstalled && isEditable();
-
- if (operation == CONTENTASSIST_CONTEXT_INFORMATION)
- return fContentAssistant != null && fContentAssistantInstalled && isEditable();
-
- if (operation == INFORMATION)
- return fInformationPresenter != null;
-
- if (operation == FORMAT) {
- Point p= getSelectedRange();
- int length= (p == null ? -1 : p.y);
- return (fContentFormatter != null && isEditable() && (length == 0 || isBlockSelected()));
- }
-
- return super.canDoOperation(operation);
- }
-
- /**
- * Creates a new formatting context for a format operation.
- * <p>
- * After the use of the context, clients are required to call
- * its <code>dispose</code> method.
- *
- * @return The new formatting context
- */
- protected IFormattingContext createFormattingContext() {
- return new FormattingContext();
- }
-
- /**
- * Remembers and returns the current selection. The saved selection can be restored
- * by calling <code>restoreSelection()</code>.
- *
- * @return the current selection
- * @see org.eclipse.jface.text.ITextViewer#getSelectedRange()
- * @since 3.0
- */
- protected Point rememberSelection() {
-
- final Point selection= getSelectedRange();
- final IDocument document= getDocument();
-
- if (fSelections.isEmpty()) {
- fSelectionCategory= _SELECTION_POSITION_CATEGORY + hashCode();
- fSelectionUpdater= new DefaultPositionUpdater(fSelectionCategory);
- document.addPositionCategory(fSelectionCategory);
- document.addPositionUpdater(fSelectionUpdater);
- }
-
- try {
-
- final Position position= new Position(selection.x, selection.y);
- document.addPosition(fSelectionCategory, position);
- fSelections.push(position);
-
- } catch (BadLocationException exception) {
- // Should not happen
- } catch (BadPositionCategoryException exception) {
- // Should not happen
- }
-
- return selection;
- }
-
- /**
- * Restores a previously saved selection in the document.
- * <p>
- * If no selection was previously saved, nothing happens.
- *
- * @since 3.0
- */
- protected void restoreSelection() {
-
- if (!fSelections.isEmpty()) {
-
- final IDocument document= getDocument();
- final Position position= (Position) fSelections.pop();
-
- try {
- document.removePosition(fSelectionCategory, position);
- setSelectedRange(position.getOffset(), position.getLength());
-
- if (fSelections.isEmpty()) {
-
- document.removePositionUpdater(fSelectionUpdater);
- fSelectionUpdater= null;
- document.removePositionCategory(fSelectionCategory);
- fSelectionCategory= null;
- }
- } catch (BadPositionCategoryException exception) {
- // Should not happen
- }
- }
- }
-
- protected void clearRememberedSelection() {
- if (fSelections.isEmpty())
- return;
- fSelections.clear();
-
- IDocument document= getDocument();
- document.removePositionUpdater(fSelectionUpdater);
- fSelectionUpdater= null;
-
- try {
- document.removePositionCategory(fSelectionCategory);
- } catch (BadPositionCategoryException e) {
- // ignore
- }
- fSelectionCategory= null;
- }
-
- /*
- * @see ITextOperationTarget#doOperation(int)
- */
- public void doOperation(int operation) {
-
- if (getTextWidget() == null || (!redraws() && operation != FORMAT))
- return;
-
- switch (operation) {
- case CONTENTASSIST_PROPOSALS:
- fContentAssistant.showPossibleCompletions();
- return;
- case CONTENTASSIST_CONTEXT_INFORMATION:
- fContentAssistant.showContextInformation();
- return;
- case INFORMATION:
- fInformationPresenter.showInformation();
- return;
- case FORMAT :
- {
- final Point selection= rememberSelection();
-
- final IRegion region= new Region(selection.x, selection.y);
- final IRewriteTarget target= getRewriteTarget();
- final IFormattingContext context= createFormattingContext();
-
- if (selection.y == 0) {
- context.setProperty(FormattingContextProperties.CONTEXT_DOCUMENT, Boolean.TRUE);
- } else {
- context.setProperty(FormattingContextProperties.CONTEXT_DOCUMENT, Boolean.FALSE);
- context.setProperty(FormattingContextProperties.CONTEXT_REGION, region);
- }
- try {
- setRedraw(false);
- startSequentialRewriteMode(false);
- target.beginCompoundChange();
-
- final IDocument document= getDocument();
- if (fContentFormatter instanceof IContentFormatterExtension2) {
-
- final IContentFormatterExtension2 extension= (IContentFormatterExtension2)fContentFormatter;
- extension.format(document, context);
-
- } else
- fContentFormatter.format(document, region);
-
- } finally {
-
- target.endCompoundChange();
- stopSequentialRewriteMode();
- setRedraw(true);
-
- restoreSelection();
- context.dispose();
- }
- return;
- }
- default :
- super.doOperation(operation);
- }
- }
-
- /*
- * @see ITextOperationTargetExtension#enableOperation(int, boolean)
- * @since 2.0
- */
- public void enableOperation(int operation, boolean enable) {
-
- switch (operation) {
- case CONTENTASSIST_PROPOSALS:
- case CONTENTASSIST_CONTEXT_INFORMATION: {
-
- if (fContentAssistant == null)
- return;
-
- if (enable) {
- if (!fContentAssistantInstalled) {
- fContentAssistant.install(this);
- fContentAssistantInstalled= true;
- }
- } else if (fContentAssistantInstalled) {
- fContentAssistant.uninstall();
- fContentAssistantInstalled= false;
- }
- }
- }
- }
-
- /*
- * @see ISourceViewer#setRangeIndicator(Annotation)
- */
- public void setRangeIndicator(Annotation rangeIndicator) {
- fRangeIndicator= rangeIndicator;
- }
-
- /*
- * @see ISourceViewer#setRangeIndication(int, int, boolean)
- */
- public void setRangeIndication(int start, int length, boolean moveCursor) {
-
- if (moveCursor) {
- setSelectedRange(start, 0);
- revealRange(start, length);
- }
-
- if (fRangeIndicator != null && fVisualAnnotationModel != null)
- fVisualAnnotationModel.modifyAnnotation(fRangeIndicator, new Position(start, length));
- }
-
- /*
- * @see ISourceViewer#getRangeIndication()
- */
- public IRegion getRangeIndication() {
- if (fRangeIndicator != null && fVisualAnnotationModel != null) {
- Position position= fVisualAnnotationModel.getPosition(fRangeIndicator);
- if (position != null)
- return new Region(position.getOffset(), position.getLength());
- }
-
- return null;
- }
-
- /*
- * @see ISourceViewer#removeRangeIndication()
- */
- public void removeRangeIndication() {
- if (fRangeIndicator != null && fVisualAnnotationModel != null)
- fVisualAnnotationModel.modifyAnnotation(fRangeIndicator, null);
- }
-
- /*
- * @see ISourceViewer#showAnnotations(boolean)
- */
- public void showAnnotations(boolean show) {
- boolean old= fIsVerticalRulerVisible;
- fIsVerticalRulerVisible= (show && fVerticalRuler != null);
- if (old != fIsVerticalRulerVisible) {
- if (fComposite != null && !fComposite.isDisposed())
- fComposite.layout();
- if (fIsVerticalRulerVisible) {
- ensureAnnotationHoverManagerInstalled();
- } else if (fVerticalRulerHoveringController != null) {
- fVerticalRulerHoveringController.dispose();
- fVerticalRulerHoveringController= null;
- }
- }
- }
-
- /*
- * @see org.eclipse.jface.text.source.ISourceViewerExtension#showAnnotationsOverview(boolean)
- * @since 2.1
- */
- public void showAnnotationsOverview(boolean show) {
- boolean old= fIsOverviewRulerVisible;
- fIsOverviewRulerVisible= (show && fOverviewRuler != null);
- if (old != fIsOverviewRulerVisible) {
- if (fComposite != null && !fComposite.isDisposed())
- fComposite.layout();
- if (fIsOverviewRulerVisible) {
- ensureOverviewHoverManagerInstalled();
- } else if (fOverviewRulerHoveringController != null) {
- fOverviewRulerHoveringController.dispose();
- fOverviewRulerHoveringController= null;
- }
- }
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewerConfiguration.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewerConfiguration.java
deleted file mode 100644
index 9da70812c1a..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewerConfiguration.java
+++ /dev/null
@@ -1,304 +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.widgets.Shell;
-
-import org.eclipse.jface.text.DefaultAutoIndentStrategy;
-import org.eclipse.jface.text.DefaultInformationControl;
-import org.eclipse.jface.text.DefaultTextDoubleClickStrategy;
-import org.eclipse.jface.text.DefaultUndoManager;
-import org.eclipse.jface.text.IAutoIndentStrategy;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentExtension3;
-import org.eclipse.jface.text.IInformationControl;
-import org.eclipse.jface.text.IInformationControlCreator;
-import org.eclipse.jface.text.ITextDoubleClickStrategy;
-import org.eclipse.jface.text.ITextHover;
-import org.eclipse.jface.text.IUndoManager;
-import org.eclipse.jface.text.contentassist.IContentAssistant;
-import org.eclipse.jface.text.formatter.IContentFormatter;
-import org.eclipse.jface.text.information.IInformationPresenter;
-import org.eclipse.jface.text.presentation.IPresentationReconciler;
-import org.eclipse.jface.text.reconciler.IReconciler;
-
-
-/**
- * This class bundles the whole configuration space of a source viewer.
- * Instances of this class are passed to the <code>configure</code> method of
- * <code>ISourceViewer</code>.<p>
- * Each method in this class get as argument the source viewer for which it should
- * provide a particular configurational setting such as a presentation reconciler.
- * Based on its specific knowledge about the returned object, the configuration
- * might share such objects or compute them according to some rules.<p>
- * Clients should subclass and override just those methods which must be specific to
- * their needs.
- *
- * @see ISourceViewer
- */
-public class SourceViewerConfiguration {
-
-
- /**
- * Creates a new source viewer configuration that behaves according to
- * specification of this class' methods.
- */
- public SourceViewerConfiguration() {
- super();
- }
-
- /**
- * Returns the visual width of the tab character. This implementation always
- * returns 4.
- *
- * @param sourceViewer the source viewer to be configured by this configuration
- * @return the tab width
- */
- public int getTabWidth(ISourceViewer sourceViewer) {
- return 4;
- }
-
- /**
- * Returns the undo manager for the given source viewer. This implementation
- * always returns a new instance of <code>DefaultUndoManager</code> whose
- * history length is set to 25.
- *
- * @param sourceViewer the source viewer to be configured by this configuration
- * @return an undo manager or <code>null</code> if no undo/redo should not be supported
- */
- public IUndoManager getUndoManager(ISourceViewer sourceViewer) {
- return new DefaultUndoManager(25);
- }
-
- /**
- * Returns the reconciler ready to be used with the given source viewer.
- * This implementation always returns <code>null</code>.
- *
- * @param sourceViewer the source viewer to be configured by this configuration
- * @return a reconciler or <code>null</code> if reconciling should not be supported
- */
- public IReconciler getReconciler(ISourceViewer sourceViewer) {
- return null;
- }
-
- /**
- * Returns the presentation reconciler ready to be used with the given source viewer.
- * This implementation always returns <code>null</code>.
- *
- * @return the presentation reconciler or <code>null</code> if presentation reconciling should not be supported
- */
- public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
- return null;
- }
-
- /**
- * Returns the content formatter ready to be used with the given source viewer.
- * This implementation always returns <code>null</code>.
- *
- * @param sourceViewer the source viewer to be configured by this configuration
- * @return a content formatter or <code>null</code> if formatting should not be supported
- */
- public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
- return null;
- }
-
- /**
- * Returns the content assistant ready to be used with the given source viewer.
- * This implementation always returns <code>null</code>.
- *
- * @param sourceViewer the source viewer to be configured by this configuration
- * @return a content assistant or <code>null</code> if content assist should not be supported
- */
- public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
- return null;
- }
-
- /**
- * Returns the auto indentation strategy ready to be used with the given source viewer
- * when manipulating text of the given content type. This implementation always
- * returns an new instance of <code>DefaultAutoIndentStrategy</code>.
- *
- * @param sourceViewer the source viewer to be configured by this configuration
- * @param contentType the content type for which the strategy is applicable
- * @return the auto indent strategy or <code>null</code> if automatic indentation is not to be enabled
- */
- public IAutoIndentStrategy getAutoIndentStrategy(ISourceViewer sourceViewer, String contentType) {
- return new DefaultAutoIndentStrategy();
- }
- /**
- * Returns the default prefixes to be used by the line-prefix operation
- * in the given source viewer for text of the given content type. This implementation always
- * returns <code>null</code>.
- *
- * @param sourceViewer the source viewer to be configured by this configuration
- * @param contentType the content type for which the prefix is applicable
- * @return the default prefixes or <code>null</code> if the prefix operation should not be supported
- * @since 2.0
- */
- public String[] getDefaultPrefixes(ISourceViewer sourceViewer, String contentType) {
- return null;
- }
-
- /**
- * Returns the double-click strategy ready to be used in this viewer when double clicking
- * onto text of the given content type. This implementation always returns a new instance of
- * <code>DefaultTextDoubleClickStrategy</code>.
- *
- * @param sourceViewer the source viewer to be configured by this configuration
- * @param contentType the content type for which the strategy is applicable
- * @return a double-click strategy or <code>null</code> if double clicking should not be supported
- */
- public ITextDoubleClickStrategy getDoubleClickStrategy(ISourceViewer sourceViewer, String contentType) {
- return new DefaultTextDoubleClickStrategy();
- }
-
- /**
- * Returns the prefixes to be used by the line-shift operation. This implementation
- * always returns <code>new String[] { "\t", " " }</code>.
- *
- * @param sourceViewer the source viewer to be configured by this configuration
- * @param contentType the content type for which the prefix is applicable
- * @return the prefixes or <code>null</code> if the prefix operation should not be supported
- */
- public String[] getIndentPrefixes(ISourceViewer sourceViewer, String contentType) {
- return new String[] { "\t", " ", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- /**
- * Returns the annotation hover which will provide the information to be
- * shown in a hover popup window when requested for the given
- * source viewer.This implementation always returns <code>null</code>.
- *
- * @param sourceViewer the source viewer to be configured by this configuration
- * @return an annotation hover or <code>null</code> if no hover support should be installed
- */
- public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
- return null;
- }
-
- /**
- * Returns the annotation hover which will provide the information to be
- * shown in a hover popup window when requested for the overview ruler
- * of the given source viewer.This implementation always returns the general
- * annotation hover returned by <code>getAnnotationHover</code>.
- *
- * @param sourceViewer the source viewer to be configured by this configuration
- * @return an annotation hover or <code>null</code> if no hover support should be installed
- * @since 3.0
- */
- public IAnnotationHover getOverviewRulerAnnotationHover(ISourceViewer sourceViewer) {
- return getAnnotationHover(sourceViewer);
- }
-
- /**
- * Returns the SWT event state masks for which text hover are configured for
- * the given content type.
- *
- * @param sourceViewer the source viewer to be configured by this configuration
- * @param contentType the content type
- * @return an <code>int</code> array with the configured SWT event state masks
- * or <code>null</code> if text hovers are not supported for the given content type
- * @since 2.1
- */
- public int[] getConfiguredTextHoverStateMasks(ISourceViewer sourceViewer, String contentType) {
- return null;
- }
-
- /**
- * Returns the text hover which will provide the information to be shown
- * in a text hover popup window when requested for the given source viewer and
- * the given content type. This implementation always returns <code>
- * null</code>.
- *
- * @param sourceViewer the source viewer to be configured by this configuration
- * @param contentType the content type
- * @param stateMask the SWT event state mask
- * @return a text hover or <code>null</code> if no hover support should be installed
- * @since 2.1
- */
- public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType, int stateMask) {
- return null;
- }
-
- /**
- * Returns the text hover which will provide the information to be shown
- * in a text hover popup window when requested for the given source viewer and
- * the given content type. This implementation always returns <code>
- * null</code>.
- *
- * @param sourceViewer the source viewer to be configured by this configuration
- * @param contentType the content type
- * @return a text hover or <code>null</code> if no hover support should be installed
- */
- public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) {
- return null;
- }
-
- /**
- * Returns the information control creator. The creator is a factory creating information
- * controls for the given source viewer. This implementation always returns a creator for
- * <code>DefaultInformationControl</code> instances.
- *
- * @param sourceViewer the source viewer to be configured by this configuration
- * @return the information control creator or <code>null</code> if no information support should be installed
- * @since 2.0
- */
- public IInformationControlCreator getInformationControlCreator(ISourceViewer sourceViewer) {
- return new IInformationControlCreator() {
- public IInformationControl createInformationControl(Shell parent) {
- return new DefaultInformationControl(parent);
- }
- };
- }
-
- /**
- * Returns the information presenter which will determine and shown
- * information requested for the current cursor position. This implementation
- * always returns <code>null</code>.
- *
- * @param sourceViewer the source viewer to be configured by this configuration
- * @return an information presenter <code>null</code> if no information presenter should be installed
- * @since 2.0
- */
- public IInformationPresenter getInformationPresenter(ISourceViewer sourceViewer) {
- return null;
- }
-
- /**
- * Returns all configured content types for the given source viewer. This list
- * tells the caller which content types must be configured for the given source
- * viewer, i.e. for which content types the given source viewer's functionalities
- * must be specified. This implementation always returns <code>
- * new String[] { IDocument.DEFAULT_CONTENT_TYPE }</code>.
- *
- * @param sourceViewer the source viewer to be configured by this configuration
- * @return the configured content types for the given viewer
- */
- public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
- return new String[] { IDocument.DEFAULT_CONTENT_TYPE };
- }
-
- /**
- * Returns the configured partitioning for the given source viewer. The partitioning is
- * used when the querying content types from the source viewer's input document. This
- * implementation always returns <code>IDocumentExtension3.DEFAULT_PARTITIONING</code>.
- *
- * @param sourceViewer the source viewer to be configured by this configuration
- * @return the configured partitioning
- * @see #getConfiguredContentTypes(ISourceViewer)
- * @since 3.0
- */
- public String getConfiguredDocumentPartitioning(ISourceViewer sourceViewer) {
- return IDocumentExtension3.DEFAULT_PARTITIONING;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/TagHandlerFactory.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/TagHandlerFactory.java
deleted file mode 100644
index 0cac8691aa9..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/TagHandlerFactory.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.source;
-
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.jface.text.Assert;
-
-/**
- * Default implementation of a tag handler factory
- *
- * @since 3.0
- */
-public class TagHandlerFactory implements ITagHandlerFactory {
-
- private Map fHandlers;
-
- public void addTagHandler(String tag, ITagHandler handler) {
- Assert.isNotNull(tag);
- Assert.isNotNull(handler);
-
- fHandlers.put(tag, handler);
- }
-
- public ITagHandler registerHandler(String tag) {
- Assert.isNotNull(tag);
- return (ITagHandler)fHandlers.remove(tag);
- }
-
-
- /*
- * @see org.eclipse.jface.text.source.ITagHandlerFactory#getHandler(java.lang.String)
- */
- public ITagHandler getHandler(String tag) {
- Assert.isNotNull(tag);
-
- return (ITagHandler)fHandlers.get(tag);
- }
-
- /*
- * @see org.eclipse.jface.text.source.ITagHandlerFactory#findHandler(java.lang.String)
- */
- public ITagHandler findHandler(String text) {
- Assert.isNotNull(text);
-
- Iterator iter= fHandlers.values().iterator();
- while (iter.hasNext()) {
- ITagHandler handler= (ITagHandler)iter.next();
- if (handler.canHandleText(text))
- return handler;
- }
- return null;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/VerticalRuler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/VerticalRuler.java
deleted file mode 100644
index 13cf8b04e4a..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/VerticalRuler.java
+++ /dev/null
@@ -1,542 +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.custom.StyledText;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Canvas;
-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.IRegion;
-import org.eclipse.jface.text.ITextListener;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.ITextViewerExtension3;
-import org.eclipse.jface.text.IViewportListener;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextEvent;
-
-
-/**
- * A vertical ruler which is connected to a text viewer. Single column standard
- * implementation of <code>IVerticalRuler</code>. The same can be achieved by
- * using <code>CompositeRuler</code> configured with an <code>AnnotationRulerColumn</code>.
- * Clients may use this class as is.
- *
- * @see ITextViewer
- */
-public final class VerticalRuler implements IVerticalRuler, IVerticalRulerExtension {
-
- /**
- * Internal listener class.
- */
- class InternalListener implements IViewportListener, IAnnotationModelListener, ITextListener {
-
- /*
- * @see IViewportListener#viewportChanged(int)
- */
- public void viewportChanged(int verticalPosition) {
- if (verticalPosition != fScrollPos)
- redraw();
- }
-
- /*
- * @see IAnnotationModelListener#modelChanged(IAnnotationModel)
- */
- public void modelChanged(IAnnotationModel model) {
- update();
- }
-
- /*
- * @see ITextListener#textChanged(TextEvent)
- */
- public void textChanged(TextEvent e) {
- if (fTextViewer != null && e.getViewerRedrawState())
- redraw();
- }
- }
-
- /** The vertical ruler's text viewer */
- private ITextViewer fTextViewer;
- /** The ruler's canvas */
- private Canvas fCanvas;
- /** The vertical ruler's model */
- private IAnnotationModel fModel;
- /** Cache for the actual scroll position in pixels */
- private int fScrollPos;
- /** The drawable for double buffering */
- private Image fBuffer;
- /** The line of the last mouse button activity */
- private int fLastMouseButtonActivityLine= -1;
- /** The internal listener */
- private InternalListener fInternalListener= new InternalListener();
- /** The width of this vertical ruler */
- private int fWidth;
-
-
- /**
- * Constructs a vertical ruler with the given width.
- *
- * @param width the width of the vertical ruler
- */
- public VerticalRuler(int width) {
- fWidth= width;
- }
-
- /*
- * @see IVerticalRuler#getControl()
- */
- public Control getControl() {
- return fCanvas;
- }
-
- /*
- * @see IVerticalRuler#createControl(Composite, ITextViewer)
- */
- public Control createControl(Composite parent, ITextViewer textViewer) {
-
- fTextViewer= textViewer;
-
- fCanvas= new Canvas(parent, SWT.NO_BACKGROUND);
-
- fCanvas.addPaintListener(new PaintListener() {
- public void paintControl(PaintEvent event) {
- if (fTextViewer != null)
- doubleBufferPaint(event.gc);
- }
- });
-
- fCanvas.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- handleDispose();
- fTextViewer= null;
- }
- });
-
- fCanvas.addMouseListener(new MouseListener() {
- public void mouseUp(MouseEvent event) {
- }
-
- public void mouseDown(MouseEvent event) {
- fLastMouseButtonActivityLine= toDocumentLineNumber(event.y);
- }
-
- public void mouseDoubleClick(MouseEvent event) {
- fLastMouseButtonActivityLine= toDocumentLineNumber(event.y);
- }
- });
-
- if (fTextViewer != null) {
- fTextViewer.addViewportListener(fInternalListener);
- fTextViewer.addTextListener(fInternalListener);
- }
-
- return fCanvas;
- }
-
- /**
- * Disposes the ruler's resources.
- */
- private void handleDispose() {
-
- if (fTextViewer != null) {
- fTextViewer.removeViewportListener(fInternalListener);
- fTextViewer.removeTextListener(fInternalListener);
- fTextViewer= null;
- }
-
- if (fModel != null)
- fModel.removeAnnotationModelListener(fInternalListener);
-
- if (fBuffer != null) {
- fBuffer.dispose();
- fBuffer= null;
- }
- }
-
-
- /**
- * Double buffer drawing.
- *
- * @param dest the gc to draw into
- */
- private void doubleBufferPaint(GC dest) {
-
- Point size= fCanvas.getSize();
-
- if (size.x <= 0 || size.y <= 0)
- return;
-
- if (fBuffer != null) {
- Rectangle r= fBuffer.getBounds();
- if (r.width != size.x || r.height != size.y) {
- fBuffer.dispose();
- fBuffer= null;
- }
- }
- if (fBuffer == null)
- fBuffer= new Image(fCanvas.getDisplay(), size.x, size.y);
-
- GC gc= new GC(fBuffer);
- gc.setFont(fTextViewer.getTextWidget().getFont());
- try {
- gc.setBackground(fCanvas.getBackground());
- gc.fillRectangle(0, 0, size.x, size.y);
-
- if (fTextViewer instanceof ITextViewerExtension3)
- doPaint1(gc);
- else
- doPaint(gc);
-
- } finally {
- gc.dispose();
- }
-
- dest.drawImage(fBuffer, 0, 0);
- }
-
- /**
- * Returns the document offset of the upper left corner of the
- * widgets viewport, possibly including partially visible lines.
- *
- * @return the document offset of the upper left corner including partially visible lines
- * @since 2.0
- */
- private int getInclusiveTopIndexStartOffset() {
-
- StyledText textWidget= fTextViewer.getTextWidget();
- if (textWidget != null && !textWidget.isDisposed()) {
- int top= fTextViewer.getTopIndex();
- if ((textWidget.getTopPixel() % textWidget.getLineHeight()) != 0)
- top--;
- try {
- IDocument document= fTextViewer.getDocument();
- return document.getLineOffset(top);
- } catch (BadLocationException ex) {
- }
- }
-
- return -1;
- }
-
- /**
- * Draws the vertical ruler w/o drawing the Canvas background.
- *
- * @param gc the gc to draw into
- */
- protected void doPaint(GC gc) {
-
- if (fModel == null || fTextViewer == null)
- return;
-
- StyledText styledText= fTextViewer.getTextWidget();
- IDocument doc= fTextViewer.getDocument();
-
- int topLeft= getInclusiveTopIndexStartOffset();
- int bottomRight= fTextViewer.getBottomIndexEndOffset();
- int viewPort= bottomRight - topLeft;
-
- Point d= fCanvas.getSize();
- fScrollPos= styledText.getTopPixel();
- int lineheight= styledText.getLineHeight();
-
- int shift= fTextViewer.getTopInset();
-
- int topLine= -1, bottomLine= -1;
- try {
- IRegion region= fTextViewer.getVisibleRegion();
- topLine= doc.getLineOfOffset(region.getOffset());
- bottomLine= doc.getLineOfOffset(region.getOffset() + region.getLength());
- } catch (BadLocationException x) {
- return;
- }
-
- // draw Annotations
- Rectangle r= new Rectangle(0, 0, 0, 0);
- int maxLayer= 1; // loop at least once thru layers.
-
- for (int layer= 0; layer < maxLayer; layer++) {
- Iterator iter= fModel.getAnnotationIterator();
- while (iter.hasNext()) {
- Annotation annotation= (Annotation) iter.next();
-
- int lay= annotation.getLayer();
- maxLayer= Math.max(maxLayer, lay+1); // dynamically update layer maximum
- if (lay != layer) // wrong layer: skip annotation
- continue;
-
- Position position= fModel.getPosition(annotation);
- if (position == null)
- continue;
-
- if (!position.overlapsWith(topLeft, viewPort))
- continue;
-
- try {
-
- int offset= position.getOffset();
- int length= position.getLength();
-
- int startLine= doc.getLineOfOffset(offset);
- if (startLine < topLine)
- startLine= topLine;
-
- int endLine= startLine;
- if (length > 0)
- endLine= doc.getLineOfOffset(offset + length - 1);
- if (endLine > bottomLine)
- endLine= bottomLine;
-
- startLine -= topLine;
- endLine -= topLine;
-
- r.x= 0;
- r.y= (startLine * lineheight) - fScrollPos + shift;
- r.width= d.x;
- int lines= endLine - startLine;
- if (lines < 0)
- lines= -lines;
- r.height= (lines+1) * lineheight;
-
- if (r.y < d.y) // annotation within visible area
- annotation.paint(gc, fCanvas, r);
-
- } catch (BadLocationException e) {
- }
- }
- }
- }
-
- /**
- * Draws the vertical ruler w/o drawing the Canvas background. Uses
- * <code>ITExtViewerExtension3</code> for its implementation. Will replace
- * <code>doPaint(GC)</code>.
- *
- * @param gc the gc to draw into
- */
- protected void doPaint1(GC gc) {
-
- if (fModel == null || fTextViewer == null)
- return;
-
- ITextViewerExtension3 extension= (ITextViewerExtension3) fTextViewer;
- StyledText textWidget= fTextViewer.getTextWidget();
-
- fScrollPos= textWidget.getTopPixel();
- int lineheight= textWidget.getLineHeight();
- Point dimension= fCanvas.getSize();
- int shift= fTextViewer.getTopInset();
-
- // draw Annotations
- Rectangle r= new Rectangle(0, 0, 0, 0);
- int maxLayer= 1; // loop at least once thru layers.
-
- for (int layer= 0; layer < maxLayer; layer++) {
- Iterator iter= fModel.getAnnotationIterator();
- while (iter.hasNext()) {
-
- Annotation annotation= (Annotation) iter.next();
-
- int lay= annotation.getLayer();
- maxLayer= Math.max(maxLayer, lay+1); // dynamically update layer maximum
- if (lay != layer) // wrong layer: skip annotation
- continue;
-
- Position position= fModel.getPosition(annotation);
- if (position == null)
- continue;
-
- IRegion widgetRegion= extension.modelRange2WidgetRange(new Region(position.getOffset(), position.getLength()));
- if (widgetRegion == null)
- continue;
-
- int startLine= extension.widgetLineOfWidgetOffset(widgetRegion.getOffset());
- if (startLine == -1)
- continue;
-
- int endLine= extension.widgetLineOfWidgetOffset(widgetRegion.getOffset() + Math.max(widgetRegion.getLength() -1, 0));
- if (endLine == -1)
- continue;
-
- r.x= 0;
- r.y= (startLine * lineheight) - fScrollPos + shift;
- r.width= dimension.x;
- int lines= endLine - startLine;
- if (lines < 0)
- lines= -lines;
- r.height= (lines+1) * lineheight;
-
- if (r.y < dimension.y) // annotation within visible area
- annotation.paint(gc, fCanvas, r);
- }
- }
- }
-
- /**
- * Thread-safe implementation.
- * Can be called from any thread.
- */
- /*
- * @see IVerticalRuler#update()
- */
- public void update() {
- if (fCanvas != null && !fCanvas.isDisposed()) {
- Display d= fCanvas.getDisplay();
- if (d != null) {
- d.asyncExec(new Runnable() {
- public void run() {
- redraw();
- }
- });
- }
- }
- }
-
- /**
- * Redraws the vertical ruler.
- */
- private void redraw() {
- if (fCanvas != null && !fCanvas.isDisposed()) {
- GC gc= new GC(fCanvas);
- doubleBufferPaint(gc);
- gc.dispose();
- }
- }
-
- /*
- * @see IVerticalRuler#setModel(IAnnotationModel)
- */
- public void setModel(IAnnotationModel model) {
- if (model != fModel) {
-
- if (fModel != null)
- fModel.removeAnnotationModelListener(fInternalListener);
-
- fModel= model;
-
- if (fModel != null)
- fModel.addAnnotationModelListener(fInternalListener);
-
- update();
- }
- }
-
- /*
- * @see IVerticalRuler#getModel()
- */
- public IAnnotationModel getModel() {
- return fModel;
- }
-
- /*
- * @see IVerticalRulerInfo#getWidth()
- */
- public int getWidth() {
- return fWidth;
- }
-
- /*
- * @see IVerticalRulerInfo#getLineOfLastMouseButtonActivity()
- */
- public int getLineOfLastMouseButtonActivity() {
- return fLastMouseButtonActivityLine;
- }
-
- /*
- * @see IVerticalRulerInfo#toDocumentLineNumber(int)
- */
- public int toDocumentLineNumber(int y_coordinate) {
-
- if (fTextViewer == null)
- return -1;
-
- StyledText text= fTextViewer.getTextWidget();
- int line= ((y_coordinate + fScrollPos) / text.getLineHeight());
- return widgetLine2ModelLine(fTextViewer, line);
- }
-
- /**
- * Returns the line of the viewer's document that corresponds to the given widget line.
- *
- * @param viewer the viewer
- * @param widgetLine the widget line
- * @return the corresponding line of the viewer's document
- * @since 2.1
- */
- protected final static int widgetLine2ModelLine(ITextViewer viewer, int widgetLine) {
-
- if (viewer instanceof ITextViewerExtension3) {
- ITextViewerExtension3 extension= (ITextViewerExtension3) viewer;
- return extension.widgetlLine2ModelLine(widgetLine);
- }
-
- try {
- IRegion r= viewer.getVisibleRegion();
- IDocument d= viewer.getDocument();
- return widgetLine += d.getLineOfOffset(r.getOffset());
- } catch (BadLocationException x) {
- }
- return widgetLine;
- }
-
- /*
- * @see IVerticalRulerExtension#setFont(Font)
- * @since 2.0
- */
- public void setFont(Font font) {
- }
-
- /*
- * @see IVerticalRulerExtension#setLocationOfLastMouseButtonActivity(int, int)
- * @since 2.0
- */
- public void setLocationOfLastMouseButtonActivity(int x, int y) {
- fLastMouseButtonActivityLine= toDocumentLineNumber(y);
- }
-
- /**
- * @deprecated will be removed
- * @since 2.0
- */
- public void addMouseListener(MouseListener listener) {
- if (fCanvas != null && !fCanvas.isDisposed())
- fCanvas.addMouseListener(listener);
- }
-
- /**
- * @deprecated will be removed
- * @since 2.0
- */
- public void removeMouseListener(MouseListener listener) {
- if (fCanvas != null && !fCanvas.isDisposed())
- fCanvas.removeMouseListener(listener);
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/VisualAnnotationModel.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/VisualAnnotationModel.java
deleted file mode 100644
index 000a14a8a18..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/VisualAnnotationModel.java
+++ /dev/null
@@ -1,189 +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.ArrayList;
-import java.util.Iterator;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.Position;
-
-
-
-/**
- * Annotation model for visual annotations. Assume a viewer's input element is annotated with
- * some semantic annotation such as a breakpoint and that it is simultanously shown in multiple
- * viewers. A source viewer, e.g., supports visual range indication for which it utilizes
- * annotations. The range indicating annotation is specific to the visual presentation
- * of the input element in this viewer and thus should only be visible in this viewer. The
- * breakpoints however are independent from the input element's presentation and thus should
- * be shown in all viewers in which the element is shown. As a viewer supports one vertical
- * ruler which is based on one annotation model, there must be a visual annotation model for
- * each viewer which all wrap the same element specific model annotation model.
- */
-class VisualAnnotationModel extends AnnotationModel implements IAnnotationModelListener {
-
- /** The wrapped model annotation model */
- private IAnnotationModel fModel;
-
- /**
- * Constructs a visual annotation model which wraps the given
- * model based annotation model
- *
- * @param modelAnnotationModel the model based annotation model
- */
- public VisualAnnotationModel(IAnnotationModel modelAnnotationModel) {
- fModel= modelAnnotationModel;
- }
-
- /**
- * Returns the visual annotation model's wrapped model based annotation model.
- *
- * @return the model based annotation model
- */
- public IAnnotationModel getModelAnnotationModel() {
- return fModel;
- }
-
- /*
- * @see IAnnotationModel#addAnnotationModelListener(IAnnotationModelListener)
- */
- public void addAnnotationModelListener(IAnnotationModelListener listener) {
-
- if (fModel != null && fAnnotationModelListeners.isEmpty())
- fModel.addAnnotationModelListener(this);
-
- super.addAnnotationModelListener(listener);
- }
-
- /*
- * @see IAnnotationModel#connect(IDocument)
- */
- public void connect(IDocument document) {
- super.connect(document);
- if (fModel != null)
- fModel.connect(document);
- }
-
- /*
- * @see IAnnotationModel#disconnect(IDocument)
- */
- public void disconnect(IDocument document) {
- super.disconnect(document);
- if (fModel != null)
- fModel.disconnect(document);
- }
-
- /*
- * @see IAnnotationModel#getAnnotationIterator()
- */
- public Iterator getAnnotationIterator() {
-
- if (fModel == null)
- return super.getAnnotationIterator();
-
- ArrayList a= new ArrayList(20);
-
- Iterator e= fModel.getAnnotationIterator();
- while (e.hasNext())
- a.add(e.next());
-
- e= super.getAnnotationIterator();
- while (e.hasNext())
- a.add(e.next());
-
- return a.iterator();
- }
-
- /*
- * @see IAnnotationModel#getPosition(Annotation)
- */
- public Position getPosition(Annotation annotation) {
-
- Position p= (Position) fAnnotations.get(annotation);
- if (p != null)
- return p;
-
- if (fModel != null)
- return fModel.getPosition(annotation);
-
- return null;
- }
-
- /*
- * @see IAnnotationModelListener#modelChanged(IAnnotationModel)
- */
- public void modelChanged(IAnnotationModel model) {
- if (model == fModel) {
- Iterator iter= new ArrayList(fAnnotationModelListeners).iterator();
- while (iter.hasNext()) {
- IAnnotationModelListener l= (IAnnotationModelListener)iter.next();
- l.modelChanged(this);
- }
- }
- }
-
- /**
- * Modifies associated position of the given annotation to the given position.
- * If the annotation is not yet managed by this annotation model, the annotation
- * is added. All annotation model change listeners will be informed about the change.
- *
- * @param annotation the annotation whose associated position should be modified
- * @param position the position to whose values the associated position should be changed
- */
- public void modifyAnnotation(Annotation annotation, Position position) {
- modifyAnnotation(annotation, position, true);
- }
-
- /**
- * Modifies the associated position of the given annotation to the given position.
- * If the annotation is not yet managed by this annotation model, the annotation
- * is added. If requested, all annotation model change listeners will be informed
- * about the change.
- *
- * @param annotation the annotation whose associated position should be modified
- * @param position the position to whose values the associated position should be changed
- * @param fireModelChanged indicates whether to notify all model listeners
- */
- private void modifyAnnotation(Annotation annotation, Position position, boolean fireModelChanged) {
- if (position == null) {
- removeAnnotation(annotation, fireModelChanged);
- } else {
- Position p= (Position) fAnnotations.get(annotation);
- if (p != null) {
- p.setOffset(position.getOffset());
- p.setLength(position.getLength());
- if (fireModelChanged)
- fireModelChanged();
- } else {
- try {
- addAnnotation(annotation, position, fireModelChanged);
- } catch (BadLocationException e) {
- // ignore invalid position
- }
- }
- }
- }
-
- /*
- * @see IAnnotationModel#removeAnnotationModelListener(IAnnotationModelListener)
- */
- public void removeAnnotationModelListener(IAnnotationModelListener listener) {
- super.removeAnnotationModelListener(listener);
-
- if (fModel != null && fAnnotationModelListeners.isEmpty())
- fModel.removeAnnotationModelListener(this);
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/package.html b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/package.html
deleted file mode 100644
index e03b1940302..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/package.html
+++ /dev/null
@@ -1,26 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="Author" content="IBM">
- <meta name="GENERATOR" content="Mozilla/4.51 [en] (WinNT; I) [Netscape]">
- <title>Package-level Javadoc</title>
-</head>
-<body>
-Provides a framework for connecting document regions
-with annotations and for displaying those annotations in combination with
-an <tt>ITextViewer</tt>. <tt>ISourceViewer</tt> combines annotation support
-and all text viewer add-ons.
-<h2>
-Package Specification</h2>
-&nbsp;<tt>ISourceViewer</tt> defines the concept of a document based, editable
-viewer supporting visual annotations. <tt>ISourceViewer</tt> supports document-specific
-and viewer-specific annotations attached to the viewer's input document.
-An <tt>ISourceViewer</tt> uses an <tt>IAnnotationModel</tt> to manage annotations
-and to inform implementers of <tt>IAnnotationModelListener</tt> about changes
-in respect to annotations. An <tt>IVerticalRuler</tt> represents an <tt>IAnnotationModel</tt>
-access adapter for an SWT widget capapble of display annotations.&nbsp;
-This package also provides default implementations for all defined interfaces.
-<br>&nbsp;
-</body>
-</html>

Back to the top