Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jface.text/src')
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/contentassist/AbstractControlContentAssistSubjectAdapter.java823
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ComboContentAssistSubjectAdapter.java211
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/contentassist/IContentAssistSubjectControl.java297
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ISubjectControlContentAssistProcessor.java53
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ISubjectControlContentAssistant.java31
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ISubjectControlContextInformationPresenter.java34
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ISubjectControlContextInformationValidator.java35
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/contentassist/SubjectControlContentAssistant.java32
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/contentassist/SubjectControlContextInformationValidator.java78
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/contentassist/TextContentAssistSubjectAdapter.java192
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/contentassist/images/content_assist_cue.gifbin106 -> 0 bytes
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/contentassist/package.html25
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/AdditionalInfoController2.java255
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/CompletionProposalPopup2.java871
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistMessages.java82
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistMessages.properties19
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java1587
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContextInformationPopup2.java629
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/HTML2TextReader.java302
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/HTMLTextPresenter.java191
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/Helper2.java32
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/IContentAssistListener2.java35
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/IProposalListener.java26
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/LineBreakingReader.java114
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/PopupCloser2.java100
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/SingleCharReader.java61
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/SubstitutionTextReader.java151
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/package.html14
-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
240 files changed, 0 insertions, 49763 deletions
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/AbstractControlContentAssistSubjectAdapter.java b/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/AbstractControlContentAssistSubjectAdapter.java
deleted file mode 100644
index 7ba696481..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/AbstractControlContentAssistSubjectAdapter.java
+++ /dev/null
@@ -1,823 +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.contentassist;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.runtime.Platform;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.VerifyKeyListener;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseTrackAdapter;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.events.VerifyEvent;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.graphics.Region;
-import org.eclipse.swt.widgets.Combo;
-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.Text;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.viewers.ILabelProvider;
-
-import org.eclipse.jface.text.IEventConsumer;
-
-
-/**
- * An <code>AbstractControlContentAssistSubjectAdapter</code> delegates assistance requests from a
- * {@linkplain org.eclipse.jface.text.contentassist.ContentAssistant content assistant}
- * to a <code>Control</code>.
- *
- * A visual affordance can be configured via {@link #setContentAssistCueProvider(ILabelProvider)}.
- *
- * @since 3.0
- */
-public abstract class AbstractControlContentAssistSubjectAdapter implements IContentAssistSubjectControl {
-
- protected static final boolean DEBUG= "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.jface.text/debug/ContentAssistSubjectAdapters")); //$NON-NLS-1$//$NON-NLS-2$
-
- /**
- * VerifyKeyListeners for the control.
- */
- private List fVerifyKeyListeners;
- /**
- * KeyListeners for the control.
- */
- private Set fKeyListeners;
- /**
- * The Listener installed on the control which passes events to
- * {@link #fVerifyKeyListeners fVerifyKeyListeners} and {@link #fKeyListeners fKeyListeners}.
- */
- private Listener fControlListener;
-
- /**
- * Creates a new {@link AbstractControlContentAssistSubjectAdapter}.
- **/
- public AbstractControlContentAssistSubjectAdapter() {
- fVerifyKeyListeners= new ArrayList(1);
- fKeyListeners= new HashSet(1);
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubjectControl#getControl()
- */
- public abstract Control getControl();
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubjectControl#addKeyListener(org.eclipse.swt.events.KeyListener)
- */
- public void addKeyListener(KeyListener keyListener) {
- fKeyListeners.add(keyListener);
-
- if (DEBUG)
- System.out.println("AbstractControlContentAssistSubjectAdapter#addKeyListener()"); //$NON-NLS-1$
-
- installControlListener();
- }
-
- /**
- * {@inheritDoc}
- */
- public void removeKeyListener(KeyListener keyListener) {
- boolean deleted= fKeyListeners.remove(keyListener);
-
- if (DEBUG) {
- if (!deleted)
- System.out.println("removeKeyListener -> wasn't here"); //$NON-NLS-1$
- System.out.println("AbstractControlContentAssistSubjectAdapter#removeKeyListener() -> " + fKeyListeners.size()); //$NON-NLS-1$
- }
-
- uninstallControlListener();
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean supportsVerifyKeyListener() {
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean appendVerifyKeyListener(final VerifyKeyListener verifyKeyListener) {
- fVerifyKeyListeners.add(verifyKeyListener);
-
- if (DEBUG)
- System.out.println("AbstractControlContentAssistSubjectAdapter#appendVerifyKeyListener() -> " + fVerifyKeyListeners.size()); //$NON-NLS-1$
-
- installControlListener();
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean prependVerifyKeyListener(final VerifyKeyListener verifyKeyListener) {
- fVerifyKeyListeners.add(0, verifyKeyListener);
-
- if (DEBUG)
- System.out.println("AbstractControlContentAssistSubjectAdapter#prependVerifyKeyListener() -> " + fVerifyKeyListeners.size()); //$NON-NLS-1$
-
- installControlListener();
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- public void removeVerifyKeyListener(VerifyKeyListener verifyKeyListener) {
- fVerifyKeyListeners.remove(verifyKeyListener);
-
- if (DEBUG)
- System.out.println("AbstractControlContentAssistSubjectAdapter#removeVerifyKeyListener() -> " + fVerifyKeyListeners.size()); //$NON-NLS-1$
-
- uninstallControlListener();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setEventConsumer(IEventConsumer eventConsumer) {
- // this is not supported
- if (DEBUG)
- System.out.println("AbstractControlContentAssistSubjectAdapter#setEventConsumer()"); //$NON-NLS-1$
- }
-
- /**
- * {@inheritDoc}
- */
- public String getLineDelimiter() {
- return System.getProperty("line.separator"); //$NON-NLS-1$
- }
-
- /**
- * Installs <code>fControlListener</code>, which handles VerifyEvents and KeyEvents by
- * passing them to <code>fVerifyKeyListeners</code> and <code>fKeyListeners</code>.
- */
- private void installControlListener() {
- if (DEBUG)
- System.out.println("AbstractControlContentAssistSubjectAdapter#installControlListener() -> k: " + fKeyListeners.size() + ", v: " + fVerifyKeyListeners.size()); //$NON-NLS-1$ //$NON-NLS-2$
-
- if (fControlListener != null)
- return;
-
- fControlListener= new Listener() {
- public void handleEvent(Event e) {
- if (! getControl().isFocusControl())
- return; //SWT.TRAVERSE_MNEMONIC events can also come in to inactive widgets
- VerifyEvent verifyEvent= new VerifyEvent(e);
- KeyEvent keyEvent= new KeyEvent(e);
- switch (e.type) {
- case SWT.Traverse :
-
- if (DEBUG)
- dump("before traverse", e, verifyEvent); //$NON-NLS-1$
-
- verifyEvent.doit= true;
- for (Iterator iter= fVerifyKeyListeners.iterator(); iter.hasNext(); ) {
- ((VerifyKeyListener) iter.next()).verifyKey(verifyEvent);
- if (! verifyEvent.doit) {
- e.detail= SWT.TRAVERSE_NONE;
- e.doit= true;
- if (DEBUG)
- dump("traverse eaten by verify", e, verifyEvent); //$NON-NLS-1$
- return;
- }
-
- if (DEBUG)
- dump("traverse ok", e, verifyEvent); //$NON-NLS-1$
- }
- break;
-
- case SWT.KeyDown:
- for (Iterator iter= fVerifyKeyListeners.iterator(); iter.hasNext(); ) {
- ((VerifyKeyListener) iter.next()).verifyKey(verifyEvent);
- if (! verifyEvent.doit) {
- e.doit= verifyEvent.doit;
- if (DEBUG)
- dump("keyDown eaten by verify", e, verifyEvent); //$NON-NLS-1$
- return;
- }
- }
-
- if (DEBUG)
- dump("keyDown ok", e, verifyEvent); //$NON-NLS-1$
-
- for (Iterator iter= fKeyListeners.iterator(); iter.hasNext();) {
- ((KeyListener) iter.next()).keyPressed(keyEvent);
- }
- break;
-
- default :
- Assert.isTrue(false);
- }
- }
-
- /**
- * Dump the given events to "standard" output.
- *
- * @param who who dump's
- * @param e the event
- * @param ve the verify event
- */
- private void dump(String who, Event e, VerifyEvent ve) {
- StringBuffer sb= new StringBuffer("--- [AbstractControlContentAssistSubjectAdapter]\n"); //$NON-NLS-1$
- sb.append(who);
- sb.append(" - e: keyCode="+e.keyCode+hex(e.keyCode)); //$NON-NLS-1$
- sb.append("; character="+e.character+hex(e.character)); //$NON-NLS-1$
- sb.append("; stateMask="+e.stateMask+hex(e.stateMask)); //$NON-NLS-1$
- sb.append("; doit="+e.doit); //$NON-NLS-1$
- sb.append("; detail="+e.detail+hex(e.detail)); //$NON-NLS-1$
- sb.append("; widget="+e.widget); //$NON-NLS-1$
- sb.append("\n"); //$NON-NLS-1$
- sb.append(" verifyEvent keyCode="+e.keyCode+hex(e.keyCode)); //$NON-NLS-1$
- sb.append("; character="+e.character+hex(e.character)); //$NON-NLS-1$
- sb.append("; stateMask="+e.stateMask+hex(e.stateMask)); //$NON-NLS-1$
- sb.append("; doit="+ve.doit); //$NON-NLS-1$
- sb.append("; widget="+e.widget); //$NON-NLS-1$
- System.out.println(sb);
- }
-
- private String hex(int i) {
- return "[0x" + Integer.toHexString(i) + ']'; //$NON-NLS-1$
- }
- };
- getControl().addListener(SWT.Traverse, fControlListener);
- getControl().addListener(SWT.KeyDown, fControlListener);
-
- if (DEBUG)
- System.out.println("AbstractControlContentAssistSubjectAdapter#installControlListener() - installed"); //$NON-NLS-1$
- }
-
- /**
- * Uninstalls <code>fControlListener</code> iff there are no <code>KeyListener</code>s and no
- * <code>VerifyKeyListener</code>s registered.
- * Otherwise does nothing.
- */
- private void uninstallControlListener() {
- if (fControlListener == null || fKeyListeners.size() + fVerifyKeyListeners.size() != 0) {
-
- if (DEBUG)
- System.out.println("AbstractControlContentAssistSubjectAdapter#uninstallControlListener() -> k: " + fKeyListeners.size() + ", v: " + fVerifyKeyListeners.size()); //$NON-NLS-1$ //$NON-NLS-2$
-
- return;
- }
- getControl().removeListener(SWT.Traverse, fControlListener);
- getControl().removeListener(SWT.KeyDown, fControlListener);
- fControlListener= null;
-
- if (DEBUG)
- System.out.println("AbstractControlContentAssistSubjectAdapter#uninstallControlListener() - done"); //$NON-NLS-1$
- }
-
- /**
- * Sets the visual affordance provider for content assist.
- * The given {@link ILabelProvider} methods are called with
- * {@link #getControl()} as argument.
- *
- * <ul>
- * <li><code>getImage(Object)</code> provides the visual cue image.
- * The image can maximally be 5 pixels wide and 8 pixels high.
- * If <code>getImage(Object)</code> returns <code>null</code>, a default image is used.
- * </li>
- * <li><code>getText(Object)</code> provides the hover info text.
- * It is shown when hovering over the cue image or the adapted {@link Control}.
- * No info text is shown if <code>getText(Object)</code> returns <code>null</code>.
- * </li>
- * </ul>
- * <p>
- * The given {@link ILabelProvider} becomes owned by the {@link AbstractControlContentAssistSubjectAdapter},
- * i.e. it gets disposed when the adapted {@link Control} is disposed
- * or when another {@link ILabelProvider} is set.
- * </p>
- *
- * @param labelProvider a {@link ILabelProvider}, or <code>null</code>
- * if the affordance should not be shown
- */
- public void setContentAssistCueProvider(ILabelProvider labelProvider) {
- SmartFieldController.setSmartCue(getControl(), labelProvider);
- }
-
- /**
- * The internal controller for cues and error messages on <code>Text</code> and
- * <code>Combo</code> <code>Control</code>s.
- */
- private static class SmartFieldController {
-
- /**
- * An info Hover to display a message next to a {@link Control}.
- */
- class Hover {
- /**
- * Distance of info hover arrow from left side.
- */
- private int HD= 10;
- /**
- * Width of info hover arrow.
- */
- private int HW= 8;
- /**
- * Height of info hover arrow.
- */
- private int HH= 10;
- /**
- * Margin around info hover text.
- */
- private int LABEL_MARGIN= 2;
- /**
- * This info hover's shell.
- */
- Shell fHoverShell;
- /**
- * The info hover text.
- */
- String fText= ""; //$NON-NLS-1$
-
- Hover(Shell parent) {
- final Display display= parent.getDisplay();
- fHoverShell= new Shell(parent, SWT.NO_TRIM | SWT.ON_TOP | SWT.NO_FOCUS);
- fHoverShell.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
- fHoverShell.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
- fHoverShell.addPaintListener(new PaintListener() {
- public void paintControl(PaintEvent pe) {
- pe.gc.drawString(fText, LABEL_MARGIN, LABEL_MARGIN);
- if (!fgCarbon)
- pe.gc.drawPolygon(getPolygon(true));
- }
- });
- fHoverShell.addMouseListener(new MouseAdapter() {
- public void mouseDown(MouseEvent e) {
- showHover(null, null);
- }
- });
- }
-
- int[] getPolygon(boolean border) {
- Point e= getExtent();
- if (border) {
- return new int[] { 0,0, e.x-1,0, e.x-1,e.y-1, HD+HW,e.y-1, HD+HW/2,e.y+HH-1, HD,e.y-1, 0,e.y-1, 0,0 };
- } else {
- return new int[] { 0,0, e.x, 0, e.x, e.y, HD+HW,e.y, HD+HW/2,e.y+HH, HD,e.y, 0,e.y, 0,0 };
- }
- }
-
- void dispose() {
- if (!fHoverShell.isDisposed())
- fHoverShell.dispose();
- }
-
- void setVisible(boolean visible) {
- if (visible) {
- if (!fHoverShell.isVisible())
- fHoverShell.setVisible(true);
- } else {
- if (fHoverShell.isVisible())
- fHoverShell.setVisible(false);
- }
- }
-
- void setText(String t) {
- if (t == null)
- t= ""; //$NON-NLS-1$
- if (! t.equals(fText)) {
- Point oldSize= getExtent();
- fText= t;
- fHoverShell.redraw();
- Point newSize= getExtent();
- if (!oldSize.equals(newSize)) {
- Region region= new Region();
- region.add(getPolygon(false));
- fHoverShell.setRegion(region);
- }
- }
- }
-
- boolean isVisible() {
- return fHoverShell.isVisible();
- }
-
- void setLocation(Control control) {
- if (control != null) {
- int h= getExtent().y;
- fHoverShell.setLocation(control.toDisplay(-HD+HW/2, -h-HH+1));
- }
- }
-
- Point getExtent() {
- GC gc= new GC(fHoverShell);
- Point e= gc.textExtent(fText);
- gc.dispose();
- e.x+= LABEL_MARGIN*2;
- e.y+= LABEL_MARGIN*2;
- return e;
- }
- }
-
- /**
- * A single plain HoverHandler is registered for the content assist control.
- * It handles mouse hover events to show/hide the info hover.
- */
- class HoverHandler extends MouseTrackAdapter {
- /**
- * The managing FieldFocusListener.
- */
- FieldFocusListener fFieldFocusListener;
- /**
- * Create a new HoverHandler.
- *
- * @param fieldFocusListener the field focus listener
- */
- HoverHandler(FieldFocusListener fieldFocusListener) {
- fFieldFocusListener= fieldFocusListener;
- }
- /**
- * @inheritDoc
- */
- public void mouseHover(MouseEvent e) {
- handleMouseEvent(e);
- }
- /**
- * @inheritDoc
- */
- public void mouseExit(MouseEvent e) {
- if (isHoverVisible())
- fFieldFocusListener.doHideHover();
- }
- /**
- * Subclasses may extend or reimplement this method.
- * @param e
- */
- void handleMouseEvent(MouseEvent e) {
- fFieldFocusListener.doShowHover();
- }
- }
-
- /**
- * One CueHandler is registered per ancestor control of the content assist control.
- * It paints the visual cue icon and handles mouse hover events to show/hide the info hover.
- */
- class CueHandler extends HoverHandler implements PaintListener {
- /**
- * Create a new CueHandler.
- *
- * @param fieldFocusListener the field focus listener
- */
- CueHandler(FieldFocusListener fieldFocusListener) {
- super(fieldFocusListener);
- }
- /**
- * @inheritDoc
- */
- public void paintControl(PaintEvent e) {
- fFieldFocusListener.paintControl(e);
- }
- /**
- * Updates the hover.
- *
- * @param event the mouse event
- */
- void handleMouseEvent(MouseEvent event) {
- fFieldFocusListener.updateHoverOnCue(event);
- }
- }
-
- class FieldFocusListener implements FocusListener {
- /**
- * Put icon relative to this control.
- */
- private Control fControl;
- /**
- * The icon's horizontal screen distance from top-left corner of control (in pixels).
- */
- private int fDx;
- /**
- * The icon's vertical screen distance from top-left corner of control (in pixels).
- */
- private int fDy;
- /**
- * The HoverHandler (only when control has focus).
- */
- private HoverHandler fHoverHandler;
-
- /**
- * Create a new FieldFocusListener
- * @param control the target control
- */
- FieldFocusListener(Control control) {
- fControl= control;
-
- fDx= -5;
- fDy= 1;
- if (fgCarbon) {
- if (control instanceof Text) {
- fDy+= 3;
- } else if (control instanceof Combo) {
- fDx-= 4;
- }
- } else if (fgWin32) {
- if (control instanceof Text) {
- fDx-= 2;
- fDy-= 2;
- }
- }
- }
-
- /**
- * Paint the cue image.
- * @param e the PaintEvent
- */
- void paintControl(PaintEvent e) {
- if (fControl.isDisposed())
- return;
- Image image= getCueImage(fControl);
- Point global= fControl.toDisplay(fDx, fDy);
- Point local= ((Control) e.widget).toControl(global);
- e.gc.drawImage(image, local.x, local.y);
- }
-
- /**
- * Show/hide the hover.
- * @param e the MouseEvent
- */
- void updateHoverOnCue(MouseEvent e) {
- Image image= getCueImage(fControl);
- Rectangle r= image.getBounds();
- Point global= fControl.toDisplay(fDx, fDy);
- Point local= ((Control) e.widget).toControl(global);
- r.x= local.x;
- r.y= local.y;
- if (r.contains(e.x, e.y))
- doShowHover();
- else
- doHideHover();
- }
-
- /**
- * Hide hover.
- */
- private void doHideHover() {
- showHover(fControl, null);
- }
-
- /**
- * Show hover.
- */
- public void doShowHover() {
- showHover(fControl, fLabelProvider.getText(fControl));
- }
-
- /*
- * @see org.eclipse.swt.events.FocusListener#focusGained(org.eclipse.swt.events.FocusEvent)
- */
- public void focusGained(FocusEvent e) {
- // install a CueHandler on every parent control
- if (DEBUG)
- System.out.println("Focus Gained: " + e.widget); //$NON-NLS-1$
-
- if (fHoverHandler == null) {
- fHoverHandler= new HoverHandler(this);
- fControl.addMouseTrackListener(fHoverHandler);
- }
-
- Control c= fControl.getParent();
- while (c != null) {
- if (DEBUG)
- System.out.println("install CueHandler: " + c.toString()); //$NON-NLS-1$
- CueHandler cueHandler= new CueHandler(this);
- Assert.isTrue(c.getData(ANNOTATION_HANDLER) == null, "parent control has CueHandler: " + c.toString()); //$NON-NLS-1$
- c.setData(ANNOTATION_HANDLER, cueHandler);
- c.addPaintListener(cueHandler);
- c.addMouseTrackListener(cueHandler);
- c.redraw();
- if (c instanceof Shell)
- break;
- else
- c= c.getParent();
- }
- }
-
- /*
- * @see org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt.events.FocusEvent)
- */
- public void focusLost(FocusEvent e) {
- if (DEBUG) {
- System.out.println("Focus Lost: " + e.widget + ", at:"); //$NON-NLS-1$ //$NON-NLS-2$
- Thread.dumpStack();
- }
-
- if (fHoverHandler != null)
- fControl.removeMouseTrackListener(fHoverHandler);
-
- Control c= fControl.getParent();
- while (c != null) {
- if (DEBUG)
- System.out.println("uninstall CueHandler: " + c.toString()); //$NON-NLS-1$
- CueHandler cueHandler= (CueHandler) c.getData(ANNOTATION_HANDLER);
- //workaround for bug 64052:
- if (cueHandler != null) {
- c.setData(ANNOTATION_HANDLER, null);
- c.removePaintListener(cueHandler);
- c.removeMouseTrackListener(cueHandler);
- c.redraw();
- }
- if (c instanceof Shell)
- break;
- else
- c= c.getParent();
- }
- }
- }
-
- private static final String SMART_FIELD_CONTROLLER= "org.eclipse.SmartFieldController"; //$NON-NLS-1$
- private static final String SMART_FOCUS_LISTENER= "org.eclipse.SmartFieldController.smartFocusListener"; //$NON-NLS-1$
- private static final String ANNOTATION_HANDLER= "org.eclipse.SmartFieldController.annotationHandler"; //$NON-NLS-1$
-
- private static String fgPlatform= SWT.getPlatform();
- private static boolean fgCarbon= "carbon".equals(fgPlatform); //$NON-NLS-1$
- private static boolean fgWin32= "win32".equals(fgPlatform); //$NON-NLS-1$
-
- private Shell fShell;
- private ILabelProvider fLabelProvider;
- private Image fCueImage;
- private Hover fHover;
- private Control fHoverControl;
-
- /**
- * Installs or deinstalls a visual cue indicating availability of content assist on the given control.
- * At most one cue and one hover info is shown at any point in time.
- *
- * @param control the control on which to install or uninstall the cue
- * @param labelProvider the label provider or <code>null</code> to uninstall the cue
- */
- public static void setSmartCue(Control control, ILabelProvider labelProvider) {
- getSmartFieldController(control).internalSetSmartCue(control, labelProvider);
- }
-
- //---- private implementation
-
- private SmartFieldController(Shell shell) {
- fShell= shell;
- fShell.setData(SMART_FIELD_CONTROLLER, this);
-
- Listener l= new Listener() {
- public void handleEvent(Event event) {
- switch (event.type) {
- case SWT.Resize:
- case SWT.Move:
- if (fHover != null)
- fHover.setLocation(fHoverControl);
- break;
- case SWT.Dispose:
- Object data= fShell.getData(SMART_FIELD_CONTROLLER);
- if (data == SmartFieldController.this) {
- fShell.setData(SMART_FIELD_CONTROLLER, null);
- handleDispose();
- }
- break;
- //case SWT.Activate:
- case SWT.Deactivate:
- case SWT.Close:
- case SWT.Iconify:
- //case SWT.Deiconify:
- showHover(null, null);
- break;
- }
- }
- };
- shell.addListener(SWT.Dispose, l);
- shell.addListener(SWT.Resize, l);
- shell.addListener(SWT.Move, l);
- //shell.addListener(SWT.Activate, l);
- shell.addListener(SWT.Close, l);
- shell.addListener(SWT.Deactivate, l);
- shell.addListener(SWT.Iconify, l);
- //shell.addListener(SWT.Deiconify, l);
- }
-
- private void handleDispose() {
- fShell= null;
- fHoverControl= null;
- if (fHover != null) {
- fHover.dispose();
- fHover= null;
- }
- if (fCueImage != null) {
- fCueImage.dispose();
- fCueImage= null;
- }
- if (fLabelProvider != null) {
- fLabelProvider.dispose();
- fLabelProvider= null;
- }
- }
- /**
- * Gets the smart field controller from the <code>control</code>'s Shell.
- * @param control that target control
- * @return <code>control</code>'s shell
- */
- private static SmartFieldController getSmartFieldController(Control control) {
- Shell shell= control.getShell();
- Object data= shell.getData(SMART_FIELD_CONTROLLER);
- if (! (data instanceof SmartFieldController))
- data= new SmartFieldController(shell);
- return (SmartFieldController) data;
- }
-
- private void internalSetSmartCue(final Control control, ILabelProvider labelProvider) {
- if (fLabelProvider != null)
- fLabelProvider.dispose();
-
- fLabelProvider= labelProvider;
-
- FieldFocusListener focuslistener= (FieldFocusListener) control.getData(SMART_FOCUS_LISTENER);
-
- if (labelProvider != null) {
- // add smart stuff
- if (focuslistener == null) {
- focuslistener= new FieldFocusListener(control);
- control.setData(SMART_FOCUS_LISTENER, focuslistener);
- control.addFocusListener(focuslistener);
- }
- } else {
- // remove smart stuff
- if (focuslistener != null) {
- control.removeFocusListener(focuslistener);
- control.setData(SMART_FOCUS_LISTENER, null);
- }
-
- if (fCueImage != null) {
- fCueImage.dispose();
- fCueImage= null;
- }
- }
- }
- /**
- * Show or hide hover.
- * @param control target control
- * @param text a String to show in hover, or <code>null</code> to hide
- */
- private void showHover(Control control, String text) {
- if (text != null) {
- fHoverControl= control;
- if (fHover == null)
- fHover= new Hover(fShell);
- fHover.setText(text);
- fHover.setLocation(fHoverControl);
- fHover.setVisible(true);
- } else {
- fHoverControl= null;
- if (fHover != null)
- fHover.setVisible(false);
- }
- }
-
- private boolean isHoverVisible() {
- return fHover != null && fHover.isVisible();
- }
-
- private Image getCueImage(Control control) {
- Image image= null;
- if (fLabelProvider != null)
- image= fLabelProvider.getImage(control);
-
- return image != null ? image : getCueImage();
- }
-
- private Image getCueImage() {
- if (fCueImage == null) {
- ImageDescriptor cueID= ImageDescriptor.createFromFile(SmartFieldController.class, "images/content_assist_cue.gif"); //$NON-NLS-1$
- fCueImage= cueID.createImage(fShell.getDisplay());
- }
- return fCueImage;
- }
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ComboContentAssistSubjectAdapter.java b/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ComboContentAssistSubjectAdapter.java
deleted file mode 100644
index d45967fc8..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ComboContentAssistSubjectAdapter.java
+++ /dev/null
@@ -1,211 +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.contentassist;
-
-import java.util.HashMap;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-
-import org.eclipse.jface.util.Assert;
-
-/**
- * Adapts a <code>Combo</code> to an <code>IContentAssistSubjectControl</code>.
- * <p>
- * Known issues:
- * <ul>
- * <li>https://bugs.eclipse.org/bugs/show_bug.cgi?id=50121
- * => Combo doesn't get Arrow_up/Down keys on GTK</li>
- *
- * <li>https://bugs.eclipse.org/bugs/show_bug.cgi?id=50123
- * => Combo broken on MacOS X</li>
- * </ul>
- * </p>
- *
- * @see org.eclipse.swt.widgets.Combo
- * @see org.eclipse.jface.contentassist.IContentAssistSubjectControl
- * @since 3.0
- */
-public class ComboContentAssistSubjectAdapter extends AbstractControlContentAssistSubjectAdapter {
-
- /**
- * The <code>Document</code> of <code>fCombo</code>'s contents.
- */
- private class InternalDocument extends Document {
- /**
- * Updates this <code>Document</code> with changes in <code>fCombo</code>.
- */
- private ModifyListener fModifyListener;
-
- private InternalDocument() {
- super(fCombo.getText());
- fModifyListener= new ModifyListener() {
- /*
- * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
- */
- public void modifyText(ModifyEvent e) {
- set(fCombo.getText());
- }
- };
- fCombo.addModifyListener(fModifyListener);
- }
-
- /*
- * @see org.eclipse.jface.text.AbstractDocument#replace(int, int, java.lang.String)
- */
- public void replace(int pos, int length, String text) throws BadLocationException {
- super.replace(pos, length, text);
- fCombo.removeModifyListener(fModifyListener);
- fCombo.setText(get());
- fCombo.addModifyListener(fModifyListener);
- }
- }
-
- /**
- * The combo.
- */
- private Combo fCombo;
- private HashMap fModifyListeners;
-
- /**
- * Creates a content assist subject control adapter for the given combo.
- *
- * @param combo the combo to adapt
- */
- public ComboContentAssistSubjectAdapter(Combo combo) {
- Assert.isNotNull(combo);
- fCombo= combo;
- fModifyListeners= new HashMap();
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubjectControl#getControl()
- */
- public Control getControl() {
- return fCombo;
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubjectControl#getLineHeight()
- */
- public int getLineHeight() {
- return fCombo.getTextHeight();
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubjectControl#getCaretOffset()
- */
- public int getCaretOffset() {
- return fCombo.getSelection().y;
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubjectControl#getLocationAtOffset(int)
- */
- public Point getLocationAtOffset(int offset) {
- String comboString= fCombo.getText();
- GC gc = new GC(fCombo);
- gc.setFont(fCombo.getFont());
- Point extent= gc.textExtent(comboString.substring(0, Math.min(offset, comboString.length())));
- int spaceWidth= gc.textExtent(" ").x; //$NON-NLS-1$
- gc.dispose();
- /*
- * FIXME: the two space widths below is a workaround for bug 44072
- */
- int x= 2 * spaceWidth + fCombo.getClientArea().x + fCombo.getBorderWidth() + extent.x;
- return new Point(x, fCombo.getClientArea().y);
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubjectControl#getSelectionRange()
- */
- public Point getWidgetSelectionRange() {
- return new Point(fCombo.getSelection().x, Math.abs(fCombo.getSelection().y - fCombo.getSelection().x));
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubjectControl#getSelectedRange()
- */
- public Point getSelectedRange() {
- return new Point(fCombo.getSelection().x, Math.abs(fCombo.getSelection().y - fCombo.getSelection().x));
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubjectControl#getDocument()
- */
- public IDocument getDocument() {
- IDocument document= (IDocument)fCombo.getData("document"); //$NON-NLS-1$
- if (document == null) {
- document= new InternalDocument() ;
- fCombo.setData("document", document); //$NON-NLS-1$
- }
- return document;
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubjectControl#setSelectedRange(int, int)
- */
- public void setSelectedRange(int i, int j) {
- fCombo.setSelection(new Point(i, i+j));
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubjectControl#revealRange(int, int)
- */
- public void revealRange(int i, int j) {
- // XXX: this should be improved
- fCombo.setSelection(new Point(i, i+j));
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubjectControl#addSelectionListener(org.eclipse.swt.events.SelectionListener)
- */
- public boolean addSelectionListener(final SelectionListener selectionListener) {
- fCombo.addSelectionListener(selectionListener);
- Listener listener= new Listener() {
- /*
- * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
- */
- public void handleEvent(Event e) {
- selectionListener.widgetSelected(new SelectionEvent(e));
-
- }
- };
- fCombo.addListener(SWT.Modify, listener);
- fModifyListeners.put(selectionListener, listener);
- return true;
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubjectControl#removeSelectionListener(org.eclipse.swt.events.SelectionListener)
- */
- public void removeSelectionListener(SelectionListener selectionListener) {
- fCombo.removeSelectionListener(selectionListener);
- Object listener= fModifyListeners.get(selectionListener);
- if (listener instanceof Listener)
- fCombo.removeListener(SWT.Modify, (Listener)listener);
- }
-
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/IContentAssistSubjectControl.java b/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/IContentAssistSubjectControl.java
deleted file mode 100644
index 51a5f5076..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/IContentAssistSubjectControl.java
+++ /dev/null
@@ -1,297 +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.contentassist;
-
-import org.eclipse.swt.custom.VerifyKeyListener;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Control;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IEventConsumer;
-
-
-/**
- * A content assist subject control can request assistance provided by a
- * {@linkplain org.eclipse.jface.contentassist.ISubjectControlContentAssistant subject control content assistant}.
- *
- * @since 3.0
- */
-public interface IContentAssistSubjectControl {
-
- /**
- * Returns the control of this content assist subject control.
- *
- * @return the control of this content assist subject control
- */
- Control getControl();
-
- /**
- * Returns the line height.
- *
- * @return line height in pixel
- * @exception org.eclipse.swt.SWTException
- * <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver</li>
- * </ul>
- */
- int getLineHeight();
-
- /**
- * Returns the caret position relative to the start of the text in widget
- * coordinates.
- *
- * @return the caret position relative to the start of the text in widget
- * coordinates
- * @exception org.eclipse.swt.SWTException
- * <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver</li>
- * </ul>
- */
- int getCaretOffset();
-
- /**
- * Returns the x, y location of the upper left corner of the character
- * bounding box at the specified offset in the text. The point is relative
- * to the upper left corner of the widget client area.
- *
- * @param offset widget offset relative to the start of the content 0
- * <= offset <= getCharCount()
- * @return x, y location of the upper left corner of the character bounding
- * box at the specified offset in the text
- * @exception org.eclipse.swt.SWTException
- * <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver</li>
- * </ul>
- * @exception IllegalArgumentException
- * <ul>
- * <li>ERROR_INVALID_RANGE when the offset is outside the
- * valid range (< 0 or >getCharCount())</li>
- * </ul>
- */
- Point getLocationAtOffset(int offset);
-
- /**
- * Returns the line delimiter used for entering new lines by key down or
- * paste operation.
- *
- * @return line delimiter used for entering new lines by key down or paste
- * operation
- * @exception org.eclipse.swt.SWTException
- * <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver</li>
- * </ul>
- */
- String getLineDelimiter();
-
- /**
- * Returns the selected range in the subject's widget.
- *
- * @return start and length of the selection, x is the offset of the
- * @exception org.eclipse.swt.SWTException
- * <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver</li>
- * </ul>
- */
- Point getWidgetSelectionRange();
-
- /**
- * Returns the selected range.
- *
- * @return start and length of the selection, x is the offset and y the
- * length based on the subject's model (e.g. document)
- */
- Point getSelectedRange();
-
- /**
- * Sets the selected range. Offset and length based on the subject's
- * model (e.g. document).
- *
- * @param offset the offset of the selection based on the subject's model
- * (e.g. document)
- * @param length the length of the selection based on the subject's model
- * (e.g. document)
- */
- void setSelectedRange(int offset, int length);
-
- /**
- * Reveals the given region. Offset and length based on the subject's
- * model (e.g. document).
- *
- * @param offset the offset of the selection based on the subject's model
- * (e.g. document)
- * @param length the length of the selection based on the subject's model
- * (e.g. document)
- */
- void revealRange(int offset, int length);
-
- /**
- * Returns this content assist subject control's document.
- *
- * @return the viewer's input document
- */
- IDocument getDocument();
-
- /**
- * If supported, appends a verify key listener to the viewer's list of verify key
- * listeners. If the listener is already registered with the viewer this
- * call moves the listener to the end of the list.
- * <p>
- * Note: This content assist subject control may not support appending a verify
- * listener, in which case <code>false</code> will be returned. If this
- * content assist subject control only supports <code>addVerifyKeyListener</code>
- * then this method can be used but <code>prependVerifyKeyListener</code>
- * must return <code>false</code>.
- * </p>
- *
- * @param verifyKeyListener the listener to be added
- * @return <code>true</code> if the listener was added
- */
- boolean appendVerifyKeyListener(VerifyKeyListener verifyKeyListener);
-
- /**
- * If supported, inserts the verify key listener at the beginning of this content assist
- * subject's list of verify key listeners. If the listener is already
- * registered with the viewer this call moves the listener to the beginning
- * of the list.
- * <p>
- * Note: This content assist subject control may not support prepending a verify
- * listener, in which case <code>false</code> will be returned. However,
- * <code>appendVerifyKeyListener</code> might work.
- * </p>
- *
- * @param verifyKeyListener the listener to be inserted
- * @return <code>true</code> if the listener was added
- */
- boolean prependVerifyKeyListener(VerifyKeyListener verifyKeyListener);
-
- /**
- * Removes the verify key listener from this content assist subject control's
- * list of verify key listeners. If the listener is not registered, this
- * call has no effect.
- *
- * @param verifyKeyListener the listener to be removed
- */
- void removeVerifyKeyListener(VerifyKeyListener verifyKeyListener);
-
- /**
- * Tests whether a verify key listener can be added either using <code>prependVerifyKeyListener</code>
- * or <code>appendVerifyKeyListener</code>.
- *
- * @return <code>true</code> if adding verify key listeners is supported
- */
- boolean supportsVerifyKeyListener();
-
- /**
- * Adds the listener to the collection of listeners who will be notified
- * when keys are pressed and released on the system keyboard, by sending it
- * one of the messages defined in the <code>KeyListener</code> interface.
- *
- * @param keyListener the listener which should be notified
- *
- * @exception IllegalArgumentException
- * <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception org.eclipse.swt.SWTException
- * <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver</li>
- * </ul>
- *
- * @see KeyListener
- * @see #removeKeyListener(KeyListener)
- */
- void addKeyListener(KeyListener keyListener);
-
- /**
- * Removes the listener from the collection of listeners who will be
- * notified when keys are pressed and released on the system keyboard.
- *
- * @param keyListener the listener which should be notified
- *
- * @exception IllegalArgumentException
- * <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception org.eclipse.swt.SWTException
- * <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver</li>
- * </ul>
- *
- * @see KeyListener
- * @see #addKeyListener(KeyListener)
- */
- void removeKeyListener(KeyListener keyListener);
-
- /**
- * If supported, registers an event consumer with this content assist
- * subject.
- *
- * @param eventConsumer the content assist subject control's event consumer. <code>null</code>
- * is a valid argument.
- */
- void setEventConsumer(IEventConsumer eventConsumer);
-
- /**
- * Removes the specified selection listener.
- * <p>
- *
- * @param selectionListener the listener
- * @exception org.eclipse.swt.SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT when listener is null</li>
- * </ul>
- */
- void removeSelectionListener(SelectionListener selectionListener);
-
- /**
- * If supported, adds a selection listener. A Selection event is sent by the widget when the
- * selection has changed.
- * <p>
- *
- * @param selectionListener the listener
- * @return <code>true</code> if adding a selection listener is supported
- * @exception org.eclipse.swt.SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT when listener is null</li>
- * </ul>
- */
- boolean addSelectionListener(SelectionListener selectionListener);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ISubjectControlContentAssistProcessor.java b/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ISubjectControlContentAssistProcessor.java
deleted file mode 100644
index 2d66441c2..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ISubjectControlContentAssistProcessor.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.contentassist;
-
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.text.contentassist.IContextInformation;
-
-/**
- * Extension interface for {@link org.eclipse.jface.text.contentassist.IContentAssistProcessor}
- * which provides the context for the
- * {@linkplain org.eclipse.jface.contentassist.ISubjectControlContentAssistant subject control content assistant}.
- *
- * @since 3.0
- */
-public interface ISubjectControlContentAssistProcessor extends IContentAssistProcessor {
- /**
- * Returns a list of completion proposals based on the specified location
- * within the document that corresponds to the current cursor position
- * within the text viewer.
- *
- * @param contentAssistSubjectControl the content assist subject control whose
- * document is used to compute the proposals
- * @param documentOffset an offset within the document for which
- * completions should be computed
- * @return an array of completion proposals or <code>null</code> if no
- * proposals are possible
- */
- ICompletionProposal[] computeCompletionProposals(IContentAssistSubjectControl contentAssistSubjectControl, int documentOffset);
-
- /**
- * Returns information about possible contexts based on the specified
- * location within the document that corresponds to the current cursor
- * position within the content assist subject control.
- *
- * @param contentAssistSubjectControl the content assist subject control whose
- * document is used to compute the possible contexts
- * @param documentOffset an offset within the document for which context
- * information should be computed
- * @return an array of context information objects or <code>null</code>
- * if no context could be found
- */
- IContextInformation[] computeContextInformation(IContentAssistSubjectControl contentAssistSubjectControl, int documentOffset);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ISubjectControlContentAssistant.java b/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ISubjectControlContentAssistant.java
deleted file mode 100644
index 0051d5dc9..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ISubjectControlContentAssistant.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.contentassist;
-
-import org.eclipse.jface.text.contentassist.IContentAssistant;
-
-
-/**
- * Extends {@link org.eclipse.jface.text.contentassist.IContentAssistant} to
- * allow to install a content assistant on the given
- * {@linkplain org.eclipse.jface.contentassist.IContentAssistSubjectControl content assist subject control}.
- *
- * @since 3.0
- */
-public interface ISubjectControlContentAssistant extends IContentAssistant {
-
- /**
- * Installs content assist support on the given subject.
- *
- * @param contentAssistSubjectControl the one who requests content assist
- */
- void install(IContentAssistSubjectControl contentAssistSubjectControl);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ISubjectControlContextInformationPresenter.java b/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ISubjectControlContextInformationPresenter.java
deleted file mode 100644
index 7364e16a1..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ISubjectControlContextInformationPresenter.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.contentassist;
-
-import org.eclipse.jface.text.contentassist.IContextInformation;
-import org.eclipse.jface.text.contentassist.IContextInformationPresenter;
-
-/**
- * Extends {@link org.eclipse.jface.text.contentassist.IContextInformationPresenter} to
- * allow to install a content assistant on the given
- * {@linkplain org.eclipse.jface.contentassist.IContentAssistSubjectControl content assist subject control}.
- *
- * @since 3.0
- */
-public interface ISubjectControlContextInformationPresenter extends IContextInformationPresenter {
-
- /**
- * Installs this presenter for the given context information.
- *
- * @param info the context information which this presenter should style
- * @param contentAssistSubjectControl the content assist subject control
- * @param documentPosition the document position for which the information has been computed
- */
- void install(IContextInformation info, IContentAssistSubjectControl contentAssistSubjectControl, int documentPosition);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ISubjectControlContextInformationValidator.java b/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ISubjectControlContextInformationValidator.java
deleted file mode 100644
index b83168fb0..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ISubjectControlContextInformationValidator.java
+++ /dev/null
@@ -1,35 +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.contentassist;
-
-import org.eclipse.jface.text.contentassist.IContextInformation;
-import org.eclipse.jface.text.contentassist.IContextInformationValidator;
-
-/**
- * Extends {@link org.eclipse.jface.text.contentassist.IContextInformationValidator} to
- * allow to install a content assistant on the given
- * {@linkplain org.eclipse.jface.contentassist.IContentAssistSubjectControl content assist subject control}.
- *
- * @since 3.0
- */
-public interface ISubjectControlContextInformationValidator extends IContextInformationValidator {
-
- /**
- * Installs this validator for the given context information.
- *
- * @param info the context information which this validator should check
- * @param contentAssistSubjectControl the content assist subject control
- * @param documentPosition the document position for which the information
- * has been computed
- */
- void install(IContextInformation info, IContentAssistSubjectControl contentAssistSubjectControl, int documentPosition);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/SubjectControlContentAssistant.java b/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/SubjectControlContentAssistant.java
deleted file mode 100644
index 1215094e2..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/SubjectControlContentAssistant.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.contentassist;
-
-import org.eclipse.jface.text.Assert;
-
-
-/**
- * The standard implementation of the <code>IControlContentAssistant</code> interface.
- * Usually, clients instantiate this class and configure it before using it.
- *
- * @since 3.0
- */
-public class SubjectControlContentAssistant extends org.eclipse.jface.text.contentassist.ContentAssistant implements ISubjectControlContentAssistant {
-
- /*
- * @see ISubjectControlContentAssistant#install(IContentAssistSubjectControl)
- */
- public void install(IContentAssistSubjectControl contentAssistSubjectControl) {
- Assert.isNotNull(contentAssistSubjectControl);
- super.install(contentAssistSubjectControl);
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/SubjectControlContextInformationValidator.java b/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/SubjectControlContextInformationValidator.java
deleted file mode 100644
index e7ee6098e..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/SubjectControlContextInformationValidator.java
+++ /dev/null
@@ -1,78 +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.contentassist;
-
-
-
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.text.contentassist.IContextInformation;
-
-
-/**
- * A default implementation of the <code>IContextInfomationValidator</code> interface.
- * This implementation determines whether the information is valid by asking the content
- * assist processor for all context information objects for the current position. If the
- * currently displayed information is in the result set, the context information is
- * considered valid.
- *
- * @since 3.0
- */
-public final class SubjectControlContextInformationValidator implements ISubjectControlContextInformationValidator {
-
- /** The content assist processor. */
- private IContentAssistProcessor fProcessor;
- /** The context information to be validated. */
- private IContextInformation fContextInformation;
- /** The content assist subject control. */
- private IContentAssistSubjectControl fContentAssistSubjectControl;
-
- /**
- * Creates a new context information validator which is ready to be installed on
- * a particular context information.
- *
- * @param processor the processor to be used for validation
- */
- public SubjectControlContextInformationValidator(IContentAssistProcessor processor) {
- fProcessor= processor;
- }
-
- /*
- * @see IContextInformationValidator#install(IContextInformation, ITextViewer, int)
- */
- public void install(IContextInformation contextInformation, ITextViewer viewer, int position) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * @see ISubjectControlContextInformationValidator#install(IContextInformation, IContentAssistSubjectControl, int)
- */
- public void install(IContextInformation contextInformation, IContentAssistSubjectControl contentAssistSubjectControl, int position) {
- fContextInformation= contextInformation;
- fContentAssistSubjectControl= contentAssistSubjectControl;
- }
-
- /*
- * @see IContentAssistTipCloser#isContextInformationValid(int)
- */
- public boolean isContextInformationValid(int position) {
- if (fContentAssistSubjectControl != null && fProcessor instanceof ISubjectControlContentAssistProcessor) {
- IContextInformation[] infos= ((ISubjectControlContentAssistProcessor)fProcessor).computeContextInformation(fContentAssistSubjectControl, position);
- if (infos != null && infos.length > 0) {
- for (int i= 0; i < infos.length; i++) {
- if (fContextInformation.equals(infos[i]))
- return true;
- }
- }
- }
- return false;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/TextContentAssistSubjectAdapter.java b/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/TextContentAssistSubjectAdapter.java
deleted file mode 100644
index 90fa23f7c..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/TextContentAssistSubjectAdapter.java
+++ /dev/null
@@ -1,192 +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.contentassist;
-
-import java.util.HashMap;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Text;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-
-/**
- * Adapts a <code>Text</code> to an <code>IContentAssistSubjectControl</code>.
- *
- * @see org.eclipse.swt.widgets.Text
- * @see org.eclipse.jface.contentassist.IContentAssistSubjectControl
- * @since 3.0
- */
-public class TextContentAssistSubjectAdapter extends AbstractControlContentAssistSubjectAdapter {
-
- /**
- * The <code>Document</code> of <code>fCombo</code>'s contents.
- */
- private class InternalDocument extends Document {
-
- /**
- * Updates this <code>Document</code> with changes in <code>fText</code>.
- */
- private ModifyListener fModifyListener;
-
- private InternalDocument() {
- super(fText.getText());
- fModifyListener= new ModifyListener() {
- /*
- * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
- */
- public void modifyText(ModifyEvent e) {
- set(fText.getText());
- }
- };
- fText.addModifyListener(fModifyListener);
- }
-
- /*
- * @see org.eclipse.jface.text.AbstractDocument#replace(int, int, java.lang.String)
- */
- public void replace(int pos, int length, String text) throws BadLocationException {
- super.replace(pos, length, text);
- fText.removeModifyListener(fModifyListener);
- fText.setText(get());
- fText.addModifyListener(fModifyListener);
- }
- }
-
- /** The text. */
- private Text fText;
- /** The modify listeners. */
- private HashMap fModifyListeners;
-
- /**
- * Creates a content assist subject control adapter for the given text.
- *
- * @param text the text to adapt
- */
- public TextContentAssistSubjectAdapter(Text text) {
- Assert.isNotNull(text);
- fText= text;
- }
-
- /**
- * {@inheritDoc}
- */
- public Control getControl() {
- return fText;
- }
-
- /**
- * {@inheritDoc}
- */
- public int getLineHeight() {
- return fText.getLineHeight();
- }
-
- /**
- * {@inheritDoc}
- */
- public int getCaretOffset() {
- return fText.getCaretPosition();
- }
-
- /**
- * {@inheritDoc}
- */
- public Point getLocationAtOffset(int offset) {
- Point caretLocation= fText.getCaretLocation();
- /*
- * FIXME workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=52520
- */
- caretLocation.y += 2;
- return caretLocation;
- }
-
- /**
- * {@inheritDoc}
- */
- public Point getWidgetSelectionRange() {
- return new Point(fText.getSelection().x, Math.abs(fText.getSelection().y - fText.getSelection().x));
- }
-
- /**
- * {@inheritDoc}
- */
- public Point getSelectedRange() {
- return new Point(fText.getSelection().x, Math.abs(fText.getSelection().y - fText.getSelection().x));
- }
-
- /**
- * {@inheritDoc}
- */
- public IDocument getDocument() {
- IDocument document= (IDocument)fText.getData("document"); //$NON-NLS-1$
- if (document == null) {
- document= new InternalDocument() ;
- fText.setData("document", document); //$NON-NLS-1$
- }
- return document;
- }
-
- /**
- * {@inheritDoc}
- */
- public void setSelectedRange(int i, int j) {
- fText.setSelection(new Point(i, i+j));
- }
-
- /**
- * {@inheritDoc}
- */
- public void revealRange(int i, int j) {
- // XXX: this should be improved
- fText.setSelection(new Point(i, i+j));
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean addSelectionListener(final SelectionListener selectionListener) {
- fText.addSelectionListener(selectionListener);
- Listener listener= new Listener() {
- /**
- * {@inheritDoc}
- */
- public void handleEvent(Event e) {
- selectionListener.widgetSelected(new SelectionEvent(e));
-
- }
- };
- fText.addListener(SWT.Modify, listener);
- fModifyListeners.put(selectionListener, listener);
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- public void removeSelectionListener(SelectionListener selectionListener) {
- fText.removeSelectionListener(selectionListener);
- Object listener= fModifyListeners.get(selectionListener);
- if (listener instanceof Listener)
- fText.removeListener(SWT.Modify, (Listener)listener);
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/images/content_assist_cue.gif b/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/images/content_assist_cue.gif
deleted file mode 100644
index fe62b77f4..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/images/content_assist_cue.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/package.html b/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/package.html
deleted file mode 100644
index 017a01312..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/package.html
+++ /dev/null
@@ -1,25 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="Author" content="IBM">
- <meta name="GENERATOR" content="Mozilla/4.51 [en] (WinNT; I) [Netscape]">
- <title>Package-level Javadoc</title>
-</head>
-<body>
-Provides a content assist add-on for implementors of <tt>IContentAssistSubjectControl</tt>.
-Content assist supports the user in writing&nbsp; by proposing context
-sensitive completions at a given position. A completion can also
-be a incomplete in itself and content assist provides means to deal with
-nested completions.
-<h2>
-Package Specification</h2>
-<tt>ISubjectControlContentAssistant</tt> defines the concept of the content assist add-on.
-It collaborates with content type specific completion processors (<tt>ISubjectControlContentAssistProcessor</tt>)
-in order to generate completion proposals (<tt>ICompletionProposal</tt>)
-valid at the current document position. The package provides a default
-implementation <tt>SubjectControlContentAssistant</tt> which completely defines and implements
-the UI and the control flow for content assist.
-<br>&nbsp;
-</body>
-</html>
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/AdditionalInfoController2.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/AdditionalInfoController2.java
deleted file mode 100644
index 1738d9e64..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/AdditionalInfoController2.java
+++ /dev/null
@@ -1,255 +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.internal.text.link.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.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.contentassist.ICompletionProposalExtension3;
-
-
-
-/**
- * Displays the additional information available for a completion proposal.
- *
- * @since 2.0
- */
-class AdditionalInfoController2 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. */
- 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
- */
- AdditionalInfoController2(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, ContentAssistMessages.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, -1);
- Rectangle area= fProposalTable.getBounds();
- area.x= 0; // subject area is the whole subject control
- area.y= 0;
-
- // set information & subject area
- setInformation(information, area);
- }
- }
-
- /*
- * @see org.eclipse.jface.text.AbstractInformationControlManager#computeSizeConstraints(Control, IInformationControl)
- */
- protected Point computeSizeConstraints(Control subjectControl, IInformationControl informationControl) {
- Point sizeConstraint= super.computeSizeConstraints(subjectControl, informationControl);
- Point size= subjectControl.getSize();
- if (sizeConstraint.x < size.x)
- sizeConstraint.x= size.x;
- if (sizeConstraint.y < size.y)
- sizeConstraint.y= size.y;
- return sizeConstraint;
- }
-}
-
-
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/CompletionProposalPopup2.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/CompletionProposalPopup2.java
deleted file mode 100644
index 56f68009f..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/CompletionProposalPopup2.java
+++ /dev/null
@@ -1,871 +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.internal.text.link.contentassist;
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-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.resource.JFaceResources;
-
-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;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.contentassist.ICompletionProposalExtension;
-import org.eclipse.jface.text.contentassist.ICompletionProposalExtension2;
-import org.eclipse.jface.text.contentassist.IContextInformation;
-
-
-
-/**
- * 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 CompletionProposalPopup2 implements IContentAssistListener2 {
-
- /** The associated text viewer */
- private ITextViewer fViewer;
- /** The associated content assistant */
- private ContentAssistant2 fContentAssistant;
- /** The used additional info controller */
- private AdditionalInfoController2 fAdditionalInfoController;
- /** The closing strategy for this completion proposal popup */
- private PopupCloser2 fPopupCloser= new PopupCloser2();
- /** The popup shell */
- private Shell fProposalShell;
- /** The proposal table */
- private Table fProposalTable;
- /** Indicates whether a completion proposal is being inserted */
- private boolean fInserting= false;
- /** The key listener to control navigation */
- private KeyListener fKeyListener;
- /** List of document events used for filtering proposals */
- private List fDocumentEvents= new ArrayList();
- /** Listener filling the document event queue */
- private IDocumentListener fDocumentListener;
- /** Reentrance count for <code>filterProposals</code> */
- private long fInvocationCounter= 0;
- /** The filter list of proposals */
- private ICompletionProposal[] fFilteredProposals;
- /** The computed list of proposals */
- private ICompletionProposal[] fComputedProposals;
- /** The offset for which the proposals have been computed */
- private int fInvocationOffset;
- /** The offset for which the computed proposaks have been filtered */
- private int fFilterOffset;
- /** The default line delimiter of the viewer's widget */
- private String fLineDelimiter;
- /** The most recently selected proposal. */
- private ICompletionProposal fLastProposal;
-
-
- /**
- * Creates a new completion proposal popup for the given elements.
- *
- * @param contentAssistant the content assistant feeding this popup
- * @param viewer the viewer on top of which this popup appears
- * @param infoController the info control collaborating with this popup
- * @since 2.0
- */
- public CompletionProposalPopup2(ContentAssistant2 contentAssistant, ITextViewer viewer, AdditionalInfoController2 infoController) {
- fContentAssistant= contentAssistant;
- fViewer= viewer;
- fAdditionalInfoController= infoController;
- }
-
- /**
- * Computes and presents completion proposals. The flag indicates whether this call has
- * be made out of an auto activation context.
- *
- * @param autoActivated <code>true</code> if auto activation context
- * @return an error message or <code>null</code> in case of no error
- */
- public String showProposals(final boolean autoActivated) {
-
- if (fKeyListener == null) {
- fKeyListener= new KeyListener() {
- public void keyPressed(KeyEvent e) {
- if (!Helper2.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 (!Helper2.okToUse(fProposalShell))
- return;
-
- if (e.character == 0 && e.keyCode == SWT.MOD1) {
- // http://dev.eclipse.org/bugs/show_bug.cgi?id=34754
- int index= fProposalTable.getSelectionIndex();
- if (index >= 0)
- selectProposal(index, false);
- }
- }
- };
- }
-
- final StyledText styledText= fViewer.getTextWidget();
- if (styledText != null && !styledText.isDisposed())
- styledText.addKeyListener(fKeyListener);
-
-// BusyIndicator.showWhile(styledText.getDisplay(), new Runnable() {
-// public void run() {
-
- fInvocationOffset= fViewer.getSelectedRange().x;
- // lazily compute proposals
-// if (fComputedProposals == null) fComputedProposals= computeProposals(fContentAssistant.getCompletionPosition());
- fComputedProposals= computeProposals(fInvocationOffset);
-
- int count= (fComputedProposals == null ? 0 : fComputedProposals.length);
- if (count == 0) {
-
- if (!autoActivated)
- styledText.getDisplay().beep();
-
- } else {
-
- if (count == 1 && !autoActivated && fContentAssistant.isAutoInserting())
-
- insertProposal(fComputedProposals[0], (char) 0, 0, fInvocationOffset);
-
- else {
-
- if (fLineDelimiter == null)
- fLineDelimiter= styledText.getLineDelimiter();
-
- createProposalSelector();
- setProposals(fComputedProposals);
- resizeProposalSelector(true);
- 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) {
- 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 (Helper2.okToUse(fProposalShell))
- return;
-
- Control control= fViewer.getTextWidget();
- fProposalShell= new Shell(control.getShell(), SWT.ON_TOP);
-// fProposalShell= new Shell(control.getShell(), SWT.ON_TOP | SWT.RESIZE );
- fProposalTable= new Table(fProposalShell, SWT.H_SCROLL | SWT.V_SCROLL);
-// 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);
- fProposalTable.setLayoutData(data);
-
- fProposalShell.pack();
-
- // set location
- Point currentLocation= fProposalShell.getLocation();
- Point newLocation= getLocation();
- if ((newLocation.x < currentLocation.x && newLocation.y == currentLocation.y) || newLocation.y < currentLocation.y)
- fProposalShell.setLocation(newLocation);
-
- if (fAdditionalInfoController != null) {
- fProposalShell.addControlListener(new ControlListener() {
-
- public void controlMoved(ControlEvent e) {}
-
- public void controlResized(ControlEvent e) {
- // resets the cached resize constraints
- fAdditionalInfoController.setSizeConstraints(50, 10, true, false);
- }
- });
- }
-
- 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, ContentAssistant2.LayoutManager.LAYOUT_PROPOSAL_SELECTOR, fContentAssistant.getSelectionOffset());
- }
-
- /**
- * Returns the proposal selected in the proposal selector.
- *
- * @return the selected proposal
- * @since 2.0
- */
- private ICompletionProposal getSelectedProposal() {
- int i= fProposalTable.getSelectionIndex();
- if (i < 0 || i >= fFilteredProposals.length)
- return null;
- return fFilteredProposals[i];
- }
-
- /**
- * Takes the selected proposal and applies it.
- *
- * @param stateMask the state mask
- * @since 2.1
- */
- private void selectProposalWithMask(int stateMask) {
- ICompletionProposal p= getSelectedProposal();
- hide();
- if (p != null)
- insertProposal(p, (char) 0, stateMask, fViewer.getSelectedRange().x);
- }
-
- /**
- * Applies the given proposal at the given offset. The given character is the
- * one that triggered the insertion of this proposal.
- *
- * @param p the completion proposal
- * @param trigger the trigger character
- * @param offset the offset
- * @since 2.1
- */
- private void insertProposal(ICompletionProposal p, char trigger, int stateMask, int offset) {
-
- fInserting= true;
- IRewriteTarget target= null;
-
- try {
-
- IDocument document= fViewer.getDocument();
-
- if (fViewer instanceof ITextViewerExtension) {
- ITextViewerExtension extension= (ITextViewerExtension) fViewer;
- target= extension.getRewriteTarget();
- }
-
- if (target != null)
- target.beginCompoundChange();
-
- if (p instanceof ICompletionProposalExtension2) {
- 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) {
- fViewer.setSelectedRange(selection.x, selection.y);
- fViewer.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= fViewer.getSelectedRange();
- position= selection.x + selection.y;
- }
-
- fContentAssistant.showContextInformation(info, position);
- }
-
- fContentAssistant.fireProposalChosen(p);
-
- } 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 (Helper2.okToUse(fProposalShell))
- return (fProposalShell.isFocusControl() || fProposalTable.isFocusControl());
-
- return false;
- }
-
- /**
- * Hides this popup.
- */
- public void hide() {
-
- unregister();
-
- if (Helper2.okToUse(fProposalShell)) {
- fContentAssistant.removeContentAssistListener(this, ContentAssistant2.PROPOSAL_SELECTOR);
-
- fPopupCloser.uninstall();
- // see bug 47511: setVisible may run the event loop on GTK
- // and trigger a rentrant call - have to make sure we don't
- // dispose another shell that was already brought up in a
- // reentrant call when calling setVisible()
- Shell tempShell= fProposalShell;
- fProposalShell= null;
- tempShell.setVisible(false);
- tempShell.dispose();
- }
- }
-
- private void unregister() {
- if (fDocumentListener != null) {
- IDocument document= fViewer.getDocument();
- if (document != null)
- document.removeDocumentListener(fDocumentListener);
- fDocumentListener= null;
- }
- fDocumentEvents.clear();
-
- StyledText styledText= fViewer.getTextWidget();
- if (fKeyListener != null && styledText != null && !styledText.isDisposed())
- styledText.removeKeyListener(fKeyListener);
-
- if (fLastProposal != null) {
- if (fLastProposal instanceof ICompletionProposalExtension2) {
- ICompletionProposalExtension2 extension= (ICompletionProposalExtension2) fLastProposal;
- extension.unselected(fViewer);
- }
-
- fLastProposal= null;
- }
-
- fFilteredProposals= null;
-
- fContentAssistant.possibleCompletionsClosed();
- }
-
- /**
- *Returns whether this popup is active. It is active if the propsal selector is visible.
- *
- * @return <code>true</code> if this popup is active
- */
- public boolean isActive() {
- return fProposalShell != null && !fProposalShell.isDisposed();
- }
-
- /**
- * Initializes the proposal selector with these given proposals.
- *
- * @param proposals the proposals
- */
- private void setProposals(ICompletionProposal[] proposals) {
- if (Helper2.okToUse(fProposalTable)) {
-
- ICompletionProposal oldProposal= getSelectedProposal();
- if (oldProposal instanceof ICompletionProposalExtension2)
- ((ICompletionProposalExtension2) oldProposal).unselected(fViewer);
-
- fFilteredProposals= proposals;
-
- fProposalTable.setRedraw(false);
- fProposalTable.removeAll();
-
- Point selection= fViewer.getSelectedRange();
- int endOffset;
- endOffset= selection.x + selection.y;
- IDocument document= fViewer.getDocument();
- boolean validate= false;
- if (selection.y != 0 && document != null) validate= true;
- int selectionIndex= 0;
-
- 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);
-
- if (validate && validateProposal(document, p, endOffset, null)) {
- selectionIndex= i;
- validate= false;
- }
- }
-
- resizeProposalSelector(false);
-
- selectProposal(selectionIndex, false);
- fProposalTable.setRedraw(true);
- }
- }
-
- private void resizeProposalSelector(boolean adjustWidth) {
- // in order to fill in the table items so size computation works correctly
- // will cause flicker, though
- fProposalTable.setRedraw(true);
-
- int width= adjustWidth ? SWT.DEFAULT : ((GridData)fProposalTable.getLayoutData()).widthHint;
- Point size= fProposalTable.computeSize(width, SWT.DEFAULT, true);
-
- GridData data= new GridData(GridData.FILL_BOTH);
- data.widthHint= adjustWidth ? Math.min(size.x, 300) : width;
- data.heightHint= Math.min(getTableHeightHint(fProposalTable, fProposalTable.getItemCount()), getTableHeightHint(fProposalTable, 10));
- fProposalTable.setLayoutData(data);
-
- fProposalShell.layout(true);
- fProposalShell.pack();
-
- if (adjustWidth) {
- fProposalShell.setLocation(getLocation());
- }
- }
-
- /**
- * Computes the table hight hint for <code>table</code>.
- *
- * @param table the table to compute the height for
- * @param rows the number of rows to compute the height for
- * @return the height hint for <code>table</code>
- */
- private int getTableHeightHint(Table table, int rows) {
- if (table.getFont().equals(JFaceResources.getDefaultFont()))
- table.setFont(JFaceResources.getDialogFont());
- int result= table.getItemHeight() * rows;
- if (table.getLinesVisible())
- result+= table.getGridLineWidth() * (rows - 1);
-
- // TODO adjustment might just work on windows
-// return result + 4;
- return result;
- }
-
- private boolean validateProposal(IDocument document, ICompletionProposal p, int offset, DocumentEvent event) {
- // detect selected
- if (p instanceof ICompletionProposalExtension2) {
- ICompletionProposalExtension2 e= (ICompletionProposalExtension2) p;
- if (e.validate(document, offset, event))
- return true;
- } else if (p instanceof ICompletionProposalExtension) {
- ICompletionProposalExtension e= (ICompletionProposalExtension) p;
- if (e.isValidFor(document, offset))
- return true;
- }
- return false;
- }
-
- /**
- * Returns the graphical location at which this popup should be made visible.
- *
- * @return the location of this popup
- */
- private Point getLocation() {
- StyledText text= fViewer.getTextWidget();
- Point selection= text.getSelection();
- Point p= text.getLocationAtOffset(selection.x);
- // TODO subtract border width!
- p.x -= fProposalShell.getBorderWidth();
- if (p.x < 0) p.x= 0;
- if (p.y < 0) p.y= 0;
- p= new Point(p.x, p.y + text.getLineHeight());
- p= text.toDisplay(p);
- if (p.x < 0) p.x= 0;
- if (p.y < 0) p.y= 0;
- return p;
- }
-
- /**
- *Displays this popup and install the additional info controller, so that additional info
- * is displayed when a proposal is selected and additional info is available.
- */
- private void displayProposals() {
- if (fContentAssistant.addContentAssistListener(this, ContentAssistant2.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= fViewer.getDocument();
- if (document != null)
- document.addDocumentListener(fDocumentListener);
-
- fProposalShell.setVisible(true);
- // see bug 47511: setVisible may run the event loop on GTK
- // and trigger a rentrant call - have to check whether we are still
- // visible
- if (!Helper2.okToUse(fProposalShell))
- return;
-
-
- if (fAdditionalInfoController != null) {
- fAdditionalInfoController.install(fProposalTable);
- fAdditionalInfoController.handleTableSelectionChanged();
- }
- }
- }
-
- /*
- * @see IContentAssistListener#verifyKey(VerifyEvent)
- */
- public boolean verifyKey(VerifyEvent e) {
- if (!Helper2.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;
-
- // in linked mode: hide popup
- // plus: don't invalidate the event in order to give LinkedUI a chance to handle it
- case '\t':
-// hide();
- break;
-
- default:
- ICompletionProposal p= getSelectedProposal();
- if (p instanceof ICompletionProposalExtension) {
- ICompletionProposalExtension t= (ICompletionProposalExtension) p;
- char[] triggers= t.getTriggerCharacters();
- if (contains(triggers, key)) {
- hide();
- if (key == ';') {
- e.doit= true;
- insertProposal(p, (char) 0, e.stateMask, fViewer.getSelectedRange().x);
- } else {
- e.doit= false;
- insertProposal(p, key, e.stateMask, fViewer.getSelectedRange().x);
- }
- }
- }
- }
- }
-
- return true;
- }
-
- /**
- * Selects the entry with the given index in the proposal selector and feeds
- * the selection to the additional info controller.
- *
- * @param index the index in the list
- * @param smartToggle <code>true</code> if the smart toogle key has been pressed
- * @since 2.1
- */
- private void selectProposal(int index, boolean smartToggle) {
-
- ICompletionProposal oldProposal= getSelectedProposal();
- if (oldProposal instanceof ICompletionProposalExtension2)
- ((ICompletionProposalExtension2) oldProposal).unselected(fViewer);
-
- ICompletionProposal proposal= fFilteredProposals[index];
- if (proposal instanceof ICompletionProposalExtension2)
- ((ICompletionProposalExtension2) proposal).selected(fViewer, smartToggle);
-
- fLastProposal= proposal;
-
- fProposalTable.setSelection(index);
- fProposalTable.showSelection();
- if (fAdditionalInfoController != null)
- fAdditionalInfoController.handleTableSelectionChanged();
- }
-
- /**
- * Returns whether the given character is contained in the given array of
- * characters.
- *
- * @param characters the list of characters
- * @param c the character to look for in the list
- * @return <code>true</code> if character belongs to the list
- * @since 2.0
- */
- private boolean contains(char[] characters, char c) {
-
- if (characters == null)
- return false;
-
- for (int i= 0; i < characters.length; i++) {
- if (c == characters[i])
- return true;
- }
-
- return false;
- }
-
- /*
- * @see IEventConsumer#processEvent(VerifyEvent)
- */
- public void processEvent(VerifyEvent e) {
- }
-
- /**
- * Filters the displayed proposal based on the given cursor position and the
- * offset of the original invocation of the content assistant.
- */
- private void filterProposals() {
- ++ fInvocationCounter;
- Control control= fViewer.getTextWidget();
- control.getDisplay().asyncExec(new Runnable() {
- long fCounter= fInvocationCounter;
- public void run() {
-
- if (fCounter != fInvocationCounter) return;
-
- int offset= fViewer.getSelectedRange().x;
- ICompletionProposal[] proposals= null;
- try {
- if (offset > -1) {
- DocumentEvent event= TextUtilities.mergeProcessedDocumentEvents(fDocumentEvents);
- proposals= computeFilteredProposals(offset, event);
- }
- } catch (BadLocationException x) {
- } finally {
- fDocumentEvents.clear();
- }
- fFilterOffset= offset;
-
- if (proposals != null && proposals.length > 0)
- setProposals(proposals);
- else
- hide();
- }
- });
- }
-
- /**
- * Computes the subset of already computed propsals that are still valid for
- * the given offset.
- *
- * @param offset the offset
- * @param event the merged document event
- * @return the set of filtered proposals
- * @since 2.0
- */
- private ICompletionProposal[] computeFilteredProposals(int offset, DocumentEvent event) {
-
- if (offset == fInvocationOffset && event == null)
- return fComputedProposals;
-
- if (offset < fInvocationOffset) {
- return null;
- }
-
- ICompletionProposal[] proposals= fComputedProposals;
- if (offset > fFilterOffset)
- proposals= fFilteredProposals;
-
- if (proposals == null)
- return null;
-
- IDocument document= fViewer.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 (Helper2.okToUse(fProposalShell))
- fProposalShell.setFocus();
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistMessages.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistMessages.java
deleted file mode 100644
index 7dd029028..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistMessages.java
+++ /dev/null
@@ -1,82 +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.internal.text.link.contentassist;
-
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-
-/**
- * Helper class to get NLSed messages.
- *
- * @since 3.0
- */
-class ContentAssistMessages {
-
- private static final String RESOURCE_BUNDLE= ContentAssistMessages.class.getName();
-
- private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
-
- private ContentAssistMessages() {
- }
-
- /**
- * Gets a string from the resource bundle.
- *
- * @param key the string used to get the bundle value, must not be null
- * @return the string from the resource bundle
- */
- public static String getString(String key) {
- try {
- return fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- }
-
- /**
- * Gets a string from the resource bundle and formats it with the given arguments.
- *
- * @param key the string used to get the bundle value, must not be null
- * @param args the arguments used to format the string
- * @return the formatted string
- */
- public static String getFormattedString(String key, Object[] args) {
- String format= null;
- try {
- format= fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- return MessageFormat.format(format, args);
- }
-
- /**
- * Gets a string from the resource bundle and formats it with the given argument.
- *
- * @param key the string used to get the bundle value, must not be null
- * @param arg the argument used to format the string
- * @return the formatted string
- */
- public static String getFormattedString(String key, Object arg) {
- String format= null;
- try {
- format= fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- if (arg == null)
- arg= ""; //$NON-NLS-1$
- return MessageFormat.format(format, new Object[] { arg });
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistMessages.properties b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistMessages.properties
deleted file mode 100644
index 8aa64448a..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistMessages.properties
+++ /dev/null
@@ -1,19 +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
-###############################################################################
-
-
-InfoPopup.info_delay_timer_name=AdditionalInfo Delay
-
-ContentAssistant.assist_delay_timer_name=AutoAssist Delay
-
-HTMLTextPresenter.ellipse= ...
-
-HTML2TextReader.listItemPrefix=\t-
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java
deleted file mode 100644
index 7d33f4997..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java
+++ /dev/null
@@ -1,1587 +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.internal.text.link.contentassist;
-
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.SWTError;
-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.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.VerifyEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Widget;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DefaultInformationControl;
-import org.eclipse.jface.text.IEventConsumer;
-import org.eclipse.jface.text.IInformationControl;
-import org.eclipse.jface.text.IInformationControlCreator;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.ITextViewerExtension;
-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;
-import org.eclipse.jface.text.contentassist.CompletionProposal;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.text.contentassist.IContentAssistant;
-import org.eclipse.jface.text.contentassist.IContentAssistantExtension;
-import org.eclipse.jface.text.contentassist.IContextInformation;
-import org.eclipse.jface.text.contentassist.IContextInformationPresenter;
-import org.eclipse.jface.text.contentassist.IContextInformationValidator;
-
-
-/**
- * A custom implementation of the <code>IContentAssistant</code> interface.
- * This implementation is used by the linked mode ui. This is internal and subject
- * to change without notice.
- */
-public class ContentAssistant2 implements IContentAssistant, IContentAssistantExtension, IWidgetTokenKeeper, IWidgetTokenKeeperExtension {
-
- /**
- * A generic closer class used to monitor various
- * interface events in order to determine whether
- * content-assist should be terminated and all
- * associated windows closed.
- */
- class Closer implements ControlListener, MouseListener, FocusListener, DisposeListener, IViewportListener {
-
- /**
- * Installs this closer on it's viewer's text widget.
- */
- protected void install() {
- Control w= fViewer.getTextWidget();
- if (Helper2.okToUse(w)) {
-
- Control shell= w.getShell();
- shell.addControlListener(this);
-
- w.addMouseListener(this);
- w.addFocusListener(this);
-
- /*
- * 1GGYYWK: ITPJUI:ALL - Dismissing editor with code assist up causes lots of Internal Errors
- */
- w.addDisposeListener(this);
- }
-
- fViewer.addViewportListener(this);
- }
-
- /**
- * Uninstalls this closer from the viewer's text widget.
- */
- protected void uninstall() {
- Control w= fViewer.getTextWidget();
- if (Helper2.okToUse(w)) {
-
- Control shell= w.getShell();
- if (Helper2.okToUse(shell))
- shell.removeControlListener(this);
-
- w.removeMouseListener(this);
- w.removeFocusListener(this);
-
- /*
- * 1GGYYWK: ITPJUI:ALL - Dismissing editor with code assist up causes lots of Internal Errors
- */
- w.removeDisposeListener(this);
- }
-
- 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) {
- if (fViewer != null) {
- Control control= fViewer.getTextWidget();
- if (control != null) {
- Display d= control.getDisplay();
- if (d != null) {
- d.asyncExec(new Runnable() {
- public void run() {
- if (!hasFocus())
- hide();
- }
- });
- }
- }
- }
- }
-
- /*
- * @seeDisposeListener#widgetDisposed(DisposeEvent)
- */
- public void widgetDisposed(DisposeEvent e) {
- /*
- * 1GGYYWK: ITPJUI:ALL - Dismissing editor with code assist up causes lots of Internal Errors
- */
- hide();
- }
-
- /*
- * @see IViewportListener#viewportChanged(int)
- */
- public void viewportChanged(int topIndex) {
- hide();
- }
-
- /**
- * Hides any open popups.
- */
- protected void hide() {
- fProposalPopup.hide();
- fContextInfoPopup.hide();
- }
- }
-
- /**
- * An implementation of <code>IContentAssistListener</code>, this class is
- * used to monitor key events in support of automatic activation
- * of the content assistant. If enabled, the implementation utilizes a
- * thread to watch for input characters matching the activation
- * characters specified by the content assist processor, and if
- * detected, will wait the indicated delay interval before
- * activating the content assistant.
- */
- class AutoAssistListener implements VerifyKeyListener, Runnable {
-
- private Thread fThread;
- private boolean fIsReset= false;
- private Object fMutex= new Object();
- private int fShowStyle;
-
- private final static int SHOW_PROPOSALS= 1;
- private final static int SHOW_CONTEXT_INFO= 2;
-
- protected AutoAssistListener() {
- }
-
- protected void start(int showStyle) {
- fShowStyle= showStyle;
- fThread= new Thread(this, ContentAssistMessages.getString("ContentAssistant.assist_delay_timer_name")); //$NON-NLS-1$
- fThread.start();
- }
-
- public void run() {
- try {
- while (true) {
- synchronized (fMutex) {
- if (fAutoActivationDelay != 0)
- fMutex.wait(fAutoActivationDelay);
- if (fIsReset) {
- fIsReset= false;
- continue;
- }
- }
- showAssist(fShowStyle);
- break;
- }
- } catch (InterruptedException e) {
- }
- fThread= null;
- }
-
- protected void reset(int showStyle) {
- synchronized (fMutex) {
- fShowStyle= showStyle;
- fIsReset= true;
- fMutex.notifyAll();
- }
- }
-
- protected void stop() {
- if (fThread != null) {
- fThread.interrupt();
- }
- }
-
- private boolean contains(char[] characters, char character) {
- if (characters != null) {
- for (int i= 0; i < characters.length; i++) {
- if (character == characters[i])
- return true;
- }
- }
- return false;
- }
-
- public void verifyKey(VerifyEvent e) {
- // Only act on typed characters and ignore modifier-only events
- if (e.character == 0 && (e.keyCode & SWT.KEYCODE_BIT) == 0)
- return;
-
- int showStyle;
- int pos= fViewer.getSelectedRange().x;
- char[] activation= getCompletionProposalAutoActivationCharacters(fViewer, pos);
-
- if (contains(activation, e.character) && !fProposalPopup.isActive())
- showStyle= SHOW_PROPOSALS;
- else {
- activation= getContextInformationAutoActivationCharacters(fViewer, pos);
- if (contains(activation, e.character) && !fContextInfoPopup.isActive())
- showStyle= SHOW_CONTEXT_INFO;
- else {
- if (fThread != null && fThread.isAlive())
- stop();
- return;
- }
- }
-
- if (fThread != null && fThread.isAlive())
- reset(showStyle);
- else
- start(showStyle);
- }
-
- protected void showAssist(final int showStyle) {
- Control control= fViewer.getTextWidget();
- Display d= control.getDisplay();
- if (d != null) {
- try {
- d.syncExec(new Runnable() {
- public void run() {
- if (showStyle == SHOW_PROPOSALS)
- fProposalPopup.showProposals(true);
- else if (showStyle == SHOW_CONTEXT_INFO)
- fContextInfoPopup.showContextProposals(true);
- }
- });
- } catch (SWTError e) {
- }
- }
- }
- }
-
- /**
- * The laypout manager layouts the various
- * windows associated with the content assistant based on the
- * settings of the content assistant.
- */
- class LayoutManager implements Listener {
-
- // Presentation types.
- /** proposal selector */
- public final static int LAYOUT_PROPOSAL_SELECTOR= 0;
- /** context selector */
- public final static int LAYOUT_CONTEXT_SELECTOR= 1;
- /** context info */
- public final static int LAYOUT_CONTEXT_INFO_POPUP= 2;
-
- int fContextType= LAYOUT_CONTEXT_SELECTOR;
- Shell[] fShells= new Shell[3];
- Object[] fPopups= new Object[3];
-
- protected void add(Object popup, Shell shell, int type, int offset) {
- Assert.isNotNull(popup);
- Assert.isTrue(shell != null && !shell.isDisposed());
- checkType(type);
-
- if (fShells[type] != shell) {
- if (fShells[type] != null)
- fShells[type].removeListener(SWT.Dispose, this);
- shell.addListener(SWT.Dispose, this);
- fShells[type]= shell;
- }
-
- fPopups[type]= popup;
- if (type == LAYOUT_CONTEXT_SELECTOR || type == LAYOUT_CONTEXT_INFO_POPUP)
- fContextType= type;
-
- layout(type, offset);
- adjustListeners(type);
- }
-
- protected void checkType(int type) {
- Assert.isTrue(type == LAYOUT_PROPOSAL_SELECTOR ||
- type == LAYOUT_CONTEXT_SELECTOR || type == LAYOUT_CONTEXT_INFO_POPUP);
- }
-
- public void handleEvent(Event event) {
- Widget source= event.widget;
- source.removeListener(SWT.Dispose, this);
-
- int type= getShellType(source);
- checkType(type);
- fShells[type]= null;
-
- switch (type) {
- case LAYOUT_PROPOSAL_SELECTOR:
- if (fContextType == LAYOUT_CONTEXT_SELECTOR &&
- Helper2.okToUse(fShells[LAYOUT_CONTEXT_SELECTOR])) {
- // Restore event notification to the tip popup.
- addContentAssistListener((IContentAssistListener2) fPopups[LAYOUT_CONTEXT_SELECTOR], CONTEXT_SELECTOR);
- }
- break;
-
- case LAYOUT_CONTEXT_SELECTOR:
- if (Helper2.okToUse(fShells[LAYOUT_PROPOSAL_SELECTOR])) {
- if (fProposalPopupOrientation == PROPOSAL_STACKED)
- layout(LAYOUT_PROPOSAL_SELECTOR, getSelectionOffset());
- // Restore event notification to the proposal popup.
- addContentAssistListener((IContentAssistListener2) fPopups[LAYOUT_PROPOSAL_SELECTOR], PROPOSAL_SELECTOR);
- }
- fContextType= LAYOUT_CONTEXT_INFO_POPUP;
- break;
-
- case LAYOUT_CONTEXT_INFO_POPUP:
- if (Helper2.okToUse(fShells[LAYOUT_PROPOSAL_SELECTOR])) {
- if (fContextInfoPopupOrientation == CONTEXT_INFO_BELOW)
- layout(LAYOUT_PROPOSAL_SELECTOR, getSelectionOffset());
- }
- fContextType= LAYOUT_CONTEXT_SELECTOR;
- break;
- }
- }
-
- protected int getShellType(Widget shell) {
- for (int i=0; i<fShells.length; i++) {
- if (fShells[i] == shell)
- return i;
- }
- return -1;
- }
-
- protected void layout(int type, int offset) {
- switch (type) {
- case LAYOUT_PROPOSAL_SELECTOR:
- layoutProposalSelector(offset);
- break;
- case LAYOUT_CONTEXT_SELECTOR:
- layoutContextSelector(offset);
- break;
- case LAYOUT_CONTEXT_INFO_POPUP:
- layoutContextInfoPopup(offset);
- break;
- }
- }
-
- protected void layoutProposalSelector(int offset) {
- if (fContextType == LAYOUT_CONTEXT_INFO_POPUP &&
- fContextInfoPopupOrientation == CONTEXT_INFO_BELOW &&
- Helper2.okToUse(fShells[LAYOUT_CONTEXT_INFO_POPUP])) {
- // Stack proposal selector beneath the tip box.
- Shell shell= fShells[LAYOUT_PROPOSAL_SELECTOR];
- Shell parent= fShells[LAYOUT_CONTEXT_INFO_POPUP];
- shell.setLocation(getStackedLocation(shell, parent));
- } else if (fContextType != LAYOUT_CONTEXT_SELECTOR ||
- !Helper2.okToUse(fShells[LAYOUT_CONTEXT_SELECTOR])) {
- // There are no other presentations to be concerned with,
- // so place the proposal selector beneath the cursor line.
- Shell shell= fShells[LAYOUT_PROPOSAL_SELECTOR];
- shell.setLocation(getBelowLocation(shell, offset));
- } else {
- switch (fProposalPopupOrientation) {
- case PROPOSAL_REMOVE: {
- // Remove the tip selector and place the
- // proposal selector beneath the cursor line.
- fShells[LAYOUT_CONTEXT_SELECTOR].dispose();
- Shell shell= fShells[LAYOUT_PROPOSAL_SELECTOR];
- shell.setLocation(getBelowLocation(shell, offset));
- break;
- }
- case PROPOSAL_OVERLAY: {
- // Overlay the tip selector with the proposal selector.
- Shell shell= fShells[LAYOUT_PROPOSAL_SELECTOR];
- shell.setLocation(getBelowLocation(shell, offset));
- break;
- }
- case PROPOSAL_STACKED: {
- // Stack the proposal selector beneath the tip selector.
- Shell shell= fShells[LAYOUT_PROPOSAL_SELECTOR];
- Shell parent= fShells[LAYOUT_CONTEXT_SELECTOR];
- shell.setLocation(getStackedLocation(shell, parent));
- break;
- }
- }
- }
- }
-
- protected void layoutContextSelector(int offset) {
- // Always place the context selector beneath the cursor line.
- Shell shell= fShells[LAYOUT_CONTEXT_SELECTOR];
- shell.setLocation(getBelowLocation(shell, offset));
-
- if (Helper2.okToUse(fShells[LAYOUT_PROPOSAL_SELECTOR])) {
- switch (fProposalPopupOrientation) {
- case PROPOSAL_REMOVE:
- // Remove the proposal selector.
- fShells[LAYOUT_PROPOSAL_SELECTOR].dispose();
- break;
-
- case PROPOSAL_OVERLAY:
- // The proposal selector has been overlayed by the tip selector.
- break;
-
- case PROPOSAL_STACKED: {
- // Stack the proposal selector beneath the tip selector.
- shell= fShells[LAYOUT_PROPOSAL_SELECTOR];
- Shell parent= fShells[LAYOUT_CONTEXT_SELECTOR];
- shell.setLocation(getStackedLocation(shell, parent));
- break;
- }
- }
- }
- }
-
- protected void layoutContextInfoPopup(int offset) {
- switch (fContextInfoPopupOrientation) {
- case CONTEXT_INFO_ABOVE: {
- // Place the popup above the cursor line.
- Shell shell= fShells[LAYOUT_CONTEXT_INFO_POPUP];
- shell.setLocation(getAboveLocation(shell, offset));
- break;
- }
- case CONTEXT_INFO_BELOW: {
- // Place the popup beneath the cursor line.
- Shell parent= fShells[LAYOUT_CONTEXT_INFO_POPUP];
- parent.setLocation(getBelowLocation(parent, offset));
- if (Helper2.okToUse(fShells[LAYOUT_PROPOSAL_SELECTOR])) {
- // Stack the proposal selector beneath the context info popup.
- Shell shell= fShells[LAYOUT_PROPOSAL_SELECTOR];
- shell.setLocation(getStackedLocation(shell, parent));
- }
- break;
- }
- }
- }
-
- protected void shiftHorizontalLocation(Point location, Rectangle shellBounds, Rectangle displayBounds) {
- if (location.x + shellBounds.width > displayBounds.width)
- location.x= displayBounds.width - shellBounds.width;
-
- if (location.x < displayBounds.x)
- location.x= displayBounds.x;
- }
-
- protected void shiftVerticalLocation(Point location, Rectangle shellBounds, Rectangle displayBounds) {
- if (location.y + shellBounds.height > displayBounds.height)
- location.y= displayBounds.height - shellBounds.height;
-
- if (location.y < displayBounds.y)
- location.y= displayBounds.y;
- }
-
- protected Point getAboveLocation(Shell shell, int offset) {
- StyledText text= fViewer.getTextWidget();
- Point location= text.getLocationAtOffset(offset);
- location= text.toDisplay(location);
-
- Rectangle shellBounds= shell.getBounds();
- Rectangle displayBounds= shell.getDisplay().getClientArea();
-
- location.y=location.y - shellBounds.height;
-
- shiftHorizontalLocation(location, shellBounds, displayBounds);
- shiftVerticalLocation(location, shellBounds, displayBounds);
-
- return location;
- }
-
- protected Point getBelowLocation(Shell shell, int offset) {
- StyledText text= fViewer.getTextWidget();
- Point location= text.getLocationAtOffset(offset);
- if (location.x < 0) location.x= 0;
- if (location.y < 0) location.y= 0;
- location= text.toDisplay(location);
-
- Rectangle shellBounds= shell.getBounds();
- Rectangle displayBounds= shell.getDisplay().getClientArea();
-
- location.y= location.y + text.getLineHeight();
- shiftHorizontalLocation(location, shellBounds, displayBounds);
- shiftVerticalLocation(location, shellBounds, displayBounds);
-
- return location;
- }
-
- protected Point getStackedLocation(Shell shell, Shell parent) {
- Point p= parent.getLocation();
- Point size= parent.getSize();
- p.x += size.x / 4;
- p.y += size.y;
-
- p= parent.toDisplay(p);
-
- Rectangle shellBounds= shell.getBounds();
- Rectangle displayBounds= shell.getDisplay().getClientArea();
- shiftHorizontalLocation(p, shellBounds, displayBounds);
- shiftVerticalLocation(p, shellBounds, displayBounds);
-
- return p;
- }
-
- protected void adjustListeners(int type) {
- switch (type) {
- case LAYOUT_PROPOSAL_SELECTOR:
- if (fContextType == LAYOUT_CONTEXT_SELECTOR &&
- Helper2.okToUse(fShells[LAYOUT_CONTEXT_SELECTOR]))
- // Disable event notification to the tip selector.
- removeContentAssistListener((IContentAssistListener2) fPopups[LAYOUT_CONTEXT_SELECTOR], CONTEXT_SELECTOR);
- break;
- case LAYOUT_CONTEXT_SELECTOR:
- if (Helper2.okToUse(fShells[LAYOUT_PROPOSAL_SELECTOR]))
- // Disable event notification to the proposal selector.
- removeContentAssistListener((IContentAssistListener2) fPopups[LAYOUT_PROPOSAL_SELECTOR], PROPOSAL_SELECTOR);
- break;
- case LAYOUT_CONTEXT_INFO_POPUP:
- break;
- }
- }
- }
-
- /**
- * Internal key listener and event consumer.
- */
- class InternalListener implements VerifyKeyListener, IEventConsumer {
-
- /**
- * Verifies key events by notifying the registered listeners.
- * Each listener is allowed to indicate that the event has been
- * handled and should not be further processed.
- *
- * @param e the verify event
- * @see VerifyKeyListener#verifyKey(org.eclipse.swt.events.VerifyEvent)
- */
- public void verifyKey(VerifyEvent e) {
- IContentAssistListener2[] listeners= (IContentAssistListener2[]) fListeners.clone();
- for (int i= 0; i < listeners.length; i++) {
- if (listeners[i] != null) {
- if (!listeners[i].verifyKey(e) || !e.doit)
- return;
- }
- }
- }
-
- /*
- * @see IEventConsumer#processEvent
- */
- public void processEvent(VerifyEvent event) {
-
- installKeyListener();
-
- IContentAssistListener2[] listeners= (IContentAssistListener2[])fListeners.clone();
- for (int i= 0; i < listeners.length; i++) {
- if (listeners[i] != null) {
- listeners[i].processEvent(event);
- if (!event.doit)
- return;
- }
- }
- }
- }
-
-
- // Content-Assist Listener types
- final static int CONTEXT_SELECTOR= 0;
- final static int PROPOSAL_SELECTOR= 1;
- final static int CONTEXT_INFO_POPUP= 2;
-
- /**
- * The popup priority: &gt; infopops, &lt; standard content assist.
- * Default value: <code>10</code>.
- *
- * @since 3.0
- */
- public static final int WIDGET_PRIORITY= 10;
-
-
- private static final int DEFAULT_AUTO_ACTIVATION_DELAY= 500;
-
- private IInformationControlCreator fInformationControlCreator;
- private int fAutoActivationDelay= DEFAULT_AUTO_ACTIVATION_DELAY;
- private boolean fIsAutoActivated= false;
- private boolean fIsAutoInserting= false;
- private int fProposalPopupOrientation= PROPOSAL_OVERLAY;
- private int fContextInfoPopupOrientation= CONTEXT_INFO_ABOVE;
- private Map fProcessors;
- private String fPartitioning;
-
- private Color fContextInfoPopupBackground;
- private Color fContextInfoPopupForeground;
- private Color fContextSelectorBackground;
- private Color fContextSelectorForeground;
- private Color fProposalSelectorBackground;
- private Color fProposalSelectorForeground;
-
- private ITextViewer fViewer;
- private String fLastErrorMessage;
-
- private Closer fCloser;
- private LayoutManager fLayoutManager;
- private AutoAssistListener fAutoAssistListener;
- private InternalListener fInternalListener;
- private CompletionProposalPopup2 fProposalPopup;
- private ContextInformationPopup2 fContextInfoPopup;
-
- private boolean fKeyListenerHooked= false;
- private IContentAssistListener2[] fListeners= new IContentAssistListener2[4];
- private int fCompletionPosition;
- private String[] fProposalStrings;
- private ICompletionProposal[] fProposals;
- private final List fProposalListeners= new ArrayList();
-
- /**
- * Creates a new content assistant. The content assistant is not automatically activated,
- * overlays the completion proposals with context information list if necessary, and
- * shows the context information above the location at which it was activated. If auto
- * activation will be enabled, without further configuration steps, this content assistant
- * is activated after a 500 ms delay. It uses the default partitioning.
- */
- public ContentAssistant2() {
- setContextInformationPopupOrientation(CONTEXT_INFO_ABOVE);
- setInformationControlCreator(getInformationControlCreator());
-
-// JavaTextTools textTools= JavaPlugin.getDefault().getJavaTextTools();
-// IColorManager manager= textTools.getColorManager();
-//
-// IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore();
-//
-// Color c= getColor(store, PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND, manager);
-// setProposalSelectorForeground(c);
-//
-// c= getColor(store, PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND, manager);
-// setProposalSelectorBackground(c);
- }
-
- /**
- * Creates an <code>IInformationControlCreator</code> to be used to display context information.
- *
- * @return an <code>IInformationControlCreator</code> to be used to display context information
- */
- private IInformationControlCreator getInformationControlCreator() {
- return new IInformationControlCreator() {
- public IInformationControl createInformationControl(Shell parent) {
- return new DefaultInformationControl(parent, new HTMLTextPresenter());
- }
- };
- }
-
- /**
- * Sets the document partitioning this content assistant is using.
- *
- * @param partitioning the document partitioning for this content assistant
- */
- public void setDocumentPartitioning(String partitioning) {
- Assert.isNotNull(partitioning);
- fPartitioning= partitioning;
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistantExtension#getDocumentPartitioning()
- * @since 3.0
- */
- public String getDocumentPartitioning() {
- return fPartitioning;
- }
-
- /**
- * Registers a given content assist processor for a particular content type.
- * If there is already a processor registered for this type, the new processor
- * is registered instead of the old one.
- *
- * @param processor the content assist processor to register, or <code>null</code> to remove an existing one
- * @param contentType the content type under which to register
- */
- public void setContentAssistProcessor(IContentAssistProcessor processor, String contentType) {
-
- Assert.isNotNull(contentType);
-
- if (fProcessors == null)
- fProcessors= new HashMap();
-
- if (processor == null)
- fProcessors.remove(contentType);
- else
- fProcessors.put(contentType, processor);
- }
-
- /*
- * @see IContentAssistant#getContentAssistProcessor
- */
- public IContentAssistProcessor getContentAssistProcessor(String contentType) {
- if (fProcessors == null)
- return null;
-
- return (IContentAssistProcessor) fProcessors.get(contentType);
- }
-
- /**
- * Enables the content assistant's auto activation mode.
- *
- * @param enabled indicates whether auto activation is enabled or not
- */
- public void enableAutoActivation(boolean enabled) {
- fIsAutoActivated= enabled;
- manageAutoActivation(fIsAutoActivated);
- }
-
- /**
- * Enables the content assistant's auto insertion mode. If enabled,
- * the content assistant inserts a proposal automatically if it is
- * the only proposal. In the case of ambiguities, the user must
- * make the choice.
- *
- * @param enabled indicates whether auto insertion is enabled or not
- * @since 2.0
- */
- public void enableAutoInsert(boolean enabled) {
- fIsAutoInserting= enabled;
- }
-
- /**
- * Returns whether this content assistant is in the auto insertion
- * mode or not.
- *
- * @return <code>true</code> if in auto insertion mode
- * @since 2.0
- */
- boolean isAutoInserting() {
- return fIsAutoInserting;
- }
-
- /**
- * Installs and uninstall the listeners needed for autoactivation.
- * @param start <code>true</code> if listeners must be installed,
- * <code>false</code> if they must be removed
- * @since 2.0
- */
- private void manageAutoActivation(boolean start) {
- if (start) {
-
- if (fViewer != null && fAutoAssistListener == null) {
- fAutoAssistListener= new AutoAssistListener();
- if (fViewer instanceof ITextViewerExtension) {
- ITextViewerExtension extension= (ITextViewerExtension) fViewer;
- extension.appendVerifyKeyListener(fAutoAssistListener);
- } else {
- StyledText textWidget= fViewer.getTextWidget();
- if (Helper2.okToUse(textWidget))
- textWidget.addVerifyKeyListener(fAutoAssistListener);
- }
- }
-
- } else if (fAutoAssistListener != null) {
-
- if (fViewer instanceof ITextViewerExtension) {
- ITextViewerExtension extension= (ITextViewerExtension) fViewer;
- extension.removeVerifyKeyListener(fAutoAssistListener);
- } else {
- StyledText textWidget= fViewer.getTextWidget();
- if (Helper2.okToUse(textWidget))
- textWidget.removeVerifyKeyListener(fAutoAssistListener);
- }
-
- fAutoAssistListener= null;
- }
- }
-
- /**
- * Sets the delay after which the content assistant is automatically invoked
- * if the cursor is behind an auto activation character.
- *
- * @param delay the auto activation delay
- */
- public void setAutoActivationDelay(int delay) {
- fAutoActivationDelay= delay;
- }
-
- /**
- * Sets the proposal popups' orientation.
- * The following values may be used:
- * <ul>
- * <li>PROPOSAL_OVERLAY<p>
- * proposal popup windows should overlay each other
- * </li>
- * <li>PROPOSAL_REMOVE<p>
- * any currently shown proposal popup should be closed
- * </li>
- * <li>PROPOSAL_STACKED<p>
- * proposal popup windows should be vertical stacked, with no overlap,
- * beneath the line containing the current cursor location
- * </li>
- * </ul>
- *
- * @param orientation the popup's orientation
- */
- public void setProposalPopupOrientation(int orientation) {
- fProposalPopupOrientation= orientation;
- }
-
- /**
- * Sets the context information popup's orientation.
- * The following values may be used:
- * <ul>
- * <li>CONTEXT_ABOVE<p>
- * context information popup should always appear above the line containing
- * the current cursor location
- * </li>
- * <li>CONTEXT_BELOW<p>
- * context information popup should always appear below the line containing
- * the current cursor location
- * </li>
- * </ul>
- *
- * @param orientation the popup's orientation
- */
- public void setContextInformationPopupOrientation(int orientation) {
- fContextInfoPopupOrientation= orientation;
- }
-
- /**
- * Sets the context information popup's background color.
- *
- * @param background the background color
- */
- public void setContextInformationPopupBackground(Color background) {
- fContextInfoPopupBackground= background;
- }
-
- /**
- * Returns the background of the context information popup.
- *
- * @return the background of the context information popup
- * @since 2.0
- */
- Color getContextInformationPopupBackground() {
- return fContextInfoPopupBackground;
- }
-
- /**
- * Sets the context information popup's foreground color.
- *
- * @param foreground the foreground color
- * @since 2.0
- */
- public void setContextInformationPopupForeground(Color foreground) {
- fContextInfoPopupForeground= foreground;
- }
-
- /**
- * Returns the foreground of the context information popup.
- *
- * @return the foreground of the context information popup
- * @since 2.0
- */
- Color getContextInformationPopupForeground() {
- return fContextInfoPopupForeground;
- }
-
- /**
- * Sets the proposal selector's background color.
- *
- * @param background the background color
- * @since 2.0
- */
- public void setProposalSelectorBackground(Color background) {
- fProposalSelectorBackground= background;
- }
-
- /**
- * Returns the background of the proposal selector.
- *
- * @return the background of the proposal selector
- * @since 2.0
- */
- Color getProposalSelectorBackground() {
- return fProposalSelectorBackground;
- }
-
- /**
- * Sets the proposal's foreground color.
- *
- * @param foreground the foreground color
- * @since 2.0
- */
- public void setProposalSelectorForeground(Color foreground) {
- fProposalSelectorForeground= foreground;
- }
-
- /**
- * Returns the foreground of the proposal selector.
- *
- * @return the foreground of the proposal selector
- * @since 2.0
- */
- Color getProposalSelectorForeground() {
- return fProposalSelectorForeground;
- }
-
- /**
- * Sets the context selector's background color.
- *
- * @param background the background color
- * @since 2.0
- */
- public void setContextSelectorBackground(Color background) {
- fContextSelectorBackground= background;
- }
-
- /**
- * Returns the background of the context selector.
- *
- * @return the background of the context selector
- * @since 2.0
- */
- Color getContextSelectorBackground() {
- return fContextSelectorBackground;
- }
-
- /**
- * Sets the context selector's foreground color.
- *
- * @param foreground the foreground color
- * @since 2.0
- */
- public void setContextSelectorForeground(Color foreground) {
- fContextSelectorForeground= foreground;
- }
-
- /**
- * Returns the foreground of the context selector.
- *
- * @return the foreground of the context selector
- * @since 2.0
- */
- Color getContextSelectorForeground() {
- return fContextSelectorForeground;
- }
-
- /**
- * Sets the information control creator for the additional information control.
- *
- * @param creator the information control creator for the additional information control
- * @since 2.0
- */
- public void setInformationControlCreator(IInformationControlCreator creator) {
- fInformationControlCreator= creator;
- }
-
- /*
- * @see IContentAssist#install
- */
- public void install(ITextViewer textViewer) {
- Assert.isNotNull(textViewer);
-
- fViewer= textViewer;
-
- fLayoutManager= new LayoutManager();
- fInternalListener= new InternalListener();
-
- AdditionalInfoController2 controller= null;
- if (fInformationControlCreator != null) {
- int delay= fAutoActivationDelay;
- if (delay == 0)
- delay= DEFAULT_AUTO_ACTIVATION_DELAY;
- delay= Math.round(delay * 1.5f);
- controller= new AdditionalInfoController2(fInformationControlCreator, delay);
- }
- fContextInfoPopup= new ContextInformationPopup2(this, fViewer);
- fProposalPopup= new CompletionProposalPopup2(this, fViewer, controller);
-
- manageAutoActivation(fIsAutoActivated);
- }
-
- /*
- * @see IContentAssist#uninstall
- */
- public void uninstall() {
-
- if (fProposalPopup != null)
- fProposalPopup.hide();
-
- if (fContextInfoPopup != null)
- fContextInfoPopup.hide();
-
- manageAutoActivation(false);
-
- if (fCloser != null) {
- fCloser.uninstall();
- fCloser= null;
- }
-
- fViewer= null;
- }
-
- /**
- * Adds the given shell of the specified type to the layout.
- * Valid types are defined by <code>LayoutManager</code>.
- *
- * @param popup a content assist popup
- * @param shell the shell of the content-assist popup
- * @param type the type of popup
- * @param visibleOffset the offset at which to layout the popup relative to the offset of the viewer's visible region
- * @since 2.0
- */
- void addToLayout(Object popup, Shell shell, int type, int visibleOffset) {
- fLayoutManager.add(popup, shell, type, visibleOffset);
- }
-
- /**
- * Layouts the registered popup of the given type relative to the
- * given offset. The offset is relative to the offset of the viewer's visible region.
- * Valid types are defined by <code>LayoutManager</code>.
- *
- * @param type the type of popup to layout
- * @param visibleOffset the offset at which to layout relative to the offset of the viewer's visible region
- * @since 2.0
- */
- void layout(int type, int visibleOffset) {
- fLayoutManager.layout(type, visibleOffset);
- }
-
- /**
- * Notifies the controller that a popup has lost focus.
- *
- * @param e the focus event
- */
- void popupFocusLost(FocusEvent e) {
- fCloser.focusLost(e);
- }
-
- /**
- * Returns the offset of the selection relative to the offset of the visible region.
- *
- * @return the offset of the selection relative to the offset of the visible region
- * @since 2.0
- */
- int getSelectionOffset() {
- StyledText text= fViewer.getTextWidget();
- return text.getSelectionRange().x;
- }
-
- /**
- * Returns whether the widget token could be acquired.
- * The following are valid listener types:
- * <ul>
- * <li>AUTO_ASSIST
- * <li>CONTEXT_SELECTOR
- * <li>PROPOSAL_SELECTOR
- * <li>CONTEXT_INFO_POPUP
- * <ul>
- * @param type the listener type for which to acquire
- * @return <code>true</code> if the widget token could be acquired
- * @since 2.0
- */
- private boolean acquireWidgetToken(int type) {
- switch (type) {
- case CONTEXT_SELECTOR:
- case PROPOSAL_SELECTOR:
- if (fViewer instanceof IWidgetTokenOwner) {
- IWidgetTokenOwner owner= (IWidgetTokenOwner) fViewer;
- return owner.requestWidgetToken(this);
- } else if (fViewer instanceof IWidgetTokenOwnerExtension) {
- IWidgetTokenOwnerExtension extension= (IWidgetTokenOwnerExtension) fViewer;
- return extension.requestWidgetToken(this, WIDGET_PRIORITY);
- }
- }
- return true;
- }
-
- /**
- * Registers a content assist listener.
- * The following are valid listener types:
- * <ul>
- * <li>AUTO_ASSIST
- * <li>CONTEXT_SELECTOR
- * <li>PROPOSAL_SELECTOR
- * <li>CONTEXT_INFO_POPUP
- * <ul>
- * Returns whether the listener could be added successfully. A listener
- * can not be added if the widget token could not be acquired.
- *
- * @param listener the listener to register
- * @param type the type of listener
- * @return <code>true</code> if the listener could be added
- */
- boolean addContentAssistListener(IContentAssistListener2 listener, int type) {
-
- if (acquireWidgetToken(type)) {
-
- fListeners[type]= listener;
-
- if (getNumberOfListeners() == 1) {
- fCloser= new Closer();
- fCloser.install();
- fViewer.setEventConsumer(fInternalListener);
- installKeyListener();
- }
- return true;
- }
-
- return false;
- }
-
- /**
- * Installs a key listener on the text viewer's widget.
- */
- private void installKeyListener() {
- if (!fKeyListenerHooked) {
- StyledText text= fViewer.getTextWidget();
- if (Helper2.okToUse(text)) {
-
- if (fViewer instanceof ITextViewerExtension) {
- ITextViewerExtension e= (ITextViewerExtension) fViewer;
- e.prependVerifyKeyListener(fInternalListener);
- } else {
- text.addVerifyKeyListener(fInternalListener);
- }
-
- fKeyListenerHooked= true;
- }
- }
- }
-
- /**
- * Releases the previously acquired widget token if the token
- * is no longer necessary.
- * The following are valid listener types:
- * <ul>
- * <li>AUTO_ASSIST
- * <li>CONTEXT_SELECTOR
- * <li>PROPOSAL_SELECTOR
- * <li>CONTEXT_INFO_POPUP
- * <ul>
- *
- * @param type the listener type
- * @since 2.0
- */
- private void releaseWidgetToken(int type) {
- if (fListeners[CONTEXT_SELECTOR] == null && fListeners[PROPOSAL_SELECTOR] == null) {
- if (fViewer instanceof IWidgetTokenOwner) {
- IWidgetTokenOwner owner= (IWidgetTokenOwner) fViewer;
- owner.releaseWidgetToken(this);
- }
- }
- }
-
- /**
- * Unregisters a content assist listener.
- *
- * @param listener the listener to unregister
- * @param type the type of listener
- *
- * @see #addContentAssistListener
- */
- void removeContentAssistListener(IContentAssistListener2 listener, int type) {
- fListeners[type]= null;
-
- if (getNumberOfListeners() == 0) {
-
- if (fCloser != null) {
- fCloser.uninstall();
- fCloser= null;
- }
-
- uninstallKeyListener();
- fViewer.setEventConsumer(null);
- }
-
- releaseWidgetToken(type);
- }
-
- /**
- * Uninstall the key listener from the text viewer's widget.
- */
- private void uninstallKeyListener() {
- if (fKeyListenerHooked) {
- StyledText text= fViewer.getTextWidget();
- if (Helper2.okToUse(text)) {
-
- if (fViewer instanceof ITextViewerExtension) {
- ITextViewerExtension e= (ITextViewerExtension) fViewer;
- e.removeVerifyKeyListener(fInternalListener);
- } else {
- text.removeVerifyKeyListener(fInternalListener);
- }
-
- fKeyListenerHooked= false;
- }
- }
- }
-
- /**
- * Returns the number of listeners.
- *
- * @return the number of listeners
- * @since 2.0
- */
- private int getNumberOfListeners() {
- int count= 0;
- for (int i= 0; i <= CONTEXT_INFO_POPUP; i++) {
- if (fListeners[i] != null)
- ++ count;
- }
- return count;
- }
-
- /*
- * @see IContentAssist#showPossibleCompletions
- */
- public String showPossibleCompletions() {
- return fProposalPopup.showProposals(false);
- }
-
- /**
- * Hides the proposal popup.
- */
- public void hidePossibleCompletions() {
- if (fProposalPopup != null)
- fProposalPopup.hide();
- }
-
- /**
- * Callback to signal this content assistant that the presentation of the possible completions has been stopped.
- * @since 2.1
- */
- protected void possibleCompletionsClosed() {
- }
-
- /*
- * @see IContentAssist#showContextInformation
- */
- public String showContextInformation() {
- return fContextInfoPopup.showContextProposals(false);
- }
-
-
- /**
- * Callback to signal this content assistant that the presentation of the context information has been stopped.
- * @since 2.1
- */
- protected void contextInformationClosed() {
- }
-
- /**
- * Requests that the specified context information to be shown.
- *
- * @param contextInformation the context information to be shown
- * @param position the position to which the context information refers to
- * @since 2.0
- */
- void showContextInformation(IContextInformation contextInformation, int position) {
- fContextInfoPopup.showContextInformation(contextInformation, position);
- }
-
- /**
- * Returns the current content assist error message.
- *
- * @return an error message or <code>null</code> if no error has occurred
- */
- String getErrorMessage() {
- return fLastErrorMessage;
- }
-
- /**
- * Returns the content assist processor for the content
- * type of the specified document position.
- *
- * @param textViewer the text viewer
- * @param offset a offset within the document
- * @return a content-assist processor or <code>null</code> if none exists
- */
- private IContentAssistProcessor getProcessor(ITextViewer viewer, int offset) {
- try {
- String type= TextUtilities.getContentType(viewer.getDocument(), getDocumentPartitioning(), offset, true);
- return getContentAssistProcessor(type);
- } catch (BadLocationException x) {
- }
- return null;
- }
-
- /**
- * Returns an array of completion proposals computed based on
- * the specified document position. The position is used to
- * determine the appropriate content assist processor to invoke.
- *
- * @param viewer the viewer for which to compute the prosposals
- * @param position a document position
- * @return an array of completion proposals
- *
- * @see IContentAssistProcessor#computeCompletionProposals
- */
- ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int position) {
- if (fProposals != null) {
- return fProposals;
- } else if (fProposalStrings != null) {
- ICompletionProposal[] result= new ICompletionProposal[fProposalStrings.length];
- for (int i= 0; i < fProposalStrings.length; i++) {
- result[i]= new CompletionProposal(fProposalStrings[i], position, fProposalStrings[i].length(), fProposalStrings[i].length());
- }
- return result;
- } else return null;
- }
-
- /**
- * Returns an array of context information objects computed based
- * on the specified document position. The position is used to determine
- * the appropriate content assist processor to invoke.
- *
- * @param viewer the viewer for which to compute the context information
- * @param position a document position
- * @return an array of context information objects
- *
- * @see IContentAssistProcessor#computeContextInformation
- */
- IContextInformation[] computeContextInformation(ITextViewer viewer, int position) {
- fLastErrorMessage= null;
-
- IContextInformation[] result= null;
-
- IContentAssistProcessor p= getProcessor(viewer, position);
- if (p != null) {
- result= p.computeContextInformation(viewer, position);
- fLastErrorMessage= p.getErrorMessage();
- }
-
- return result;
- }
-
- /**
- * Returns the context information validator that should be used to
- * determine when the currently displayed context information should
- * be dismissed. The position is used to determine the appropriate
- * content assist processor to invoke.
- *
- * @param textViewer the text viewer
- * @param offset a document offset
- * @return an validator
- *
- * @see IContentAssistProcessor#getContextInformationValidator
- */
- IContextInformationValidator getContextInformationValidator(ITextViewer textViewer, int offset) {
- IContentAssistProcessor p= getProcessor(textViewer, offset);
- return p != null ? p.getContextInformationValidator() : null;
- }
-
- /**
- * Returns the context information presenter that should be used to
- * display context information. The position is used to determine the appropriate
- * content assist processor to invoke.
- *
- * @param textViewer the text viewer
- * @param offset a document offset
- * @return a presenter
- * @since 2.0
- */
- IContextInformationPresenter getContextInformationPresenter(ITextViewer textViewer, int offset) {
- IContextInformationValidator validator= getContextInformationValidator(textViewer, offset);
- if (validator instanceof IContextInformationPresenter)
- return (IContextInformationPresenter) validator;
- return null;
- }
-
- /**
- * Returns the characters which when typed by the user should automatically
- * initiate proposing completions. The position is used to determine the
- * appropriate content assist processor to invoke.
- *
- * @param textViewer the text viewer
- * @param offset a document offset
- * @return the auto activation characters
- *
- * @see IContentAssistProcessor#getCompletionProposalAutoActivationCharacters
- */
- private char[] getCompletionProposalAutoActivationCharacters(ITextViewer textViewer, int offset) {
- IContentAssistProcessor p= getProcessor(textViewer, offset);
- return p != null ? p.getCompletionProposalAutoActivationCharacters() : null;
- }
-
- /**
- * Returns the characters which when typed by the user should automatically
- * initiate the presentation of context information. The position is used
- * to determine the appropriate content assist processor to invoke.
- *
- * @param textViewer the text viewer
- * @param offset a document offset
- * @return the auto activation characters
- *
- * @see IContentAssistProcessor#getContextInformationAutoActivationCharacters
- */
- private char[] getContextInformationAutoActivationCharacters(ITextViewer textViewer, int offset) {
- IContentAssistProcessor p= getProcessor(textViewer, offset);
- return p != null ? p.getContextInformationAutoActivationCharacters() : null;
- }
-
- /*
- * @see org.eclipse.jface.text.IWidgetTokenKeeper#requestWidgetToken(IWidgetTokenOwner)
- * @since 2.0
- */
- public boolean requestWidgetToken(IWidgetTokenOwner owner) {
- hidePossibleCompletions();
- return true;
- }
-
- /**
- * @param completionPosition
- */
- public void setCompletionPosition(int completionPosition) {
- fCompletionPosition= completionPosition;
- }
-
- /**
- * @return the completion position
- */
- public int getCompletionPosition() {
- return fCompletionPosition;
- }
-
- /**
- * @param proposals
- */
- public void setCompletions(String[] proposals) {
- fProposalStrings= proposals;
- }
-
- /**
- * @param proposals
- */
- public void setCompletions(ICompletionProposal[] proposals) {
- fProposals= proposals;
- }
-
- /*
- * @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) {
- hidePossibleCompletions();
- return true;
- } else
- return false;
- }
-
- /*
- * @see org.eclipse.jface.text.IWidgetTokenKeeperExtension#setFocus(org.eclipse.jface.text.IWidgetTokenOwner)
- * @since 3.0
- */
- public boolean setFocus(IWidgetTokenOwner owner) {
- if (fProposalPopup != null) {
- fProposalPopup.setFocus();
- return fProposalPopup.hasFocus();
- }
- return false;
- }
-
- /**
- * Returns whether any popups controlled by the receiver have the input focus.
- *
- * @return <code>true</code> if any of the managed popups have the focus, <code>false</code> otherwise
- */
- public boolean hasFocus() {
- return (fProposalPopup != null && fProposalPopup.hasFocus())
- || (fContextInfoPopup != null && fContextInfoPopup.hasFocus());
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistantExtension#completePrefix()
- */
- public String completePrefix() {
- // TODO Auto-generated method stub
- return null;
- }
-
- /**
- * @param proposal
- */
- public void fireProposalChosen(ICompletionProposal proposal) {
- List list= new ArrayList(fProposalListeners);
- for (Iterator it= list.iterator(); it.hasNext();) {
- IProposalListener listener= (IProposalListener) it.next();
- listener.proposalChosen(proposal);
- }
-
- }
-
- /**
- * @param listener
- */
- public void removeProposalListener(IProposalListener listener) {
- fProposalListeners.remove(listener);
- }
-
- /**
- * @param listener
- */
- public void addProposalListener(IProposalListener listener) {
- fProposalListeners.add(listener);
- }
-}
-
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContextInformationPopup2.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContextInformationPopup2.java
deleted file mode 100644
index 5b1dea55c..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContextInformationPopup2.java
+++ /dev/null
@@ -1,629 +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.internal.text.link.contentassist;
-
-
-import java.util.Stack;
-
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.TextPresentation;
-import org.eclipse.jface.text.contentassist.IContextInformation;
-import org.eclipse.jface.text.contentassist.IContextInformationExtension;
-import org.eclipse.jface.text.contentassist.IContextInformationPresenter;
-import org.eclipse.jface.text.contentassist.IContextInformationValidator;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.events.VerifyEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-
-
-/**
- * This class is used to present context information to the user.
- * If multiple contexts are valid at the current cursor location,
- * a list is presented from which the user may choose one context.
- * Once the user makes their choice, or if there was only a single
- * possible context, the context information is shown in a tooltip like popup. <p>
- * If the tooltip is visible and the user wants to see context information of
- * a context embedded into the one for which context information is displayed,
- * context information for the embedded context is shown. As soon as the
- * cursor leaves the embedded context area, the context information for
- * the embedding context is shown again.
- *
- * @see IContextInformation
- * @see IContextInformationValidator
- */
-class ContextInformationPopup2 implements IContentAssistListener2 {
-
-
-
- /**
- * Represents the state necessary for embedding contexts.
- * @since 2.0
- */
- static class ContextFrame {
- public int fBeginOffset;
- public int fOffset;
- public int fVisibleOffset;
- public IContextInformation fInformation;
- public IContextInformationValidator fValidator;
- public IContextInformationPresenter fPresenter;
- }
-
- private ITextViewer fViewer;
- private ContentAssistant2 fContentAssistant;
-
- private PopupCloser2 fPopupCloser= new PopupCloser2();
- private Shell fContextSelectorShell;
- private Table fContextSelectorTable;
- private IContextInformation[] fContextSelectorInput;
- private String fLineDelimiter= null;
-
- private Shell fContextInfoPopup;
- private StyledText fContextInfoText;
- private TextPresentation fTextPresentation;
-
- private Stack fContextFrameStack= new Stack();
-
-
- /**
- * Creates a new context information popup.
- *
- * @param contentAssistant the content assist for computing the context information
- * @param viewer the viewer on top of which the context information is shown
- */
- public ContextInformationPopup2(ContentAssistant2 contentAssistant, ITextViewer viewer) {
- fContentAssistant= contentAssistant;
- fViewer= viewer;
- }
-
- /**
- * Shows all possible contexts for the given cursor position of the viewer.
- *
- * @param autoActivated <code>true</code> if auto activated
- * @return a potential error message or <code>null</code> in case of no error
- */
- public String showContextProposals(final boolean autoActivated) {
- final StyledText styledText= fViewer.getTextWidget();
- BusyIndicator.showWhile(styledText.getDisplay(), new Runnable() {
- public void run() {
-
- int position= fViewer.getSelectedRange().x;
-
- IContextInformation[] contexts= computeContextInformation(position);
- int count = (contexts == null ? 0 : contexts.length);
- if (count == 1) {
-
- // Show context information directly
- internalShowContextInfo(contexts[0], position);
-
- } else if (count > 0) {
- // Precise context must be selected
-
- if (fLineDelimiter == null)
- fLineDelimiter= styledText.getLineDelimiter();
-
- createContextSelector();
- setContexts(contexts);
- displayContextSelector();
- hideContextInfoPopup();
-
- } else if (!autoActivated) {
- styledText.getDisplay().beep();
- }
- }
- });
-
- return getErrorMessage();
- }
-
- /**
- * Displays the given context information for the given offset.
- *
- * @param info the context information
- * @param position the offset
- * @since 2.0
- */
- public void showContextInformation(final IContextInformation info, final int position) {
- Control control= fViewer.getTextWidget();
- BusyIndicator.showWhile(control.getDisplay(), new Runnable() {
- public void run() {
- internalShowContextInfo(info, position);
- hideContextSelector();
- }
- });
- }
-
- /**
- * Displays the given context information for the given offset.
- *
- * @param info the context information
- * @param position the offset
- * @since 2.0
- */
-
- private void internalShowContextInfo(IContextInformation information, int offset) {
-
- IContextInformationValidator validator= fContentAssistant.getContextInformationValidator(fViewer, offset);
-
- if (validator != null) {
- ContextFrame current= new ContextFrame();
- current.fInformation= information;
- current.fBeginOffset= (information instanceof IContextInformationExtension) ? ((IContextInformationExtension) information).getContextInformationPosition() : offset;
- if (current.fBeginOffset == -1) current.fBeginOffset= offset;
- current.fOffset= offset;
- current.fVisibleOffset= fViewer.getTextWidget().getSelectionRange().x - (offset - current.fBeginOffset);
- current.fValidator= validator;
- current.fPresenter= fContentAssistant.getContextInformationPresenter(fViewer, offset);
-
- fContextFrameStack.push(current);
-
- internalShowContextFrame(current, fContextFrameStack.size() == 1);
- }
- }
-
- /**
- * Shows the given context frame.
- *
- * @param frame the frane to display
- * @param initial <code>true</code> if this is the first frame to be displayed
- * @since 2.0
- */
- private void internalShowContextFrame(ContextFrame frame, boolean initial) {
-
- frame.fValidator.install(frame.fInformation, fViewer, frame.fOffset);
-
- if (frame.fPresenter != null) {
- if (fTextPresentation == null)
- fTextPresentation= new TextPresentation();
- frame.fPresenter.install(frame.fInformation, fViewer, frame.fBeginOffset);
- frame.fPresenter.updatePresentation(frame.fOffset, fTextPresentation);
- }
-
- createContextInfoPopup();
-
- fContextInfoText.setText(frame.fInformation.getInformationDisplayString());
- if (fTextPresentation != null)
- TextPresentation.applyTextPresentation(fTextPresentation, fContextInfoText);
- resize();
-
- if (initial) {
- if (fContentAssistant.addContentAssistListener(this, ContentAssistant2.CONTEXT_INFO_POPUP)) {
- fContentAssistant.addToLayout(this, fContextInfoPopup, ContentAssistant2.LayoutManager.LAYOUT_CONTEXT_INFO_POPUP, frame.fVisibleOffset);
- fContextInfoPopup.setVisible(true);
- }
- } else {
- fContentAssistant.layout(ContentAssistant2.LayoutManager.LAYOUT_CONTEXT_INFO_POPUP, frame.fVisibleOffset);
- }
- }
-
- /**
- * Computes all possible context information for the given offset.
- *
- * @param position the offset
- * @return all possible context information for the given offset
- * @since 2.0
- */
- private IContextInformation[] computeContextInformation(int position) {
- return fContentAssistant.computeContextInformation(fViewer, position);
- }
-
- /**
- *Returns the error message generated while computing context information.
- *
- * @return the error message
- */
- private String getErrorMessage() {
- return fContentAssistant.getErrorMessage();
- }
-
- /**
- * Creates the context information popup. This is the tooltip like overlay window.
- */
- private void createContextInfoPopup() {
- if (Helper2.okToUse(fContextInfoPopup))
- return;
-
- Control control= fViewer.getTextWidget();
- Display display= control.getDisplay();
-
- fContextInfoPopup= new Shell(control.getShell(), SWT.NO_TRIM | SWT.ON_TOP);
- fContextInfoPopup.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
-
- fContextInfoText= new StyledText(fContextInfoPopup, SWT.MULTI | SWT.READ_ONLY);
-
- Color c= fContentAssistant.getContextInformationPopupBackground();
- if (c == null)
- c= display.getSystemColor(SWT.COLOR_INFO_BACKGROUND);
- fContextInfoText.setBackground(c);
-
- c= fContentAssistant.getContextInformationPopupForeground();
- if (c == null)
- c= display.getSystemColor(SWT.COLOR_INFO_FOREGROUND);
- fContextInfoText.setForeground(c);
- }
-
- /**
- * Resizes the context information popup.
- * @since 2.0
- */
- private void resize() {
- Point size= fContextInfoText.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
- size.x += 3;
- fContextInfoText.setSize(size);
- fContextInfoText.setLocation(1,1);
- size.x += 2;
- size.y += 2;
- fContextInfoPopup.setSize(size);
- }
-
- /**
- *Hides the context information popup.
- */
- private void hideContextInfoPopup() {
-
- if (Helper2.okToUse(fContextInfoPopup)) {
-
- int size= fContextFrameStack.size();
- if (size > 0) {
- fContextFrameStack.pop();
- -- size;
- }
-
- if (size > 0) {
- ContextFrame current= (ContextFrame) fContextFrameStack.peek();
- internalShowContextFrame(current, false);
- } else {
-
- fContentAssistant.removeContentAssistListener(this, ContentAssistant2.CONTEXT_INFO_POPUP);
-
- fContextInfoPopup.setVisible(false);
- fContextInfoPopup.dispose();
- fContextInfoPopup= null;
-
- if (fTextPresentation != null) {
- fTextPresentation.clear();
- fTextPresentation= null;
- }
- }
- }
-
- if (fContextInfoPopup == null)
- fContentAssistant.contextInformationClosed();
- }
-
- /**
- * Creates the context selector in case the user has the choice between multiple valid contexts
- * at a given offset.
- */
- private void createContextSelector() {
- if (Helper2.okToUse(fContextSelectorShell))
- return;
-
- Control control= fViewer.getTextWidget();
- fContextSelectorShell= new Shell(control.getShell(), SWT.NO_TRIM | SWT.ON_TOP);
- fContextSelectorTable= new Table(fContextSelectorShell, SWT.H_SCROLL | SWT.V_SCROLL);
-
- int height= fContextSelectorTable.getItemHeight() * 10;
- fContextSelectorShell.setSize(302, height + 2);
- fContextSelectorTable.setSize(300, height);
- fContextSelectorTable.setLocation(1, 1);
-
- fContextSelectorShell.setBackground(control.getDisplay().getSystemColor(SWT.COLOR_BLACK));
-
- Color c= fContentAssistant.getContextSelectorBackground();
- if (c == null)
- c= control.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND);
- fContextSelectorTable.setBackground(c);
-
- c= fContentAssistant.getContextSelectorForeground();
- if (c == null)
- c= control.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND);
- fContextSelectorTable.setForeground(c);
-
- fContextSelectorTable.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- insertSelectedContext();
- hideContextSelector();
- }
- });
-
- fPopupCloser.install(fContentAssistant, fContextSelectorTable);
-
- fContextSelectorTable.setHeaderVisible(false);
- fContentAssistant.addToLayout(this, fContextSelectorShell, ContentAssistant2.LayoutManager.LAYOUT_CONTEXT_SELECTOR, fContentAssistant.getSelectionOffset());
- }
-
- /**
- * Causes the context information of the context selected in the context selector
- * to be displayed in the context information popup.
- */
- private void insertSelectedContext() {
- int i= fContextSelectorTable.getSelectionIndex();
-
- if (i < 0 || i >= fContextSelectorInput.length)
- return;
-
- int position= fViewer.getSelectedRange().x;
- internalShowContextInfo(fContextSelectorInput[i], position);
- }
-
- /**
- * Sets the contexts in the context selector to the given set.
- *
- * @param contexts the possible contexts
- */
- private void setContexts(IContextInformation[] contexts) {
- if (Helper2.okToUse(fContextSelectorTable)) {
-
- fContextSelectorInput= contexts;
-
- fContextSelectorTable.setRedraw(false);
- fContextSelectorTable.removeAll();
-
- TableItem item;
- IContextInformation t;
- for (int i= 0; i < contexts.length; i++) {
- t= contexts[i];
- item= new TableItem(fContextSelectorTable, SWT.NULL);
- if (t.getImage() != null)
- item.setImage(t.getImage());
- item.setText(t.getContextDisplayString());
- }
-
- fContextSelectorTable.select(0);
- fContextSelectorTable.setRedraw(true);
- }
- }
-
- /**
- * Displays the context selector.
- */
- private void displayContextSelector() {
- if (fContentAssistant.addContentAssistListener(this, ContentAssistant2.CONTEXT_SELECTOR))
- fContextSelectorShell.setVisible(true);
- }
-
- /**
- * Hodes the context selector.
- */
- private void hideContextSelector() {
- if (Helper2.okToUse(fContextSelectorShell)) {
- fContentAssistant.removeContentAssistListener(this, ContentAssistant2.CONTEXT_SELECTOR);
-
- fPopupCloser.uninstall();
- fContextSelectorShell.setVisible(false);
- fContextSelectorShell.dispose();
- fContextSelectorShell= null;
- }
-
- if (!Helper2.okToUse(fContextInfoPopup))
- fContentAssistant.contextInformationClosed();
- }
-
- /**
- *Returns whether the context selector has the focus.
- *
- * @return <code>true</code> if teh context selector has the focus
- */
- public boolean hasFocus() {
- if (Helper2.okToUse(fContextSelectorShell))
- return (fContextSelectorShell.isFocusControl() || fContextSelectorTable.isFocusControl());
-
- return false;
- }
-
- /**
- * Hides context selector and context information popup.
- */
- public void hide() {
- hideContextSelector();
- hideContextInfoPopup();
- }
-
- /**
- * Returns whether this context information popup is active. I.e., either
- * a context selector or context information is displayed.
- *
- * @return <code>true</code> if the context selector is active
- */
- public boolean isActive() {
- return (Helper2.okToUse(fContextInfoPopup) || Helper2.okToUse(fContextSelectorShell));
- }
-
- /*
- * @see IContentAssistListener#verifyKey(VerifyEvent)
- */
- public boolean verifyKey(VerifyEvent e) {
- if (Helper2.okToUse(fContextSelectorShell))
- return contextSelectorKeyPressed(e);
- if (Helper2.okToUse(fContextInfoPopup))
- return contextInfoPopupKeyPressed(e);
- return true;
- }
-
- /**
- * Processes a key stroke in the context selector.
- *
- * @param e the verify event describing the key stroke
- * @return <code>true</code> if processing can be stopped
- */
- private boolean contextSelectorKeyPressed(VerifyEvent e) {
-
- char key= e.character;
- if (key == 0) {
-
- int change;
- int visibleRows= (fContextSelectorTable.getSize().y / fContextSelectorTable.getItemHeight()) - 1;
- int selection= fContextSelectorTable.getSelectionIndex();
-
- switch (e.keyCode) {
-
- case SWT.ARROW_UP:
- change= (fContextSelectorTable.getSelectionIndex() > 0 ? -1 : 0);
- break;
-
- case SWT.ARROW_DOWN:
- change= (fContextSelectorTable.getSelectionIndex() < fContextSelectorTable.getItemCount() - 1 ? 1 : 0);
- break;
-
- case SWT.PAGE_DOWN :
- change= visibleRows;
- if (selection + change >= fContextSelectorTable.getItemCount())
- change= fContextSelectorTable.getItemCount() - selection;
- break;
-
- case SWT.PAGE_UP :
- change= -visibleRows;
- if (selection + change < 0)
- change= -selection;
- break;
-
- case SWT.HOME :
- change= -selection;
- break;
-
- case SWT.END :
- change= fContextSelectorTable.getItemCount() - selection;
- break;
-
- default:
- if (e.keyCode != SWT.MOD1 && e.keyCode != SWT.MOD2 && e.keyCode != SWT.MOD3 && e.keyCode != SWT.MOD4)
- hideContextSelector();
- return true;
- }
-
- fContextSelectorTable.setSelection(selection + change);
- fContextSelectorTable.showSelection();
- e.doit= false;
- return false;
-
- } else if ('\t' == key) {
- // switch focus to selector shell
- e.doit= false;
- fContextSelectorShell.setFocus();
- return false;
- } else if (key == 0x1B) {
- // terminate on Esc
- hideContextSelector();
- }
-
- return true;
- }
-
- /**
- * Processes a key stroke while the info popup is up.
- *
- * @param e the verify event describing the key stroke
- * @return <code>true</code> if processing can be stopped
- */
- private boolean contextInfoPopupKeyPressed(KeyEvent e) {
-
- char key= e.character;
- if (key == 0) {
-
- switch (e.keyCode) {
-
- case SWT.ARROW_LEFT:
- case SWT.ARROW_RIGHT:
- validateContextInformation();
- break;
- default:
- if (e.keyCode != SWT.MOD1 && e.keyCode != SWT.MOD2 && e.keyCode != SWT.MOD3 && e.keyCode != SWT.MOD4)
- hideContextInfoPopup();
- break;
- }
-
- } else if (key == 0x1B) {
- // terminate on Esc
- hideContextInfoPopup();
- } else {
- validateContextInformation();
- }
- return true;
- }
-
- /*
- * @see IEventConsumer#processEvent(VerifyEvent)
- */
- public void processEvent(VerifyEvent event) {
- if (Helper2.okToUse(fContextSelectorShell))
- contextSelectorProcessEvent(event);
- if (Helper2.okToUse(fContextInfoPopup))
- contextInfoPopupProcessEvent(event);
- }
-
- /**
- * Processes a key stroke in the context selector.
- *
- * @param e the verify event describing the key stroke
- */
- private void contextSelectorProcessEvent(VerifyEvent e) {
-
- if (e.start == e.end && e.text != null && e.text.equals(fLineDelimiter)) {
- e.doit= false;
- insertSelectedContext();
- }
-
- hideContextSelector();
- }
-
- /**
- * Processes a key stroke while the info popup is up.
- *
- * @param e the verify event describing the key stroke
- */
- private void contextInfoPopupProcessEvent(VerifyEvent e) {
- if (e.start != e.end && (e.text == null || e.text.length() == 0))
- validateContextInformation();
- }
-
- /**
- * Validates the context information for the viewer's actual cursor position.
- */
- private void validateContextInformation() {
- /*
- * Post the code in the event queue in order to ensure that the
- * action described by this verify key event has already beed executed.
- * Otherwise, we'd validate the context information based on the
- * pre-key-stroke state.
- */
- fContextInfoPopup.getDisplay().asyncExec(new Runnable() {
-
- private ContextFrame fFrame= (ContextFrame) fContextFrameStack.peek();
-
- public void run() {
- if (Helper2.okToUse(fContextInfoPopup) && fFrame == fContextFrameStack.peek()) {
- int offset= fViewer.getSelectedRange().x;
- if (fFrame.fValidator == null || !fFrame.fValidator.isContextInformationValid(offset)) {
- hideContextInfoPopup();
- } else if (fFrame.fPresenter != null && fFrame.fPresenter.updatePresentation(offset, fTextPresentation)) {
- TextPresentation.applyTextPresentation(fTextPresentation, fContextInfoText);
- resize();
- }
- }
- }
- });
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/HTML2TextReader.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/HTML2TextReader.java
deleted file mode 100644
index d22f786ee..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/HTML2TextReader.java
+++ /dev/null
@@ -1,302 +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.internal.text.link.contentassist;
-
-
-
-
-import java.io.IOException;
-import java.io.PushbackReader;
-import java.io.Reader;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyleRange;
-
-import org.eclipse.jface.text.TextPresentation;
-
-
-/**
- * Reads the text contents from a reader of HTML contents and translates
- * the tags or cut them out.
- */
-class HTML2TextReader extends SubstitutionTextReader {
-
- private static final String EMPTY_STRING= ""; //$NON-NLS-1$
- private static final Map fgEntityLookup;
- private static final Set fgTags;
-
- static {
-
- fgTags= new HashSet();
- fgTags.add("b"); //$NON-NLS-1$
- fgTags.add("br"); //$NON-NLS-1$
- fgTags.add("h5"); //$NON-NLS-1$
- fgTags.add("p"); //$NON-NLS-1$
- fgTags.add("dl"); //$NON-NLS-1$
- fgTags.add("dt"); //$NON-NLS-1$
- fgTags.add("dd"); //$NON-NLS-1$
- fgTags.add("li"); //$NON-NLS-1$
- fgTags.add("ul"); //$NON-NLS-1$
- fgTags.add("pre"); //$NON-NLS-1$
-
- fgEntityLookup= new HashMap(7);
- fgEntityLookup.put("lt", "<"); //$NON-NLS-1$ //$NON-NLS-2$
- fgEntityLookup.put("gt", ">"); //$NON-NLS-1$ //$NON-NLS-2$
- fgEntityLookup.put("nbsp", " "); //$NON-NLS-1$ //$NON-NLS-2$
- fgEntityLookup.put("amp", "&"); //$NON-NLS-1$ //$NON-NLS-2$
- fgEntityLookup.put("circ", "^"); //$NON-NLS-1$ //$NON-NLS-2$
- fgEntityLookup.put("tilde", "~"); //$NON-NLS-2$ //$NON-NLS-1$
- fgEntityLookup.put("quot", "\""); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- private int fCounter= 0;
- private TextPresentation fTextPresentation;
- private int fBold= 0;
- private int fStartOffset= -1;
- private boolean fInParagraph= false;
- private boolean fIsPreformattedText= false;
-
- /**
- * Transforms the HTML text from the reader to formatted text.
- *
- * @param reader the reader
- * @param presentation If not <code>null</code>, formattings will be applied to
- * the presentation.
- */
- public HTML2TextReader(Reader reader, TextPresentation presentation) {
- super(new PushbackReader(reader));
- fTextPresentation= presentation;
- }
-
- public int read() throws IOException {
- int c= super.read();
- if (c != -1)
- ++ fCounter;
- return c;
- }
-
- protected void startBold() {
- if (fBold == 0)
- fStartOffset= fCounter;
- ++ fBold;
- }
-
- protected void startPreformattedText() {
- fIsPreformattedText= true;
- setSkipWhitespace(false);
- }
-
- protected void stopPreformattedText() {
- fIsPreformattedText= false;
- setSkipWhitespace(true);
- }
-
- protected void stopBold() {
- -- fBold;
- if (fBold == 0) {
- if (fTextPresentation != null) {
- fTextPresentation.addStyleRange(new StyleRange(fStartOffset, fCounter - fStartOffset, null, null, SWT.BOLD));
- }
- fStartOffset= -1;
- }
- }
-
- /*
- * @see org.eclipse.jdt.internal.ui.text.SubstitutionTextReader#computeSubstitution(int)
- */
- protected String computeSubstitution(int c) throws IOException {
-
- if (c == '<')
- return processHTMLTag();
- else if (c == '&')
- return processEntity();
- else if (fIsPreformattedText)
- return processPreformattedText(c);
-
- return null;
- }
-
- private String html2Text(String html) {
-
- if (html == null || html.length() == 0)
- return EMPTY_STRING;
-
- String tag= html;
- if ('/' == tag.charAt(0))
- tag= tag.substring(1);
-
- if (!fgTags.contains(tag))
- return EMPTY_STRING;
-
-
- if ("pre".equals(html)) { //$NON-NLS-1$
- startPreformattedText();
- return EMPTY_STRING;
- }
-
- if ("/pre".equals(html)) { //$NON-NLS-1$
- stopPreformattedText();
- return EMPTY_STRING;
- }
-
- if (fIsPreformattedText)
- return EMPTY_STRING;
-
- if ("b".equals(html)) { //$NON-NLS-1$
- startBold();
- return EMPTY_STRING;
- }
-
- if ("h5".equals(html) || "dt".equals(html)) { //$NON-NLS-1$ //$NON-NLS-2$
- startBold();
- return EMPTY_STRING;
- }
-
- if ("dl".equals(html)) //$NON-NLS-1$
- return LINE_DELIM;
-
- if ("dd".equals(html)) //$NON-NLS-1$
- return "\t"; //$NON-NLS-1$
-
- if ("li".equals(html)) //$NON-NLS-1$
- return LINE_DELIM + ContentAssistMessages.getString("HTML2TextReader.listItemPrefix"); //$NON-NLS-1$ //$NON-NLS-2$
-
- if ("/b".equals(html)) { //$NON-NLS-1$
- stopBold();
- return EMPTY_STRING;
- }
-
- if ("p".equals(html)) { //$NON-NLS-1$
- fInParagraph= true;
- return LINE_DELIM;
- }
-
- if ("br".equals(html)) //$NON-NLS-1$
- return LINE_DELIM;
-
- if ("/p".equals(html)) { //$NON-NLS-1$
- boolean inParagraph= fInParagraph;
- fInParagraph= false;
- return inParagraph ? EMPTY_STRING : LINE_DELIM;
- }
-
- if ("/h5".equals(html) || "/dt".equals(html)) { //$NON-NLS-1$ //$NON-NLS-2$
- stopBold();
- return LINE_DELIM;
- }
-
- if ("/dd".equals(html)) //$NON-NLS-1$
- return LINE_DELIM;
-
- return EMPTY_STRING;
- }
-
- /*
- * A '<' has been read. Process a HTML tag
- */
- private String processHTMLTag() throws IOException {
-
- StringBuffer buf= new StringBuffer();
- int ch;
- do {
-
- ch= nextChar();
-
- while (ch != -1 && ch != '>') {
- buf.append(Character.toLowerCase((char) ch));
- ch= nextChar();
- if (ch == '"'){
- buf.append(Character.toLowerCase((char) ch));
- ch= nextChar();
- while (ch != -1 && ch != '"'){
- buf.append(Character.toLowerCase((char) ch));
- ch= nextChar();
- }
- }
- if (ch == '<'){
- unread(ch);
- return '<' + buf.toString();
- }
- }
-
- if (ch == -1)
- return null;
-
- int tagLen= buf.length();
- // needs special treatment for comments
- if ((tagLen >= 3 && "!--".equals(buf.substring(0, 3))) //$NON-NLS-1$
- && !(tagLen >= 5 && "--!".equals(buf.substring(tagLen - 3)))) { //$NON-NLS-1$
- // unfinished comment
- buf.append(ch);
- } else {
- break;
- }
- } while (true);
-
- return html2Text(buf.toString());
- }
-
- private String processPreformattedText(int c) {
- if (c == '\r' || c == '\n')
- fCounter++;
- return null;
- }
-
-
- private void unread(int ch) throws IOException {
- ((PushbackReader) getReader()).unread(ch);
- }
-
- protected String entity2Text(String symbol) {
- if (symbol.length() > 1 && symbol.charAt(0) == '#') {
- int ch;
- try {
- if (symbol.charAt(1) == 'x') {
- ch= Integer.parseInt(symbol.substring(2), 16);
- } else {
- ch= Integer.parseInt(symbol.substring(1), 10);
- }
- return EMPTY_STRING + (char)ch;
- } catch (NumberFormatException e) {
- }
- } else {
- String str= (String) fgEntityLookup.get(symbol);
- if (str != null) {
- return str;
- }
- }
- return "&" + symbol; // not found //$NON-NLS-1$
- }
-
- /*
- * A '&' has been read. Process a entity
- */
- private String processEntity() throws IOException {
- StringBuffer buf= new StringBuffer();
- int ch= nextChar();
- while (Character.isLetterOrDigit((char)ch) || ch == '#') {
- buf.append((char) ch);
- ch= nextChar();
- }
-
- if (ch == ';')
- return entity2Text(buf.toString());
-
- buf.insert(0, '&');
- if (ch != -1)
- buf.append((char) ch);
- return buf.toString();
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/HTMLTextPresenter.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/HTMLTextPresenter.java
deleted file mode 100644
index 3591392f5..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/HTMLTextPresenter.java
+++ /dev/null
@@ -1,191 +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.internal.text.link.contentassist;
-
-
-
-import java.io.IOException;
-import java.io.Reader;
-import java.io.StringReader;
-import java.util.Iterator;
-
-import org.eclipse.swt.custom.StyleRange;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.widgets.Display;
-
-import org.eclipse.jface.text.DefaultInformationControl;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextPresentation;
-
-
-
-class HTMLTextPresenter implements DefaultInformationControl.IInformationPresenter {
-
- private static final String LINE_DELIM= System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
-
- private int fCounter;
- private boolean fEnforceUpperLineLimit;
-
- public HTMLTextPresenter(boolean enforceUpperLineLimit) {
- super();
- fEnforceUpperLineLimit= enforceUpperLineLimit;
- }
-
- public HTMLTextPresenter() {
- this(true);
- }
-
- protected Reader createReader(String hoverInfo, TextPresentation presentation) {
- return new HTML2TextReader(new StringReader(hoverInfo), presentation);
- }
-
- protected void adaptTextPresentation(TextPresentation presentation, int offset, int insertLength) {
-
- int yoursStart= offset;
- int yoursEnd= offset + insertLength -1;
- yoursEnd= Math.max(yoursStart, yoursEnd);
-
- Iterator e= presentation.getAllStyleRangeIterator();
- while (e.hasNext()) {
-
- StyleRange range= (StyleRange) e.next();
-
- int myStart= range.start;
- int myEnd= range.start + range.length -1;
- myEnd= Math.max(myStart, myEnd);
-
- if (myEnd < yoursStart)
- continue;
-
- if (myStart < yoursStart)
- range.length += insertLength;
- else
- range.start += insertLength;
- }
- }
-
- private void append(StringBuffer buffer, String string, TextPresentation presentation) {
-
- int length= string.length();
- buffer.append(string);
-
- if (presentation != null)
- adaptTextPresentation(presentation, fCounter, length);
-
- fCounter += length;
- }
-
- private String getIndent(String line) {
- int length= line.length();
-
- int i= 0;
- while (i < length && Character.isWhitespace(line.charAt(i))) ++i;
-
- return (i == length ? line : line.substring(0, i)) + " "; //$NON-NLS-1$
- }
-
- /*
- * @see IHoverInformationPresenter#updatePresentation(Display display, String, TextPresentation, int, int)
- */
- public String updatePresentation(Display display, String hoverInfo, TextPresentation presentation, int maxWidth, int maxHeight) {
-
- if (hoverInfo == null)
- return null;
-
- GC gc= new GC(display);
- try {
-
- StringBuffer buffer= new StringBuffer();
- int maxNumberOfLines= Math.round(maxHeight / gc.getFontMetrics().getHeight());
-
- fCounter= 0;
- LineBreakingReader reader= new LineBreakingReader(createReader(hoverInfo, presentation), gc, maxWidth);
-
- boolean lastLineFormatted= false;
- String lastLineIndent= null;
-
- String line=reader.readLine();
- boolean lineFormatted= reader.isFormattedLine();
- boolean firstLineProcessed= false;
-
- while (line != null) {
-
- if (fEnforceUpperLineLimit && maxNumberOfLines <= 0)
- break;
-
- if (firstLineProcessed) {
- if (!lastLineFormatted)
- append(buffer, LINE_DELIM, null);
- else {
- append(buffer, LINE_DELIM, presentation);
- if (lastLineIndent != null)
- append(buffer, lastLineIndent, presentation);
- }
- }
-
- append(buffer, line, null);
- firstLineProcessed= true;
-
- lastLineFormatted= lineFormatted;
- if (!lineFormatted)
- lastLineIndent= null;
- else if (lastLineIndent == null)
- lastLineIndent= getIndent(line);
-
- line= reader.readLine();
- lineFormatted= reader.isFormattedLine();
-
- maxNumberOfLines--;
- }
-
- if (line != null) {
- append(buffer, LINE_DELIM, lineFormatted ? presentation : null);
- append(buffer, ContentAssistMessages.getString("HTMLTextPresenter.ellipse"), presentation); //$NON-NLS-1$
- }
-
- return trim(buffer, presentation);
-
- } catch (IOException e) {
-
- // ignore TODO do something else?
- return null;
-
- } finally {
- gc.dispose();
- }
- }
-
- private String trim(StringBuffer buffer, TextPresentation presentation) {
-
- int length= buffer.length();
-
- int end= length -1;
- while (end >= 0 && Character.isWhitespace(buffer.charAt(end)))
- -- end;
-
- if (end == -1)
- return ""; //$NON-NLS-1$
-
- if (end < length -1)
- buffer.delete(end + 1, length);
- else
- end= length;
-
- int start= 0;
- while (start < end && Character.isWhitespace(buffer.charAt(start)))
- ++ start;
-
- buffer.delete(0, start);
- presentation.setResultWindow(new Region(start, buffer.length()));
- return buffer.toString();
- }
-}
-
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/Helper2.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/Helper2.java
deleted file mode 100644
index 463c395fb..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/Helper2.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.internal.text.link.contentassist;
-
-
-
-import org.eclipse.swt.widgets.Widget;
-
-
-/**
- * Helper class for testing widget state.
- */
-class Helper2 {
-
- /**
- * Returns whether the widget is <code>null</code> or disposed.
- *
- * @param widget the widget to check
- * @return <code>true</code> if the widget is neither <code>null</code> nor disposed
- */
- public static boolean okToUse(Widget widget) {
- return (widget != null && !widget.isDisposed());
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/IContentAssistListener2.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/IContentAssistListener2.java
deleted file mode 100644
index f8041937c..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/IContentAssistListener2.java
+++ /dev/null
@@ -1,35 +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.internal.text.link.contentassist;
-
-
-
-import org.eclipse.swt.events.VerifyEvent;
-
-import org.eclipse.jface.text.IEventConsumer;
-
-
-
-/**
- * An interface whereby listeners can not only receive key events,
- * but can also consume them to prevent subsequent listeners from
- * processing the event.
- */
-interface IContentAssistListener2 extends IEventConsumer {
-
- /**
- * Verifies the key event.
- *
- * @return <code>true</code> if processing should be continued by additional listeners
- * @see org.eclipse.swt.custom.VerifyKeyListener#verifyKey(VerifyEvent)
- */
- public boolean verifyKey(VerifyEvent event);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/IProposalListener.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/IProposalListener.java
deleted file mode 100644
index 1e4924dc9..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/IProposalListener.java
+++ /dev/null
@@ -1,26 +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.internal.text.link.contentassist;
-
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-
-
-/**
- *
- */
-public interface IProposalListener {
-
- /**
- * @param proposal
- */
- void proposalChosen(ICompletionProposal proposal);
-
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/LineBreakingReader.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/LineBreakingReader.java
deleted file mode 100644
index 100a2d4f2..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/LineBreakingReader.java
+++ /dev/null
@@ -1,114 +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.internal.text.link.contentassist;
-
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.Reader;
-
-import java.text.BreakIterator;
-import org.eclipse.swt.graphics.GC;
-
-/*
- * Not a real reader. Could change if requested
- */
-class LineBreakingReader {
-
- private BufferedReader fReader;
- private GC fGC;
- private int fMaxWidth;
-
- private String fLine;
- private int fOffset;
-
- private BreakIterator fLineBreakIterator;
-
- /**
- * Creates a reader that breaks an input text to fit in a given width.
- * @param reader Reader of the input text
- * @param gc The graphic context that defines the currently used font sizes
- * @param maxLineWidth The max width (pixes) where the text has to fit in
- */
- public LineBreakingReader(Reader reader, GC gc, int maxLineWidth) {
- fReader= new BufferedReader(reader);
- fGC= gc;
- fMaxWidth= maxLineWidth;
- fOffset= 0;
- fLine= null;
- fLineBreakIterator= BreakIterator.getLineInstance();
- }
-
- public boolean isFormattedLine() {
- return fLine != null;
- }
-
- /**
- * Reads the next line. The lengths of the line will not exceed the gived maximum
- * width.
- */
- public String readLine() throws IOException {
- if (fLine == null) {
- String line= fReader.readLine();
- if (line == null)
- return null;
-
- int lineLen= fGC.textExtent(line).x;
- if (lineLen < fMaxWidth) {
- return line;
- }
- fLine= line;
- fLineBreakIterator.setText(line);
- fOffset= 0;
- }
- int breakOffset= findNextBreakOffset(fOffset);
- String res;
- if (breakOffset != BreakIterator.DONE) {
- res= fLine.substring(fOffset, breakOffset);
- fOffset= findWordBegin(breakOffset);
- if (fOffset == fLine.length()) {
- fLine= null;
- }
- } else {
- res= fLine.substring(fOffset);
- fLine= null;
- }
- return res;
- }
-
- private int findNextBreakOffset(int currOffset) {
- int currWidth= 0;
- int nextOffset= fLineBreakIterator.following(currOffset);
- while (nextOffset != BreakIterator.DONE) {
- String word= fLine.substring(currOffset, nextOffset);
- int wordWidth= fGC.textExtent(word).x;
- int nextWidth= wordWidth + currWidth;
- if (nextWidth > fMaxWidth) {
- if (currWidth > 0) {
- return currOffset;
- } else {
- return nextOffset;
- }
- }
- currWidth= nextWidth;
- currOffset= nextOffset;
- nextOffset= fLineBreakIterator.next();
- }
- return nextOffset;
- }
-
- private int findWordBegin(int idx) {
- while (idx < fLine.length() && Character.isWhitespace(fLine.charAt(idx))) {
- idx++;
- }
- return idx;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/PopupCloser2.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/PopupCloser2.java
deleted file mode 100644
index 842ab23c1..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/PopupCloser2.java
+++ /dev/null
@@ -1,100 +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.internal.text.link.contentassist;
-
-
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.ScrollBar;
-import org.eclipse.swt.widgets.Table;
-
-
-/**
- * A generic closer class used to monitor various
- * interface events in order to determine whether
- * a content assistant should be terminated and all
- * associated windows be closed.
- */
-class PopupCloser2 implements FocusListener, SelectionListener {
-
- /** The content assistant to be monitored */
- private ContentAssistant2 fContentAssistant;
- /** The table of a selector popup opened by the content assistant */
- private Table fTable;
- /** The scrollbar of the table for the selector popup */
- private ScrollBar fScrollbar;
- /** Indicates whether the scrollbar thumb has been grabed */
- private boolean fScrollbarClicked= false;
-
- /**
- * Installs this closer on the given table opened by the given content assistant.
- *
- * @param contentAssistant the content assistant
- * @param table the table to be tracked
- */
- public void install(ContentAssistant2 contentAssistant, Table table) {
- fContentAssistant= contentAssistant;
- fTable= table;
- if (Helper2.okToUse(fTable)) {
- fTable.addFocusListener(this);
- fScrollbar= fTable.getVerticalBar();
- if (fScrollbar != null)
- fScrollbar.addSelectionListener(this);
- }
- }
-
- /**
- * Uninstalls this closer if previously installed.
- */
- public void uninstall() {
- if (Helper2.okToUse(fScrollbar))
- fScrollbar.removeSelectionListener(this);
- if (Helper2.okToUse(fTable))
- fTable.removeFocusListener(this);
- }
-
- /*
- * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
- */
- public void widgetSelected(SelectionEvent e) {
- fScrollbarClicked= true;
- }
-
- /*
- * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
- */
- public void widgetDefaultSelected(SelectionEvent e) {
- fScrollbarClicked= true;
- }
-
- /*
- * @see org.eclipse.swt.events.FocusListener#focusGained(org.eclipse.swt.events.FocusEvent)
- */
- public void focusGained(FocusEvent e) {
- }
-
- /*
- * @see org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt.events.FocusEvent)
- */
- public void focusLost(final FocusEvent e) {
- fScrollbarClicked= false;
- Display d= fTable.getDisplay();
- d.asyncExec(new Runnable() {
- public void run() {
- if (Helper2.okToUse(fTable) && !fTable.isFocusControl() && !fScrollbarClicked)
- fContentAssistant.popupFocusLost(e);
- }
- });
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/SingleCharReader.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/SingleCharReader.java
deleted file mode 100644
index 0ed727148..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/SingleCharReader.java
+++ /dev/null
@@ -1,61 +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.internal.text.link.contentassist;
-
-
-import java.io.IOException;
-import java.io.Reader;
-
-abstract class SingleCharReader extends Reader {
-
- /**
- * @see Reader#read()
- */
- public abstract int read() throws IOException;
-
- /**
- * @see Reader#read(char[],int,int)
- */
- public int read(char cbuf[], int off, int len) throws IOException {
- int end= off + len;
- for (int i= off; i < end; i++) {
- int ch= read();
- if (ch == -1) {
- if (i == off) {
- return -1;
- } else {
- return i - off;
- }
- }
- cbuf[i]= (char)ch;
- }
- return len;
- }
-
- /**
- * @see Reader#ready()
- */
- public boolean ready() throws IOException {
- return true;
- }
-
- /**
- * Gets the content as a String
- */
- public String getString() throws IOException {
- StringBuffer buf= new StringBuffer();
- int ch;
- while ((ch= read()) != -1) {
- buf.append((char)ch);
- }
- return buf.toString();
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/SubstitutionTextReader.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/SubstitutionTextReader.java
deleted file mode 100644
index 3a129d371..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/SubstitutionTextReader.java
+++ /dev/null
@@ -1,151 +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.internal.text.link.contentassist;
-
-
-import java.io.IOException;
-import java.io.Reader;
-
-
-/**
- * Reads the text contents from a reader and computes for each character
- * a potential substitution. The substitution may eat more characters than
- * only the one passed into the computation routine.
- */
-abstract class SubstitutionTextReader extends SingleCharReader {
-
- protected static final String LINE_DELIM= System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
-
- private Reader fReader;
- private boolean fWasWhiteSpace;
- private int fCharAfterWhiteSpace;
-
- /**
- * Tells whether white space characters are skipped.
- */
- private boolean fSkipWhiteSpace= true;
-
- private boolean fReadFromBuffer;
- private StringBuffer fBuffer;
- private int fIndex;
-
-
- protected SubstitutionTextReader(Reader reader) {
- fReader= reader;
- fBuffer= new StringBuffer();
- fIndex= 0;
- fReadFromBuffer= false;
- fCharAfterWhiteSpace= -1;
- fWasWhiteSpace= true;
- }
-
- /**
- * Implement to compute the substitution for the given character and
- * if necessary subsequent characters. Use <code>nextChar</code>
- * to read subsequent characters.
- */
- protected abstract String computeSubstitution(int c) throws IOException;
-
- /**
- * Returns the internal reader.
- */
- protected Reader getReader() {
- return fReader;
- }
-
- /**
- * Returns the next character.
- */
- protected int nextChar() throws IOException {
- fReadFromBuffer= (fBuffer.length() > 0);
- if (fReadFromBuffer) {
- char ch= fBuffer.charAt(fIndex++);
- if (fIndex >= fBuffer.length()) {
- fBuffer.setLength(0);
- fIndex= 0;
- }
- return ch;
- } else {
- int ch= fCharAfterWhiteSpace;
- if (ch == -1) {
- ch= fReader.read();
- }
- if (fSkipWhiteSpace && Character.isWhitespace((char)ch)) {
- do {
- ch= fReader.read();
- } while (Character.isWhitespace((char)ch));
- if (ch != -1) {
- fCharAfterWhiteSpace= ch;
- return ' ';
- }
- } else {
- fCharAfterWhiteSpace= -1;
- }
- return ch;
- }
- }
-
- /**
- * @see Reader#read()
- */
- public int read() throws IOException {
- int c;
- do {
-
- c= nextChar();
- while (!fReadFromBuffer) {
- String s= computeSubstitution(c);
- if (s == null)
- break;
- if (s.length() > 0)
- fBuffer.insert(0, s);
- c= nextChar();
- }
-
- } while (fSkipWhiteSpace && fWasWhiteSpace && (c == ' '));
- fWasWhiteSpace= (c == ' ' || c == '\r' || c == '\n');
- return c;
- }
-
- /**
- * @see Reader#ready()
- */
- public boolean ready() throws IOException {
- return fReader.ready();
- }
-
- /**
- * @see Reader#close()
- */
- public void close() throws IOException {
- fReader.close();
- }
-
- /**
- * @see Reader#reset()
- */
- public void reset() throws IOException {
- fReader.reset();
- fWasWhiteSpace= true;
- fCharAfterWhiteSpace= -1;
- fBuffer.setLength(0);
- fIndex= 0;
- }
-
- protected final void setSkipWhitespace(boolean state) {
- fSkipWhiteSpace= state;
- }
-
- protected final boolean isSkippingWhitespace() {
- return fSkipWhiteSpace;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/package.html b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/package.html
deleted file mode 100644
index 98a5bfbda..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/package.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta content="text/html; charset=iso-8859-1"
- http-equiv="Content-Type">
- <meta content="IBM" name="Author">
- name="GENERATOR">
- <title>Linked Position Infrastructure - Internal Copy of Content Assistant</title>
-</head>
-<body>
-This package is a modified copy of <code>org.eclipse.jface.text.contentassist</code> that supports the linked mode proposals.
-This package is internal and may disappear if the changes are merged with the API content assist package. Subject to change without notice.
-</body>
-</html>
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 bec