Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jface.text/src/org/eclipse/jface/text')
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractHoverInformationControlManager.java488
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractInformationControlManager.java1011
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/CursorLinePainter.java259
-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/DefaultDocumentAdapter.java410
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultInformationControl.java420
-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.java835
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/DocumentClone.java72
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/DocumentCommand.java468
-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.java21
-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.java145
-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.java41
-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/IInformationControlExtension3.java73
-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/ISelectionValidator.java36
-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/ITextPresentationListener.java34
-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.java434
-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.java96
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension4.java50
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension5.java118
-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.java32
-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.properties33
-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.java380
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/PropagatingFontFieldEditor.java133
-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.java120
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/TextPresentation.java699
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/TextSelection.java189
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java4858
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewerHoverManager.java417
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AdditionalInfoController.java268
-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.java1107
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistSubjectControlAdapter.java408
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java1803
-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.java794
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationValidator.java64
-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.java68
-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.java70
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistListener.java36
-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/IContentAssistant.java91
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistantExtension.java35
-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/IContextInformationValidator.java44
-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.java796
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContextBasedFormattingStrategy.java76
-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.java69
-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.java75
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IFormattingContext.java156
-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/MultiPassContentFormatter.java314
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/package.html57
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/information/IInformationPresenter.java64
-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.java494
-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/link/LinkedModeUI.java1178
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedPositionAnnotations.java310
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/link/ProposalPosition.java88
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/link/TabStopIterator.java215
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/link/package.html71
-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.java583
-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.java165
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/AbstractReconciler.java544
-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/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.java218
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/DefaultPartitioner.java635
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/EndOfLineRule.java67
-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.java28
-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.java273
-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.java587
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedScanner.java198
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/SingleLineRule.java89
-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/AnnotationBarHoverManager.java555
-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/AnnotationPainter.java1394
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationRulerColumn.java985
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/ChangeRulerColumn.java665
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/CompositeRuler.java856
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationAccess.java51
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationAccessExtension.java89
-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.java65
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationPresentation.java46
-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.java73
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/ILineDiffer.java73
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/ILineRange.java31
-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/ISourceViewerExtension2.java37
-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.java47
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRulerListener.java48
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/ImageUtilities.java87
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/JFaceTextMessages.java68
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineChangeHover.java308
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberChangeRulerColumn.java434
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberRulerColumn.java895
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineRange.java39
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/MatchingCharacterPainter.java262
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRuler.java1229
-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.java902
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewerConfiguration.java309
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/VerticalRuler.java588
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/VerticalRulerEvent.java46
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/VisualAnnotationModel.java146
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/package.html26
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/templates/ContextTypeRegistry.java55
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/templates/InclusivePositionUpdater.java103
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/templates/JFaceTextTemplateMessages.java61
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/templates/JFaceTextTemplateMessages.properties14
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/templates/PositionBasedCompletionProposal.java168
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/templates/TemplateCompletionProcessor.java228
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/templates/TemplateProposal.java408
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/templates/package.html113
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplatePersistenceData.java173
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplatePersistenceMessages.java61
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplatePersistenceMessages.properties14
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateReaderWriter.java345
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateStore.java344
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/package.html113
212 files changed, 0 insertions, 43483 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 965f6251b..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractHoverInformationControlManager.java
+++ /dev/null
@@ -1,488 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.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.
- * @since 3.0
- */
- 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 8044c9944..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractInformationControlManager.java
+++ /dev/null
@@ -1,1011 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.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;
-import org.eclipse.swt.widgets.Display;
-
-import org.eclipse.jface.dialogs.IDialogSettings;
-
-
-/**
- * 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();
-
- /**
- * Dialog store constant for the location's x-coordinate.
- * @since 3.0
- */
- public static final String STORE_LOCATION_X= "location.x"; //$NON-NLS-1$
- /**
- * Dialog store constant for the location's y-coordinate.
- * @since 3.0
- */
- public static final String STORE_LOCATION_Y= "location.y"; //$NON-NLS-1$
- /**
- * Dialog store constant for the size's width.
- * @since 3.0
- */
- public static final String STORE_SIZE_WIDTH= "size.width"; //$NON-NLS-1$
- /**
- * Dialog store constant for the size's height.
- * @since 3.0
- */
- public static final String STORE_SIZE_HEIGHT= "size.height"; //$NON-NLS-1$
-
-
- /** 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;
-
- /**
- * The dialog settings for the control's bounds.
- *
- * @since 3.0
- */
- private IDialogSettings fDialogSettings;
-
- /**
- * Tells whether the control's location should be read
- * from the dialog settings and whether the last
- * valid control's size is stored back into the settings.
- *
- * @since 3.0
- */
- private boolean fIsRestoringLocation;
-
- /**
- * Tells whether the control's size should be read
- * from the dialog settings and whether the last
- * valid control's size is stored back into the settings.
- *
- * @since 3.0
- */
- private boolean fIsRestoringSize;
-
-
- /**
- * 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;
-
- }
-
- /**
- * Tells this information control manager to open the information
- * control with the values contained in the given dialog settings
- * and to store the control's last valid size in the given dialog
- * settings.
- * <p>
- * Note: This API is only valid if the information control implements
- * {@link IInformationControlExtension3}. Not following this restriction
- * will later result in an {@link UnsupportedOperationException}.
- * </p>
- * <p>
- * The constants used to store the values are:
- * <ul>
- * <li>{@link AbstractInformationControlManager#STORE_LOCATION_X}</li>
- * <li>{@link AbstractInformationControlManager#STORE_LOCATION_Y}</li>
- * <li>{@link AbstractInformationControlManager#STORE_SIZE_WIDTH}</li>
- * <li>{@link AbstractInformationControlManager#STORE_SIZE_HEIGHT}</li>
- * </ul>
- * </p>
- *
- * @param dialogSettings
- * @param restoreLocation <code>true</code> iff the location is must be (re-)stored
- * @param restoreSize <code>true</code>iff the size is (re-)stored
- * @since 3.0
- */
- public void setRestoreInformationControlBounds(IDialogSettings dialogSettings, boolean restoreLocation, boolean restoreSize) {
- Assert.isTrue(dialogSettings != null && (restoreLocation || restoreSize));
- fDialogSettings= dialogSettings;
- fIsRestoringLocation= restoreLocation;
- fIsRestoringSize= restoreSize;
- }
-
- /**
- * 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);
- fDisposed= false;
- }
-
- /**
- * 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;
- }
-
- /**
- * Computes the size constraints of the information control in points.
- *
- * @param subjectControl the subject control
- * @param subjectArea the subject area
- * @param informationControl the information control whose size constraints are computed
- * @return the computed size constraints in points
- * @since 3.0
- */
- protected Point computeSizeConstraints(Control subjectControl, Rectangle subjectArea, IInformationControl informationControl) {
- return computeSizeConstraints(subjectControl, informationControl);
- }
-
- /**
- * Handles the disposal of the information control. By default, the information
- * control closer is stopped.
- */
- protected void handleInformationControlDisposed() {
-
- storeInformationControlBounds();
-
- 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 lying 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, fSubjectArea, 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= null;
- Point location= null;
- Rectangle bounds= restoreInformationControlBounds();
-
- if (bounds != null) {
- if (bounds.x > -1 && bounds.y > -1)
- location= new Point(bounds.x, bounds.y);
-
- if (bounds.width > -1 && bounds.height > -1)
- size= new Point(bounds.width, bounds.height);
- }
-
- if (size == null)
- 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);
-
- if (location == null)
- 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) {
- storeInformationControlBounds();
- 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;
- }
- }
-
- // ------ control's size handling dialog settings ------
-
- /**
- * Stores the information control's bounds.
- *
- * @since 3.0
- */
- protected void storeInformationControlBounds() {
- if (fDialogSettings == null || fInformationControl == null || !(fIsRestoringLocation || fIsRestoringSize))
- return;
-
- if (!(fInformationControl instanceof IInformationControlExtension3))
- throw new UnsupportedOperationException();
-
- boolean controlRestoresSize= ((IInformationControlExtension3)fInformationControl).restoresSize();
- boolean controlRestoresLocation= ((IInformationControlExtension3)fInformationControl).restoresLocation();
-
- Rectangle bounds= ((IInformationControlExtension3)fInformationControl).getBounds();
- if (bounds == null)
- return;
-
- if (fIsRestoringSize && controlRestoresSize) {
- fDialogSettings.put(STORE_SIZE_WIDTH, bounds.width);
- fDialogSettings.put(STORE_SIZE_HEIGHT, bounds.height);
- }
- if (fIsRestoringLocation && controlRestoresLocation) {
- fDialogSettings.put(STORE_LOCATION_X, bounds.x);
- fDialogSettings.put(STORE_LOCATION_Y, bounds.y);
- }
- }
- /**
- * Restores the information control's bounds.
- *
- * @return the stored bounds
- * @since 3.0
- */
- protected Rectangle restoreInformationControlBounds() {
- if (fDialogSettings == null || !(fIsRestoringLocation || fIsRestoringSize))
- return null;
-
- if (!(fInformationControl instanceof IInformationControlExtension3))
- throw new UnsupportedOperationException();
-
- boolean controlRestoresSize= ((IInformationControlExtension3)fInformationControl).restoresSize();
- boolean controlRestoresLocation= ((IInformationControlExtension3)fInformationControl).restoresLocation();
-
- Rectangle bounds= new Rectangle(-1, -1, -1, -1);
-
- if (fIsRestoringSize && controlRestoresSize) {
- try {
- bounds.width= fDialogSettings.getInt(STORE_SIZE_WIDTH);
- bounds.height= fDialogSettings.getInt(STORE_SIZE_HEIGHT);
- } catch (NumberFormatException ex) {
- bounds.width= -1;
- bounds.height= -1;
- }
- }
-
- if (fIsRestoringLocation && controlRestoresLocation) {
- try {
- bounds.x= fDialogSettings.getInt(STORE_LOCATION_X);
- bounds.y= fDialogSettings.getInt(STORE_LOCATION_Y);
- } catch (NumberFormatException ex) {
- bounds.x= -1;
- bounds.y= -1;
- }
- }
-
- // sanity check
- if (bounds.x == -1 && bounds.y == -1 && bounds.width == -1 && bounds.height == -1)
- return null;
-
- Rectangle maxBounds= null;
- if (fSubjectControl != null && !fSubjectControl.isDisposed())
- maxBounds= fSubjectControl.getDisplay().getBounds();
- else {
- // fallback
- Display display= Display.getCurrent();
- if (display == null)
- display= Display.getDefault();
- if (display != null && !display.isDisposed())
- maxBounds= display.getBounds();
- }
-
-
- if (bounds.width > -1 && bounds.height > -1) {
- if (maxBounds != null) {
- bounds.width= Math.min(bounds.width, maxBounds.width);
- bounds.height= Math.min(bounds.height, maxBounds.height);
- }
-
- // Enforce an absolute minimal size
- bounds.width= Math.max(bounds.width, 30);
- bounds.height= Math.max(bounds.height, 30);
- }
-
- if (bounds.x > -1 && bounds.y > -1 && maxBounds != null) {
- bounds.x= Math.max(bounds.x, maxBounds.x);
- bounds.y= Math.max(bounds.y, maxBounds.y);
-
- if (bounds .width > -1 && bounds.height > -1) {
- bounds.x= Math.min(bounds.x, maxBounds.width - bounds.width);
- bounds.y= Math.min(bounds.y, maxBounds.height - bounds.height);
- }
- }
-
- return bounds;
- }
-}
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 e827c4099..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/CursorLinePainter.java
+++ /dev/null
@@ -1,259 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.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.ITextViewerExtension5;
-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;
-
- if (fCurrentLine.isDeleted) {
- fCurrentLine.isDeleted= false;
- fPositionManager.managePosition(fCurrentLine);
- }
-
- 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 ITextViewerExtension5) {
- ITextViewerExtension5 extension= (ITextViewerExtension5) fViewer;
- return extension.widgetOffset2ModelOffset(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 ITextViewerExtension5) {
-
- ITextViewerExtension5 extension= (ITextViewerExtension5) 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();
- // check for https://bugs.eclipse.org/bugs/show_bug.cgi?id=64898
- // this is a guard against the symptoms but not the actual solution
- if (0 <= widgetOffset && widgetOffset <= textWidget.getCharCount()) {
- 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;
- fCurrentLine.offset= 0;
- fCurrentLine.length= 0;
- }
- }
-
- /*
- * @see IPainter#dispose()
- */
- public void dispose() {
- }
-
- /*
- * @see IPainter#paint(int)
- */
- public void paint(int reason) {
- if (fViewer.getDocument() == null) {
- deactivate(false);
- return;
- }
-
- StyledText textWidget= fViewer.getTextWidget();
-
- // check selection
- Point selection= textWidget.getSelection();
- int startLine= textWidget.getLineAtOffset(selection.x);
- int endLine= textWidget.getLineAtOffset(selection.y);
- if (startLine != endLine) {
- deactivate(true);
- return;
- }
-
- // initialization
- if (!fIsActive) {
- textWidget.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 71a3f45a5..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultAutoIndentStrategy.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.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/DefaultDocumentAdapter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultDocumentAdapter.java
deleted file mode 100644
index bae74ebbf..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultDocumentAdapter.java
+++ /dev/null
@@ -1,410 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.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 DefaultDocumentAdapter implements IDocumentAdapter, IDocumentListener, IDocumentAdapterExtension {
-
- /** The adapted document. */
- private IDocument fDocument;
- /** The document clone for the non-forwarding case. */
- private IDocument fDocumentClone;
- /** The original content */
- private String fOriginalContent;
- /** The original line delimiters */
- private String[] fOriginalLineDelimiters;
- /** 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 initially not connected to
- * any document.
- */
- public DefaultDocumentAdapter() {
- }
-
- /**
- * 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 (!fIsForwarding) {
- fDocumentClone= null;
- fOriginalContent= fDocument.get();
- fOriginalLineDelimiters= fDocument.getLegalLineDelimiters();
- }
-
- 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);
- }
-
- /**
- * Tries to repair the line information.
- *
- * @see IRepairableDocument#repairLineInformation()
- * @since 3.0
- */
- private void repairLineInformation(IDocument document) {
- if (document instanceof IRepairableDocument) {
- IRepairableDocument repairable= (IRepairableDocument) document;
- repairable.repairLineInformation();
- }
- }
-
- /**
- * Returns the line for the given line number.
- *
- * @param line the line number
- * @return the line
- * @throws BadLocationException if the line number is invalid for the adapted document
- * @since 3.0
- */
- private String doGetLine(IDocument document, int line) throws BadLocationException {
- IRegion r= document.getLineInformation(line);
- return document.get(r.getOffset(), r.getLength());
- }
-
- private IDocument getDocumentForRead() {
- if (!fIsForwarding) {
- if (fDocumentClone == null) {
- String content= fOriginalContent == null ? "" : fOriginalContent;
- String[] delims= fOriginalLineDelimiters == null ? DefaultLineTracker.DELIMITERS : fOriginalLineDelimiters;
- fDocumentClone= new DocumentClone(content, delims);
- }
- return fDocumentClone;
- }
-
- return fDocument;
- }
-
- /*
- * @see StyledTextContent#getLine(int)
- */
- public String getLine(int line) {
-
- IDocument document= getDocumentForRead();
- try {
- return doGetLine(document, line);
- } catch (BadLocationException x) {
- repairLineInformation(document);
- try {
- return doGetLine(document, line);
- } catch (BadLocationException x2) {
- }
- }
-
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- return null;
- }
-
- /*
- * @see StyledTextContent#getLineAtOffset(int)
- */
- public int getLineAtOffset(int offset) {
- IDocument document= getDocumentForRead();
- try {
- return document.getLineOfOffset(offset);
- } catch (BadLocationException x) {
- repairLineInformation(document);
- try {
- return document.getLineOfOffset(offset);
- } catch (BadLocationException x2) {
- }
- }
-
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- return -1;
- }
-
- /*
- * @see StyledTextContent#getLineCount()
- */
- public int getLineCount() {
- return getDocumentForRead().getNumberOfLines();
- }
-
- /*
- * @see StyledTextContent#getOffsetAtLine(int)
- */
- public int getOffsetAtLine(int line) {
- IDocument document= getDocumentForRead();
- try {
- return document.getLineOffset(line);
- } catch (BadLocationException x) {
- repairLineInformation(document);
- try {
- return document.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 getDocumentForRead().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 getDocumentForRead().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;
- fDocumentClone= null;
- fOriginalContent= null;
- fOriginalLineDelimiters= null;
- fireTextSet();
- }
-
- /*
- * @see IDocumentAdapterExtension#stopForwardingDocumentChanges()
- * @since 2.0
- */
- public void stopForwardingDocumentChanges() {
- fDocumentClone= null;
- fOriginalContent= fDocument.get();
- fOriginalLineDelimiters= fDocument.getLegalLineDelimiters();
- fIsForwarding= false;
- }
-}
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 619eafb75..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultInformationControl.java
+++ /dev/null
@@ -1,420 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-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.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, IInformationControlExtension3, DisposeListener {
-
- /**
- * 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);
-
- statusField.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW));
-
- statusField.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
- }
-
- addDisposeListener(this);
- }
-
- /**
- * 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 (fShell != null && !fShell.isDisposed())
- fShell.dispose();
- else
- widgetDisposed(null);
- }
-
- /*
- * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent)
- * @since 3.0
- */
- public void widgetDisposed(DisposeEvent event) {
- if (fStatusTextFont != null && !fStatusTextFont.isDisposed())
- fStatusTextFont.dispose();
-
- fShell= null;
- fText= null;
- fStatusTextFont= 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 org.eclipse.jface.text.IInformationControlExtension3#computeTrim()
- * @since 3.0
- */
- public Rectangle computeTrim() {
- return fShell.computeTrim(0, 0, 0, 0);
- }
-
- /*
- * @see org.eclipse.jface.text.IInformationControlExtension3#getBounds()
- * @since 3.0
- */
- public Rectangle getBounds() {
- return fShell.getBounds();
- }
-
- /*
- * @see org.eclipse.jface.text.IInformationControlExtension3#restoresLocation()
- * @since 3.0
- */
- public boolean restoresLocation() {
- return false;
- }
-
- /*
- * @see org.eclipse.jface.text.IInformationControlExtension3#restoresSize()
- * @since 3.0
- */
- public boolean restoresSize() {
- return false;
- }
-
- /*
- * @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 59c0c6f40..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultTextDoubleClickStrategy.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.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 2a29fcfd7..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultUndoManager.java
+++ /dev/null
@@ -1,835 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.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 input listener and document listener 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 org.eclipse.jface.text.ITextViewer
- * @see org.eclipse.jface.text.ITextInputListener
- * @see org.eclipse.jface.text.IDocumentListener
- * @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.
- *
- * @since 2.0
- */
- protected void undoTextChange() {
- try {
- fTextViewer.getDocument().replace(fStart, fText.length(), fPreservedText);
- } catch (BadLocationException x) {
- }
- }
-
- /**
- * Undo the change described by this command. Also selects and
- * reveals the change.
- */
- protected void undo() {
- undoTextChange();
- selectAndReveal(fStart, fPreservedText == null ? 0 : fPreservedText.length());
- }
-
- /**
- * Re-applies the change described by this command.
- *
- * @since 2.0
- */
- protected void redoTextChange() {
- try {
- fTextViewer.getDocument().replace(fStart, fEnd - fStart, fText);
- } catch (BadLocationException x) {
- }
- }
-
- /**
- * Re-applies the change described by this command that previously been
- * rolled back. Also selects and reveals the change.
- */
- protected void redo() {
- redoTextChange();
- selectAndReveal(fStart, fText == null ? 0 : fText.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 org.eclipse.jface.text.DefaultUndoManager2.TextCommand#undo()
- */
- protected void undo() {
- 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();
- }
-
- c= (TextCommand) fCommands.get(0);
- c.undo();
- }
-
- } finally {
- if (extension != null)
- extension.setRedraw(true);
- }
- }
-
- /*
- * @see org.eclipse.jface.text.DefaultUndoManager2.TextCommand#redo()
- */
- protected void redo() {
-
- 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();
- }
-
- c= (TextCommand) fCommands.get(size -1);
- c.redo();
- }
-
- } 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 document changes.
- */
- class DocumentListener implements IDocumentListener {
-
- private String fReplacedText;
-
- /*
- * @see org.eclipse.jface.text.IDocumentListener#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent)
- */
- public void documentAboutToBeChanged(DocumentEvent event) {
- try {
- fReplacedText= event.getDocument().get(event.getOffset(), event.getLength());
- } catch (BadLocationException x) {
- fReplacedText= null;
- }
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentListener#documentChanged(org.eclipse.jface.text.DocumentEvent)
- */
- public void documentChanged(DocumentEvent event) {
- processChange(event.getOffset(), event.getOffset() + event.getLength(), event.getText(), fReplacedText);
- }
- }
-
- /**
- * Internal text input listener.
- */
- class TextInputListener implements ITextInputListener {
-
- /*
- * @see org.eclipse.jface.text.ITextInputListener#inputDocumentAboutToBeChanged(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IDocument)
- */
- public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {
- if (oldInput != null && fDocumentListener != null) {
- oldInput.removeDocumentListener(fDocumentListener);
- commit();
- }
- }
-
- /*
- * @see org.eclipse.jface.text.ITextInputListener#inputDocumentChanged(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IDocument)
- */
- public void inputDocumentChanged(IDocument oldInput, IDocument newInput) {
- if (newInput != null) {
- if (fDocumentListener == null)
- fDocumentListener= new DocumentListener();
- newInput.addDocumentListener(fDocumentListener);
- }
- }
-
- }
-
-
- /** 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 key and mouse event listener */
- private KeyAndMouseListener fKeyAndMouseListener;
- /** The internal document listener */
- private DocumentListener fDocumentListener;
- /** The internal text input listener */
- private TextInputListener fTextInputListener;
-
-
- /** 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);
- fTextInputListener= new TextInputListener();
- fTextViewer.addTextInputListener(fTextInputListener);
- listenToTextChanges(true);
- }
- }
-
- /**
- * Unregister all previously installed listeners from the text viewer.
- */
- private void removeListeners() {
- StyledText text= fTextViewer.getTextWidget();
- if (text != null) {
- if (fKeyAndMouseListener != null) {
- text.removeMouseListener(fKeyAndMouseListener);
- text.removeKeyListener(fKeyAndMouseListener);
- fKeyAndMouseListener= null;
- }
- if (fTextInputListener != null) {
- fTextViewer.removeTextInputListener(fTextInputListener);
- fTextInputListener= null;
- }
- 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) {
- if (fDocumentListener == null && fTextViewer.getDocument() != null) {
- fDocumentListener= new DocumentListener();
- fTextViewer.getDocument().addDocumentListener(fDocumentListener);
- }
- } else if (!listen) {
- if (fDocumentListener != null && fTextViewer.getDocument() != null) {
- fTextViewer.getDocument().removeDocumentListener(fDocumentListener);
- fDocumentListener= null;
- }
- }
- }
-
- /**
- * Closes the current editing command and opens a new one.
- */
- private void commit() {
-
- fInserting= false;
- fOverwriting= false;
- fPreviousDelete.reinitialize();
-
- fCurrent.commit();
- }
-
- /**
- * Re-applies the previously undone editing command.
- */
- private void internalRedo() {
- ++fCommandCounter;
- TextCommand cmd= (TextCommand) fCommandStack.get(fCommandCounter);
-
- listenToTextChanges(false);
- cmd.redo();
- listenToTextChanges(true);
-
- fCurrent= new TextCommand();
- }
-
- /**
- * Does undo the last editing command.
- */
- private void internalUndo() {
- TextCommand cmd= (TextCommand) fCommandStack.get(fCommandCounter);
- -- fCommandCounter;
-
- listenToTextChanges(false);
- cmd.undo();
- 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;
- }
-
- private void processChange(int modelStart, int modelEnd, String insertedText, String replacedText) {
-
- if (insertedText == null)
- insertedText= ""; //$NON-NLS-1$
-
- if (replacedText == null)
- replacedText= ""; //$NON-NLS-1$
-
- int length= insertedText.length();
- int diff= modelEnd - modelStart;
-
- // normalize
- if (diff < 0) {
- int tmp= modelEnd;
- modelEnd= modelStart;
- modelStart= tmp;
- }
-
- if (modelStart == modelEnd) {
- // text will be inserted
- if ((length == 1) || isWhitespaceText(insertedText)) {
- // by typing or model manipulation
- if (!fInserting || (modelStart != fCurrent.fStart + fTextBuffer.length())) {
- commit();
- fInserting= true;
- }
- if (fCurrent.fStart < 0)
- fCurrent.fStart= fCurrent.fEnd= modelStart;
- if (length > 0)
- fTextBuffer.append(insertedText);
- } else if (length > 0) {
- // by pasting
- commit();
- fCurrent.fStart= fCurrent.fEnd= modelStart;
- fTextBuffer.append(insertedText);
- commit();
- }
- } else {
- if (length == 0) {
- // text will be deleted by backspace or DEL key or empty clipboard
- length= replacedText.length();
- String[] delimiters= fTextViewer.getDocument().getLegalLineDelimiters();
-
- if ((length == 1) || TextUtilities.equals(delimiters, replacedText) > -1) {
-
- // whereby selection is empty
-
- if (fPreviousDelete.fStart == modelStart && fPreviousDelete.fEnd == modelEnd) {
- // repeated DEL
-
- // correct wrong settings of fCurrent
- if (fCurrent.fStart == modelEnd && fCurrent.fEnd == modelStart) {
- fCurrent.fStart= modelStart;
- fCurrent.fEnd= modelEnd;
- }
- // append to buffer && extend command range
- fPreservedTextBuffer.append(replacedText);
- ++fCurrent.fEnd;
-
- } else if (fPreviousDelete.fStart == modelEnd) {
- // repeated backspace
-
- // insert in buffer and extend command range
- fPreservedTextBuffer.insert(0, replacedText);
- fCurrent.fStart= modelStart;
-
- } 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(replacedText);
- fCurrent.fStart= modelStart;
- fCurrent.fEnd= modelEnd;
- }
-
- fPreviousDelete.set(modelStart, modelEnd);
-
- } else if (length > 0) {
- // whereby selection is not empty
- commit();
- fCurrent.fStart= modelStart;
- fCurrent.fEnd= modelEnd;
- fPreservedTextBuffer.append(replacedText);
- }
- } else {
- // text will be replaced
-
- if (length == 1) {
- length= replacedText.length();
- String[] delimiters= fTextViewer.getDocument().getLegalLineDelimiters();
-
- if ((length == 1) || TextUtilities.equals(delimiters, replacedText) > -1) {
- // because of overwrite mode or model manipulation
- if (!fOverwriting || (modelStart != fCurrent.fStart + fTextBuffer.length())) {
- commit();
- fOverwriting= true;
- }
-
- if (fCurrent.fStart < 0)
- fCurrent.fStart= modelStart;
-
- fCurrent.fEnd= modelEnd;
- fTextBuffer.append(insertedText);
- fPreservedTextBuffer.append(replacedText);
- return;
- }
- }
- // because of typing or pasting whereby selection is not empty
- commit();
- fCurrent.fStart= modelStart;
- fCurrent.fEnd= modelEnd;
- fTextBuffer.append(insertedText);
- fPreservedTextBuffer.append(replacedText);
- }
- }
- }
-
- /*
- * @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();
- }
- }
-
- protected void selectAndReveal(int offset, int length) {
- if (fTextViewer instanceof ITextViewerExtension5) {
- ITextViewerExtension5 extension= (ITextViewerExtension5) fTextViewer;
- extension.exposeModelRange(new Region(offset, length));
- } else if (!fTextViewer.overlapsWithVisibleRegion(offset, length))
- fTextViewer.resetVisibleRegion();
-
- fTextViewer.setSelectedRange(offset, length);
- fTextViewer.revealRange(offset, length);
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/DocumentClone.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/DocumentClone.java
deleted file mode 100644
index add26238f..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/DocumentClone.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-/**
- * An {@link org.eclipse.jface.text.IDocument} that is a read-only clone of another document.
- *
- * @since 3.0
- */
-class DocumentClone extends AbstractDocument {
-
- private static class StringTextStore implements ITextStore {
-
- private String fContent;
-
- public StringTextStore(String content) {
- Assert.isNotNull(content);
- fContent= content;
- }
-
- /*
- * @see org.eclipse.jface.text.ITextStore#get(int)
- */
- public char get(int offset) {
- return fContent.charAt(offset);
- }
-
- /*
- * @see org.eclipse.jface.text.ITextStore#get(int, int)
- */
- public String get(int offset, int length) {
- return fContent.substring(offset, offset + length);
- }
-
- /*
- * @see org.eclipse.jface.text.ITextStore#getLength()
- */
- public int getLength() {
- return fContent.length();
- }
-
- /*
- * @see org.eclipse.jface.text.ITextStore#replace(int, int, java.lang.String)
- */
- public void replace(int offset, int length, String text) {
- }
-
- /*
- * @see org.eclipse.jface.text.ITextStore#set(java.lang.String)
- */
- public void set(String text) {
- }
-
- }
-
- public DocumentClone(String content, String[] lineDelimiters) {
- super();
- setTextStore(new StringTextStore(content));
- ConfigurableLineTracker tracker= new ConfigurableLineTracker(lineDelimiters);
- setLineTracker(tracker);
- getTracker().set(content);
- completeInitialization();
- }
-}
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 8b26cbd0b..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/DocumentCommand.java
+++ /dev/null
@@ -1,468 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.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;
-
- /**
- * 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 owner the document command owner, may be <code>null</code>
- * @since 3.0
- */
- public Command(int offset, int length, String text, IDocumentListener owner) {
- if (offset < 0 || length < 0)
- throw new IllegalArgumentException();
- fOffset= offset;
- fLength= length;
- fText= text;
- 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.
- * @param listIterator the iterator that this reverse iterator is based upon
- */
- 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 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 {
- final Command command= new Command(offset, length, text, 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);
- }
-
- /**
- * 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, 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;
-
- DefaultPositionUpdater updater= new DefaultPositionUpdater(getCategory());
- Position caretPosition= null;
- try {
- if (updateCaret()) {
- document.addPositionCategory(getCategory());
- document.addPositionUpdater(updater);
- caretPosition= new Position(caretOffset);
- document.addPosition(getCategory(), caretPosition);
- }
-
- final Command originalCommand= new Command(offset, length, text, owner);
- for (final Iterator iterator= new CommandIterator(fCommands, originalCommand, false); iterator.hasNext(); )
- ((Command) iterator.next()).execute(document);
-
- } catch (BadLocationException e) {
- // ignore
- } catch (BadPositionCategoryException e) {
- // ignore
- } finally {
- if (updateCaret()) {
- document.removePositionUpdater(updater);
- try {
- document.removePositionCategory(getCategory());
- } catch (BadPositionCategoryException e) {
- Assert.isTrue(false);
- }
- caretOffset= caretPosition.getOffset();
- }
- }
- }
-
- /**
- * Returns <code>true</code> if the caret offset should be updated, <code>false</code> otherwise.
- *
- * @return <code>true</code> if the caret offset should be updated, <code>false</code> otherwise
- * @since 3.0
- */
- private boolean updateCaret() {
- return shiftsCaret && caretOffset != -1;
- }
-
- /**
- * Returns the position category for the caret offset position.
- *
- * @return the position category for the caret offset position
- * @since 3.0
- */
- private String getCategory() {
- return toString();
- }
-
-}
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 514a4acad..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IAutoEditStrategy.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.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 dbbebb263..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IAutoIndentStrategy.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-
-
-/**
- * Exists for backward compatibility.
- *
- * @deprecated since 3.0, use <code>IAutoEditStrategy</code> directly
- */
-public interface IAutoIndentStrategy extends IAutoEditStrategy {
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IDocumentAdapter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IDocumentAdapter.java
deleted file mode 100644
index db856dbef..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IDocumentAdapter.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.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 cc45fbb59..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IDocumentAdapterExtension.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.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 469370882..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IEventConsumer.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.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 3fa28d030..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IFindReplaceTarget.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.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 widget offset and using the specified search
- * directives. If a string has been found it is selected and its start offset is
- * returned.
- *
- * @param widgetOffset the widget 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> performs a case sensitive search, <code>false</code> an insensitive search
- * @param wholeWord if <code>true</code> only occurrences 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 widgetOffset, String findString, boolean searchForward, boolean caseSensitive, boolean wholeWord);
-
- /**
- * Returns the currently selected range of characters as a offset and length in widget coordinates.
- *
- * @return the currently selected character range in widget coordinates
- */
- 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 4a2cf2a05..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IFindReplaceTargetExtension.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.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 76637a2ea..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IFindReplaceTargetExtension3.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.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 9d1f14779..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControl.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.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.
- * <p>
- * Note: An information control which implements {@link IInformationControlExtension3}
- * can ignore this method or use it as hint for its very first appearance.
- * </p>
- * @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
- * return 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 35c882df0..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControlCreator.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.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 f9cbe605f..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControlCreatorExtension.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.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 this information control creator can replace the given
- * information control creator. This is the case if the two creators create
- * the same kind of information controls.
- *
- * @param creator the creator to be checked
- * @return <code>true</code> if the given creator can be replaced,
- * <code>false</code> otherwise
- */
- 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 1315b31b9..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControlExtension.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.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 4e7829a91..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControlExtension2.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.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/IInformationControlExtension3.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControlExtension3.java
deleted file mode 100644
index f9335f43b..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControlExtension3.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-import org.eclipse.swt.graphics.Rectangle;
-
-
-/**
- * Extension interface for <code>IInformationControl</code>. Adds API which
- * allows to get this information control's bounds i.e. location and size.
- * <p>
- * Note: An information control which implements this interface can ignore
- * calls to {@link org.eclipse.jface.text.IInformationControl#setSizeConstraints(int, int)}
- * or use it as hint for its very first appearance.
- * </p>
- *
- * @see org.eclipse.jface.text.IInformationControl
- * @since 3.0
- */
-public interface IInformationControlExtension3 {
-
- /**
- * Returns a rectangle describing the receiver's size and location
- * relative to its parent (or its display if its parent is null).
- * <p>
- * Note: If the receiver is already disposed then this methods must
- * return the last valid location and size.
- * </p>
- *
- * @return the receiver's bounding rectangle
- */
- Rectangle getBounds();
-
- /**
- * Computes the trim for this control.
- * x and y denote the upper left corner of the trimming relative
- * to this control's location i.e. this will most likely be
- * negative values. Width and height represent the border sizes.
- *
- * @return the receivers trim
- */
- Rectangle computeTrim();
-
- /**
- * Tells whether this control allows to restore the previously
- * used size.
- * <p>
- * Note: This is not a static property - it can change during the
- * lifetime of this control.</p>
- *
- * @return <code>true</code> if restoring size is supported
- */
- boolean restoresSize();
-
- /**
- * Tells whether this control allows to restore the previously
- * used location.
- * <p>
- * Note: This is not a static property - it can change during the
- * lifetime of this control.</p>
- *
- * @return <code>true</code> if restoring location is supported
- */
- boolean restoresLocation();
-}
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 c58a57953..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IMarkRegionTarget.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.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 1391589c8..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IMarkSelection.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.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 fd5f315fc..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IPaintPositionManager.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.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 20b3852b3..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IPainter.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.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 1ad6bb12b..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IRewriteTarget.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.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/ISelectionValidator.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/ISelectionValidator.java
deleted file mode 100644
index f629f5f73..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ISelectionValidator.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-import org.eclipse.jface.viewers.ISelection;
-
-/**
- * A selection validator allows clients to test
- * whether the selection they received during selection
- * changed notification is still valid.
- * <p>
- * For example selection and document changes cause the
- * selection to be invalid.
- * </p>
- *
- * @since 3.0
- */
-public interface ISelectionValidator {
-
- /**
- * Tests whether the given post selection is still valid.
- *
- * @param selection
- * @return <code>true</code> if the selection is still valid
- */
- boolean isValid(ISelection selection);
-}
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 3e9f10491..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextDoubleClickStrategy.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.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(org.eclipse.swt.events.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 e3eb53eb3..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextHover.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.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 c25a4b2e9..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextHoverExtension.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.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 hover control creator of this text hover.
- *
- * @return the hover control creator
- */
- IInformationControlCreator getHoverControlCreator();
-}
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 4b2751617..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextInputListener.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.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 357e7ccc3..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextListener.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-
-
-/**
- * Text listeners registered with a 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 corresponding 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 69c67b26c..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextOperationTarget.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.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 66804736c..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextOperationTargetExtension.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.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/ITextPresentationListener.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextPresentationListener.java
deleted file mode 100644
index 92a76ff15..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextPresentationListener.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-/**
- * Text presentation listeners registered with a text viewer are informed
- * when a text region is about to be drawn in order to get the text
- * presentation information.
- *
- * @since 3.0
- */
-public interface ITextPresentationListener {
-
- /**
- * This method is called when a region is about to be
- * drawn in order to get the text presentation information.
- * Even though the given text presentation may cover a wider
- * region than the given one clients should not modify text
- * presentation outside the given region since this might be
- * ignored.
- *
- * @param textPresentation the current text presentation
- */
- public void applyTextPresentation(TextPresentation textPresentation);
-}
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 8820d0627..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextSelection.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.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 b20dbda38..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewer.java
+++ /dev/null
@@ -1,434 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.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> view port listeners to inform about changes of the viewer's view port
- * <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();
-
-
- /* --------- plug-ins --------- */
-
- /**
- * 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 view port 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 view port 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 appropriate <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 flag.
- *
- * @param editable the editable flag
- */
- void setEditable(boolean editable);
-
- /**
- * Returns whether the shown text can be manipulated.
- *
- * @return the viewer's editable flag
- */
- boolean isEditable();
-
-
- /* ----------- visible region support ------------- */
-
- /**
- * Sets the given document as this viewer's model and
- * exposes the specified region. An appropriate
- * <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 modelRangeOffset the offset of the model range
- * @param modelRangeLength the length of the model range
- */
- void setDocument(IDocument document, int modelRangeOffset, int modelRangeLength);
-
- /**
- * 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.
- *
- * @param offset the offset
- * @param length the length
- * @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 view port.
- *
- * @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 view port. 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 c050e02ce..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.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 610661166..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension2.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.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 80baf8836..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension3.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.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
- * @deprecated completely replaced by <code>ITextViewerExtension5</code>
- */
-public interface ITextViewerExtension3 {
-
-
- /**
- * Returns the minimal region of the viewer's document that completely comprises everything that is
- * visible in the viewer's widget or <code>null</code> if there is no such region.
- *
- * @return the minimal region of the viewer's document comprising the contents of the viewer's widget or <code>null</code>
- */
- 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>
- */
- 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>
- */
- 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>
- */
- 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>
- */
- 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>
- */
- 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>
- */
- 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
- */
- 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 bc9ee2884..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension4.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-
-/**
- * Extension interface for <code>ITextViewer</code>. Adds the following functionality:
- * <ul>
- * <li>focus handling for widget token keepers</li>
- * <li>introduces text presentation listener</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();
-
- /**
- * Adds the given text presentation listener to this text viewer.
- * This call has no effect if the listener is already registered
- * with this text viewer.
- *
- * @param listener the text presentation listener
- */
- void addTextPresentationListener(ITextPresentationListener listener);
-
- /**
- * Removes the given text presentation listener from this text viewer.
- * This call has no effect if the listener is not registered with this
- * text viewer.
- *
- * @param listener the text presentation listener
- */
- void removeTextPresentationListener(ITextPresentationListener listener);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension5.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension5.java
deleted file mode 100644
index 64c2c182b..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension5.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-/**
- * Extension interface to <code>ITextViewer</code>. Defines a complete
- * replacement of all visible region related methods defined in
- * <code>ITextViewer</code>.
- * <p>
- * Introduces 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>
- * All model ranges that have a corresponding widget ranges are considered
- * "exposed model ranges". The set of exposed model ranges can be defined to
- * contain only a single region using <code>setExposedModelRange</code>. The
- * viewer can be requested to expose a given model range.<p>
- *
- * @since 3.0
- */
-public interface ITextViewerExtension5 extends ITextViewerExtension3 {
-
- /**
- * Returns the minimal region of the viewer's document that completely comprises everything that is
- * visible in the viewer's widget or <code>null</code> if there is no such region.
- *
- * @return the minimal region of the viewer's document comprising the contents of the viewer's widget or <code>null</code>
- */
- 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>
- */
- 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>
- */
- 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>
- */
- 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>
- */
- 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>
- */
- 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>
- */
- int widgetLine2ModelLine(int widgetLine);
-
- /**
- * Returns the widget line of the given widget offset.
- *
- * @param widgetOffset the widget offset
- * @return the widget line of the widget offset
- */
- int widgetLineOfWidgetOffset(int widgetOffset);
-
-
- /**
- * Returns the maximal subranges of the given model range thus that there is
- * no offset inside a subrange for which there is no image offset.
- *
- * @param modelRange the model range
- * @return the list of subranges
- */
- IRegion[] getCoveredModelRanges(IRegion modelRange);
-
- /**
- * Exposes the given model range. Returns whether this call caused a change
- * of the set of exposed model ranges.
- *
- * @param modelRange the model range to be exposed
- * @return <code>true</code> if the set of exposed model ranges changed, <code>false</code> otherwise
- */
- boolean exposeModelRange(IRegion modelRange);
-}
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 c0049f402..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IUndoManager.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.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 7183b6382..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IViewportListener.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.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.
- *
- * @param verticalOffset the vertical offset
- */
- 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 7c3add55d..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IWidgetTokenKeeper.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.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 decde9137..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IWidgetTokenKeeperExtension.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.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 8eed2af94..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IWidgetTokenOwner.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.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 2e48c32e7..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IWidgetTokenOwnerExtension.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.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 67fab7616..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/JFaceTextMessages.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.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 35a697192..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/JFaceTextMessages.properties
+++ /dev/null
@@ -1,33 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2004 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-
-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
-
-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 5ebb74c49..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/MarginPainter.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.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 749e1c699..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/MarkSelection.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.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 dd6609f91..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/PaintManager.java
+++ /dev/null
@@ -1,380 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.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.deactivate(true);
- 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);
-
- addListeners();
- }
-
- /**
- * Installs our listener set on the text viewer and the text widget,
- * respectively.
- */
- private void addListeners() {
- 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);
-
- removeListeners();
- }
-
- /**
- * Removes our set of listeners from the text viewer and widget,
- * respectively.
- */
- private void removeListeners() {
- 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
- */
- private 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);
- removeListeners();
- }
- }
-
- /*
- * @see ITextInputListener#inputDocumentChanged(IDocument, IDocument)
- */
- public void inputDocumentChanged(IDocument oldInput, IDocument newInput) {
- if (newInput != null) {
- fManager.install(newInput);
- paint(IPainter.TEXT_CHANGE);
- addListeners();
- }
- }
-}
-
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 61b8d47c6..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/PropagatingFontFieldEditor.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.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
- * @deprecated since 3.0 not longer in use, no longer supported
- */
-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 3be050845..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextAttribute.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.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 9d83d0fce..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextEvent.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.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.
- * Clients 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 text the inserted text
- * @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 9ad1cb7ba..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextPresentation.java
+++ /dev/null
@@ -1,699 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.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 text 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 style 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;
- /**
- * The optional extent for this presentation.
- * @since 3.0
- */
- private IRegion fExtent;
-
-
- /**
- * 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);
- }
-
- /**
- * Creates a new empty text presentation with the given extent.
- * <code>sizeHint</code> tells the expected size of this presentation.
- *
- * @param extent the extent of the created <code>TextPresentation</code>
- * @param sizeHint the expected size of this presentation
- * @since 3.0
- */
- public TextPresentation(IRegion extent, int sizeHint) {
- this(sizeHint);
- Assert.isNotNull(extent);
- fExtent= extent;
- }
-
- /**
- * 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 describing 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() {
- StyleRange range= createWindowRelativeRange(fResultWindow, fDefaultRange);
- if (range == null)
- return null;
- else
- return (StyleRange)range.clone();
-
- }
-
- /**
- * 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);
- }
-
- /**
- * Replaces the given range in this presentation. The range must be a
- * subrange of the presentation's default range.
- *
- * @param range the range to be added
- * @since 3.0
- */
- public void replaceStyleRange(StyleRange range) {
- applyStyleRange(range, false);
- }
-
- /**
- * Merges the given range into this presentation. The range must be a
- * subrange of the presentation's default range.
- *
- * @param range the range to be added
- * @since 3.0
- */
- public void mergeStyleRange(StyleRange range) {
- applyStyleRange(range, true);
- }
-
- /**
- * Applies the given range to this presentation. The range must be a
- * subrange of the presentation's default range.
- *
- * @param range the range to be added
- * @param merge <code>true</code> if the style should be merged instead of replaced
- * @since 3.0
- */
- private void applyStyleRange(StyleRange range, boolean merge) {
- if (range.length == 0)
- return;
-
- checkConsistency(range);
-
- int start= range.start;
- int length= range.length;
- int end= start + length;
-
- if (fRanges.size() == 0) {
- StyleRange defaultRange= getDefaultStyleRange();
- if (defaultRange == null)
- defaultRange= range;
-
- defaultRange.start= start;
- defaultRange.length= length;
- applyStyle(range, defaultRange, merge);
- fRanges.add(defaultRange);
- } else {
- IRegion rangeRegion= new Region(start, length);
- int first= getFirstIndexInWindow(rangeRegion);
-
- if (first == fRanges.size()) {
- StyleRange defaultRange= getDefaultStyleRange();
- if (defaultRange == null)
- defaultRange= range;
- defaultRange.start= start;
- defaultRange.length= length;
- applyStyle(range, defaultRange, merge);
- fRanges.add(defaultRange);
- return;
- }
-
- int last= getFirstIndexAfterWindow(rangeRegion);
- for (int i= first; i < last && length > 0; i++) {
-
- StyleRange current= (StyleRange)fRanges.get(i);
- int currentStart= current.start;
- int currentEnd= currentStart + current.length;
-
- if (end <= currentStart) {
- fRanges.add(i, range);
- return;
- }
-
- if (start >= currentEnd)
- continue;
-
- StyleRange currentCopy= null;
- if (end < currentEnd)
- currentCopy= (StyleRange)current.clone();
-
- if (start < currentStart) {
- // Apply background to new default range and add it
- StyleRange defaultRange= getDefaultStyleRange();
- if (defaultRange == null)
- defaultRange= new StyleRange();
-
- defaultRange.start= start;
- defaultRange.length= currentStart - start;
- applyStyle(range, defaultRange, merge);
- fRanges.add(i, defaultRange);
- i++; last++;
-
-
- // Apply background to first part of current range
- current.length= Math.min(end, currentEnd) - currentStart;
- applyStyle(range, current, merge);
- }
-
- if (start >= currentStart) {
- // Shorten the current range
- current.length= start - currentStart;
-
- // Apply the background to the rest of the current range and add it
- if (current.length > 0) {
- current= (StyleRange)current.clone();
- i++; last++;
- fRanges.add(i, current);
- }
- applyStyle(range, current, merge);
- current.start= start;
- current.length= Math.min(end, currentEnd) - start;
- }
-
- if (end < currentEnd) {
- // Add rest of current range
- currentCopy.start= end;
- currentCopy.length= currentEnd - end;
- i++; last++;
- fRanges.add(i, currentCopy);
- }
-
- // Update range
- range.start= currentEnd;
- range.length= Math.max(end - currentEnd, 0);
- start= range.start;
- length= range.length;
- }
- if (length > 0) {
- // Apply background to new default range and add it
- StyleRange defaultRange= getDefaultStyleRange();
- if (defaultRange == null)
- defaultRange= range;
- defaultRange.start= start;
- defaultRange.length= end - start;
- defaultRange.background= range.background;
- fRanges.add(last, defaultRange);
- }
- }
- }
-
- /**
- * Replaces the given ranges in this presentation. Each range must be a
- * subrange of the presentation's default range. The ranges must be ordered
- * by increasing offset and must not overlap (but may be adjacent).
- *
- * @param ranges the ranges to be added
- * @since 3.0
- */
- public void replaceStyleRanges(StyleRange[] ranges) {
- applyStyleRanges(ranges, false);
- }
-
- /**
- * Merges the given ranges into this presentation. Each range must be a
- * subrange of the presentation's default range. The ranges must be ordered
- * by increasing offset and must not overlap (but may be adjacent).
- *
- * @param ranges the ranges to be added
- * @since 3.0
- */
- public void mergeStyleRanges(StyleRange[] ranges) {
- applyStyleRanges(ranges, true);
- }
-
- /**
- * Applies the given ranges to this presentation. Each range must be a
- * subrange of the presentation's default range. The ranges must be ordered
- * by increasing offset and must not overlap (but may be adjacent).
- *
- * @param ranges the ranges to be added
- * @param merge <code>true</code> if the style should be merged instead of replaced
- * @since 3.0
- */
- private void applyStyleRanges(StyleRange[] ranges, boolean merge) {
- int j= 0;
- ArrayList oldRanges= fRanges;
- ArrayList newRanges= new ArrayList(2*ranges.length + oldRanges.size());
- for (int i= 0, n= ranges.length; i < n; i++) {
- StyleRange range= ranges[i];
- fRanges= oldRanges; // for getFirstIndexAfterWindow(...)
- for (int m= getFirstIndexAfterWindow(new Region(range.start, range.length)); j < m; j++)
- newRanges.add(oldRanges.get(j));
- fRanges= newRanges; // for mergeStyleRange(...)
- applyStyleRange(range, merge);
- }
- for (int m= oldRanges.size(); j < m; j++)
- newRanges.add(oldRanges.get(j));
- fRanges= newRanges;
- }
-
- /**
- * Applies the template's style to the target.
- *
- * @param template the style range to be used as template
- * @param target the style range to which to apply the template
- * @param merge <code>true</code> if the style should be merged instead of replaced
- * @since 3.0
- */
- private void applyStyle(StyleRange template, StyleRange target, boolean merge) {
- if (merge) {
- if (template.foreground != null)
- target.foreground= template.foreground;
- if (template.background != null)
- target.background= template.background;
- target.fontStyle |= template.fontStyle;
- } else {
- target.foreground= template.foreground;
- target.background= template.background;
- target.fontStyle= template.fontStyle;
- }
- }
-
- /**
- * 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 -= (end - defaultEnd);
- }
- }
-
- /**
- * 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) {
- if (window != null) {
- int start= window.getOffset();
- int i= -1, j= fRanges.size();
- while (j - i > 1) {
- int k= (i + j) >> 1;
- StyleRange r= (StyleRange) fRanges.get(k);
- if (r.start + r.length > start)
- j= k;
- else
- i= k;
- }
- return j;
- }
- return 0;
- }
-
- /**
- * 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) {
- if (window != null) {
- int end= window.getOffset() + window.getLength();
- int i= -1, j= fRanges.size();
- while (j - i > 1) {
- int k= (i + j) >> 1;
- StyleRange r= (StyleRange) fRanges.get(k);
- if (r.start < end)
- i= k;
- else
- j= k;
- }
- return j;
- }
- return fRanges.size();
- }
-
- /**
- * 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 the region which is relative to the specified window and
- * appropriately clipped if necessary.
- *
- * @param coverage the absolute coverage
- * @return the window relative region based on the absolute coverage
- * @since 3.0
- */
- private IRegion createWindowRelativeRegion(IRegion coverage) {
- if (fResultWindow == null || coverage == null)
- return coverage;
-
- int start= coverage.getOffset() - fResultWindow.getOffset();
- if (start < 0)
- start= 0;
-
- int rangeEnd= coverage.getOffset() + coverage.getLength();
- int windowEnd= fResultWindow.getOffset() + fResultWindow.getLength();
- int end= (rangeEnd > windowEnd ? windowEnd : rangeEnd);
- end -= fResultWindow.getOffset();
-
- return new Region(start, end - start);
- }
-
- /**
- * 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 iterator
- */
- 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 smallest 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);
- }
-
- /**
- * Returns the extent of this presentation clipped by the
- * presentation's result window.
- *
- * @return the clipped extent
- * @since 3.0
- */
- public IRegion getExtent() {
- if (fExtent != null)
- return createWindowRelativeRegion(fExtent);
- else
- return getCoverage();
- }
-
- /**
- * 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 1c89cef70..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextSelection.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.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.
- *
- * @return <code>true</code> if this selection is empty
- * @see org.eclipse.jface.viewers.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 7884aa649..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java
+++ /dev/null
@@ -1,4858 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.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;
-
-import org.eclipse.jface.text.projection.ChildDocument;
-import org.eclipse.jface.text.projection.ChildDocumentManager;
-
-/**
- * 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 {
-
- /** The document event encapsulated by this command. */
- public DocumentEvent event;
- /** The start and length fields of <code>event</code>. */
- public int start, length;
- /** The inserted and replaced text segments of <code>event</code>. */
- 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 {
-
- if (e instanceof SlaveDocumentEvent) {
- SlaveDocumentEvent slave= (SlaveDocumentEvent) e;
- DocumentEvent master= slave.getMasterEvent();
- if (master != null)
- preservedText= master.getDocument().get(master.getOffset(), master.getLength());
- } else {
- 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 on the visible document.
- */
- class VisibleDocumentListener implements IDocumentListener {
-
- /*
- * @see IDocumentListener#documentAboutToBeChanged
- */
- public void documentAboutToBeChanged(DocumentEvent e) {
- if (e.getDocument() == getVisibleDocument())
- fWidgetCommand.setEvent(e);
- handleVisibleDocumentAboutToBeChanged(e);
- }
-
- /*
- * @see IDocumentListener#documentChanged
- */
- public void documentChanged(DocumentEvent e) {
- if (fWidgetCommand.event == e)
- updateTextListeners(fWidgetCommand);
- fLastSentSelectionChange= null;
- handleVisibleDocumentChanged(e);
- }
- }
-
-
- /**
- * 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 responsible for registered verify key listeners.
- * Uses batches rather than robust iterators because of performance issues.
- * <p>
- * The implementation is reentrant, i.e. installed listeners may trigger
- * further <code>VerifyKeyEvent</code>s that may cause other listeners to be
- * installed, but not thread safe.
- * </p>
- * @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 registered verify key listeners. */
- private List fListeners= new ArrayList();
- /** List of pending batches. */
- private List fBatched= new ArrayList();
- /** The reentrance count. */
- private int fReentranceCount= 0;
-
- /*
- * @see VerifyKeyListener#verifyKey(VerifyEvent)
- */
- public void verifyKey(VerifyEvent event) {
- if (fListeners.isEmpty())
- return;
-
- try {
- fReentranceCount++;
- Iterator iterator= fListeners.iterator();
- while (iterator.hasNext() && event.doit) {
- VerifyKeyListener listener= (VerifyKeyListener) iterator.next();
- listener.verifyKey(event); // we might trigger reentrant calls on GTK
- }
- } finally {
- fReentranceCount--;
- }
- if (fReentranceCount == 0)
- 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 (fReentranceCount > 0) {
-
- 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 (fReentranceCount > 0) {
-
- 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;
-
- /*
- * @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.getFindReplaceDocumentAdapter().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 modelSelection= TextViewer.this.getSelectedRange();
- return modelSelection2WidgetSelection(modelSelection);
- }
-
- /*
- * @see IFindReplaceTarget#findAndSelect(int, String, boolean, boolean, boolean)
- */
- public int findAndSelect(int widgetOffset, String findString, boolean searchForward, boolean caseSensitive, boolean wholeWord) {
- try {
- return findAndSelect(widgetOffset, findString, searchForward, caseSensitive, wholeWord, false);
- } catch (PatternSyntaxException x) {
- return -1;
- }
- }
-
- /*
- * @see IFindReplaceTarget#findAndSelect(int, String, boolean, boolean, boolean)
- */
- public int findAndSelect(int widgetOffset, String findString, boolean searchForward, boolean caseSensitive, boolean wholeWord, boolean regExSearch) {
-
- int modelOffset= widgetOffset == -1 ? -1 : widgetOffset2ModelOffset(widgetOffset);
-
- 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);
- }
-
- widgetOffset= modelOffset == -1 ? -1 : modelOffset2WidgetOffset(modelOffset);
- return widgetOffset;
- }
-
- /*
- * @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 represented 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 anchor.
- */
- 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 view port 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;
- /** Listener on the visible document */
- private VisibleDocumentListener fVisibleDocumentListener= new VisibleDocumentListener();
- /** 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
- */
- protected 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 listeners.
- * @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
- */
- protected FindReplaceDocumentAdapter fFindReplaceDocumentAdapter;
-
- /** 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 view port 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;
- /**
- * All registered text presentation listeners.
- * since 3.0
- */
- protected List fTextPresentationListeners;
-
-
-
- //---- 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 DefaultDocumentAdapter();
- }
-
- /**
- * 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 (fVisibleDocumentListener !=null) {
- if (fVisibleDocument != null)
- fVisibleDocument.removeDocumentListener(fVisibleDocumentListener);
- fVisibleDocumentListener= 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>
- * <p>
- * The same value (<code>500</code>) is used in <code>OpenStrategy.TIME</code>.</p>
- *
- * @return delay in milliseconds
- * @see org.eclipse.jface.util.OpenStrategy
- * @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, true), 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 {
- accepted= 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() && fDocumentSelection != null)
- return fDocumentSelection.getNormalizedSelection();
-
- if (fTextWidget != null) {
- Point p= fTextWidget.getSelectionRange();
- p= widgetSelection2ModelSelection(p);
- if (p != null)
- return 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 successful 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);
-
- resetPlugins();
- inputChanged(fDocument, oldDocument);
-
- fireInputDocumentChanged(oldDocument, fDocument);
- fLastSentSelectionChange= null;
- fReplaceTextPresentation= false;
- }
-
- /*
- * @see ITextViewer#setDocument(IDocument, int, int)
- */
- public void setDocument(IDocument document, int modelRangeOffset, int modelRangeLength) {
-
- fReplaceTextPresentation= true;
- fireInputDocumentAboutToBeChanged(fDocument, document);
-
- IDocument oldDocument= fDocument;
- fDocument= document;
-
- try {
-
- IDocument slaveDocument= createSlaveDocument(document);
- updateSlaveDocument(slaveDocument, modelRangeOffset, modelRangeLength);
- setVisibleDocument(slaveDocument);
-
- } catch (BadLocationException x) {
- throw new IllegalArgumentException(JFaceTextMessages.getString("TextViewer.error.invalid_visible_region_1")); //$NON-NLS-1$
- }
-
- resetPlugins();
- 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
- * @deprecated use <code>updateSlaveDocument</code> instead
- */
- 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;
- }
-
- /**
- * Updates the given slave document to show the specified range of its master document.
- *
- * @param slaveDocument the slave document
- * @param modelRangeOffset the offset of the master document range
- * @param modelRangeLength 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 3.0
- */
- protected boolean updateSlaveDocument(IDocument slaveDocument, int modelRangeOffset, int modelRangeLength) throws BadLocationException {
- return updateVisibleDocument(slaveDocument, modelRangeOffset, modelRangeLength);
- }
-
-
-
- //---- View ports
-
- /**
- * Initializes all listeners and structures required to set up view port 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 view port 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 view port 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 widgetLine2ModelLine(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 view port height in lines. The actual visible lines can be fewer if the
- * document is shorter than the view port.
- *
- * @return the view port 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();
- if (coverage == null)
- return -1;
-
- 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;
- int modelLine= widgetLine2ModelLine(widgetBottomIndex);
- if (modelLine == -1)
- return endLine;
- return modelLine;
- }
-
- 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 widgetLine2ModelLine(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();
- if (coverage == null)
- return -1;
-
- 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= (coverage == null || 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 drawn into this viewer's widget.
- *
- * @param text the string to measure
- * @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 view port
- * 0 <= offset <= getCharCount()
- * @param end offset relative to the start of this viewer's view port
- * 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();
- }
- }
-
- /**
- * Frees the given document if it is a slave document.
- *
- * @param slave the potential slave document
- * @since 3.0
- */
- protected void freeSlaveDocument(IDocument slave) {
- ISlaveDocumentManager manager= getSlaveDocumentManager();
- if (manager != null && manager.isSlaveDocument(slave))
- manager.freeSlaveDocument(slave);
- }
-
- /**
- * 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 == document && fVisibleDocument instanceof ChildDocument) {
- // optimization for new child documents
- return;
- }
-
- if (fVisibleDocument != null) {
- if (fVisibleDocumentListener != null)
- fVisibleDocument.removeDocumentListener(fVisibleDocumentListener);
- if (fVisibleDocument != document)
- freeSlaveDocument(fVisibleDocument);
- }
-
- fVisibleDocument= document;
- initializeDocumentInformationMapping(fVisibleDocument);
-
- initializeWidgetContents();
-
- fFindReplaceDocumentAdapter= null;
- if (fVisibleDocument != null && fVisibleDocumentListener != null)
- fVisibleDocument.addDocumentListener(fVisibleDocumentListener);
- }
-
- /**
- * Hook method called when the visible document is about to be changed.
- * <p>
- * Subclasses may override.
- *
- * @param event the document event
- * @since 3.0
- */
- protected void handleVisibleDocumentAboutToBeChanged(DocumentEvent event) {
- }
-
- /**
- * Hook method called when the visible document has been changed.
- * <p>
- * Subclasses may override.
- *
- * @param event the document event
- * @since 3.0
- */
- protected void handleVisibleDocumentChanged(DocumentEvent event) {
- }
-
- /**
- * 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;
- }
-
- setRedraw(false);
- try {
-
- IDocument slaveDocument= createSlaveDocument(getVisibleDocument());
- if (updateSlaveDocument(slaveDocument, start, length))
- setVisibleDocument(slaveDocument);
-
- } catch (BadLocationException x) {
- throw new IllegalArgumentException(JFaceTextMessages.getString("TextViewer.error.invalid_visible_region_2")); //$NON-NLS-1$
- } finally {
- setRedraw(true);
- }
- }
-
- /*
- * @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);
- }
- }
- }
-
-
- //--------------------------------------
-
- /*
- * @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 plug-in
- * @return the plug-in registered under the offset's content type
- */
- protected Object selectContentTypePlugin(int offset, Map plugins) {
- try {
- return selectContentTypePlugin(TextUtilities.getContentType(getDocument(), getDocumentPartitioning(), offset, true), 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>plug-ins</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()) {
- // optimization
- 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 behavior 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 (region != null) {
- 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 regularly 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
- */
- protected 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 beginning 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 whitespace 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(), false);
-
- 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 length= regions[i].getLength();
- int offset= regions[i].getOffset() + length;
- if (length > 0)
- offset--;
- 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= getFindReplaceDocumentAdapter().find(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
- */
- protected 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= getFindReplaceDocumentAdapter().find(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 {
- IRegion region= modelRange2WidgetRange(presentation.getCoverage());
- if (region == null)
- return;
-
- List list= new ArrayList(presentation.getDenumerableRanges());
- 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);
- 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 (fTextWidget == null)
- return;
-
-
- /*
- * Call registered text presentation listeners
- * and let them apply their presentation.
- */
- if (fTextPresentationListeners != null) {
- ArrayList listeners= new ArrayList(fTextPresentationListeners);
- for (int i= 0, size= listeners.size(); i < size; i++) {
- ITextPresentationListener listener= (ITextPresentationListener)listeners.get(i);
- listener.applyTextPresentation(presentation);
- }
- }
-
- if (presentation.isEmpty())
- 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
- */
- protected FindReplaceDocumentAdapter getFindReplaceDocumentAdapter() {
- if (fFindReplaceDocumentAdapter == null)
- fFindReplaceDocumentAdapter= new FindReplaceDocumentAdapter(getVisibleDocument());
- return fFindReplaceDocumentAdapter;
- }
-
- /*
- * @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() {
- enabledRedrawing(-1);
- }
- /**
- * Enables the redrawing of this text viewer.
- *
- * @param topIndex the top index to be set or <code>-1</code>
- * @since 3.0
- */
- protected void enabledRedrawing(int topIndex) {
- if (fDocumentAdapter instanceof IDocumentAdapterExtension) {
- IDocumentAdapterExtension extension= (IDocumentAdapterExtension) fDocumentAdapter;
- StyledText textWidget= getTextWidget();
- if (textWidget != null && !textWidget.isDisposed()) {
- int topPixel= textWidget.getTopPixel();
- extension.resumeForwardingDocumentChanges();
- if (topIndex > -1) {
- try {
- setTopIndex(topIndex);
- } catch (IllegalArgumentException x) {
- // changes don't allow for the previous top pixel
- }
- } else 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);
- if (topIndex == -1)
- 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) {
- setRedraw(redraw, -1);
- }
-
- /**
- * Basically same functionality as
- * <code>ITextViewerExtension.setRedraw(boolean)</code>. Adds a way for
- * subclasses to pass in a desired top index that should be used when
- * <code>redraw</code> is <code>true</code>. If <code>topIndex</code>
- * is -1, this method is identical to
- * <code>ITextViewerExtension.setRedraw(boolean)</code>.
- *
- * @see ITextViewerExtension#setRedraw(boolean)
- *
- * @param redraw
- * @param topIndex
- * @since 3.0
- */
- protected final void setRedraw(boolean redraw, int topIndex) {
- if (!redraw) {
-
- ++ fRedrawCounter;
- if (fRedrawCounter == 1)
- disableRedrawing();
-
- } else {
- -- fRedrawCounter;
- if (fRedrawCounter == 0) {
- if (topIndex == -1)
- enabledRedrawing();
- else
- enabledRedrawing(topIndex);
- }
- }
- }
-
- /**
- * 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) {
- return widgetLine2ModelLine(widgetLine);
- }
-
- /**
- * @see ITextViewerExtension5#widgetLine2ModelLine(int)
- * @since 3.0
- */
- public int widgetLine2ModelLine(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;
- }
-
- //---- Text presentation listeners ----
-
- /*
- * @see ITextViewerExtension4#addTextPresentationListener(ITextPresentationListener)
- * @since 3.0
- */
- public void addTextPresentationListener(ITextPresentationListener listener) {
-
- Assert.isNotNull(listener);
-
- if (fTextPresentationListeners == null)
- fTextPresentationListeners= new ArrayList();
-
- if (!fTextPresentationListeners.contains(listener))
- fTextPresentationListeners.add(listener);
- }
-
- /*
- * @see ITextViewerExtension4#removeTextPresentationListener(ITextPresentationListener)
- * @since 3.0
- */
- public void removeTextPresentationListener(ITextPresentationListener listener) {
-
- Assert.isNotNull(listener);
-
- if (fTextPresentationListeners != null) {
- fTextPresentationListeners.remove(listener);
- if (fTextPresentationListeners.size() == 0)
- fTextPresentationListeners= null;
- }
- }
-}
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 5277b8c8e..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewerHoverManager.java
+++ /dev/null
@@ -1,417 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseMoveListener;
-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;
- /**
- * Tells whether the next mouse hover event
- * should be processed.
- * @since 3.0
- */
- private boolean fProcessMouseHoverEvent= true;
- /**
- * Internal mouse move listener.
- * @since 3.0
- */
- private MouseMoveListener fMouseMoveListener;
- /**
- * Internal viewport listener.
- * @since 3.0
- */
- private IViewportListener fViewportListener;
-
-
- /**
- * 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;
- }
- }
- }
- };
- fViewportListener= new IViewportListener() {
- /*
- * @see org.eclipse.jface.text.IViewportListener#viewportChanged(int)
- */
- public void viewportChanged(int verticalOffset) {
- fProcessMouseHoverEvent= false;
- }
- };
- fTextViewer.addViewportListener(fViewportListener);
- fMouseMoveListener= new MouseMoveListener() {
- /*
- * @see MouseMoveListener#mouseMove(MouseEvent)
- */
- public void mouseMove(MouseEvent event) {
- fProcessMouseHoverEvent= true;
- }
- };
- fTextViewer.getTextWidget().addMouseMoveListener(fMouseMoveListener);
- }
-
- /**
- * Determines all necessary details and delegates the computation into
- * a background thread.
- */
- protected void computeInformation() {
-
- if (!fProcessMouseHoverEvent) {
- setInformation(null, null);
- return;
- }
-
- 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).getHoverControlCreator());
- 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 ITextViewerExtension5) {
- ITextViewerExtension5 extension= (ITextViewerExtension5) 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 ITextViewerExtension5) {
- ITextViewerExtension5 extension= (ITextViewerExtension5) 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;
- }
-
- /*
- * @see org.eclipse.jface.text.AbstractHoverInformationControlManager#dispose()
- * @since 3.0
- */
- public void dispose() {
- if (fTextViewer != null) {
- fTextViewer.removeViewportListener(fViewportListener);
- fViewportListener= null;
-
- StyledText st= fTextViewer.getTextWidget();
- if (st != null && !st.isDisposed())
- st.removeMouseMoveListener(fMouseMoveListener);
- fMouseMoveListener= null;
- }
- super.dispose();
- }
-}
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 2d90eb245..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AdditionalInfoController.java
+++ /dev/null
@@ -1,268 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.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;
-import org.eclipse.jface.text.IInformationControlExtension3;
-
-
-
-/**
- * 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 final Object fMutex= new Object();
- /**
- * Thread access lock.
- * since 3.0
- */
- private final Object fThreadAccess= 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);
- synchronized (fThreadAccess) {
- if (fThread != null)
- fThread.interrupt();
- 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() {
-
- synchronized (fThreadAccess) {
- 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) {
- }
-
- synchronized (fThreadAccess) {
- // only null fThread if it is us!
- if (Thread.currentThread() == fThread)
- 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, -2);
- 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();
-
- Rectangle otherTrim= subjectControl.getShell().computeTrim(0, 0, 0, 0);
- size.x += otherTrim.width;
- size.y += otherTrim.height;
-
- if (informationControl instanceof IInformationControlExtension3) {
- Rectangle thisTrim= ((IInformationControlExtension3)informationControl).computeTrim();
- size.x -= thisTrim.width;
- size.y -= thisTrim.height;
- }
-
- 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 bcf3e9ede..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposal.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.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 contextInformation 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 2bc09082d..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java
+++ /dev/null
@@ -1,1107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.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.contentassist.IContentAssistSubjectControl;
-
-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 {
-
- private final class ProposalSelectionListener implements 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);
- }
- }
- }
-
- /** 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 ProposalSelectionListener 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 proposals have been filtered */
- private int fFilterOffset;
- /** The default line delimiter of the viewer's widget */
- private String fLineDelimiter;
- /**
- * The most recently selected proposal.
- * @since 3.0
- */
- private ICompletionProposal fLastProposal;
- /**
- * The content assist subject control.
- * This replaces <code>fViewer</code>
- *
- * @since 3.0
- */
- private IContentAssistSubjectControl fContentAssistSubjectControl;
- /**
- * The content assist subject control adapter.
- * This replaces <code>fViewer</code>
- *
- * @since 3.0
- */
- private ContentAssistSubjectControlAdapter fContentAssistSubjectControlAdapter;
- /**
- * Remembers the size for this completion proposal popup.
- * @since 3.0
- */
- private Point fSize;
-
- /**
- * 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 information control collaborating with this popup
- * @since 2.0
- */
- public CompletionProposalPopup(ContentAssistant contentAssistant, ITextViewer viewer, AdditionalInfoController infoController) {
- fContentAssistant= contentAssistant;
- fViewer= viewer;
- fAdditionalInfoController= infoController;
- fContentAssistSubjectControlAdapter= new ContentAssistSubjectControlAdapter(fViewer);
- }
-
- /**
- * Creates a new completion proposal popup for the given elements.
- *
- * @param contentAssistant the content assistant feeding this popup
- * @param contentAssistSubjectControl the content assist subject control on top of which this popup appears
- * @param infoController the information control collaborating with this popup
- * @since 3.0
- */
- public CompletionProposalPopup(ContentAssistant contentAssistant, IContentAssistSubjectControl contentAssistSubjectControl, AdditionalInfoController infoController) {
- fContentAssistant= contentAssistant;
- fContentAssistSubjectControl= contentAssistSubjectControl;
- fAdditionalInfoController= infoController;
- fContentAssistSubjectControlAdapter= new ContentAssistSubjectControlAdapter(fContentAssistSubjectControl);
- }
-
- /**
- * 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 ProposalSelectionListener();
-
- final Control control= fContentAssistSubjectControlAdapter.getControl();
-
- if (!Helper.okToUse(fProposalShell) && control != null && !control.isDisposed()) {
-
- // add the listener before computing the proposals so we don't move the caret
- // when the user types fast.
- fContentAssistSubjectControlAdapter.addKeyListener(fKeyListener);
-
- BusyIndicator.showWhile(control.getDisplay(), new Runnable() {
- public void run() {
-
- fInvocationOffset= fContentAssistSubjectControlAdapter.getSelectedRange().x;
- fFilterOffset= fInvocationOffset;
- fComputedProposals= computeProposals(fInvocationOffset);
-
- int count= (fComputedProposals == null ? 0 : fComputedProposals.length);
- if (count == 0) {
-
- if (!autoActivated)
- control.getDisplay().beep();
-
- hide();
-
- } else {
-
- if (count == 1 && !autoActivated && fContentAssistant.isAutoInserting()) {
-
- insertProposal(fComputedProposals[0], (char) 0, 0, fInvocationOffset);
- hide();
-
- } else {
-
- if (fLineDelimiter == null)
- fLineDelimiter= fContentAssistSubjectControlAdapter.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 (fContentAssistSubjectControl != null)
- return fContentAssistant.computeCompletionProposals(fContentAssistSubjectControl, 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= fContentAssistSubjectControlAdapter.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);
-
-
- Point size= fContentAssistant.restoreCompletionProposalPopupSize();
- if (size != null) {
- fProposalTable.setLayoutData(data);
- fProposalShell.setSize(size);
- } else {
- data.heightHint= fProposalTable.getItemHeight() * 10;
- data.widthHint= 300;
- fProposalTable.setLayoutData(data);
- fProposalShell.pack();
- }
-
- fProposalShell.addControlListener(new ControlListener() {
-
- public void controlMoved(ControlEvent e) {}
-
- public void controlResized(ControlEvent e) {
- if (fAdditionalInfoController != null) {
- // reset the cached resize constraints
- fAdditionalInfoController.setSizeConstraints(50, 10, true, false);
- }
-
- fSize= fProposalShell.getSize();
- }
- });
-
- 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 (fFilteredProposals == null || 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, fContentAssistSubjectControlAdapter.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 stateMask the state mask
- * @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= fContentAssistSubjectControlAdapter.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) {
- fContentAssistSubjectControlAdapter.setSelectedRange(selection.x, selection.y);
- fContentAssistSubjectControlAdapter.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= fContentAssistSubjectControlAdapter.getSelectedRange();
- position= selection.x + selection.y;
- }
-
- fContentAssistant.showContextInformation(info, position);
- } else
- fContentAssistant.showContextInformation(null, -1);
-
-
- } 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;
- }
- }
-
- /**
- * Unregister this completion proposal popup.
- *
- * @since 3.0
- */
- private void unregister() {
- if (fDocumentListener != null) {
- IDocument document= fContentAssistSubjectControlAdapter.getDocument();
- if (document != null)
- document.removeDocumentListener(fDocumentListener);
- fDocumentListener= null;
- }
- fDocumentEvents.clear();
-
- if (fKeyListener != null && fContentAssistSubjectControlAdapter.getControl() != null && !fContentAssistSubjectControlAdapter.getControl().isDisposed()) {
- fContentAssistSubjectControlAdapter.removeKeyListener(fKeyListener);
- fKeyListener= null;
- }
-
- if (fLastProposal != null) {
- if (fLastProposal instanceof ICompletionProposalExtension2 && fViewer != null) {
- ICompletionProposalExtension2 extension= (ICompletionProposalExtension2) fLastProposal;
- extension.unselected(fViewer);
- }
- fLastProposal= null;
- }
-
- fFilteredProposals= null;
- fComputedProposals= null;
-
- fContentAssistant.possibleCompletionsClosed();
- }
-
- /**
- *Returns whether this popup is active. It is active if the proposal 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= fContentAssistSubjectControlAdapter.getCaretOffset();
- Point p= fContentAssistSubjectControlAdapter.getLocationAtOffset(caret);
- if (p.x < 0) p.x= 0;
- if (p.y < 0) p.y= 0;
- p= new Point(p.x, p.y + fContentAssistSubjectControlAdapter.getLineHeight());
- p= fContentAssistSubjectControlAdapter.getControl().toDisplay(p);
- if (p.x < 0) p.x= 0;
- if (p.y < 0) p.y= 0;
- return p;
- }
-
- /**
- * Returns the size of this completion proposal popup.
- *
- * @return a Point containing the size
- * @since 3.0
- */
- Point getSize() {
- return fSize;
- }
-
- /**
- * 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= fContentAssistSubjectControlAdapter.getDocument();
- if (document != null)
- document.addDocumentListener(fDocumentListener);
-
- /* https://bugs.eclipse.org/bugs/show_bug.cgi?id=52646
- * on GTK, setVisible and such may run the event loop
- * (see also https://bugs.eclipse.org/bugs/show_bug.cgi?id=47511)
- * Since the user may have already canceled the popup or selected
- * an entry (ESC or RETURN), we have to double check whether
- * the table is still okToUse. See comments below
- */
- fProposalShell.setVisible(true); // may run event loop on GTK
- // XXX: transfer focus since no verify key listener can be attached
- if (!fContentAssistSubjectControlAdapter.supportsVerifyKeyListener() && Helper.okToUse(fProposalShell))
- fProposalShell.setFocus(); // may run event loop on GTK ??
-
- if (fAdditionalInfoController != null && Helper.okToUse(fProposalTable)) {
- 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, fContentAssistSubjectControlAdapter.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 toggle key has been pressed
- * @since 2.1
- */
- private void selectProposal(int index, boolean smartToggle) {
-
- if (fFilteredProposals == null)
- return;
-
- 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;
- final Control control= fContentAssistSubjectControlAdapter.getControl();
- control.getDisplay().asyncExec(new Runnable() {
- long fCounter= fInvocationCounter;
- public void run() {
-
- if (fCounter != fInvocationCounter)
- return;
-
- if (control.isDisposed())
- return;
-
- int offset= fContentAssistSubjectControlAdapter.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 proposals 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 3.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= fContentAssistSubjectControlAdapter.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();
- }
- }
-
- /**
- * Completes the common prefix of all proposals directly in the code. If no
- * common prefix can be found, the proposal popup is shown.
- *
- * @return an error message if completion failed.
- * @since 3.0
- */
- public String incrementalComplete() {
- if (Helper.okToUse(fProposalShell) && fFilteredProposals != null) {
- completeCommonPrefix();
- } else {
- final Control control= fContentAssistSubjectControlAdapter.getControl();
-
- if (fKeyListener == null)
- fKeyListener= new ProposalSelectionListener();
-
- if (!Helper.okToUse(fProposalShell) && !control.isDisposed())
- fContentAssistSubjectControlAdapter.addKeyListener(fKeyListener);
-
- BusyIndicator.showWhile(control.getDisplay(), new Runnable() {
- public void run() {
-
- fInvocationOffset= fContentAssistSubjectControlAdapter.getSelectedRange().x;
- fFilterOffset= fInvocationOffset;
- fFilteredProposals= computeProposals(fInvocationOffset);
-
- int count= (fFilteredProposals == null ? 0 : fFilteredProposals.length);
- if (count == 0) {
- control.getDisplay().beep();
- hide();
- } else if (count == 1 && fContentAssistant.isAutoInserting()) {
- insertProposal(fFilteredProposals[0], (char) 0, 0, fInvocationOffset);
- hide();
- } else {
- if (fLineDelimiter == null)
- fLineDelimiter= fContentAssistSubjectControlAdapter.getLineDelimiter();
-
- if (completeCommonPrefix())
- hide(); // TODO add some caching? for now: just throw away the completions
- else {
- fComputedProposals= fFilteredProposals;
- createProposalSelector();
- setProposals(fComputedProposals);
- displayProposals();
- }
- }
- }
- });
- }
- return getErrorMessage();
- }
-
- /**
- * Acts upon <code>fFilteredProposals</code>: if there is just one valid
- * proposal, it is inserted, otherwise, the common prefix of all proposals
- * is inserted into the document. If there is no common prefix, <code>false</code>
- * is returned.
- *
- * @return <code>true</code> if common prefix insertion was successful, <code>false</code> otherwise
- * @since 3.0
- */
- private boolean completeCommonPrefix() {
-
- // 0: insert single proposals
- if (fFilteredProposals.length == 1) {
- insertProposal(fFilteredProposals[0], (char) 0, 0, fInvocationOffset);
- hide();
- return true;
- }
-
- // 1: get the common ignore-case prefix of all remaining proposals
- // note that the prefix still
- StringBuffer prefix= null; // the common prefix
- boolean isCaseCompatible= true;
- IDocument document= fContentAssistSubjectControlAdapter.getDocument();
- int startOffset= -1; // the location where the proposals would insert (< fInvocationOffset if invoked in the middle of an indent)
- String currentPrefix= null; // the prefix already in the document
- int currentPrefixLen= -1; // the length of the current prefix
- List caseFiltered= new ArrayList();
-
- for (int i= 0; i < fFilteredProposals.length; i++) {
- ICompletionProposal proposal= fFilteredProposals[i];
- CharSequence insertion= getReplacementString(proposal);
-
- if (currentPrefix == null) {
- startOffset= getReplacementOffset(proposal);
- currentPrefixLen= fFilterOffset - startOffset;
- try {
- // make sure we get the right case
- currentPrefix= document.get(startOffset, currentPrefixLen);
- } catch (BadLocationException e1) {
- // bail out silently
- return false;
- }
- }
-
- // prune ignore-case matches
- if (isCaseSensitive() && !insertion.toString().startsWith(currentPrefix))
- continue;
-
- caseFiltered.add(proposal);
-
- if (prefix == null)
- prefix= new StringBuffer(insertion.toString()); // initial
- else
- isCaseCompatible &= truncatePrefix(prefix, insertion);
-
- // early break computation if there is nothing left to check
- if (prefix.length() == 0)
- break;
- }
-
- if (prefix == null || currentPrefixLen > prefix.length() || prefix.toString().equals(currentPrefix))
- return false;
-
- // 2: replace / insert the common prefix in the document
-
- if (caseFiltered.size() == 1) {
- insertProposal((ICompletionProposal) caseFiltered.get(0), (char) 0, 0, fInvocationOffset);
- hide();
- return true;
- }
-
- try {
- String presentPart= prefix.substring(0, currentPrefixLen);
- int replaceOffset;
- int replaceLen;
- if (isCaseCompatible && !currentPrefix.equals(presentPart)) {
- // update case
- currentPrefixLen= 0;
- replaceOffset= startOffset;
- replaceLen= fFilterOffset - startOffset;
- } else {
- // only insert remaining part
- replaceOffset= fFilterOffset;
- replaceLen= 0;
- }
-
- int remainingLen= prefix.length() - currentPrefixLen;
- String remainingPrefix= prefix.subSequence(currentPrefixLen, currentPrefixLen + remainingLen).toString();
-
- document.replace(replaceOffset, replaceLen, remainingPrefix);
-
- fContentAssistSubjectControlAdapter.setSelectedRange(replaceOffset + remainingLen, 0);
- fContentAssistSubjectControlAdapter.revealRange(replaceOffset + remainingLen, 0);
-
- return true;
- } catch (BadLocationException e) {
- // ignore and return false
- return false;
- }
- }
-
- /**
- * Truncates <code>prefix</code> to the longest prefix it has in common with
- * <code>sequence</code> and returns <code>true</code> if the common prefix
- * has the same case for <code>prefix</code> and <code>sequence</code>.
- *
- * @param prefix the previous prefix that will get truncated to the prefix it has in common with <code>sequence</code>
- * @param sequence the character sequence to match
- * @return <code>true</code> if the match is case compatible, <code>false</code> if the common prefix differs in case
- * @since 3.0
- */
- private boolean truncatePrefix(StringBuffer prefix, CharSequence sequence) {
- // find common prefix
- int min= Math.min(prefix.length(), sequence.length());
- boolean caseCompatible= true;
- for (int c= 0; c < min; c++) {
- char compareChar= sequence.charAt(c);
- char prefixChar= prefix.charAt(c);
- if (prefixChar != compareChar) {
- if (isCaseSensitive() || Character.toLowerCase(prefixChar) != Character.toLowerCase(compareChar)) {
- prefix.delete(c, prefix.length());
- return caseCompatible;
- } else
- caseCompatible= false;
- }
- }
-
- prefix.delete(min, prefix.length());
- return caseCompatible;
- }
-
- /**
- * Returns whether common prefix completion should be case sensitive or not.
- * Returns <code>true</code> if no proposal popup is currently showing, <code>false</code> if there is.
- *
- * @return <code>true</code> if common prefix completion should be case sensitive, <code>false</code> otherwise
- * @since 3.0
- */
- private boolean isCaseSensitive() {
- return !Helper.okToUse(fProposalShell);
- }
-
- /**
- * Extracts the completion offset of an <code>ICompletionProposal</code>. If
- * <code>proposal</code> is a <code>ICompletionProposalExtension3</code>, its
- * <code>getCompletionOffset</code> method is called, otherwise, the invocation
- * offset of this popup is shown.
- *
- * @param proposal the proposal to extract the offset from
- * @return the proposals completion offset, or <code>fInvocationOffset</code>
- * @since 3.0
- */
- private int getReplacementOffset(ICompletionProposal proposal) {
- if (proposal instanceof ICompletionProposalExtension3)
- return ((ICompletionProposalExtension3) proposal).getPrefixCompletionStart(fContentAssistSubjectControlAdapter.getDocument(), fFilterOffset);
- else
- return fInvocationOffset;
- }
-
- /**
- * Extracts the replacement string from an <code>ICompletionProposal</code>.
- * If <code>proposal</code> is a <code>ICompletionProposalExtension3</code>, its
- * <code>getCompletionText</code> method is called, otherwise, the display
- * string is used.
- *
- * @param proposal the proposal to extract the text from
- * @return the proposals completion text
- * @since 3.0
- */
- private CharSequence getReplacementString(ICompletionProposal proposal) {
- CharSequence insertion= null;
- if (proposal instanceof ICompletionProposalExtension3)
- insertion= ((ICompletionProposalExtension3) proposal).getPrefixCompletionText(fContentAssistSubjectControlAdapter.getDocument(), fFilterOffset);
-
- if (insertion == null)
- insertion= proposal.getDisplayString();
-
- return insertion;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistSubjectControlAdapter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistSubjectControlAdapter.java
deleted file mode 100644
index c9e697569..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistSubjectControlAdapter.java
+++ /dev/null
@@ -1,408 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.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.contentassist.*;
-
-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 calls either to
- * a text viewer or to a content assist subject control.
- *
- * @since 3.0
- */
-final class ContentAssistSubjectControlAdapter implements IContentAssistSubjectControl {
-
- /**
- * The text viewer which is used as content assist subject control.
- */
- private ITextViewer fViewer;
-
- /**
- * The content assist subject control.
- */
- private IContentAssistSubjectControl fContentAssistSubjectControl;
-
-
- /**
- * Creates an adapter for the given content assist subject control.
- *
- * @param contentAssistSubjectControl the content assist subject control
- */
- ContentAssistSubjectControlAdapter(IContentAssistSubjectControl contentAssistSubjectControl) {
- Assert.isNotNull(contentAssistSubjectControl);
- fContentAssistSubjectControl= contentAssistSubjectControl;
- }
-
- /**
- * Creates an adapter for the given text viewer.
- *
- * @param viewer the text viewer
- */
- public ContentAssistSubjectControlAdapter(ITextViewer viewer) {
- Assert.isNotNull(viewer);
- fViewer= viewer;
- }
-
- /*
- * @see IContentAssistSubjectControl#getLineHeight()
- */
- public int getLineHeight() {
- if (fContentAssistSubjectControl != null)
- return fContentAssistSubjectControl.getLineHeight();
- else
- return fViewer.getTextWidget().getLineHeight();
- }
-
- /*
- * @see IContentAssistSubjectControl#getControl()
- */
- public Control getControl() {
- if (fContentAssistSubjectControl != null)
- return fContentAssistSubjectControl.getControl();
- else
- return fViewer.getTextWidget();
- }
-
- /*
- * @see IContentAssistSubjectControl#getLocationAtOffset(int)
- */
- public Point getLocationAtOffset(int offset) {
- if (fContentAssistSubjectControl != null)
- return fContentAssistSubjectControl.getLocationAtOffset(offset);
- else
- return fViewer.getTextWidget().getLocationAtOffset(offset);
- }
-
- /*
- * @see IContentAssistSubjectControl#getWidgetSelectionRange()
- */
- public Point getWidgetSelectionRange() {
- if (fContentAssistSubjectControl != null)
- return fContentAssistSubjectControl.getWidgetSelectionRange();
- else
- return fViewer.getTextWidget().getSelectionRange();
- }
-
- /*
- * @see IContentAssistSubjectControl#getSelectedRange()
- */
- public Point getSelectedRange() {
- if (fContentAssistSubjectControl != null)
- return fContentAssistSubjectControl.getSelectedRange();
- else
- return fViewer.getSelectedRange();
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubjectControl#getCaretOffset()
- */
- public int getCaretOffset() {
- if (fContentAssistSubjectControl != null)
- return fContentAssistSubjectControl.getCaretOffset();
- else
- return fViewer.getTextWidget().getCaretOffset();
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubjectControl#getLineDelimiter()
- */
- public String getLineDelimiter() {
- if (fContentAssistSubjectControl != null)
- return fContentAssistSubjectControl.getLineDelimiter();
- else
- return fViewer.getTextWidget().getLineDelimiter();
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubjectControl#addKeyListener(org.eclipse.swt.events.KeyListener)
- */
- public void addKeyListener(KeyListener keyListener) {
- if (fContentAssistSubjectControl != null)
- fContentAssistSubjectControl.addKeyListener(keyListener);
- else
- fViewer.getTextWidget().addKeyListener(keyListener);
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubjectControl#removeKeyListener(org.eclipse.swt.events.KeyListener)
- */
- public void removeKeyListener(KeyListener keyListener) {
- if (fContentAssistSubjectControl != null)
- fContentAssistSubjectControl.removeKeyListener(keyListener);
- else
- fViewer.getTextWidget().removeKeyListener(keyListener);
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubjectControl#getDocument()
- */
- public IDocument getDocument() {
- if (fContentAssistSubjectControl != null)
- return fContentAssistSubjectControl.getDocument();
- else
- return fViewer.getDocument();
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubjectControl#prependVerifyKeyListener(VerifyKeyListener)
- */
- public boolean prependVerifyKeyListener(VerifyKeyListener verifyKeyListener) {
- if (fContentAssistSubjectControl != null) {
- return fContentAssistSubjectControl.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.IContentAssistSubjectControl#appendVerifyKeyListener(org.eclipse.swt.custom.VerifyKeyListener)
- */
- public boolean appendVerifyKeyListener(VerifyKeyListener verifyKeyListener) {
- if (fContentAssistSubjectControl != null)
- return fContentAssistSubjectControl.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.IContentAssistSubjectControl#removeVerifyKeyListener(org.eclipse.swt.custom.VerifyKeyListener)
- */
- public void removeVerifyKeyListener(VerifyKeyListener verifyKeyListener) {
- if (fContentAssistSubjectControl != null) {
- fContentAssistSubjectControl.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.IContentAssistSubjectControl#setEventConsumer(org.eclipse.jface.text.contentassist.ContentAssistant.InternalListener)
- */
- public void setEventConsumer(IEventConsumer eventConsumer) {
- if (fContentAssistSubjectControl != null)
- fContentAssistSubjectControl.setEventConsumer(eventConsumer);
- else
- fViewer.setEventConsumer(eventConsumer);
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubjectControl#setSelectedRange(int, int)
- */
- public void setSelectedRange(int i, int j) {
- if (fContentAssistSubjectControl != null)
- fContentAssistSubjectControl.setSelectedRange(i, j);
- else
- fViewer.setSelectedRange(i, j);
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubjectControl#revealRange(int, int)
- */
- public void revealRange(int i, int j) {
- if (fContentAssistSubjectControl != null)
- fContentAssistSubjectControl.revealRange(i, j);
- else
- fViewer.revealRange(i, j);
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubjectControl#canAddVerifyKeyListener()
- */
- public boolean supportsVerifyKeyListener() {
- if (fContentAssistSubjectControl != null)
- return fContentAssistSubjectControl.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 (fContentAssistSubjectControl != null)
- return contentAssistant.getCompletionProposalAutoActivationCharacters(fContentAssistSubjectControl, 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 (fContentAssistSubjectControl != null)
- return contentAssistant.getContextInformationAutoActivationCharacters(fContentAssistSubjectControl, 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 (fContentAssistSubjectControl != null)
- return new CompletionProposalPopup(contentAssistant, fContentAssistSubjectControl, 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 (fContentAssistSubjectControl != null)
- return new ContextInformationPopup(contentAssistant, fContentAssistSubjectControl);
- else
- return new ContextInformationPopup(contentAssistant, fViewer);
-
- }
-
- /**
- * @param contentAssistant
- * @param offset
- * @return
- */
- public IContextInformationValidator getContextInformationValidator(ContentAssistant contentAssistant, int offset) {
- if (fContentAssistSubjectControl != null)
- return contentAssistant.getContextInformationValidator(fContentAssistSubjectControl, offset);
- else
- return contentAssistant.getContextInformationValidator(fViewer, offset);
- }
-
- /**
- * @param contentAssistant
- * @param offset
- * @return
- */
- public IContextInformationPresenter getContextInformationPresenter(ContentAssistant contentAssistant, int offset) {
- if (fContentAssistSubjectControl != null)
- return contentAssistant.getContextInformationPresenter(fContentAssistSubjectControl, offset);
- else
- return contentAssistant.getContextInformationPresenter(fViewer, offset);
- }
-
- /**
- * @param frame
- */
- public void installValidator(ContextFrame frame) {
- if (fContentAssistSubjectControl != null) {
- if (frame.fValidator instanceof ISubjectControlContextInformationValidator)
- ((ISubjectControlContextInformationValidator)frame.fValidator).install(frame.fInformation, fContentAssistSubjectControl, frame.fOffset);
- } else
- frame.fValidator.install(frame.fInformation, fViewer, frame.fOffset);
- }
-
- /**
- * @param frame
- */
- public void installContextInformationPresenter(ContextFrame frame) {
- if (fContentAssistSubjectControl != null) {
- if (frame.fPresenter instanceof ISubjectControlContextInformationPresenter)
- ((ISubjectControlContextInformationPresenter)frame.fValidator).install(frame.fInformation, fContentAssistSubjectControl, frame.fBeginOffset);
- } else
- frame.fPresenter.install(frame.fInformation, fViewer, frame.fBeginOffset);
- }
-
- /**
- * @param contentAssistant
- * @param position
- * @return
- */
- public IContextInformation[] computeContextInformation(ContentAssistant contentAssistant, int position) {
- if (fContentAssistSubjectControl != null)
- return contentAssistant.computeContextInformation(fContentAssistSubjectControl, position);
- else
- return contentAssistant.computeContextInformation(fViewer, position);
- }
-
- /*
- * @see IContentAssistSubjectControl#addSelectionListener(SelectionListener)
- */
- public boolean addSelectionListener(SelectionListener selectionListener) {
- if (fContentAssistSubjectControl != null)
- return fContentAssistSubjectControl.addSelectionListener(selectionListener);
- else {
- fViewer.getTextWidget().addSelectionListener(selectionListener);
- return true;
- }
- }
-
- /*
- * @see IContentAssistSubjectControl#removeSelectionListener(SelectionListener)
- */
- public void removeSelectionListener(SelectionListener selectionListener) {
- if (fContentAssistSubjectControl != null)
- fContentAssistSubjectControl.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 84348334e..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java
+++ /dev/null
@@ -1,1803 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.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.contentassist.*;
-import org.eclipse.jface.dialogs.IDialogSettings;
-
-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 {
-
- /** The shell that a <code>ControlListener</code> is registered with. */
- private Control fShell;
- /** The control that a <code>MouseListener</code>, a<code>FocusListener</code> and a <code>DisposeListener</code> are registered with. */
- private Control fControl;
-
- /**
- * Installs this closer on it's viewer's text widget.
- */
- protected void install() {
- Control control= fContentAssistSubjectControlAdapter.getControl();
- fControl= control;
- if (Helper.okToUse(control)) {
-
- Control shell= control.getShell();
- fShell= shell;
- 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 shell= fShell;
- fShell= null;
- if (Helper.okToUse(shell))
- shell.removeControlListener(this);
-
- Control control= fControl;
- fControl= null;
- if (Helper.okToUse(control)) {
-
- 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= fControl;
- if (Helper.okToUse(control)) {
- Display d= control.getDisplay();
- if (d != null) {
- d.asyncExec(new Runnable() {
- public void run() {
- if (!fProposalPopup.hasFocus() && (fContextInfoPopup == null || !fContextInfoPopup.has