This commit was manufactured by cvs2svn to create tag 'v20040407'.
Sprout from master 2004-04-06 09:01:18 UTC Kai Maetzel <kmaetzel> 'adapter for IAnnotationAccess'
Cherrypick from master 2004-04-06 17:19:47 UTC Dani Megert <dmegert> 'Added support for override indicators - cleanup':
org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/SelectMarkerRulerAction.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ResourceAction.java
Delete:
org.eclipse.core.filebuffers/.classpath
org.eclipse.core.filebuffers/.cvsignore
org.eclipse.core.filebuffers/.project
org.eclipse.core.filebuffers/about.html
org.eclipse.core.filebuffers/build.properties
org.eclipse.core.filebuffers/hglegal2003.htm
org.eclipse.core.filebuffers/ngibmcpy2003.gif
org.eclipse.core.filebuffers/plugin.properties
org.eclipse.core.filebuffers/plugin.xml
org.eclipse.core.filebuffers/schema/documentCreation.exsd
org.eclipse.core.filebuffers/schema/documentSetup.exsd
org.eclipse.core.filebuffers/scripts/exportplugin.xml
org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/FileBuffers.java
org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IDocumentFactory.java
org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IDocumentSetupParticipant.java
org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IFileBuffer.java
org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IFileBufferListener.java
org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IFileBufferManager.java
org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/ISynchronizationContext.java
org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/ITextFileBuffer.java
org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/ITextFileBufferManager.java
org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/AbstractFileBuffer.java
org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ContainerGenerator.java
org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/DefaultDocumentFactory.java
org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ExtensionsRegistry.java
org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/FileBuffersPlugin.java
org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/JavaFileBuffer.java
org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/JavaTextFileBuffer.java
org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceFileBuffer.java
org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceTextFileBuffer.java
org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/TextFileBufferManager.java
org.eclipse.jface.text/.classpath
org.eclipse.jface.text/.cvsignore
org.eclipse.jface.text/.options
org.eclipse.jface.text/.project
org.eclipse.jface.text/about.html
org.eclipse.jface.text/build.properties
org.eclipse.jface.text/plugin.properties
org.eclipse.jface.text/plugin.xml
org.eclipse.jface.text/projection/org/eclipse/jface/text/source/OutlinerRulerColumn.java
org.eclipse.jface.text/projection/org/eclipse/jface/text/source/ProjectionAnnotation.java
org.eclipse.jface.text/projection/org/eclipse/jface/text/source/ProjectionSourceViewer.java
org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionAnnotation.java
org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionAnnotationHover.java
org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionAnnotationModel.java
org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionRulerColumn.java
org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionSupport.java
org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java
org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/SourceViewerInformationControl.java
org.eclipse.jface.text/scripts/exportplugin.xml
org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/AdditionalInfoController2.java
org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/CompletionProposalPopup2.java
org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java
org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContextInformationPopup2.java
org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/HTML2TextReader.java
org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/HTMLTextPresenter.java
org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/Helper2.java
org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/IContentAssistListener2.java
org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/IProposalListener.java
org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/JFaceTextMessages2.java
org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/LineBreakingReader.java
org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/PopupCloser2.java
org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/SingleCharReader.java
org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/SubstitutionTextReader.java
org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/package.html
org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractHoverInformationControlManager.java
org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractInformationControlManager.java
org.eclipse.jface.text/src/org/eclipse/jface/text/CursorLinePainter.java
org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultAutoIndentStrategy.java
org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultInformationControl.java
org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultTextDoubleClickStrategy.java
org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultUndoManager.java
org.eclipse.jface.text/src/org/eclipse/jface/text/DocumentAdapter.java
org.eclipse.jface.text/src/org/eclipse/jface/text/DocumentCommand.java
org.eclipse.jface.text/src/org/eclipse/jface/text/IAutoEditStrategy.java
org.eclipse.jface.text/src/org/eclipse/jface/text/IAutoIndentStrategy.java
org.eclipse.jface.text/src/org/eclipse/jface/text/IDocumentAdapter.java
org.eclipse.jface.text/src/org/eclipse/jface/text/IDocumentAdapterExtension.java
org.eclipse.jface.text/src/org/eclipse/jface/text/IEventConsumer.java
org.eclipse.jface.text/src/org/eclipse/jface/text/IFindReplaceTarget.java
org.eclipse.jface.text/src/org/eclipse/jface/text/IFindReplaceTargetExtension.java
org.eclipse.jface.text/src/org/eclipse/jface/text/IFindReplaceTargetExtension3.java
org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControl.java
org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControlCreator.java
org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControlCreatorExtension.java
org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControlExtension.java
org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControlExtension2.java
org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControlExtension3.java
org.eclipse.jface.text/src/org/eclipse/jface/text/IMarkRegionTarget.java
org.eclipse.jface.text/src/org/eclipse/jface/text/IMarkSelection.java
org.eclipse.jface.text/src/org/eclipse/jface/text/IPaintPositionManager.java
org.eclipse.jface.text/src/org/eclipse/jface/text/IPainter.java
org.eclipse.jface.text/src/org/eclipse/jface/text/IRewriteTarget.java
org.eclipse.jface.text/src/org/eclipse/jface/text/ISelectionValidator.java
org.eclipse.jface.text/src/org/eclipse/jface/text/ISynchronizable.java
org.eclipse.jface.text/src/org/eclipse/jface/text/ITextDoubleClickStrategy.java
org.eclipse.jface.text/src/org/eclipse/jface/text/ITextHover.java
org.eclipse.jface.text/src/org/eclipse/jface/text/ITextHoverExtension.java
org.eclipse.jface.text/src/org/eclipse/jface/text/ITextInputListener.java
org.eclipse.jface.text/src/org/eclipse/jface/text/ITextListener.java
org.eclipse.jface.text/src/org/eclipse/jface/text/ITextOperationTarget.java
org.eclipse.jface.text/src/org/eclipse/jface/text/ITextOperationTargetExtension.java
org.eclipse.jface.text/src/org/eclipse/jface/text/ITextPresentationListener.java
org.eclipse.jface.text/src/org/eclipse/jface/text/ITextSelection.java
org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewer.java
org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension.java
org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension2.java
org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension3.java
org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension4.java
org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension5.java
org.eclipse.jface.text/src/org/eclipse/jface/text/IUndoManager.java
org.eclipse.jface.text/src/org/eclipse/jface/text/IViewportListener.java
org.eclipse.jface.text/src/org/eclipse/jface/text/IWidgetTokenKeeper.java
org.eclipse.jface.text/src/org/eclipse/jface/text/IWidgetTokenKeeperExtension.java
org.eclipse.jface.text/src/org/eclipse/jface/text/IWidgetTokenOwner.java
org.eclipse.jface.text/src/org/eclipse/jface/text/IWidgetTokenOwnerExtension.java
org.eclipse.jface.text/src/org/eclipse/jface/text/JFaceTextMessages.java
org.eclipse.jface.text/src/org/eclipse/jface/text/JFaceTextMessages.properties
org.eclipse.jface.text/src/org/eclipse/jface/text/MarginPainter.java
org.eclipse.jface.text/src/org/eclipse/jface/text/MarkSelection.java
org.eclipse.jface.text/src/org/eclipse/jface/text/PaintManager.java
org.eclipse.jface.text/src/org/eclipse/jface/text/PropagatingFontFieldEditor.java
org.eclipse.jface.text/src/org/eclipse/jface/text/TextAttribute.java
org.eclipse.jface.text/src/org/eclipse/jface/text/TextEvent.java
org.eclipse.jface.text/src/org/eclipse/jface/text/TextPresentation.java
org.eclipse.jface.text/src/org/eclipse/jface/text/TextSelection.java
org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java
org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewerHoverManager.java
org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AbstractControlContentAssistSubjectAdapter.java
org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AdditionalInfoController.java
org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ComboContentAssistSubjectAdapter.java
org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposal.java
org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java
org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistSubjectAdapter.java
org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java
org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformation.java
org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.java
org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationValidator.java
org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/Helper.java
org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposal.java
org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposalExtension.java
org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposalExtension2.java
org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposalExtension3.java
org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistListener.java
org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistProcessor.java
org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistProcessorExtension.java
org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistSubject.java
org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistant.java
org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistantExtension.java
org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformation.java
org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformationExtension.java
org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformationPresenter.java
org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformationPresenterExtension.java
org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformationValidator.java
org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformationValidatorExtension.java
org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/JFaceTextMessages.java
org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/PopupCloser.java
org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/TextContentAssistSubjectAdapter.java
org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/images/content_assist_cue.gif
org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/images/error_small.gif
org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/package.html
org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContentFormatter.java
org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContextBasedFormattingStrategy.java
org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/FormattingContext.java
org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/FormattingContextProperties.java
org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IContentFormatter.java
org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IContentFormatterExtension.java
org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IContentFormatterExtension2.java
org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IFormattingContext.java
org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IFormattingStrategy.java
org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IFormattingStrategyExtension.java
org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/MultiPassContentFormatter.java
org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/package.html
org.eclipse.jface.text/src/org/eclipse/jface/text/information/IInformationPresenter.java
org.eclipse.jface.text/src/org/eclipse/jface/text/information/IInformationPresenterExtension.java
org.eclipse.jface.text/src/org/eclipse/jface/text/information/IInformationProvider.java
org.eclipse.jface.text/src/org/eclipse/jface/text/information/IInformationProviderExtension.java
org.eclipse.jface.text/src/org/eclipse/jface/text/information/IInformationProviderExtension2.java
org.eclipse.jface.text/src/org/eclipse/jface/text/information/InformationPresenter.java
org.eclipse.jface.text/src/org/eclipse/jface/text/information/package.html
org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedPositionAnnotations.java
org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedUIControl.java
org.eclipse.jface.text/src/org/eclipse/jface/text/link/ProposalPosition.java
org.eclipse.jface.text/src/org/eclipse/jface/text/link/TabStopIterator.java
org.eclipse.jface.text/src/org/eclipse/jface/text/link/package.html
org.eclipse.jface.text/src/org/eclipse/jface/text/package.html
org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/IPresentationDamager.java
org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/IPresentationReconciler.java
org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/IPresentationReconcilerExtension.java
org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/IPresentationRepairer.java
org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/PresentationReconciler.java
org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/package.html
org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/AbstractReconcileStep.java
org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/AbstractReconciler.java
org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/CompositeReconcilingStrategy.java
org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/DirtyRegion.java
org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/DirtyRegionQueue.java
org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/DocumentAdapter.java
org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcilableModel.java
org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcileResult.java
org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcileStep.java
org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconciler.java
org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcilerExtension.java
org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcilingStrategy.java
org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcilingStrategyExtension.java
org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/MonoReconciler.java
org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/Reconciler.java
org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/package.html
org.eclipse.jface.text/src/org/eclipse/jface/text/rules/BufferedRuleBasedScanner.java
org.eclipse.jface.text/src/org/eclipse/jface/text/rules/DefaultDamagerRepairer.java
org.eclipse.jface.text/src/org/eclipse/jface/text/rules/DefaultPartitioner.java
org.eclipse.jface.text/src/org/eclipse/jface/text/rules/EndOfLineRule.java
org.eclipse.jface.text/src/org/eclipse/jface/text/rules/ICharacterScanner.java
org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IPartitionTokenScanner.java
org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IPredicateRule.java
org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IRule.java
org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IToken.java
org.eclipse.jface.text/src/org/eclipse/jface/text/rules/ITokenScanner.java
org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IWhitespaceDetector.java
org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IWordDetector.java
org.eclipse.jface.text/src/org/eclipse/jface/text/rules/MultiLineRule.java
org.eclipse.jface.text/src/org/eclipse/jface/text/rules/NumberRule.java
org.eclipse.jface.text/src/org/eclipse/jface/text/rules/PatternRule.java
org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedDamagerRepairer.java
org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedPartitionScanner.java
org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedPartitioner.java
org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedScanner.java
org.eclipse.jface.text/src/org/eclipse/jface/text/rules/SingleLineRule.java
org.eclipse.jface.text/src/org/eclipse/jface/text/rules/Token.java
org.eclipse.jface.text/src/org/eclipse/jface/text/rules/WhitespaceRule.java
org.eclipse.jface.text/src/org/eclipse/jface/text/rules/WordPatternRule.java
org.eclipse.jface.text/src/org/eclipse/jface/text/rules/WordRule.java
org.eclipse.jface.text/src/org/eclipse/jface/text/rules/package.html
org.eclipse.jface.text/src/org/eclipse/jface/text/source/Annotation.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationBarHoverManager.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationColumn.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationEvent.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationMap.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationModel.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationModelEvent.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationPainter.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationRulerColumn.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/ChangeRulerColumn.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/CompositeRuler.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationAccess.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationAccessExtension.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationHover.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationHoverExtension.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationHoverExtension2.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationListener.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationMap.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModel.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModelExtension.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModelListener.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModelListenerExtension.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationPresentation.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/IChangeRulerColumn.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/ICharacterPairMatcher.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/ILineDiffInfo.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/ILineDiffer.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/IOverviewRuler.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/ISharedTextColors.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/ISourceViewer.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/ISourceViewerExtension.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/ISourceViewerExtension2.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/ITagHandler.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/ITagHandlerFactory.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/ITranslator.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/ITranslatorResultCollector.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRuler.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRulerColumn.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRulerExtension.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRulerInfo.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRulerInfoExtension.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/JFaceTextMessages.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineChangeHover.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberChangeRulerColumn.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberRulerColumn.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/MatchingCharacterPainter.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRuler.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRulerHoverManager.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewerConfiguration.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/TagHandlerFactory.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/VerticalRuler.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/VisualAnnotationModel.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/package.html
org.eclipse.jface.text/src/org/eclipse/jface/text/templates/ContextTypeRegistry.java
org.eclipse.jface.text/src/org/eclipse/jface/text/templates/PositionBasedCompletionProposal.java
org.eclipse.jface.text/src/org/eclipse/jface/text/templates/TemplateCompletionProcessor.java
org.eclipse.jface.text/src/org/eclipse/jface/text/templates/TemplateProposal.java
org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateMessages.java
org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateMessages.properties
org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplatePersistenceData.java
org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateReaderWriter.java
org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateSet.java
org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateStore.java
org.eclipse.search.tests/.classpath
org.eclipse.search.tests/.cvsignore
org.eclipse.search.tests/.project
org.eclipse.search.tests/.template
org.eclipse.search.tests/build.properties
org.eclipse.search.tests/plugin.xml
org.eclipse.search.tests/src/org/eclipse/search/core/tests/AllSearchModelTests.java
org.eclipse.search.tests/src/org/eclipse/search/core/tests/LongQuery.java
org.eclipse.search.tests/src/org/eclipse/search/core/tests/NullQuery.java
org.eclipse.search.tests/src/org/eclipse/search/core/tests/NullSearchResult.java
org.eclipse.search.tests/src/org/eclipse/search/core/tests/QueryManagerTest.java
org.eclipse.search.tests/src/org/eclipse/search/core/tests/TestSearchResult.java
org.eclipse.search.tests/src/org/eclipse/search/tests/AllSearchTests.java
org.eclipse.search.tests/src/org/eclipse/search/tests/SearchTestPlugin.java
org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/AllFileSearchTests.java
org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/AnnotationManagerTest.java
org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SearchResultPageTest.java
org.eclipse.search.tests/testresources/junit37-noUI-src.zip
org.eclipse.search/.classpath
org.eclipse.search/.cvsignore
org.eclipse.search/.project
org.eclipse.search/about.html
org.eclipse.search/build.properties
org.eclipse.search/buildnotes_search.html
org.eclipse.search/hglegal2003.htm
org.eclipse.search/icons/full/clcl16/flatLayout.gif
org.eclipse.search/icons/full/clcl16/hierarchicalLayout.gif
org.eclipse.search/icons/full/clcl16/search_goto.gif
org.eclipse.search/icons/full/clcl16/search_history.gif
org.eclipse.search/icons/full/clcl16/search_next.gif
org.eclipse.search/icons/full/clcl16/search_prev.gif
org.eclipse.search/icons/full/clcl16/search_rem.gif
org.eclipse.search/icons/full/clcl16/search_remall.gif
org.eclipse.search/icons/full/clcl16/search_sortmatch.gif
org.eclipse.search/icons/full/clcl16/stop.gif
org.eclipse.search/icons/full/ctool16/search.gif
org.eclipse.search/icons/full/cview16/searchres.gif
org.eclipse.search/icons/full/dlcl16/flatLayout.gif
org.eclipse.search/icons/full/dlcl16/hierarchicalLayout.gif
org.eclipse.search/icons/full/dlcl16/search_goto.gif
org.eclipse.search/icons/full/dlcl16/search_history.gif
org.eclipse.search/icons/full/dlcl16/search_next.gif
org.eclipse.search/icons/full/dlcl16/search_prev.gif
org.eclipse.search/icons/full/dlcl16/search_rem.gif
org.eclipse.search/icons/full/dlcl16/search_remall.gif
org.eclipse.search/icons/full/dlcl16/search_sortmatch.gif
org.eclipse.search/icons/full/dlcl16/stop.gif
org.eclipse.search/icons/full/dtool16/search.gif
org.eclipse.search/icons/full/elcl16/flatLayout.gif
org.eclipse.search/icons/full/elcl16/hierarchicalLayout.gif
org.eclipse.search/icons/full/elcl16/search_goto.gif
org.eclipse.search/icons/full/elcl16/search_history.gif
org.eclipse.search/icons/full/elcl16/search_next.gif
org.eclipse.search/icons/full/elcl16/search_prev.gif
org.eclipse.search/icons/full/elcl16/search_rem.gif
org.eclipse.search/icons/full/elcl16/search_remall.gif
org.eclipse.search/icons/full/elcl16/search_sortmatch.gif
org.eclipse.search/icons/full/elcl16/stop.gif
org.eclipse.search/icons/full/etool16/search.gif
org.eclipse.search/icons/full/eview16/searchres.gif
org.eclipse.search/icons/full/obj16/searchm_obj.gif
org.eclipse.search/icons/full/obj16/tsearch_dpdn_obj.gif
org.eclipse.search/icons/full/obj16/tsearch_obj.gif
org.eclipse.search/new search/org/eclipse/search/ui/IQueryListener.java
org.eclipse.search/new search/org/eclipse/search/ui/ISearchQuery.java
org.eclipse.search/new search/org/eclipse/search/ui/ISearchResult.java
org.eclipse.search/new search/org/eclipse/search/ui/ISearchResultListener.java
org.eclipse.search/new search/org/eclipse/search/ui/ISearchResultPage.java
org.eclipse.search/new search/org/eclipse/search/ui/ISearchResultViewPart.java
org.eclipse.search/new search/org/eclipse/search/ui/NewSearchUI.java
org.eclipse.search/new search/org/eclipse/search/ui/SearchResultEvent.java
org.eclipse.search/new search/org/eclipse/search/ui/package.html
org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchResult.java
org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java
org.eclipse.search/new search/org/eclipse/search/ui/text/Match.java
org.eclipse.search/new search/org/eclipse/search/ui/text/MatchEvent.java
org.eclipse.search/new search/org/eclipse/search/ui/text/RemoveAllEvent.java
org.eclipse.search/new search/org/eclipse/search/ui/text/package.html
org.eclipse.search/new search/org/eclipse/search2/internal/ui/CancelSearchAction.java
org.eclipse.search/new search/org/eclipse/search2/internal/ui/InternalSearchUI.java
org.eclipse.search/new search/org/eclipse/search2/internal/ui/ListDialog.java
org.eclipse.search/new search/org/eclipse/search2/internal/ui/QueryManager.java
org.eclipse.search/new search/org/eclipse/search2/internal/ui/RemoveAllSearchesAction.java
org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchAgainAction.java
org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchDropDownAction.java
org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchMessages.java
org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchMessages.properties
org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchPageRegistry.java
org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchView.java
org.eclipse.search/new search/org/eclipse/search2/internal/ui/ShowSearchAction.java
org.eclipse.search/new search/org/eclipse/search2/internal/ui/ShowSearchesAction.java
org.eclipse.search/new search/org/eclipse/search2/internal/ui/ThrottlingProgressMonitor.java
org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/INavigate.java
org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/RemoveAllResultsAction.java
org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/RemoveMatchAction.java
org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/SearchResultsTableViewer.java
org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/SearchResultsTreeViewer.java
org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/SetLayoutAction.java
org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/ShowNextResultAction.java
org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/ShowPreviousResultAction.java
org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/AnnotationManager.java
org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/PositionTracker.java
org.eclipse.search/ngibmcpy2003.gif
org.eclipse.search/old_buildnotes_search_2.1.html
org.eclipse.search/old_buildnotes_search_2_0.html
org.eclipse.search/plugin.properties
org.eclipse.search/plugin.xml
org.eclipse.search/schema/searchPages.exsd
org.eclipse.search/schema/searchResultSorters.exsd
org.eclipse.search/schema/searchResultViewPages.exsd
org.eclipse.search/scripts/exportplugin.xml
org.eclipse.search/search/org/eclipse/search/internal/core/ISearchScope.java
org.eclipse.search/search/org/eclipse/search/internal/core/SearchScope.java
org.eclipse.search/search/org/eclipse/search/internal/core/text/AmountOfWorkCalculator.java
org.eclipse.search/search/org/eclipse/search/internal/core/text/FileMatchCollector.java
org.eclipse.search/search/org/eclipse/search/internal/core/text/IMatchCollector.java
org.eclipse.search/search/org/eclipse/search/internal/core/text/ITextSearchResultCollector.java
org.eclipse.search/search/org/eclipse/search/internal/core/text/MatchLocator.java
org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchEngine.java
org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchScope.java
org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchVisitor.java
org.eclipse.search/search/org/eclipse/search/internal/core/text/TypedResourceVisitor.java
org.eclipse.search/search/org/eclipse/search/internal/ui/CopyToClipboardAction.java
org.eclipse.search/search/org/eclipse/search/internal/ui/GotoMarkerAction.java
org.eclipse.search/search/org/eclipse/search/internal/ui/ISearchHelpContextIds.java
org.eclipse.search/search/org/eclipse/search/internal/ui/OpenFileSearchPageAction.java
org.eclipse.search/search/org/eclipse/search/internal/ui/OpenSearchDialogAction.java
org.eclipse.search/search/org/eclipse/search/internal/ui/RemoveAllResultsAction.java
org.eclipse.search/search/org/eclipse/search/internal/ui/RemoveAllSearchesAction.java
org.eclipse.search/search/org/eclipse/search/internal/ui/RemoveMatchAction.java
org.eclipse.search/search/org/eclipse/search/internal/ui/RemovePotentialMatchesAction.java
org.eclipse.search/search/org/eclipse/search/internal/ui/RemoveResultAction.java
org.eclipse.search/search/org/eclipse/search/internal/ui/ResourceToItemsMapper.java
org.eclipse.search/search/org/eclipse/search/internal/ui/ScopePart.java
org.eclipse.search/search/org/eclipse/search/internal/ui/Search.java
org.eclipse.search/search/org/eclipse/search/internal/ui/SearchAgainAction.java
org.eclipse.search/search/org/eclipse/search/internal/ui/SearchDialog.java
org.eclipse.search/search/org/eclipse/search/internal/ui/SearchDropDownAction.java
org.eclipse.search/search/org/eclipse/search/internal/ui/SearchManager.java
org.eclipse.search/search/org/eclipse/search/internal/ui/SearchMessages.java
org.eclipse.search/search/org/eclipse/search/internal/ui/SearchMessages.properties
org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPageDescriptor.java
org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPlugin.java
org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPluginImages.java
org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPreferencePage.java
org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultContentProvider.java
org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultLabelProvider.java
org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultView.java
org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewEntry.java
org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewEntryAdapterFactory.java
org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewer.java
org.eclipse.search/search/org/eclipse/search/internal/ui/SelectAllAction.java
org.eclipse.search/search/org/eclipse/search/internal/ui/ShowNextResultAction.java
org.eclipse.search/search/org/eclipse/search/internal/ui/ShowPreviousResultAction.java
org.eclipse.search/search/org/eclipse/search/internal/ui/ShowSearchAction.java
org.eclipse.search/search/org/eclipse/search/internal/ui/ShowSearchesAction.java
org.eclipse.search/search/org/eclipse/search/internal/ui/SortDropDownAction.java
org.eclipse.search/search/org/eclipse/search/internal/ui/SorterDescriptor.java
org.eclipse.search/search/org/eclipse/search/internal/ui/WorkInProgressPreferencePage.java
org.eclipse.search/search/org/eclipse/search/internal/ui/WorkingSetComparator.java
org.eclipse.search/search/org/eclipse/search/internal/ui/text/DelegatingLabelProvider.java
org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileContentProvider.java
org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileLabelProvider.java
org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileMatch.java
org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchDescription.java
org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchPage.java
org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchQuery.java
org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchResult.java
org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileTableContentProvider.java
org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileTreeContentProvider.java
org.eclipse.search/search/org/eclipse/search/internal/ui/text/GotoMarkerAction.java
org.eclipse.search/search/org/eclipse/search/internal/ui/text/GroupByKeyComputer.java
org.eclipse.search/search/org/eclipse/search/internal/ui/text/NameSorter.java
org.eclipse.search/search/org/eclipse/search/internal/ui/text/NewTextSearchActionGroup.java
org.eclipse.search/search/org/eclipse/search/internal/ui/text/PathSorter.java
org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceAction.java
org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceAction2.java
org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceDialog.java
org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceDialog2.java
org.eclipse.search/search/org/eclipse/search/internal/ui/text/ResourcePathSorter.java
org.eclipse.search/search/org/eclipse/search/internal/ui/text/ResourcenameSorter.java
org.eclipse.search/search/org/eclipse/search/internal/ui/text/SearchAgainConfirmationDialog.java
org.eclipse.search/search/org/eclipse/search/internal/ui/text/SortAction.java
org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchActionGroup.java
org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchOperation.java
org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchPage.java
org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchResultCollector.java
org.eclipse.search/search/org/eclipse/search/internal/ui/util/ComboFieldEditor.java
org.eclipse.search/search/org/eclipse/search/internal/ui/util/ExceptionHandler.java
org.eclipse.search/search/org/eclipse/search/internal/ui/util/ExtendedDialogWindow.java
org.eclipse.search/search/org/eclipse/search/internal/ui/util/FileLabelProvider.java
org.eclipse.search/search/org/eclipse/search/internal/ui/util/FileTypeEditor.java
org.eclipse.search/search/org/eclipse/search/internal/ui/util/ListContentProvider.java
org.eclipse.search/search/org/eclipse/search/internal/ui/util/ListDialog.java
org.eclipse.search/search/org/eclipse/search/internal/ui/util/MessageLine.java
org.eclipse.search/search/org/eclipse/search/internal/ui/util/PixelConverter.java
org.eclipse.search/search/org/eclipse/search/internal/ui/util/RowLayouter.java
org.eclipse.search/search/org/eclipse/search/internal/ui/util/SWTUtil.java
org.eclipse.search/search/org/eclipse/search/internal/ui/util/TypeFilteringDialog.java
org.eclipse.search/search/org/eclipse/search/ui/IActionGroupFactory.java
org.eclipse.search/search/org/eclipse/search/ui/IContextMenuConstants.java
org.eclipse.search/search/org/eclipse/search/ui/IContextMenuContributor.java
org.eclipse.search/search/org/eclipse/search/ui/IGroupByKeyComputer.java
org.eclipse.search/search/org/eclipse/search/ui/IReplacePage.java
org.eclipse.search/search/org/eclipse/search/ui/ISearchPage.java
org.eclipse.search/search/org/eclipse/search/ui/ISearchPageContainer.java
org.eclipse.search/search/org/eclipse/search/ui/ISearchPageScoreComputer.java
org.eclipse.search/search/org/eclipse/search/ui/ISearchResultView.java
org.eclipse.search/search/org/eclipse/search/ui/ISearchResultViewEntry.java
org.eclipse.search/search/org/eclipse/search/ui/SearchUI.java
org.eclipse.search/search/org/eclipse/search/ui/package.html
org.eclipse.text/.classpath
org.eclipse.text/.cvsignore
org.eclipse.text/.project
org.eclipse.text/about.html
org.eclipse.text/build.properties
org.eclipse.text/plugin.properties
org.eclipse.text/plugin.xml
org.eclipse.text/projection/org/eclipse/jface/text/CoordinatesTranslator.java
org.eclipse.text/projection/org/eclipse/jface/text/Fragment.java
org.eclipse.text/projection/org/eclipse/jface/text/FragmentUpdater.java
org.eclipse.text/projection/org/eclipse/jface/text/ProjectionDocument.java
org.eclipse.text/projection/org/eclipse/jface/text/ProjectionDocumentManager.java
org.eclipse.text/projection/org/eclipse/jface/text/ProjectionPosition.java
org.eclipse.text/projection/org/eclipse/jface/text/ProjectionPositionUpdater.java
org.eclipse.text/projection/org/eclipse/jface/text/ProjectionTextStore.java
org.eclipse.text/projection/org/eclipse/jface/text/projection/ChildDocument.java
org.eclipse.text/projection/org/eclipse/jface/text/projection/ChildDocumentManager.java
org.eclipse.text/projection/org/eclipse/jface/text/projection/Fragment.java
org.eclipse.text/projection/org/eclipse/jface/text/projection/FragmentUpdater.java
org.eclipse.text/projection/org/eclipse/jface/text/projection/IMinimalMapping.java
org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionDocument.java
org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionDocumentEvent.java
org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionDocumentManager.java
org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionMapping.java
org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionTextStore.java
org.eclipse.text/projection/org/eclipse/jface/text/projection/Segment.java
org.eclipse.text/projection/org/eclipse/jface/text/projection/SegmentUpdater.java
org.eclipse.text/scripts/exportplugin.xml
org.eclipse.text/src/org/eclipse/jface/text/AbstractDocument.java
org.eclipse.text/src/org/eclipse/jface/text/AbstractLineTracker.java
org.eclipse.text/src/org/eclipse/jface/text/Assert.java
org.eclipse.text/src/org/eclipse/jface/text/BadLocationException.java
org.eclipse.text/src/org/eclipse/jface/text/BadPartitioningException.java
org.eclipse.text/src/org/eclipse/jface/text/BadPositionCategoryException.java
org.eclipse.text/src/org/eclipse/jface/text/ChildDocument.java
org.eclipse.text/src/org/eclipse/jface/text/ChildDocumentManager.java
org.eclipse.text/src/org/eclipse/jface/text/ConfigurableLineTracker.java
org.eclipse.text/src/org/eclipse/jface/text/DefaultLineTracker.java
org.eclipse.text/src/org/eclipse/jface/text/DefaultPositionUpdater.java
org.eclipse.text/src/org/eclipse/jface/text/Document.java
org.eclipse.text/src/org/eclipse/jface/text/DocumentEvent.java
org.eclipse.text/src/org/eclipse/jface/text/DocumentPartitioningChangedEvent.java
org.eclipse.text/src/org/eclipse/jface/text/FindReplaceDocumentAdapter.java
org.eclipse.text/src/org/eclipse/jface/text/FindReplaceOperationCode.java
org.eclipse.text/src/org/eclipse/jface/text/GapTextStore.java
org.eclipse.text/src/org/eclipse/jface/text/IDocument.java
org.eclipse.text/src/org/eclipse/jface/text/IDocumentExtension.java
org.eclipse.text/src/org/eclipse/jface/text/IDocumentExtension2.java
org.eclipse.text/src/org/eclipse/jface/text/IDocumentExtension3.java
org.eclipse.text/src/org/eclipse/jface/text/IDocumentInformationMapping.java
org.eclipse.text/src/org/eclipse/jface/text/IDocumentInformationMappingExtension.java
org.eclipse.text/src/org/eclipse/jface/text/IDocumentListener.java
org.eclipse.text/src/org/eclipse/jface/text/IDocumentPartitioner.java
org.eclipse.text/src/org/eclipse/jface/text/IDocumentPartitionerExtension.java
org.eclipse.text/src/org/eclipse/jface/text/IDocumentPartitionerExtension2.java
org.eclipse.text/src/org/eclipse/jface/text/IDocumentPartitioningListener.java
org.eclipse.text/src/org/eclipse/jface/text/IDocumentPartitioningListenerExtension.java
org.eclipse.text/src/org/eclipse/jface/text/IDocumentPartitioningListenerExtension2.java
org.eclipse.text/src/org/eclipse/jface/text/ILineTracker.java
org.eclipse.text/src/org/eclipse/jface/text/IPositionUpdater.java
org.eclipse.text/src/org/eclipse/jface/text/IRegion.java
org.eclipse.text/src/org/eclipse/jface/text/IRepairableDocument.java
org.eclipse.text/src/org/eclipse/jface/text/ISlaveDocumentManager.java
org.eclipse.text/src/org/eclipse/jface/text/ISlaveDocumentManagerExtension.java
org.eclipse.text/src/org/eclipse/jface/text/ITextStore.java
org.eclipse.text/src/org/eclipse/jface/text/ITypedRegion.java
org.eclipse.text/src/org/eclipse/jface/text/Line.java
org.eclipse.text/src/org/eclipse/jface/text/ParentChildMapping.java
org.eclipse.text/src/org/eclipse/jface/text/Position.java
org.eclipse.text/src/org/eclipse/jface/text/Region.java
org.eclipse.text/src/org/eclipse/jface/text/SequentialRewriteTextStore.java
org.eclipse.text/src/org/eclipse/jface/text/SlaveDocumentEvent.java
org.eclipse.text/src/org/eclipse/jface/text/TextUtilities.java
org.eclipse.text/src/org/eclipse/jface/text/TypedPosition.java
org.eclipse.text/src/org/eclipse/jface/text/TypedRegion.java
org.eclipse.text/src/org/eclipse/jface/text/link/ExclusivePositionUpdater.java
org.eclipse.text/src/org/eclipse/jface/text/link/ILinkedListener.java
org.eclipse.text/src/org/eclipse/jface/text/link/InclusivePositionUpdater.java
org.eclipse.text/src/org/eclipse/jface/text/link/LinkedEnvironment.java
org.eclipse.text/src/org/eclipse/jface/text/link/LinkedManager.java
org.eclipse.text/src/org/eclipse/jface/text/link/LinkedPosition.java
org.eclipse.text/src/org/eclipse/jface/text/link/LinkedPositionGroup.java
org.eclipse.text/src/org/eclipse/jface/text/link/package.html
org.eclipse.text/src/org/eclipse/jface/text/templates/ContextType.java
org.eclipse.text/src/org/eclipse/jface/text/templates/DocumentTemplateContext.java
org.eclipse.text/src/org/eclipse/jface/text/templates/GlobalVariables.java
org.eclipse.text/src/org/eclipse/jface/text/templates/SimpleVariableResolver.java
org.eclipse.text/src/org/eclipse/jface/text/templates/Template.java
org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateBuffer.java
org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateContext.java
org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateMessages.java
org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateMessages.properties
org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateTranslator.java
org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateVariable.java
org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateVariableResolver.java
org.eclipse.text/src/org/eclipse/text/edits/CopySourceEdit.java
org.eclipse.text/src/org/eclipse/text/edits/CopyTargetEdit.java
org.eclipse.text/src/org/eclipse/text/edits/CopyingRangeMarker.java
org.eclipse.text/src/org/eclipse/text/edits/DeleteEdit.java
org.eclipse.text/src/org/eclipse/text/edits/EditDocument.java
org.eclipse.text/src/org/eclipse/text/edits/ISourceModifier.java
org.eclipse.text/src/org/eclipse/text/edits/InsertEdit.java
org.eclipse.text/src/org/eclipse/text/edits/MalformedTreeException.java
org.eclipse.text/src/org/eclipse/text/edits/Messages.properties
org.eclipse.text/src/org/eclipse/text/edits/MoveSourceEdit.java
org.eclipse.text/src/org/eclipse/text/edits/MoveTargetEdit.java
org.eclipse.text/src/org/eclipse/text/edits/MultiTextEdit.java
org.eclipse.text/src/org/eclipse/text/edits/RangeMarker.java
org.eclipse.text/src/org/eclipse/text/edits/ReplaceEdit.java
org.eclipse.text/src/org/eclipse/text/edits/TextEdit.java
org.eclipse.text/src/org/eclipse/text/edits/TextEditCopier.java
org.eclipse.text/src/org/eclipse/text/edits/TextEditGroup.java
org.eclipse.text/src/org/eclipse/text/edits/TextEditMessages.java
org.eclipse.text/src/org/eclipse/text/edits/TextEditProcessor.java
org.eclipse.text/src/org/eclipse/text/edits/TextEditVisitor.java
org.eclipse.text/src/org/eclipse/text/edits/TreeIterationInfo.java
org.eclipse.text/src/org/eclipse/text/edits/UndoCollector.java
org.eclipse.text/src/org/eclipse/text/edits/UndoEdit.java
org.eclipse.ui.examples.javaeditor/.classpath
org.eclipse.ui.examples.javaeditor/.cvsignore
org.eclipse.ui.examples.javaeditor/.project
org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaActionContributor.java
org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaAnnotationHover.java
org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaContentOutlinePage.java
org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaDocumentSetupParticipant.java
org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaEditor.java
org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaEditorExamplePlugin.java
org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaEditorMessages.java
org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaEditorMessages.properties
org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaPartitionScanner.java
org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaSourceViewerConfiguration.java
org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaTextHover.java
org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/PresentationAction.java
org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/java/JavaAutoIndentStrategy.java
org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/java/JavaCodeScanner.java
org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/java/JavaCompletionProcessor.java
org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/java/JavaDoubleClickSelector.java
org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/java/JavaEditorMessages.java
org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/javadoc/JavaDocCompletionProcessor.java
org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/javadoc/JavaDocScanner.java
org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/togglepresentation.gif
org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/util/JavaColorProvider.java
org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/util/JavaWhitespaceDetector.java
org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/util/JavaWordDetector.java
org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/ColorManager.java
org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/IXMLColorConstants.java
org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/NonRuleBasedDamagerRepairer.java
org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/TagRule.java
org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/TemplateEditor.java
org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/TemplateEditorUI.java
org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/TemplateMessages.java
org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/TemplateMessages.properties
org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/XMLConfiguration.java
org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/XMLDocumentProvider.java
org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/XMLDoubleClickStrategy.java
org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/XMLPartitionScanner.java
org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/XMLScanner.java
org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/XMLTagScanner.java
org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/XMLWhitespaceDetector.java
org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/preferences/TemplatesPreferencePage.java
org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/template/AntVariableResolver.java
org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/template/XMLCompletionProcessor.java
org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/template/XMLContextType.java
org.eclipse.ui.examples.javaeditor/about.html
org.eclipse.ui.examples.javaeditor/build.properties
org.eclipse.ui.examples.javaeditor/doc-html/hglegal.htm
org.eclipse.ui.examples.javaeditor/doc-html/hglegal2002.htm
org.eclipse.ui.examples.javaeditor/doc-html/hglegal2003.htm
org.eclipse.ui.examples.javaeditor/doc-html/ngibmcpy.gif
org.eclipse.ui.examples.javaeditor/doc-html/ngibmcpy2002.gif
org.eclipse.ui.examples.javaeditor/doc-html/ngibmcpy2003.gif
org.eclipse.ui.examples.javaeditor/doc-html/ui_javaeditor_ex.html
org.eclipse.ui.examples.javaeditor/doc-html/ui_templateeditor_ex.html
org.eclipse.ui.examples.javaeditor/icons/obj16/java.gif
org.eclipse.ui.examples.javaeditor/icons/resolver.gif
org.eclipse.ui.examples.javaeditor/icons/sample.gif
org.eclipse.ui.examples.javaeditor/icons/template.gif
org.eclipse.ui.examples.javaeditor/plugin.properties
org.eclipse.ui.examples.javaeditor/plugin.xml
org.eclipse.ui.examples.javaeditor/templates/ant.properties
org.eclipse.ui.examples.javaeditor/templates/ant.xml
diff --git a/org.eclipse.core.filebuffers/.classpath b/org.eclipse.core.filebuffers/.classpath
deleted file mode 100644
index 065ac06..0000000
--- a/org.eclipse.core.filebuffers/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/org.eclipse.core.filebuffers/.cvsignore b/org.eclipse.core.filebuffers/.cvsignore
deleted file mode 100644
index c5e82d7..0000000
--- a/org.eclipse.core.filebuffers/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
\ No newline at end of file
diff --git a/org.eclipse.core.filebuffers/.project b/org.eclipse.core.filebuffers/.project
deleted file mode 100644
index ac71d98..0000000
--- a/org.eclipse.core.filebuffers/.project
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.core.filebuffers</name>
- <comment></comment>
- <projects>
- <project>org.eclipse.core.resources</project>
- <project>org.eclipse.core.runtime.compatibility</project>
- <project>org.eclipse.text</project>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/org.eclipse.core.filebuffers/about.html b/org.eclipse.core.filebuffers/about.html
deleted file mode 100644
index 9db411a..0000000
--- a/org.eclipse.core.filebuffers/about.html
+++ /dev/null
@@ -1,30 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<html>
-<head>
-<title>About</title>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</head>
-<body lang="EN-US">
-<h2>About This Content</h2>
-
-<p>20th June, 2002</p>
-<h3>License</h3>
-<p>Eclipse.org makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
-Common Public License Version 1.0 ("CPL"). A copy of the CPL is available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>.
-For purposes of the CPL, "Program" will mean the Content.</p>
-
-<h3>Contributions</h3>
-
-<p>If this Content is licensed to you under the terms and conditions of the CPL, any Contributions, as defined in the CPL, uploaded, submitted, or otherwise
-made available to Eclipse.org, members of Eclipse.org and/or the host of Eclipse.org web site, by you that relate to such
-Content are provided under the terms and conditions of the CPL and can be made available to others under the terms of the CPL.</p>
-
-<p>If this Content is licensed to you under license terms and conditions other than the CPL ("Other License"), any modifications, enhancements and/or
-other code and/or documentation ("Modifications") uploaded, submitted, or otherwise made available to Eclipse.org, members of Eclipse.org and/or the
-host of Eclipse.org, by you that relate to such Content are provided under terms and conditions of the Other License and can be made available
-to others under the terms of the Other License. In addition, with regard to Modifications for which you are the copyright holder, you are also
-providing the Modifications under the terms and conditions of the CPL and such Modifications can be made available to others under the terms of
-the CPL.</p>
-
-</body>
-</html>
\ No newline at end of file
diff --git a/org.eclipse.core.filebuffers/build.properties b/org.eclipse.core.filebuffers/build.properties
deleted file mode 100644
index 95c07de..0000000
--- a/org.eclipse.core.filebuffers/build.properties
+++ /dev/null
@@ -1,17 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2003 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-bin.includes = plugin.properties,\
- plugin.xml,\
- *.jar,\
- about.html
-src.includes = about.html,\
- schema/
-source.filebuffers.jar = src/
diff --git a/org.eclipse.core.filebuffers/hglegal2003.htm b/org.eclipse.core.filebuffers/hglegal2003.htm
deleted file mode 100644
index 47c8540..0000000
--- a/org.eclipse.core.filebuffers/hglegal2003.htm
+++ /dev/null
@@ -1,14 +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">
- <LINK REL="stylesheet" HREF="book.css" CHARSET="ISO-8859-1" TYPE="text/css">
- <title>Legal Notices</title>
-</head>
-<body>
-
-<h3>
-<a NAME="Notices"></a>Notices</h3>
-(c) Copyright (c) 2000, 2003 IBM Corporation and others. All Rights Reserved.
-</body>
-</html>
diff --git a/org.eclipse.core.filebuffers/ngibmcpy2003.gif b/org.eclipse.core.filebuffers/ngibmcpy2003.gif
deleted file mode 100644
index c786e43..0000000
--- a/org.eclipse.core.filebuffers/ngibmcpy2003.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.core.filebuffers/plugin.properties b/org.eclipse.core.filebuffers/plugin.properties
deleted file mode 100644
index 23d210c..0000000
--- a/org.eclipse.core.filebuffers/plugin.properties
+++ /dev/null
@@ -1,15 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2003 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-pluginName= File Buffers
-providerName= Eclipse.org
-documentCreationPoint= Document Creation
-documentSetupPoint= Document Setup
-defaultDocumentFactory= Default Document Factory
diff --git a/org.eclipse.core.filebuffers/plugin.xml b/org.eclipse.core.filebuffers/plugin.xml
deleted file mode 100644
index f961a99..0000000
--- a/org.eclipse.core.filebuffers/plugin.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
-<plugin
- id="org.eclipse.core.filebuffers"
- name="%pluginName"
- version="3.0"
- provider-name="%providerName"
- class="org.eclipse.core.internal.filebuffers.FileBuffersPlugin">
-
- <runtime>
- <library name="filebuffers.jar">
- <export name="*"/>
- <packages prefixes="org.eclipse.core.filebuffers,org.eclipse.core.internal.filebuffers"/>
- </library>
- </runtime>
- <requires>
- <import plugin="org.eclipse.core.runtime.compatibility"/>
- <import plugin="org.eclipse.core.resources"/>
- <import plugin="org.eclipse.text"/>
- </requires>
-
-
- <extension-point id="documentCreation" name="%documentCreationPoint" schema="schema/documentCreation.exsd"/>
- <extension-point id="documentSetup" name="%documentSetupPoint" schema="schema/documentSetup.exsd"/>
-
- <extension
- id="DefaultDocumentFactory"
- name="%defaultDocumentFactory"
- point="org.eclipse.core.filebuffers.documentCreation">
- <factory
- extensions="*"
- class="org.eclipse.core.internal.filebuffers.DefaultDocumentFactory">
- </factory>
- </extension>
-</plugin>
diff --git a/org.eclipse.core.filebuffers/schema/documentCreation.exsd b/org.eclipse.core.filebuffers/schema/documentCreation.exsd
deleted file mode 100644
index 1d3ddc7..0000000
--- a/org.eclipse.core.filebuffers/schema/documentCreation.exsd
+++ /dev/null
@@ -1,114 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.core.filebuffers">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.eclipse.core.filebuffers" id="documentCreation" name="Document Creation"/>
- </appInfo>
- <documentation>
- This extension point is interesting for your if you want the file buffer manager to instantiate a specific document implementation for certain file extensions.
- </documentation>
- </annotation>
-
- <element name="extension">
- <complexType>
- <sequence>
- <element ref="factory"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="factory">
- <complexType>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute kind="java"/>
- </appInfo>
- </annotation>
- </attribute>
- <attribute name="extensions" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="since"/>
- </appInfo>
- <documentation>
- 3.0
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- [Enter extension point usage example here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiInfo"/>
- </appInfo>
- <documentation>
- [Enter API information here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="implementation"/>
- </appInfo>
- <documentation>
- [Enter information about supplied implementation of this extension point.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="copyright"/>
- </appInfo>
- <documentation>
- <p>
-<a href="hglegal.htm">
- <img SRC="ngibmcpy.gif"
- ALT="Copyright (c) 2000, 2003 IBM Corporation and others. All Rights Reserved."
- BORDER="0" height="14" width="324"></a>
-</p>
- </documentation>
- </annotation>
-
-</schema>
diff --git a/org.eclipse.core.filebuffers/schema/documentSetup.exsd b/org.eclipse.core.filebuffers/schema/documentSetup.exsd
deleted file mode 100644
index 1f3908d..0000000
--- a/org.eclipse.core.filebuffers/schema/documentSetup.exsd
+++ /dev/null
@@ -1,114 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.core.filebuffers">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.eclipse.core.filebuffers" id="documentSetup" name="Document Setup"/>
- </appInfo>
- <documentation>
- This extension point is interesting if you want to install specific partitioners etc. on documents created by the file buffer manager for certain file extensions.
- </documentation>
- </annotation>
-
- <element name="extension">
- <complexType>
- <sequence>
- <element ref="participant"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="participant">
- <complexType>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute kind="java"/>
- </appInfo>
- </annotation>
- </attribute>
- <attribute name="extensions" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="since"/>
- </appInfo>
- <documentation>
- 3.0
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- [Enter extension point usage example here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiInfo"/>
- </appInfo>
- <documentation>
- [Enter API information here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="implementation"/>
- </appInfo>
- <documentation>
- [Enter information about supplied implementation of this extension point.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="copyright"/>
- </appInfo>
- <documentation>
- <p>
-<a href="hglegal.htm">
- <img SRC="ngibmcpy.gif"
- ALT="Copyright (c) 2000, 2003 IBM Corporation and others. All Rights Reserved."
- BORDER="0" height="14" width="324"></a>
-</p>
- </documentation>
- </annotation>
-
-</schema>
diff --git a/org.eclipse.core.filebuffers/scripts/exportplugin.xml b/org.eclipse.core.filebuffers/scripts/exportplugin.xml
deleted file mode 100644
index 57d44f3..0000000
--- a/org.eclipse.core.filebuffers/scripts/exportplugin.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<project name="Export Text" default="export" basedir="..">
- <target name="init">
- <tstamp/>
- <property name="destdir" value="../../plugin-export" />
- <property name="plugin" value="org.eclipse.core.filebuffers" />
- <property name="version" value="_3.0.0" />
- <property name="dest" value="${destdir}/${plugin}${version}" />
- </target>
-
- <target name="build" depends="init">
- <eclipse.incrementalBuild project="${plugin}" kind="incr"/>
- </target>
-
- <target name="export" depends="build">
- <mkdir dir="${destdir}" />
- <delete dir="${dest}" />
- <mkdir dir="${dest}" />
- <jar
- jarfile="${dest}/filebuffers.jar"
- basedir="bin"
- />
- <copy file="plugin.xml" todir="${dest}"/>
- <copy file="plugin.properties" todir="${dest}"/>
- <zip zipfile="${dest}/filebufferssrc.zip">
- <fileset dir="src" />
- </zip>
- </target>
-</project>
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/FileBuffers.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/FileBuffers.java
deleted file mode 100644
index 447f95e..0000000
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/FileBuffers.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/**********************************************************************
-Copyright (c) 2000, 2003 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-
-Contributors:
- IBM Corporation - Initial implementation
-**********************************************************************/
-package org.eclipse.core.filebuffers;
-
-import java.io.File;
-
-import org.eclipse.core.internal.filebuffers.FileBuffersPlugin;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-
-/**
- * Facade for the file buffers plug-in. Provides access to the
- * text file buffer manager.
- *
- * @since 3.0
- */
-public final class FileBuffers {
-
- /**
- * Cannot be instantiated.
- */
- private FileBuffers() {
- }
-
- /**
- * Returns the text file buffer manager.
- *
- * @return the text file buffer manager
- */
- public static ITextFileBufferManager getTextFileBufferManager() {
- return FileBuffersPlugin.getDefault().getFileBufferManager();
- }
-
- /**
- * Returns the workspace file at the given location or <code>null</code> if
- * the location is not a valid location in the workspace.
- *
- * @param location the location
- * @return the workspace file at the location or <code>null</code>
- */
- public static IFile getWorkspaceFileAtLocation(IPath location) {
- IPath normalized= normalizeLocation(location);
- if (normalized.segmentCount() >= 2) {
- // @see IContainer#getFile for the required number of segments
- IWorkspaceRoot workspaceRoot= ResourcesPlugin.getWorkspace().getRoot();
- IFile file= workspaceRoot.getFile(normalized);
- if (file != null && file.exists())
- return file;
- }
- return null;
- }
-
- /**
- * Returns a copy of the given location in a normalized form.
- *
- * @param location the location to be normalized
- * @return normalized copy of location
- */
- public static IPath normalizeLocation(IPath location) {
- IWorkspaceRoot workspaceRoot= ResourcesPlugin.getWorkspace().getRoot();
- IProject[] projects= workspaceRoot.getProjects();
-
- for (int i= 0, length= projects.length; i < length; i++) {
- IPath path= projects[i].getLocation();
- if (path.isPrefixOf(location)) {
- IPath filePath= location.removeFirstSegments(path.segmentCount());
- filePath= projects[i].getFullPath().append(filePath);
- return filePath.makeAbsolute();
- }
-
- }
- return location.makeAbsolute();
- }
-
- /**
- * Returns the file in the local file system for the given location.
- * <p>
- * The location is either a full path of a workspace resource or an
- * absolute path in the local file system.
- * </p>
- *
- * @param location
- * @return
- */
- public static File getSystemFileAtLocation(IPath location) {
- if (location == null)
- return null;
-
- IFile file= getWorkspaceFileAtLocation(location);
- if (file != null) {
- IPath path= file.getLocation();
- return path.toFile();
- }
-
- return location.toFile();
- }
-}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IDocumentFactory.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IDocumentFactory.java
deleted file mode 100644
index 989ecf9..0000000
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IDocumentFactory.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**********************************************************************
-Copyright (c) 2000, 2003 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-
-Contributors:
- IBM Corporation - Initial implementation
-**********************************************************************/
-package org.eclipse.core.filebuffers;
-
-import org.eclipse.jface.text.IDocument;
-
-/**
- * Factory for text file buffer documents. Used by the text file buffer
- * manager to create the document for a new text file buffer.
- *
- * @since 3.0
- */
-public interface IDocumentFactory {
-
- /**
- * Creates and returns a new, empty document.
- *
- * @return a new, empty document
- */
- IDocument createDocument();
-}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IDocumentSetupParticipant.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IDocumentSetupParticipant.java
deleted file mode 100644
index 93a5d5a..0000000
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IDocumentSetupParticipant.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/**********************************************************************
-Copyright (c) 2000, 2003 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-
-Contributors:
- IBM Corporation - Initial implementation
-**********************************************************************/
-package org.eclipse.core.filebuffers;
-
-import org.eclipse.jface.text.IDocument;
-
-/**
- * Participates in the setup of a text file buffer document.
- *
- * @since 3.0
- */
-public interface IDocumentSetupParticipant {
-
- /**
- * Sets up the document to be ready for use by a text file buffer.
- *
- * @param document the document to be set up
- */
- void setup(IDocument document);
-}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IFileBuffer.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IFileBuffer.java
deleted file mode 100644
index 28b82b1..0000000
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IFileBuffer.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/**********************************************************************
-Copyright (c) 2000, 2003 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-
-Contributors:
- IBM Corporation - Initial implementation
-**********************************************************************/
-package org.eclipse.core.filebuffers;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-
-/**
- * A file buffer represents a file that can be edited by more than one client. Editing is
- * session oriented. This means that editing is a sequence of modification steps. The
- * start of the sequence and the end of the sequence are explicitly indicated. There are
- * no time constraints connected with the sequence of modification steps. A file buffer
- * reifies editing sessions and allows them to interleave.<p>
- * It is not specified whether simultaneous editing sessions can be owned by different
- * threads.
- *
- * @since 3.0
- */
-public interface IFileBuffer {
-
- /**
- * Returns the location of this file buffer.
- * <p>
- * The location is either a full path of a workspace resource or an
- * absolute path in the local file system.
- * </p>
- *
- * @return the location of this file buffer
- */
- IPath getLocation();
-
- /**
- * Returns whether this file buffer is synchronized with the file system. This is when
- * the file buffer's underlying file is in sync with the file system and the file buffer
- * has been initialized after the underlying files has been modified the last time.
- *
- * @return <code>true</code> if the file buffer is synchronized with the file system
- */
- boolean isSynchronized();
-
- /**
- * Reverts the contents of this file buffer to the content of its underlying file. After
- * that call successfully returned, <code>isDirty</code> returns <code>false</code> and
- * <code>isSynchronized</code> returns <code>true</code>.
- *
- * @param monitor the progress monitor
- * @throws CoreException if reading or accessing the underlying file fails
- */
- void revert(IProgressMonitor monitor) throws CoreException;
-
- /**
- * Commits this file buffer by changing the contents of th underlying file to
- * the contents of this file buffer. After that call, <code>isDirty</code>
- * returns <code>false</code> and <code>isSynchronized</code> returns
- * <code>true</code>.
- *
- * @param monitor the progress monitor
- * @param overwrite indicates whether the underlying file should be overwritten if it is not synchronized with the file system
- * @throws CoreException if writing or accessing the underlying file fails
- */
- void commit(IProgressMonitor monitor, boolean overwrite) throws CoreException;
-
- /**
- * Returns whether changes have been applied to this file buffer since initialization, or the most
- * recent <code>revert</code> or <code>commit</code> call.
- *
- * @return <code>true</code> if changes have been applied to this buffer
- */
- boolean isDirty();
-
- /**
- * Returns whether this file buffer is shared by more than one client.
- *
- * @return <code>true</code> if this file buffer is shared by more than one client
- */
- boolean isShared();
-
- /**
- * Validates the state of this file buffer and tries to bring the buffer's
- * underlying file into a state in which it can be modified. If state
- * validation is not supported this operation does nothing.
- *
- * @param monitor the progress monitor
- * @param computationContext the context in which the validation is
- * performed, e.g., a SWT shell
- * @exception CoreException if the underlying file can not be accessed to
- * it's state cannot be changed
- */
- void validateState(IProgressMonitor monitor, Object computationContext) throws CoreException;
-
- /**
- * Returns whether the state of this file buffer has been validated. If
- * state validation is not supported this method always returns <code>true</code>.
- *
- * @return <code>true</code> if the state has been validated, <code>false</code>
- * otherwise
- */
- boolean isStateValidated();
-
- /**
- * Resets state validation. If state validation is supported, <code>isStateValidated</code>
- * afterwars returns <code>false</code> unti the state is revalidated.
- */
- void resetStateValidation();
-
- /**
- * Returns the status of this file buffer. This is the result of the last operation peformed on this file buffer or
- * internally initiated by this file buffer.
- *
- * @return the status of this file buffer
- */
- IStatus getStatus();
-
- /**
- * Returns the modification stamp of the file underlying this file buffer.
- *
- * @return the modification stamp of the file underlying this file buffer
- */
- long getModificationStamp();
-}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IFileBufferListener.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IFileBufferListener.java
deleted file mode 100644
index 06f8e24..0000000
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IFileBufferListener.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/**********************************************************************
-Copyright (c) 2000, 2003 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-
-Contributors:
- IBM Corporation - Initial implementation
-**********************************************************************/
-package org.eclipse.core.filebuffers;
-
-import org.eclipse.core.runtime.IPath;
-
-/**
- * Interface for listeners of file buffer changes.
- *
- * @since 3.0
- */
-public interface IFileBufferListener {
-
- /**
- * Informs the listener about the creation of the given buffer.
- *
- * @param buffer the created file buffer
- */
- void bufferCreated(IFileBuffer buffer);
-
- /**
- * Informs the listener about the disposal of the given buffer.
- *
- * @param buffer
- */
- void bufferDisposed(IFileBuffer buffer);
-
- /**
- * Informs the listener about an upcoming replace of the contents of the given buffer.
- *
- * @param buffer the effected file buffer
- */
- void bufferContentAboutToBeReplaced(IFileBuffer buffer);
-
- /**
- * Informs the listener that the buffer of the given buffer has been replaced.
- *
- * @param buffer the effected file buffer
- */
- void bufferContentReplaced(IFileBuffer buffer);
-
- /**
- * Informs the listener about the start of a state changing operation on
- * the given buffer.
- *
- * @param buffer the effected file buffer
- */
- void stateChanging(IFileBuffer buffer);
-
- /**
- * Informs the listener that the dirty state of the given buffer changed
- * to the specified value
- *
- * @param buffer the effected file buffer
- * @param isDirty <code>true</code> if the buffer is dirty, <code>false</code> otherwise
- */
- void dirtyStateChanged(IFileBuffer buffer, boolean isDirty);
-
- /**
- * Informs the listener that the state validation changed to the specified value.
- *
- * @param buffer the effected file buffer
- * @param isStateValidated <code>true</code> if the buffer state is validated, <code>false</code> otherwise
- */
- void stateValidationChanged(IFileBuffer buffer, boolean isStateValidated);
-
- /**
- * Informs the listener that the file underlying the given file buffer has been moved to the
- * given location.
- *
- * @param buffer the effected file buffer
- * @param target the new location (not just the container)
- */
- void underlyingFileMoved(IFileBuffer buffer, IPath path);
-
- /**
- * Informs the listener that the file underlying the given file buffer has been deleted.
- *
- * @param buffer the effected file buffer
- */
- void underlyingFileDeleted(IFileBuffer buffer);
-
- /**
- * Informs the listener that a state changing operation on the given
- * file buffer failed.
- *
- * @param buffer the effected file buffer
- */
- void stateChangeFailed(IFileBuffer buffer);
-}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IFileBufferManager.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IFileBufferManager.java
deleted file mode 100644
index f0e7cae..0000000
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IFileBufferManager.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/**********************************************************************
-Copyright (c) 2000, 2003 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-
-Contributors:
- IBM Corporation - Initial implementation
-**********************************************************************/
-
-package org.eclipse.core.filebuffers;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-/**
- * A file buffer manager manages file buffers for files while the files are
- * connected to the file buffer manager. In order to connect a file to a file
- * buffer manager call <code>connect</code>. After that call has
- * successfully completed the file buffer can be obtained by <code>getFileBuffer</code>.
- * The file buffer is created on the first connect and destroyed on the last
- * disconnect. I.e. the file buffer manager keeps track of how often a file is
- * connected and returns the same file buffer to each client as long as the
- * file is connected.
- *
- * @since 3.0
- */
-public interface IFileBufferManager {
-
- /**
- * Connects the file at the given location to this manager. After that call
- * successfully completed it is guaranteed that each call to <code>getFileBuffer</code>
- * returns the same file buffer until <code>disconnect</code> is called.
- * <p>
- * The provided location is either a full path of a workspace resource or
- * an absolute path in the local file system. The file buffer manager does
- * not resolve the location of workspace resources in the case of linked
- * resources.
- * </p>
- *
- * @param location the location of the file to be connected
- * @param monitor the progress monitor
- * @throws CoreException if the file could not successfully be connected
- */
- void connect(IPath location, IProgressMonitor monitor) throws CoreException;
-
- /**
- * Disconnects the file at the given location from this manager. After that
- * call successfully completed there is no guarantee that <code>getFileBuffer</code>
- * will return a valid file buffer.
- * <p>
- * The provided location is either a full path of a workspace resource or
- * an absolute path in the local file system. The file buffer manager does
- * not resolve the location of workspace resources in the case of linked
- * resources.
- * </p>
- *
- * @param location the location of the file to be disconnected
- * @param monitor the progress monitor
- * @throws CoreException if the file could not successfully be disconnected
- */
- void disconnect(IPath location, IProgressMonitor monitor) throws CoreException;
-
- /**
- * Returns the file buffer managed for the given location or <code>null</code>
- * if there is no such file buffer.
- * <p>
- * The provided location is either a full path of a workspace resource or
- * an absolute path in the local file system. The file buffer manager does
- * not resolve the location of workspace resources in the case of linked
- * resources.
- * </p>
- *
- * @param location the location
- * @return the file buffer managed for that location or <code>null</code>
- */
- IFileBuffer getFileBuffer(IPath location);
-
- /**
- * Sets the synchronization context for this file buffer manager, i.e., for
- * all file buffers this manager manages.
- *
- * @param context the synchronization context managed by this file buffer
- * manager
- */
- void setSynchronizationContext(ISynchronizationContext context);
-
- /**
- * Requests that the synchronization context is used to synchronize the
- * given location with its file buffer. This call as no effect if there is
- * no file buffer managed for the given location.
- * <p>
- * The provided location is either a full path of a workspace resource or
- * an absolute path in the local file system. The file buffer manager does
- * not resolve the location of workspace resources in the case of linked
- * resources.
- * </p>
- *
- * @param location the location
- */
- void requestSynchronizationContext(IPath location);
-
- /**
- * No longer requests the synchronization context for the filebuffer for
- * the given location. This method has no effect if there is no file buffer
- * managed for this location.
- * <p>
- * The provided location is either a full path of a workspace resource or
- * an absolute path in the local file system. The file buffer manager does
- * not resolve the location of workspace resources in the case of linked
- * resources.
- * </p>
- *
- * @param location the location
- */
- void releaseSynchronizationContext(IPath location);
-
- /**
- * Adds the given listener to the list of file buffer listeners. After that
- * call the listener is informated about changes related to this file
- * buffer. If the listener is already registered with the file buffer, this
- * call has no effect.
- *
- * @param listener the listener to be added
- */
- void addFileBufferListener(IFileBufferListener listener);
-
- /**
- * Removes the given listener from the list of file buffer listeners. If
- * the listener is not registered with this file buffer, this call has no
- * effect.
- *
- * @param listener the listener to be removed
- */
- void removeFileBufferListener(IFileBufferListener listener);
-}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/ISynchronizationContext.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/ISynchronizationContext.java
deleted file mode 100644
index 046e9a9..0000000
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/ISynchronizationContext.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/**********************************************************************
-Copyright (c) 2000, 2003 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-
-Contributors:
- IBM Corporation - Initial implementation
-**********************************************************************/
-package org.eclipse.core.filebuffers;
-
-/**
- * Executes runnables that describe how to synchronize a file buffer with its underlying file.
- *
- * @since 3.0
- */
-public interface ISynchronizationContext {
-
- /**
- * Executes the given runnable.
- *
- * @param runnable the runnable to be executed
- */
- void run(Runnable runnable);
-}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/ITextFileBuffer.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/ITextFileBuffer.java
deleted file mode 100644
index 60da3a8..0000000
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/ITextFileBuffer.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**********************************************************************
-Copyright (c) 2000, 2003 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-
-Contributors:
- IBM Corporation - Initial implementation
-**********************************************************************/
-package org.eclipse.core.filebuffers;
-
-
-import org.eclipse.jface.text.IDocument;
-
-/**
- * A text file buffer is a file buffer for text files. The contents of a text file buffe is
- * given in the form of a document. Also, the text file buffer provides methods to
- * manage the character encoding used to read and write the buffer's underlying
- * text file.
- *
- * @since 3.0
- */
-public interface ITextFileBuffer extends IFileBuffer {
-
- /**
- * Returns the document of this text file buffer.
- *
- * @return the document of this text file buffer
- */
- IDocument getDocument();
-
- /**
- * Returns the character encoding to be used for reading and writing the
- * buffer's underlying file.
- *
- * @return the character encoding
- */
- String getEncoding();
-
- /**
- * Sets the character encoding to be used for reading and writing the buffer's
- * underlyning file.
- *
- * @param encoding the encoding
- */
- void setEncoding(String encoding);
-}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/ITextFileBufferManager.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/ITextFileBufferManager.java
deleted file mode 100644
index 6897cdf..0000000
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/ITextFileBufferManager.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/**********************************************************************
-Copyright (c) 2000, 2003 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-
-Contributors:
- IBM Corporation - Initial implementation
-**********************************************************************/
-
-package org.eclipse.core.filebuffers;
-
-import org.eclipse.core.runtime.IPath;
-
-import org.eclipse.jface.text.IDocument;
-
-
-/**
- * A text file buffer manager manages text file buffers for files whose contents
- * could be considered text.
- *
- * @since 3.0
- */
-public interface ITextFileBufferManager extends IFileBufferManager {
-
- /**
- * Returns the text file buffer managed for the file at the given location
- * or <code>null</code> if either there is no such text file buffer.
- * <p>
- * The provided location is either a full path of a workspace resource or
- * an absolute path in the local file system. The file buffer manager does
- * not resolve the location of workspace resources in the case of linked
- * resources.
- * </p>
- *
- * @param location the location
- * @return the text file buffer managed for that location or <code>null</code>
- */
- ITextFileBuffer getTextFileBuffer(IPath location);
-
- /**
- * Returns the default encoding that is used to read the contents of text files
- * if no other encoding is specified.
- *
- * @return the default text file encoding
- */
- String getDefaultEncoding();
-
- /**
- * Creates a new empty document . The document is set up in the same way as
- * it would be used in a text file buffer for a file at the given location.
- * <p>
- * The provided location is either a full path of a workspace resource or
- * an absolute path in the local file system. The file buffer manager does
- * not resolve the location of workspace resources in the case of linked
- * resources.
- * </p>
- *
- * @param location the location used to set up the newly created document
- * @return a new empty document
- */
- IDocument createEmptyDocument(IPath location);
-}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/AbstractFileBuffer.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/AbstractFileBuffer.java
deleted file mode 100644
index 6be8c2a..0000000
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/AbstractFileBuffer.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**********************************************************************
-Copyright (c) 2000, 2003 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-
-Contributors:
- IBM Corporation - Initial implementation
-**********************************************************************/
-package org.eclipse.core.internal.filebuffers;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-import org.eclipse.core.filebuffers.IFileBuffer;
-
-/**
- * @since 3.0
- */
-public abstract class AbstractFileBuffer implements IFileBuffer {
-
-
- public abstract void create(IPath location, IProgressMonitor monitor) throws CoreException;
-
- public abstract void connect();
-
- public abstract void disconnect() throws CoreException;
-
- public abstract boolean isDisposed();
-
- public abstract void requestSynchronizationContext();
-
- public abstract void releaseSynchronizationContext();
-}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ContainerGenerator.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ContainerGenerator.java
deleted file mode 100644
index c1b0c70..0000000
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ContainerGenerator.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/**********************************************************************
-Copyright (c) 2000, 2003 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-
-Contributors:
- IBM Corporation - Initial implementation
-**********************************************************************/
-package org.eclipse.core.internal.filebuffers;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.SubProgressMonitor;
-
-public class ContainerGenerator {
-
- private IPath fContainerFullPath;
- private IContainer fContainer;
- private IWorkspace fWorkspace;
-
- public ContainerGenerator(IWorkspace workspace, IPath containerPath) {
- fWorkspace= workspace;
- fContainerFullPath = containerPath;
- }
-
- private IFolder createFolder(IFolder folderHandle, IProgressMonitor monitor) throws CoreException {
- folderHandle.create(false, true, monitor);
- if (monitor.isCanceled())
- throw new OperationCanceledException();
- return folderHandle;
- }
-
- private IFolder createFolderHandle(IContainer container, String folderName) {
- return container.getFolder(new Path(folderName));
- }
-
- private IProject createProject(IProject projectHandle, IProgressMonitor monitor) throws CoreException {
- try {
- monitor.beginTask("",2000);//$NON-NLS-1$
-
- projectHandle.create(new SubProgressMonitor(monitor, 1000));
- if (monitor.isCanceled())
- throw new OperationCanceledException();
-
- projectHandle.open(new SubProgressMonitor(monitor, 1000));
- if (monitor.isCanceled())
- throw new OperationCanceledException();
-
- } finally {
- monitor.done();
- }
-
- return projectHandle;
- }
-
- private IProject createProjectHandle(IWorkspaceRoot root, String projectName) {
- return root.getProject(projectName);
- }
-
- public IContainer generateContainer(IProgressMonitor monitor) throws CoreException {
- IWorkspaceRunnable runnable= new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- monitor.beginTask("creating container", 1000 * fContainerFullPath.segmentCount());
- if (fContainer != null)
- return;
-
- // Does the container exist already?
- IWorkspaceRoot root= fWorkspace.getRoot();
- fContainer= (IContainer) root.findMember(fContainerFullPath);
- if (fContainer != null)
- return;
-
- // Create the container for the given path
- fContainer= root;
- for (int i = 0; i < fContainerFullPath.segmentCount(); i++) {
- String currentSegment = fContainerFullPath.segment(i);
- IResource resource = fContainer.findMember(currentSegment);
- if (resource != null) {
- fContainer= (IContainer) resource;
- monitor.worked(1000);
- }
- else {
- if (i == 0) {
- IProject projectHandle= createProjectHandle(root, currentSegment);
- fContainer= createProject(projectHandle, new SubProgressMonitor(monitor,1000));
- }
- else {
- IFolder folderHandle= createFolderHandle(fContainer, currentSegment);
- fContainer= createFolder(folderHandle, new SubProgressMonitor(monitor,1000));
- }
- }
- }
- }
- };
-
- // Get scheduling rule
- IWorkspaceRoot root= fWorkspace.getRoot();
- IPath existingParentPath= fContainerFullPath;
- while (!root.exists(existingParentPath))
- existingParentPath= existingParentPath.removeLastSegments(1);
-
- IResource schedulingRule= root.findMember(existingParentPath);
- fWorkspace.run(runnable, schedulingRule, IWorkspace.AVOID_UPDATE, monitor);
- return fContainer;
- }
-}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/DefaultDocumentFactory.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/DefaultDocumentFactory.java
deleted file mode 100644
index 0a4973a..0000000
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/DefaultDocumentFactory.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/**********************************************************************
-Copyright (c) 2000, 2003 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-
-Contributors:
- IBM Corporation - Initial implementation
-**********************************************************************/
-package org.eclipse.core.internal.filebuffers;
-
-import org.eclipse.core.filebuffers.IDocumentFactory;
-
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-
-/**
- * The default document factory.
- */
-public class DefaultDocumentFactory implements IDocumentFactory {
-
- public DefaultDocumentFactory() {
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IDocumentFactory#createDocument()
- */
- public IDocument createDocument() {
- return new Document();
- }
-}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ExtensionsRegistry.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ExtensionsRegistry.java
deleted file mode 100644
index f8fc178..0000000
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ExtensionsRegistry.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.filebuffers;
-
-
-
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.filebuffers.IDocumentFactory;
-import org.eclipse.core.filebuffers.IDocumentSetupParticipant;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.ILog;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-
-
-/**
- * This registry manages shareable document factories. Document factories are specified
- * in <code>plugin.xml</code> per file name extension.
- */
-public class ExtensionsRegistry {
-
- private final static String WILDCARD= "*"; //$NON-NLS-1$
-
- /** The mapping between name extensions and configuration elements describing document factories. */
- private Map fFactoryDescriptors= new HashMap();
- /** The mapping between configuration elements for document factories and instantiated document factories. */
- private Map fFactories= new HashMap();
- /** The mapping between name extensions and configuration elements describing document setup participants. */
- private Map fSetupParticipantDescriptors= new HashMap();
- /** The mapping between configuration elements for setup participants and instantiated setup participants. */
- private Map fSetupParticipants= new HashMap();
-
-
- /**
- * Creates a new document factory registry and intializes it with the information
- * found in the plugin registry.
- */
- public ExtensionsRegistry() {
- initialize("documentCreation", "extensions", fFactoryDescriptors); //$NON-NLS-1$ //$NON-NLS-2$
- initialize("documentSetup", "extensions", fSetupParticipantDescriptors); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * Reads the comma-separated value of the given configuration element for the given attribute name and remembers the configuration element
- * in the given map under the individual tokens of the attribute value.
- */
- private void read(String attributeName, IConfigurationElement element, Map map) {
- String value= element.getAttribute(attributeName);
- if (value != null) {
- StringTokenizer tokenizer= new StringTokenizer(value, ","); //$NON-NLS-1$
- while (tokenizer.hasMoreTokens()) {
- String token= tokenizer.nextToken().trim();
-
- Set s= (Set) map.get(token);
- if (s == null) {
- s= new HashSet();
- map.put(token, s);
- }
- s.add(element);
- }
- }
- }
-
- /**
- * Adds an entry to the log of this plugin for the given status
- * @param status the status to log
- */
- private void log(IStatus status) {
- ILog log= Platform.getPlugin(FileBuffersPlugin.PLUGIN_ID).getLog();
- log.log(status);
- }
-
- /**
- * Initializes this registry. It retrieves all implementers of the given
- * extension point and remembers those implementers based on the
- * file name extensions in the given map.
- *
- * @param extensionPointName the name of the extension point
- * @param childElementName the name of the child elements
- * @param descriptors the map to be filled
- */
- private void initialize(String extensionPointName, String childElementName, Map descriptors) {
-
- IExtensionPoint extensionPoint= Platform.getPluginRegistry().getExtensionPoint(FileBuffersPlugin.PLUGIN_ID, extensionPointName);
- if (extensionPoint == null) {
- log(new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, 0, MessageFormat.format("Extension point \"{0}\" not found.", new Object[] { extensionPointName}), null));
- return;
- }
-
- IConfigurationElement[] elements= extensionPoint.getConfigurationElements();
- for (int i= 0; i < elements.length; i++)
- read(childElementName, elements[i], descriptors);
- }
-
- /**
- * Returns the executable extension for the given configuration element.
- * If there is no instantiated extension remembered for this
- * element, a new extension is created and put into the cache if it is of the requested type.
- *
- * @param entry the configuration element
- * @param extensions the map of instantiated extensions
- * @param extensionType the requested result type
- */
- private Object getExtension(IConfigurationElement entry, Map extensions, Class extensionType) {
- Object extension= extensions.get(entry);
- if (extension != null)
- return extension;
-
- try {
- extension= entry.createExecutableExtension("class"); //$NON-NLS-1$
- } catch (CoreException x) {
- log(x.getStatus());
- }
-
- if (extensionType.isInstance(extension)) {
- extensions.put(entry, extension);
- return extension;
- }
-
- return null;
- }
-
- /**
- * Returns the first enumerated element of the given set.
- *
- * @param set the set from which to choose
- */
- private IConfigurationElement selectConfigurationElement(Set set) {
- if (set != null && !set.isEmpty()) {
- Iterator e= set.iterator();
- return (IConfigurationElement) e.next();
- }
- return null;
- }
-
- /**
- * Returns a shareable document factory for the given file name extension.
- *
- * @param extension the name extension to be used for lookup
- * @return the shareable document factory or <code>null</code>
- */
- private IDocumentFactory getDocumentFactory(String extension) {
-
- Set set= (Set) fFactoryDescriptors.get(extension);
- if (set != null) {
- IConfigurationElement entry= selectConfigurationElement(set);
- return (IDocumentFactory) getExtension(entry, fFactories, IDocumentFactory.class);
- }
- return null;
- }
-
- /**
- * Returns the set of setup participants for the given file name.
- *
- * @param extension the name extension to be used for lookup
- * @return the shareable set of document setup participants
- */
- private List getDocumentSetupParticipants(String extension) {
-
- Set set= (Set) fSetupParticipantDescriptors.get(extension);
- if (set == null)
- return null;
-
- List participants= new ArrayList();
- Iterator e= set.iterator();
- while (e.hasNext()) {
- IConfigurationElement entry= (IConfigurationElement) e.next();
- Object participant= getExtension(entry, fSetupParticipants, IDocumentSetupParticipant.class);
- if (participant != null)
- participants.add(participant);
- }
-
- return participants;
- }
-
- /**
- * Returns the shareable document factory for the given location.
- *
- * @param location the location for which to looked up the factory
- * @return the shareable document factory
- */
- public IDocumentFactory getDocumentFactory(IPath location) {
- IDocumentFactory factory= getDocumentFactory(location.getFileExtension());
- if (factory == null)
- factory= getDocumentFactory(WILDCARD);
- return factory;
- }
-
- /**
- * Returns the shareable set of document setup participants for the given location.
- *
- * @param location the location for which to look up the setup participants
- * @return the shareable set of document setup participants
- */
- public IDocumentSetupParticipant[] getDocumentSetupParticipants(IPath location) {
- List participants= new ArrayList();
-
- List p= getDocumentSetupParticipants(location.getFileExtension());
- if (p != null)
- participants.addAll(p);
-
- p= getDocumentSetupParticipants(WILDCARD);
- if (p != null)
- participants.addAll(p);
-
- IDocumentSetupParticipant[] result= new IDocumentSetupParticipant[participants.size()];
- participants.toArray(result);
- return result;
- }
-}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/FileBuffersPlugin.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/FileBuffersPlugin.java
deleted file mode 100644
index 752cffe..0000000
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/FileBuffersPlugin.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package org.eclipse.core.internal.filebuffers;
-
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-import org.eclipse.core.filebuffers.ITextFileBufferManager;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.core.runtime.Plugin;
-
-
-/**
- * The main plugin class to be used in the desktop.
- */
-public class FileBuffersPlugin extends Plugin {
-
- public final static String PLUGIN_ID= "org.eclipse.core.filebuffers"; //$NON-NLS-1$
-
- /** The shared plug-in instance */
- private static FileBuffersPlugin fgPlugin;
- /** The resource bundle */
- private ResourceBundle fResourceBundle;
- /** The file buffer manager */
- private ITextFileBufferManager fTextFileBufferManager;
-
- /**
- * The constructor.
- */
- public FileBuffersPlugin(IPluginDescriptor descriptor) {
- super(descriptor);
- fgPlugin = this;
- try {
- fResourceBundle= ResourceBundle.getBundle("org.eclipse.core.internal.filebuffers.FileBuffersPlugin"); //$NON-NLS-1$
- } catch (MissingResourceException x) {
- fResourceBundle = null;
- }
- }
-
- /**
- * Returns the shared instance.
- */
- public static FileBuffersPlugin getDefault() {
- return fgPlugin;
- }
-
- /**
- * Returns the workspace instance.
- */
- public static IWorkspace getWorkspace() {
- return ResourcesPlugin.getWorkspace();
- }
-
- /**
- * Returns the string from the plugin's resource bundle,
- * or 'key' if not found.
- */
- public static String getResourceString(String key) {
- ResourceBundle bundle= FileBuffersPlugin.getDefault().getResourceBundle();
- try {
- return (bundle!=null ? bundle.getString(key) : key);
- } catch (MissingResourceException e) {
- return key;
- }
- }
-
- /**
- * Returns the plugin's resource bundle,
- */
- public ResourceBundle getResourceBundle() {
- return fResourceBundle;
- }
-
- /**
- * Returns the text file buffer manager of this plug-in.
- *
- * @return the text file buffer manager of this plug-in
- */
- public ITextFileBufferManager getFileBufferManager() {
- if (fTextFileBufferManager == null)
- fTextFileBufferManager= new TextFileBufferManager();
- return fTextFileBufferManager;
- }
-}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/JavaFileBuffer.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/JavaFileBuffer.java
deleted file mode 100644
index d636116..0000000
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/JavaFileBuffer.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/**********************************************************************
-Copyright (c) 2000, 2003 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-
-Contributors:
- IBM Corporation - Initial implementation
-**********************************************************************/
-package org.eclipse.core.internal.filebuffers;
-
-import java.io.File;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.ILog;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-
-import org.eclipse.core.filebuffers.FileBuffers;
-
-/**
- * @since 3.0
- */
-public abstract class JavaFileBuffer extends AbstractFileBuffer {
-
- /** The location */
- protected IPath fLocation;
- /** The element for which the info is stored */
- protected File fFile;
- /** How often the element has been connected */
- protected int fReferenceCount;
- /** Can the element be saved */
- protected boolean fCanBeSaved= false;
- /** The status of this element */
- protected IStatus fStatus;
- /** The time stamp at which this buffer synchronized with the underlying file. */
- protected long fSynchronizationStamp= IFile.NULL_STAMP;
- /** How often the synchronization context has been requested */
- protected int fSynchronizationContextCount;
- /** The text file buffer manager */
- protected TextFileBufferManager fManager;
-
-
- public JavaFileBuffer(TextFileBufferManager manager) {
- super();
- fManager= manager;
- }
-
- abstract protected void addFileBufferContentListeners();
-
- abstract protected void removeFileBufferContentListeners();
-
- abstract protected void initializeFileBufferContent(IProgressMonitor monitor) throws CoreException;
-
- abstract protected void commitFileBufferContent(IProgressMonitor monitor, boolean overwrite) throws CoreException;
-
- /**
- * Returns the file at the given location or <code>null</code> if
- * there is no such file.
- *
- * @param location the location
- * @return the file at the given location
- */
- private File getFileAtLocation(IPath location) {
- File file= FileBuffers.getSystemFileAtLocation(location);
- return file.exists() ? file : null;
- }
-
- public void create(IPath location, IProgressMonitor monitor) throws CoreException {
- File file= getFileAtLocation(location);
- if (file == null)
- throw new CoreException(new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, IStatus.OK, "File does not exist", null));
-
- fLocation= location;
- fFile= file;
- initializeFileBufferContent(monitor);
- fSynchronizationStamp= fFile.lastModified();
-
- addFileBufferContentListeners();
- }
-
- public void connect() {
- ++ fReferenceCount;
- }
-
- public void disconnect() throws CoreException {
- -- fReferenceCount;
- }
-
- /**
- * Returns whether this file buffer has already been disposed.
- *
- * @return <code>true</code> if already disposed, <code>false</code> otherwise
- */
- public boolean isDisposed() {
- return fReferenceCount <= 0;
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBuffer#getLocation()
- */
- public IPath getLocation() {
- return fLocation;
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBuffer#commit(org.eclipse.core.runtime.IProgressMonitor, boolean)
- */
- public void commit(IProgressMonitor monitor, boolean overwrite) throws CoreException {
- if (!isDisposed() && fCanBeSaved) {
-
- fManager.fireStateChanging(this);
-
- try {
- commitFileBufferContent(monitor, overwrite);
- } catch (CoreException x) {
- fManager.fireStateChangeFailed(this);
- throw x;
- } catch (RuntimeException x) {
- fManager.fireStateChangeFailed(this);
- throw x;
- }
-
- fCanBeSaved= false;
- addFileBufferContentListeners();
- fManager.fireDirtyStateChanged(this, fCanBeSaved);
- }
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBuffer#isDirty()
- */
- public boolean isDirty() {
- return fCanBeSaved;
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBuffer#isShared()
- */
- public boolean isShared() {
- return fReferenceCount > 1;
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBuffer#validateState(org.eclipse.core.runtime.IProgressMonitor, java.lang.Object)
- */
- public void validateState(IProgressMonitor monitor, Object computationContext) throws CoreException {
- // nop
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBuffer#isStateValidated()
- */
- public boolean isStateValidated() {
- return true;
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBuffer#resetStateValidation()
- */
- public void resetStateValidation() {
- // nop
- }
-
- /**
- * Sends out the notification that the file serving as document input has been moved.
- *
- * @param newLocation the path of the new location of the file
- */
- protected void handleFileMoved(IPath newLocation) {
- fManager.fireUnderlyingFileMoved(this, newLocation);
- }
-
- /**
- * Defines the standard procedure to handle <code>CoreExceptions</code>. Exceptions
- * are written to the plug-in log.
- *
- * @param exception the exception to be logged
- * @param message the message to be logged
- */
- protected void handleCoreException(CoreException exception) {
- ILog log= Platform.getPlugin(FileBuffersPlugin.PLUGIN_ID).getLog();
- log.log(exception.getStatus());
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBuffer#isSynchronized()
- */
- public boolean isSynchronized() {
- return fSynchronizationStamp == fFile.lastModified();
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBuffer#getModificationStamp()
- */
- public long getModificationStamp() {
- return fFile.lastModified();
- }
-
- /**
- * Requests the file buffer manager's synchronization context for this file buffer.
- */
- public void requestSynchronizationContext() {
- ++ fSynchronizationContextCount;
- }
-
- /**
- * Releases the file buffer manager's synchronization context for this file buffer.
- */
- public void releaseSynchronizationContext() {
- -- fSynchronizationContextCount;
- }
-}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/JavaTextFileBuffer.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/JavaTextFileBuffer.java
deleted file mode 100644
index d4b0592..0000000
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/JavaTextFileBuffer.java
+++ /dev/null
@@ -1,338 +0,0 @@
-/**********************************************************************
-Copyright (c) 2000, 2003 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-
-Contributors:
- IBM Corporation - Initial implementation
-**********************************************************************/
-package org.eclipse.core.internal.filebuffers;
-
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.Reader;
-
-import org.eclipse.core.resources.IResourceStatus;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-
-import org.eclipse.core.filebuffers.ITextFileBuffer;
-
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentListener;
-
-/**
- * @since 3.0
- */
-public class JavaTextFileBuffer extends JavaFileBuffer implements ITextFileBuffer {
-
-
- private class DocumentListener implements IDocumentListener {
-
- /*
- * @see org.eclipse.jface.text.IDocumentListener#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent)
- */
- public void documentAboutToBeChanged(DocumentEvent event) {
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentListener#documentChanged(org.eclipse.jface.text.DocumentEvent)
- */
- public void documentChanged(DocumentEvent event) {
- fCanBeSaved= true;
- removeFileBufferContentListeners();
- fManager.fireDirtyStateChanged(JavaTextFileBuffer.this, fCanBeSaved);
- }
- }
-
- /**
- * Reader chunk size.
- */
- static final private int READER_CHUNK_SIZE= 2048;
- /**
- * Buffer size.
- */
- static final private int BUFFER_SIZE= 8 * READER_CHUNK_SIZE;
- /**
- * Constant for representing the ok status. This is considered a value object.
- */
- static final private IStatus STATUS_OK= new Status(IStatus.OK, FileBuffersPlugin.PLUGIN_ID, IStatus.OK, "OK", null);
- /**
- * Constant for representing the error status. This is considered a value object.
- */
- static final private IStatus STATUS_ERROR= new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, IStatus.INFO, "Error", null);
-
-
-
- /** The element's document */
- protected IDocument fDocument;
- /** The encoding used to create the document from the storage or <code>null</code> for workbench encoding. */
- protected String fEncoding;
- /** Internal document listener */
- protected IDocumentListener fDocumentListener= new DocumentListener();
-
-
-
- public JavaTextFileBuffer(TextFileBufferManager manager) {
- super(manager);
- }
-
- /*
- * @see org.eclipse.core.buffer.text.IBufferedTextFile#getDocument()
- */
- public IDocument getDocument() {
- return fDocument;
- }
-
- /*
- * @see org.eclipse.core.buffer.text.IBufferedTextFile#getEncoding()
- */
- public String getEncoding() {
- return fEncoding;
- }
-
- /*
- * @see org.eclipse.core.buffer.text.IBufferedTextFile#setEncoding(java.lang.String)
- */
- public void setEncoding(String encoding) {
- fEncoding= encoding;
- }
-
- /*
- * @see org.eclipse.core.buffer.text.IBufferedFile#getStatus()
- */
- public IStatus getStatus() {
- if (!isDisposed()) {
- if (fStatus != null)
- return fStatus;
- return (fDocument == null ? STATUS_ERROR : STATUS_OK);
- }
- return STATUS_ERROR;
- }
-
- private InputStream getFileContents(IProgressMonitor monitor) {
- try {
- return new FileInputStream(fFile);
- } catch (FileNotFoundException e) {
- }
- return null;
- }
-
- private void setFileContents(InputStream stream, boolean overwrite, IProgressMonitor monitor) {
- try {
- OutputStream out= new FileOutputStream(fFile, false);
-
- try {
- byte[] buffer = new byte[8192];
- while (true) {
- int bytesRead = -1;
- try {
- bytesRead = stream.read(buffer);
- } catch (IOException e) {
- }
- if (bytesRead == -1)
- break;
- try {
- out.write(buffer, 0, bytesRead);
- } catch (IOException e) {
- }
- monitor.worked(1);
- }
- } finally {
- try {
- stream.close();
- } catch (IOException e) {
- } finally {
- try {
- out.close();
- } catch (IOException e) {
- }
- }
- }
- } catch (FileNotFoundException e) {
- }
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBuffer#revert(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void revert(IProgressMonitor monitor) throws CoreException {
- if (isDisposed())
- return;
-
- IDocument original= null;
- IStatus status= null;
-
- try {
- original= fManager.createEmptyDocument(getLocation());
- setDocumentContent(original, getFileContents(monitor), fEncoding);
- } catch (CoreException x) {
- status= x.getStatus();
- }
-
- fStatus= status;
-
- if (original != null) {
-
- String originalContents= original.get();
- boolean replaceContents= !originalContents.equals(fDocument.get());
-
- if (replaceContents) {
- fManager.fireBufferContentAboutToBeReplaced(this);
- fDocument.set(original.get());
- }
-
- if (fCanBeSaved) {
- fCanBeSaved= false;
- addFileBufferContentListeners();
- }
-
- if (replaceContents)
- fManager.fireBufferContentReplaced(this);
-
- fManager.fireDirtyStateChanged(this, fCanBeSaved);
- }
- }
-
- /*
- * @see org.eclipse.core.internal.filebuffers.FileBuffer#addFileBufferContentListeners()
- */
- protected void addFileBufferContentListeners() {
- if (fDocument != null)
- fDocument.addDocumentListener(fDocumentListener);
- }
-
- /*
- * @see org.eclipse.core.internal.filebuffers.FileBuffer#removeFileBufferContentListeners()
- */
- protected void removeFileBufferContentListeners() {
- if (fDocument != null)
- fDocument.removeDocumentListener(fDocumentListener);
- }
-
- /*
- * @see org.eclipse.core.internal.filebuffers.FileBuffer#initializeFileBufferContent(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void initializeFileBufferContent(IProgressMonitor monitor) throws CoreException {
- try {
- fDocument= fManager.createEmptyDocument(getLocation());
- setDocumentContent(fDocument, getFileContents(monitor), fEncoding);
- } catch (CoreException x) {
- fDocument= fManager.createEmptyDocument(getLocation());
- fStatus= x.getStatus();
- }
- }
-
- /*
- * @see org.eclipse.core.internal.filebuffers.FileBuffer#commitFileBufferContent(org.eclipse.core.runtime.IProgressMonitor, boolean)
- */
- protected void commitFileBufferContent(IProgressMonitor monitor, boolean overwrite) throws CoreException {
- try {
-
- String encoding= getEncoding();
- if (encoding == null)
- encoding= fManager.getDefaultEncoding();
-
- InputStream stream= new ByteArrayInputStream(fDocument.get().getBytes(encoding));
-
- if (fFile.exists()) {
-
- if (!overwrite)
- checkSynchronizationState();
-
-
- // here the file synchronizer should actually be removed and afterwards added again. However,
- // we are already inside an operation, so the delta is sent AFTER we have added the listener
- setFileContents(stream, overwrite, monitor);
- // set synchronization stamp to know whether the file synchronizer must become active
- fSynchronizationStamp= fFile.lastModified();
-
- // TODO if there is an annotation model update it here
-
- } else {
-
-// try {
-// monitor.beginTask("Saving", 2000); //$NON-NLS-1$
-// ContainerGenerator generator = new ContainerGenerator(fFile.getWorkspace(), fFile.getParent().getFullPath());
-// generator.generateContainer(new SubProgressMonitor(monitor, 1000));
-// fFile.create(stream, false, new SubProgressMonitor(monitor, 1000));
-// }
-// finally {
-// monitor.done();
-// }
-
- }
-
- } catch (IOException x) {
- String message= (x.getMessage() != null ? x.getMessage() : ""); //$NON-NLS-1$
- IStatus s= new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, IStatus.OK, message, x);
- throw new CoreException(s);
- }
- }
-
- /**
- * Intitializes the given document with the given stream using the given encoding.
- *
- * @param document the document to be initialized
- * @param contentStream the stream which delivers the document content
- * @param encoding the character encoding for reading the given stream
- * @exception CoreException if the given stream can not be read
- */
- private void setDocumentContent(IDocument document, InputStream contentStream, String encoding) throws CoreException {
- Reader in= null;
- try {
-
- if (encoding == null)
- encoding= fManager.getDefaultEncoding();
-
- in= new BufferedReader(new InputStreamReader(contentStream, encoding), BUFFER_SIZE);
- StringBuffer buffer= new StringBuffer(BUFFER_SIZE);
- char[] readBuffer= new char[READER_CHUNK_SIZE];
- int n= in.read(readBuffer);
- while (n > 0) {
- buffer.append(readBuffer, 0, n);
- n= in.read(readBuffer);
- }
-
- document.set(buffer.toString());
-
- } catch (IOException x) {
- String msg= x.getMessage() == null ? "" : x.getMessage(); //$NON-NLS-1$
- IStatus s= new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, IStatus.OK, msg, x);
- throw new CoreException(s);
- } finally {
- if (in != null) {
- try {
- in.close();
- } catch (IOException x) {
- }
- }
- }
- }
-
- /**
- * Checks whether the given file is synchronized with the the local file system.
- * If the file has been changed, a <code>CoreException</code> is thrown.
- *
- * @param file the file to check
- * @exception CoreException if file has been changed on the file system
- */
- private void checkSynchronizationState() throws CoreException {
- if (!isSynchronized()) {
- Status status= new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, IResourceStatus.OUT_OF_SYNC_LOCAL, "out of sync", null);
- throw new CoreException(status);
- }
- }
-}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceFileBuffer.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceFileBuffer.java
deleted file mode 100644
index d28d10b..0000000
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceFileBuffer.java
+++ /dev/null
@@ -1,406 +0,0 @@
-/**********************************************************************
-Copyright (c) 2000, 2003 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-
-Contributors:
- IBM Corporation - Initial implementation
-**********************************************************************/
-package org.eclipse.core.internal.filebuffers;
-
-import java.io.File;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IResourceDeltaVisitor;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.ILog;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-
-import org.eclipse.core.filebuffers.FileBuffers;
-
-
-public abstract class ResourceFileBuffer extends AbstractFileBuffer {
-
- /**
- * Runnable encapsulating an element state change. This runnable ensures
- * that a element change failed message is sent out to the element state
- * listeners in case an exception occurred.
- */
- private class SafeFileChange implements Runnable {
-
- /**
- * Creates a new safe runnable for the given file.
- */
- public SafeFileChange() {
- }
-
- /**
- * Execute the change.
- * Subclass responsibility.
- *
- * @exception an exception in case of error
- */
- protected void execute() throws Exception {
- }
-
- /**
- * Does everything necessary prior to execution.
- */
- public void preRun() {
- fManager.fireStateChanging(ResourceFileBuffer.this);
- }
-
- /*
- * @see java.lang.Runnable#run()
- */
- public void run() {
-
- if (isDisposed()) {
- fManager.fireStateChangeFailed(ResourceFileBuffer.this);
- return;
- }
-
- try {
- execute();
- } catch (Exception x) {
- FileBuffersPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, IStatus.OK, "Exception when synchronizing", x)); //$NON-NLS-1$
- fManager.fireStateChangeFailed(ResourceFileBuffer.this);
- }
- }
- }
-
- /**
- * Synchronizes the document with external resource changes.
- */
- private class FileSynchronizer implements IResourceChangeListener, IResourceDeltaVisitor {
-
- /** A flag indicating whether this synchronizer is installed or not. */
- private boolean fIsInstalled= false;
-
- /**
- * Creates a new file synchronizer. Is not yet installed on a file.
- */
- public FileSynchronizer() {
- }
-
- /**
- * Installs the synchronizer on the file.
- */
- public void install() {
- fFile.getWorkspace().addResourceChangeListener(this);
- fIsInstalled= true;
- }
-
- /**
- * Uninstalls the synchronizer from the file.
- */
- public void uninstall() {
- fFile.getWorkspace().removeResourceChangeListener(this);
- fIsInstalled= false;
- }
-
- /*
- * @see IResourceChangeListener#resourceChanged(IResourceChangeEvent)
- */
- public void resourceChanged(IResourceChangeEvent e) {
- IResourceDelta delta= e.getDelta();
- try {
- if (delta != null && fIsInstalled)
- delta.accept(this);
- } catch (CoreException x) {
- handleCoreException(x);
- }
- }
-
- /*
- * @see IResourceDeltaVisitor#visit(org.eclipse.core.resources.IResourceDelta)
- */
- public boolean visit(IResourceDelta delta) throws CoreException {
-
- if (delta != null && fFile.equals(delta.getResource())) {
-
- SafeFileChange fileChange= null;
-
- switch (delta.getKind()) {
- case IResourceDelta.CHANGED:
- if ((IResourceDelta.CONTENT & delta.getFlags()) != 0) {
- if (!isDisposed() && !fCanBeSaved && !isSynchronized()) {
- fileChange= new SafeFileChange() {
- protected void execute() throws Exception {
- handleFileContentChanged();
- }
- };
- }
- }
- break;
- case IResourceDelta.REMOVED:
- if ((IResourceDelta.MOVED_TO & delta.getFlags()) != 0) {
- final IPath path= delta.getMovedToPath();
- fileChange= new SafeFileChange() {
- protected void execute() throws Exception {
- handleFileMoved(path);
- }
- };
- } else {
- if (!isDisposed() && !fCanBeSaved) {
- fileChange= new SafeFileChange() {
- protected void execute() throws Exception {
- handleFileDeleted();
- }
- };
- }
- }
- break;
- }
-
- if (fileChange != null) {
- fileChange.preRun();
- fManager.execute(fileChange, fSynchronizationContextCount > 0);
- }
- }
-
- return true; // because we are sitting on files anyway
- }
- }
-
-
-
- /** The location */
- protected IPath fLocation;
- /** The element for which the info is stored */
- protected IFile fFile;
- /** How often the element has been connected */
- protected int fReferenceCount;
- /** Can the element be saved */
- protected boolean fCanBeSaved= false;
- /** Has element state been validated */
- protected boolean fIsStateValidated= false;
- /** The status of this element */
- protected IStatus fStatus;
- /** The file synchronizer. */
- protected FileSynchronizer fFileSynchronizer;
- /** The time stamp at which this buffer synchronized with the underlying file. */
- protected long fSynchronizationStamp= IFile.NULL_STAMP;
- /** How often the synchronization context has been requested */
- protected int fSynchronizationContextCount;
- /** The text file buffer manager */
- protected TextFileBufferManager fManager;
-
-
-
-
- public ResourceFileBuffer(TextFileBufferManager manager) {
- super();
- fManager= manager;
- }
-
- abstract protected void handleFileContentChanged();
-
- abstract protected void addFileBufferContentListeners();
-
- abstract protected void removeFileBufferContentListeners();
-
- abstract protected void initializeFileBufferContent(IProgressMonitor monitor) throws CoreException;
-
- abstract protected void commitFileBufferContent(IProgressMonitor monitor, boolean overwrite) throws CoreException;
-
- public void create(IPath location, IProgressMonitor monitor) throws CoreException {
- IFile file= FileBuffers.getWorkspaceFileAtLocation(location);
- if (file == null || !file.exists())
- throw new CoreException(new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, IStatus.OK, "File does not exist", null));
-
- fLocation= location;
- fFile= file;
- fFileSynchronizer= new FileSynchronizer();
-
- refreshFile(monitor);
- initializeFileBufferContent(monitor);
- fSynchronizationStamp= fFile.getModificationStamp();
-
- addFileBufferContentListeners();
- }
-
- public void connect() {
- ++ fReferenceCount;
- if (fReferenceCount == 1)
- fFileSynchronizer.install();
- }
-
- public void disconnect() throws CoreException {
- -- fReferenceCount;
- if (fReferenceCount == 0) {
- if (fFileSynchronizer != null)
- fFileSynchronizer.uninstall();
- fFileSynchronizer= null;
- }
- }
-
- /**
- * Returns whether this file buffer has already been disposed.
- *
- * @return <code>true</code> if already disposed, <code>false</code> otherwise
- */
- public boolean isDisposed() {
- return fFileSynchronizer == null;
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBuffer#getLocation()
- */
- public IPath getLocation() {
- return fLocation;
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBuffer#commit(org.eclipse.core.runtime.IProgressMonitor, boolean)
- */
- public void commit(IProgressMonitor monitor, boolean overwrite) throws CoreException {
- if (!isDisposed() && fCanBeSaved) {
-
- fManager.fireStateChanging(this);
-
- try {
- commitFileBufferContent(monitor, overwrite);
- } catch (CoreException x) {
- fManager.fireStateChangeFailed(this);
- throw x;
- } catch (RuntimeException x) {
- fManager.fireStateChangeFailed(this);
- throw x;
- }
-
- fCanBeSaved= false;
- addFileBufferContentListeners();
- fManager.fireDirtyStateChanged(this, fCanBeSaved);
- }
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBuffer#isDirty()
- */
- public boolean isDirty() {
- return fCanBeSaved;
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBuffer#isShared()
- */
- public boolean isShared() {
- return fReferenceCount > 1;
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBuffer#validateState(org.eclipse.core.runtime.IProgressMonitor, java.lang.Object)
- */
- public void validateState(IProgressMonitor monitor, Object computationContext) throws CoreException {
- if (!isDisposed() && !fIsStateValidated) {
-
- if (fFile.isReadOnly()) {
- IWorkspace workspace= fFile.getWorkspace();
- fStatus= workspace.validateEdit(new IFile[] { fFile }, computationContext);
- }
- fIsStateValidated= true;
- fManager.fireStateValidationChanged(this, fIsStateValidated);
- }
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBuffer#isStateValidated()
- */
- public boolean isStateValidated() {
- return fIsStateValidated;
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBuffer#resetStateValidation()
- */
- public void resetStateValidation() {
- if (fIsStateValidated) {
- fIsStateValidated= false;
- fManager.fireStateValidationChanged(this, fIsStateValidated);
- }
- }
-
- /**
- * Sends out the notification that the file serving as document input has been moved.
- *
- * @param newLocation the path of the new location of the file
- */
- protected void handleFileMoved(IPath newLocation) {
- fManager.fireUnderlyingFileMoved(this, newLocation);
- }
-
- /**
- * Sends out the notification that the file serving as document input has been deleted.
- */
- protected void handleFileDeleted() {
- fManager.fireUnderlyingFileDeleted(this);
- }
-
- /**
- * Refreshes the given file.
- */
- protected void refreshFile(IProgressMonitor monitor) {
- try {
- fFile.refreshLocal(IFile.DEPTH_INFINITE, monitor);
- } catch (OperationCanceledException x) {
- } catch (CoreException x) {
- handleCoreException(x);
- }
- }
-
- /**
- * Defines the standard procedure to handle <code>CoreExceptions</code>. Exceptions
- * are written to the plug-in log.
- *
- * @param exception the exception to be logged
- * @param message the message to be logged
- */
- protected void handleCoreException(CoreException exception) {
- ILog log= Platform.getPlugin(FileBuffersPlugin.PLUGIN_ID).getLog();
- log.log(exception.getStatus());
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBuffer#isSynchronized()
- */
- public boolean isSynchronized() {
- return fSynchronizationStamp == fFile.getModificationStamp() && fFile.isSynchronized(IResource.DEPTH_ZERO);
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBuffer#getModificationStamp()
- */
- public long getModificationStamp() {
- File file= FileBuffers.getSystemFileAtLocation(getLocation());
- if (file != null)
- return file.lastModified();
- return IResource.NULL_STAMP;
- }
-
- /**
- * Requests the file buffer manager's synchronization context for this file buffer.
- */
- public void requestSynchronizationContext() {
- ++ fSynchronizationContextCount;
- }
-
- /**
- * Releases the file buffer manager's synchronization context for this file buffer.
- */
- public void releaseSynchronizationContext() {
- -- fSynchronizationContextCount;
- }
-}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceTextFileBuffer.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceTextFileBuffer.java
deleted file mode 100644
index 9a35358..0000000
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceTextFileBuffer.java
+++ /dev/null
@@ -1,365 +0,0 @@
-/**********************************************************************
-Copyright (c) 2000, 2003 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-
-Contributors:
- IBM Corporation - Initial implementation
-**********************************************************************/
-package org.eclipse.core.internal.filebuffers;
-
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-
-import org.eclipse.core.filebuffers.ITextFileBuffer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResourceStatus;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.QualifiedName;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubProgressMonitor;
-
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentListener;
-
-/**
- *
- */
-public class ResourceTextFileBuffer extends ResourceFileBuffer implements ITextFileBuffer {
-
-
- private class DocumentListener implements IDocumentListener {
-
- /*
- * @see org.eclipse.jface.text.IDocumentListener#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent)
- */
- public void documentAboutToBeChanged(DocumentEvent event) {
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentListener#documentChanged(org.eclipse.jface.text.DocumentEvent)
- */
- public void documentChanged(DocumentEvent event) {
- fCanBeSaved= true;
- removeFileBufferContentListeners();
- fManager.fireDirtyStateChanged(ResourceTextFileBuffer.this, fCanBeSaved);
- }
- }
-
- /**
- * Reader chunk size.
- */
- static final private int READER_CHUNK_SIZE= 2048;
- /**
- * Buffer size.
- */
- static final private int BUFFER_SIZE= 8 * READER_CHUNK_SIZE;
- /**
- * Qualified name for the encoding key.
- */
- static final private QualifiedName ENCODING_KEY= new QualifiedName(FileBuffersPlugin.PLUGIN_ID, "encoding"); //$NON-NLS-1$
- /**
- * Constant for representing the ok status. This is considered a value object.
- */
- static final private IStatus STATUS_OK= new Status(IStatus.OK, FileBuffersPlugin.PLUGIN_ID, IStatus.OK, "OK", null);
- /**
- * Constant for representing the error status. This is considered a value object.
- */
- static final private IStatus STATUS_ERROR= new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, IStatus.INFO, "Error", null);
-
-
-
- /** The element's document */
- protected IDocument fDocument;
- /** The encoding used to create the document from the storage or <code>null</code> for workbench encoding. */
- protected String fEncoding;
- /** Internal document listener */
- protected IDocumentListener fDocumentListener= new DocumentListener();
-
-
-
- public ResourceTextFileBuffer(TextFileBufferManager manager) {
- super(manager);
- }
-
- /*
- * @see org.eclipse.core.buffer.text.IBufferedTextFile#getDocument()
- */
- public IDocument getDocument() {
- return fDocument;
- }
-
- /*
- * @see org.eclipse.core.buffer.text.IBufferedTextFile#getEncoding()
- */
- public String getEncoding() {
- return fEncoding;
- }
-
- /*
- * @see org.eclipse.core.buffer.text.IBufferedTextFile#setEncoding(java.lang.String)
- */
- public void setEncoding(String encoding) {
- fEncoding= encoding;
- try {
- fFile.setCharset(encoding);
- } catch (CoreException x) {
- handleCoreException(x);
- }
- }
-
- /*
- * @see org.eclipse.core.buffer.text.IBufferedFile#getStatus()
- */
- public IStatus getStatus() {
- if (!isDisposed()) {
- if (fStatus != null)
- return fStatus;
- return (fDocument == null ? STATUS_ERROR : STATUS_OK);
- }
- return STATUS_ERROR;
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBuffer#revert(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void revert(IProgressMonitor monitor) throws CoreException {
- if (isDisposed())
- return;
-
- refreshFile(monitor);
-
- IDocument original= null;
- IStatus status= null;
-
- try {
- original= fManager.createEmptyDocument(fFile.getLocation());
- setDocumentContent(original, fFile.getContents(), fEncoding);
- } catch (CoreException x) {
- status= x.getStatus();
- }
-
- fStatus= status;
-
- if (original != null) {
-
- String originalContents= original.get();
- boolean replaceContents= !originalContents.equals(fDocument.get());
-
- if (replaceContents) {
- fManager.fireBufferContentAboutToBeReplaced(this);
- fDocument.set(original.get());
- }
-
- if (fCanBeSaved) {
- fCanBeSaved= false;
- addFileBufferContentListeners();
- }
-
- if (replaceContents)
- fManager.fireBufferContentReplaced(this);
-
- fManager.fireDirtyStateChanged(this, fCanBeSaved);
- }
- }
-
- /*
- * @see org.eclipse.core.internal.filebuffers.FileBuffer#addFileBufferContentListeners()
- */
- protected void addFileBufferContentListeners() {
- if (fDocument != null)
- fDocument.addDocumentListener(fDocumentListener);
- }
-
- /*
- * @see org.eclipse.core.internal.filebuffers.FileBuffer#removeFileBufferContentListeners()
- */
- protected void removeFileBufferContentListeners() {
- if (fDocument != null)
- fDocument.removeDocumentListener(fDocumentListener);
- }
-
- /*
- * @see org.eclipse.core.internal.filebuffers.FileBuffer#initializeFileBufferContent(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void initializeFileBufferContent(IProgressMonitor monitor) throws CoreException {
- try {
- fEncoding= null;
- try {
- fEncoding= fFile.getPersistentProperty(ENCODING_KEY);
- } catch (CoreException x) {
- // we ignore exceptions here because we support the ENCODING_KEY property only for compatibility reasons
- }
- if (fEncoding != null) {
- // if we found an old encoding property, we try to migrate it to the new core.resources encoding support
- try {
- fFile.setCharset(fEncoding);
- // if successful delete old property
- fFile.setPersistentProperty(ENCODING_KEY, null);
- } catch (CoreException ex) {
- // log problem because we could not migrate the property successfully
- handleCoreException(ex);
- }
- } else {
- fEncoding= fFile.getCharset();
- }
- fDocument= fManager.createEmptyDocument(fFile.getLocation());
- setDocumentContent(fDocument, fFile.getContents(), fEncoding);
- } catch (CoreException x) {
- fDocument= fManager.createEmptyDocument(fFile.getLocation());
- fStatus= x.getStatus();
- }
- }
-
- /*
- * @see org.eclipse.core.internal.filebuffers.FileBuffer#commitFileBufferContent(org.eclipse.core.runtime.IProgressMonitor, boolean)
- */
- protected void commitFileBufferContent(IProgressMonitor monitor, boolean overwrite) throws CoreException {
- try {
-
- String encoding= getEncoding();
- if (encoding == null)
- encoding= fManager.getDefaultEncoding();
-
- InputStream stream= new ByteArrayInputStream(fDocument.get().getBytes(encoding));
-
- if (fFile.exists()) {
-
- if (!overwrite)
- checkSynchronizationState();
-
-
- // here the file synchronizer should actually be removed and afterwards added again. However,
- // we are already inside an operation, so the delta is sent AFTER we have added the listener
- fFile.setContents(stream, overwrite, true, monitor);
- // set synchronization stamp to know whether the file synchronizer must become active
- fSynchronizationStamp= fFile.getModificationStamp();
-
- // TODO if there is an annotation model update it here
-
- } else {
-
- try {
- monitor.beginTask("Saving", 2000); //$NON-NLS-1$
- ContainerGenerator generator = new ContainerGenerator(fFile.getWorkspace(), fFile.getParent().getFullPath());
- generator.generateContainer(new SubProgressMonitor(monitor, 1000));
- fFile.create(stream, false, new SubProgressMonitor(monitor, 1000));
- }
- finally {
- monitor.done();
- }
- }
-
- } catch (IOException x) {
- String message= (x.getMessage() != null ? x.getMessage() : ""); //$NON-NLS-1$
- IStatus s= new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, IStatus.OK, message, x);
- throw new CoreException(s);
- }
- }
-
- /**
- * Updates the element info to a change of the file content and sends out appropriate notifications.
- */
- protected void handleFileContentChanged() {
- if (isDisposed())
- return;
-
- IDocument document= fManager.createEmptyDocument(fFile.getLocation());
- IStatus status= null;
-
- try {
- setDocumentContent(document, fFile.getContents(false), fEncoding);
- } catch (CoreException x) {
- status= x.getStatus();
- }
-
- String newContent= document.get();
-
- if ( !newContent.equals(fDocument.get())) {
-
- fManager.fireBufferContentAboutToBeReplaced(this);
-
- removeFileBufferContentListeners();
- fDocument.set(newContent);
- fCanBeSaved= false;
- fSynchronizationStamp= fFile.getModificationStamp();
- fStatus= status;
- addFileBufferContentListeners();
-
- fManager.fireBufferContentReplaced(this);
-
- } else {
-
- removeFileBufferContentListeners();
- fCanBeSaved= false;
- fSynchronizationStamp= fFile.getModificationStamp();
- fStatus= status;
- addFileBufferContentListeners();
-
- fManager.fireDirtyStateChanged(this, fCanBeSaved);
- }
- }
-
- /**
- * Intitializes the given document with the given stream using the given encoding.
- *
- * @param document the document to be initialized
- * @param contentStream the stream which delivers the document content
- * @param encoding the character encoding for reading the given stream
- * @exception CoreException if the given stream can not be read
- */
- private void setDocumentContent(IDocument document, InputStream contentStream, String encoding) throws CoreException {
- Reader in= null;
- try {
-
- if (encoding == null)
- encoding= fManager.getDefaultEncoding();
-
- in= new BufferedReader(new InputStreamReader(contentStream, encoding), BUFFER_SIZE);
- StringBuffer buffer= new StringBuffer(BUFFER_SIZE);
- char[] readBuffer= new char[READER_CHUNK_SIZE];
- int n= in.read(readBuffer);
- while (n > 0) {
- buffer.append(readBuffer, 0, n);
- n= in.read(readBuffer);
- }
-
- document.set(buffer.toString());
-
- } catch (IOException x) {
- String message= (x.getMessage() != null ? x.getMessage() : ""); //$NON-NLS-1$
- IStatus s= new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, IStatus.OK, message, x);
- throw new CoreException(s);
- } finally {
- if (in != null) {
- try {
- in.close();
- } catch (IOException x) {
- }
- }
- }
- }
-
- /**
- * Checks whether the given file is synchronized with the the local file system.
- * If the file has been changed, a <code>CoreException</code> is thrown.
- *
- * @param file the file to check
- * @exception CoreException if file has been changed on the file system
- */
- private void checkSynchronizationState() throws CoreException {
- if (!fFile.isSynchronized(IFile.DEPTH_ZERO)) {
- Status status= new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, IResourceStatus.OUT_OF_SYNC_LOCAL, "out of sync", null);
- throw new CoreException(status);
- }
- }
-}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/TextFileBufferManager.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/TextFileBufferManager.java
deleted file mode 100644
index e268556..0000000
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/TextFileBufferManager.java
+++ /dev/null
@@ -1,301 +0,0 @@
-/**********************************************************************
-Copyright (c) 2000, 2003 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-
-Contributors:
- IBM Corporation - Initial implementation
-**********************************************************************/
-package org.eclipse.core.internal.filebuffers;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-
-import org.eclipse.core.filebuffers.FileBuffers;
-import org.eclipse.core.filebuffers.IDocumentFactory;
-import org.eclipse.core.filebuffers.IDocumentSetupParticipant;
-import org.eclipse.core.filebuffers.IFileBuffer;
-import org.eclipse.core.filebuffers.IFileBufferListener;
-import org.eclipse.core.filebuffers.ISynchronizationContext;
-import org.eclipse.core.filebuffers.ITextFileBuffer;
-import org.eclipse.core.filebuffers.ITextFileBufferManager;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-
-/**
- * @since 3.0
- */
-public class TextFileBufferManager implements ITextFileBufferManager {
-
- private Map fFilesBuffers= new HashMap();
- private List fFileBufferListeners= new ArrayList();
- private ExtensionsRegistry fRegistry;
- private ISynchronizationContext fSynchronizationContext;
-
-
- public TextFileBufferManager() {
- fRegistry= new ExtensionsRegistry();
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBufferManager#connect(org.eclipse.core.runtime.IPath, org.eclipse.core.runtime.IProgressMonitor)
- */
- public void connect(IPath location, IProgressMonitor monitor) throws CoreException {
- Assert.isNotNull(location);
- location= FileBuffers.normalizeLocation(location);
-
- AbstractFileBuffer fileBuffer= (AbstractFileBuffer) fFilesBuffers.get(location);
- if (fileBuffer == null) {
-
- fileBuffer= createFileBuffer(location);
- if (fileBuffer == null)
- throw new CoreException(new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, 0, "Cannot create file buffer.", null));
-
- fileBuffer.create(location, monitor);
- fileBuffer.connect();
- fFilesBuffers.put(location, fileBuffer);
- fireBufferCreated(fileBuffer);
-
- } else {
- fileBuffer.connect();
- }
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBufferManager#disconnect(org.eclipse.core.runtime.IPath, org.eclipse.core.runtime.IProgressMonitor)
- */
- public void disconnect(IPath location, IProgressMonitor monitor) throws CoreException {
- Assert.isNotNull(location);
- location= FileBuffers.normalizeLocation(location);
-
- AbstractFileBuffer fileBuffer= (AbstractFileBuffer) fFilesBuffers.get(location);
- if (fileBuffer != null) {
- fileBuffer.disconnect();
- if (fileBuffer.isDisposed()) {
- fFilesBuffers.remove(location);
- fireBufferDisposed(fileBuffer);
- }
- }
- }
-
- private AbstractFileBuffer createFileBuffer(IPath location) {
- if (!isTextFile(location))
- return null;
-
- if (isWorkspaceResource(location))
- return new ResourceTextFileBuffer(this);
-
- return new JavaTextFileBuffer(this);
- }
-
- private boolean isWorkspaceResource(IPath location) {
- return FileBuffers.getWorkspaceFileAtLocation(location) != null;
- }
-
- private boolean isTextFile(IPath location) {
- return true;
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBufferManager#getFileBuffer(org.eclipse.core.runtime.IPath)
- */
- public IFileBuffer getFileBuffer(IPath location) {
- location= FileBuffers.normalizeLocation(location);
- return (IFileBuffer) fFilesBuffers.get(location);
- }
-
- /*
- * @see org.eclipse.core.filebuffers.ITextFileBufferManager#getTextFileBuffer(org.eclipse.core.runtime.IPath)
- */
- public ITextFileBuffer getTextFileBuffer(IPath location) {
- location= FileBuffers.normalizeLocation(location);
- return (ITextFileBuffer) fFilesBuffers.get(location);
- }
-
- /*
- * @see org.eclipse.core.buffer.text.IBufferedFileManager#getDefaultEncoding()
- */
- public String getDefaultEncoding() {
- return ResourcesPlugin.getEncoding();
- }
-
- /*
- * @see org.eclipse.core.filebuffers.ITextFileBufferManager#createEmptyDocument(org.eclipse.core.runtime.IPath)
- */
- public IDocument createEmptyDocument(IPath location) {
- Assert.isNotNull(location);
- location= FileBuffers.normalizeLocation(location);
-
- IDocumentFactory factory= fRegistry.getDocumentFactory(location);
-
- IDocument document= null;
- if (factory != null)
- document= factory.createDocument();
- else
- document= new Document();
-
- IDocumentSetupParticipant[] participants= fRegistry.getDocumentSetupParticipants(location);
- if (participants != null) {
- for (int i= 0; i < participants.length; i++)
- participants[i].setup(document);
- }
-
- return document;
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBufferManager#addFileBufferListener(org.eclipse.core.filebuffers.IFileBufferListener)
- */
- public void addFileBufferListener(IFileBufferListener listener) {
- Assert.isNotNull(listener);
- if (!fFileBufferListeners.contains(listener))
- fFileBufferListeners.add(listener);
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBufferManager#removeFileBufferListener(org.eclipse.core.filebuffers.IFileBufferListener)
- */
- public void removeFileBufferListener(IFileBufferListener listener) {
- Assert.isNotNull(listener);
- fFileBufferListeners.remove(listener);
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBufferManager#setSynchronizationContext(org.eclipse.core.filebuffers.ISynchronizationContext)
- */
- public void setSynchronizationContext(ISynchronizationContext context) {
- fSynchronizationContext= context;
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBufferManager#requestSynchronizationContext(org.eclipse.core.runtime.IPath)
- */
- public void requestSynchronizationContext(IPath location) {
- Assert.isNotNull(location);
- location= FileBuffers.normalizeLocation(location);
-
- AbstractFileBuffer fileBuffer= (AbstractFileBuffer) fFilesBuffers.get(location);
- if (fileBuffer != null)
- fileBuffer.requestSynchronizationContext();
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBufferManager#releaseSynchronizationContext(org.eclipse.core.runtime.IPath)
- */
- public void releaseSynchronizationContext(IPath location) {
- Assert.isNotNull(location);
- location= FileBuffers.normalizeLocation(location);
-
- AbstractFileBuffer fileBuffer= (AbstractFileBuffer) fFilesBuffers.get(location);
- if (fileBuffer != null)
- fileBuffer.releaseSynchronizationContext();
- }
-
- /**
- * Executes the given runnable in the synchronization context of this file buffer manager.
- * If there is no synchronization context connected with this manager, the runnable is
- * directly executed.
- *
- * @param runnable the runnable to be executed
- */
- public void execute(Runnable runnable, boolean requestSynchronizationContext) {
- if (requestSynchronizationContext && fSynchronizationContext != null)
- fSynchronizationContext.run(runnable);
- else
- runnable.run();
- }
-
- protected void fireDirtyStateChanged(IFileBuffer buffer, boolean isDirty) {
- Iterator e= new ArrayList(fFileBufferListeners).iterator();
- while (e.hasNext()) {
- IFileBufferListener l= (IFileBufferListener) e.next();
- l.dirtyStateChanged(buffer, isDirty);
- }
- }
-
- protected void fireBufferContentAboutToBeReplaced(IFileBuffer buffer) {
- Iterator e= new ArrayList(fFileBufferListeners).iterator();
- while (e.hasNext()) {
- IFileBufferListener l= (IFileBufferListener) e.next();
- l.bufferContentAboutToBeReplaced(buffer);
- }
- }
-
- protected void fireBufferContentReplaced(IFileBuffer buffer) {
- Iterator e= new ArrayList(fFileBufferListeners).iterator();
- while (e.hasNext()) {
- IFileBufferListener l= (IFileBufferListener) e.next();
- l.bufferContentReplaced(buffer);
- }
- }
-
- protected void fireUnderlyingFileMoved(IFileBuffer buffer, IPath target) {
- Iterator e= new ArrayList(fFileBufferListeners).iterator();
- while (e.hasNext()) {
- IFileBufferListener l= (IFileBufferListener) e.next();
- l.underlyingFileMoved(buffer, target);
- }
- }
-
- protected void fireUnderlyingFileDeleted(IFileBuffer buffer) {
- Iterator e= new ArrayList(fFileBufferListeners).iterator();
- while (e.hasNext()) {
- IFileBufferListener l= (IFileBufferListener) e.next();
- l.underlyingFileDeleted(buffer);
- }
- }
-
- protected void fireStateValidationChanged(IFileBuffer buffer, boolean isStateValidated) {
- Iterator e= new ArrayList(fFileBufferListeners).iterator();
- while (e.hasNext()) {
- IFileBufferListener l= (IFileBufferListener) e.next();
- l.stateValidationChanged(buffer, isStateValidated);
- }
- }
-
- protected void fireStateChanging(IFileBuffer buffer) {
- Iterator e= new ArrayList(fFileBufferListeners).iterator();
- while (e.hasNext()) {
- IFileBufferListener l= (IFileBufferListener) e.next();
- l.stateChanging(buffer);
- }
- }
-
- protected void fireStateChangeFailed(IFileBuffer buffer) {
- Iterator e= new ArrayList(fFileBufferListeners).iterator();
- while (e.hasNext()) {
- IFileBufferListener l= (IFileBufferListener) e.next();
- l.stateChangeFailed(buffer);
- }
- }
-
- protected void fireBufferCreated(IFileBuffer buffer) {
- Iterator e= new ArrayList(fFileBufferListeners).iterator();
- while (e.hasNext()) {
- IFileBufferListener l= (IFileBufferListener) e.next();
- l.bufferCreated(buffer);
- }
- }
-
- protected void fireBufferDisposed(IFileBuffer buffer) {
- Iterator e= new ArrayList(fFileBufferListeners).iterator();
- while (e.hasNext()) {
- IFileBufferListener l= (IFileBufferListener) e.next();
- l.bufferDisposed(buffer);
- }
- }
-}
diff --git a/org.eclipse.jface.text/.classpath b/org.eclipse.jface.text/.classpath
deleted file mode 100644
index f2a7ad8..0000000
--- a/org.eclipse.jface.text/.classpath
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="projection"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/org.eclipse.jface.text/.cvsignore b/org.eclipse.jface.text/.cvsignore
deleted file mode 100644
index ba077a4..0000000
--- a/org.eclipse.jface.text/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
diff --git a/org.eclipse.jface.text/.options b/org.eclipse.jface.text/.options
deleted file mode 100644
index 9435aef..0000000
--- a/org.eclipse.jface.text/.options
+++ /dev/null
@@ -1,7 +0,0 @@
-# Debugging options for the org.eclipse.jface.text plug-in
-
-# Prints debug information related to AnnotationPainter
-org.eclipse.jface.text/debug/AnnotationPainter= true
-
-# Prints debug information related to AbstractContentAssistSubjectAdapter and its subclasses
-org.eclipse.jface.text/debug/ContentAssistSubjectAdapters= true
\ No newline at end of file
diff --git a/org.eclipse.jface.text/.project b/org.eclipse.jface.text/.project
deleted file mode 100644
index 4c20484..0000000
--- a/org.eclipse.jface.text/.project
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jface.text</name>
- <comment></comment>
- <projects>
- <project>org.eclipse.core.runtime.compatibility</project>
- <project>org.eclipse.jface</project>
- <project>org.eclipse.swt</project>
- <project>org.eclipse.text</project>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.eclipse.pde.PluginNature</nature>
- </natures>
-</projectDescription>
diff --git a/org.eclipse.jface.text/about.html b/org.eclipse.jface.text/about.html
deleted file mode 100644
index 9db411a..0000000
--- a/org.eclipse.jface.text/about.html
+++ /dev/null
@@ -1,30 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<html>
-<head>
-<title>About</title>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</head>
-<body lang="EN-US">
-<h2>About This Content</h2>
-
-<p>20th June, 2002</p>
-<h3>License</h3>
-<p>Eclipse.org makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
-Common Public License Version 1.0 ("CPL"). A copy of the CPL is available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>.
-For purposes of the CPL, "Program" will mean the Content.</p>
-
-<h3>Contributions</h3>
-
-<p>If this Content is licensed to you under the terms and conditions of the CPL, any Contributions, as defined in the CPL, uploaded, submitted, or otherwise
-made available to Eclipse.org, members of Eclipse.org and/or the host of Eclipse.org web site, by you that relate to such
-Content are provided under the terms and conditions of the CPL and can be made available to others under the terms of the CPL.</p>
-
-<p>If this Content is licensed to you under license terms and conditions other than the CPL ("Other License"), any modifications, enhancements and/or
-other code and/or documentation ("Modifications") uploaded, submitted, or otherwise made available to Eclipse.org, members of Eclipse.org and/or the
-host of Eclipse.org, by you that relate to such Content are provided under terms and conditions of the Other License and can be made available
-to others under the terms of the Other License. In addition, with regard to Modifications for which you are the copyright holder, you are also
-providing the Modifications under the terms and conditions of the CPL and such Modifications can be made available to others under the terms of
-the CPL.</p>
-
-</body>
-</html>
\ No newline at end of file
diff --git a/org.eclipse.jface.text/build.properties b/org.eclipse.jface.text/build.properties
deleted file mode 100644
index 01abca1..0000000
--- a/org.eclipse.jface.text/build.properties
+++ /dev/null
@@ -1,16 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2003 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-bin.includes = plugin.properties,\
- plugin.xml,\
- *.jar,\
- about.html
-source.jfacetext.jar = src/,\
- projection/
diff --git a/org.eclipse.jface.text/plugin.properties b/org.eclipse.jface.text/plugin.properties
deleted file mode 100644
index eb29566..0000000
--- a/org.eclipse.jface.text/plugin.properties
+++ /dev/null
@@ -1,12 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2003 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-pluginName = JFace Text
-providerName = Eclipse.org
diff --git a/org.eclipse.jface.text/plugin.xml b/org.eclipse.jface.text/plugin.xml
deleted file mode 100644
index 0e997a5..0000000
--- a/org.eclipse.jface.text/plugin.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
-<plugin
- id="org.eclipse.jface.text"
- name="%pluginName"
- version="3.0.0"
- provider-name="%providerName">
-
- <runtime>
- <library name="jfacetext.jar">
- <export name="*"/>
- <packages prefixes="org.eclipse.jface.text"/>
- </library>
- </runtime>
-
- <requires>
- <import plugin="org.eclipse.core.runtime.compatibility"/>
- <import plugin="org.eclipse.text" export="true"/>
- <import plugin="org.eclipse.swt"/>
- <import plugin="org.eclipse.jface"/>
- </requires>
-
-</plugin>
diff --git a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/OutlinerRulerColumn.java b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/OutlinerRulerColumn.java
deleted file mode 100644
index d8a7e9b..0000000
--- a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/OutlinerRulerColumn.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.source;
-
-
-import java.util.Iterator;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.Position;
-
-
-/**
- * A ruler column for controlling the behavior of a <code>ProjectionSourceViewer</code>.
- * This class is for internal use only.
- *
- * @since 2.1
- * @deprecated
- */
-public class OutlinerRulerColumn extends AnnotationRulerColumn {
-
- /**
- * Creates a new outliner ruler column.
- *
- * @param model the column's annotation model
- * @param width the width in pixels
- */
- public OutlinerRulerColumn(IAnnotationModel model, int width) {
- super(model, width);
- }
-
- /*
- * @see org.eclipse.jface.text.source.AnnotationRulerColumn#mouseDoubleClicked(int)
- */
- protected void mouseDoubleClicked(int line) {
- ProjectionAnnotation annotation= findAnnotation(line);
- if (annotation != null)
- annotation.run(getCachedTextViewer());
- }
-
- /**
- * Returns the projection annotation of the column's annotation
- * model that contains the given line.
- *
- * @param line the line
- * @return the projection annotation containing the given line
- */
- private ProjectionAnnotation findAnnotation(int line) {
- IAnnotationModel model= getModel();
- if (model != null) {
- Iterator e= model.getAnnotationIterator();
- while (e.hasNext()) {
- Object next= e.next();
- if (next instanceof ProjectionAnnotation) {
- ProjectionAnnotation annotation= (ProjectionAnnotation) next;
- Position p= model.getPosition(annotation);
- if (contains(p, line))
- return annotation;
- }
- }
- }
- return null;
- }
-
- /**
- * Returns whether the given position contains the given line.
- *
- * @param p the position
- * @param line the line
- * @return <code>true</code> if the given position contains the given line, <code>false</code> otherwise
- */
- private boolean contains(Position p, int line) {
-
- IDocument document= getCachedTextViewer().getDocument();
-
- try {
-
- int startLine= document.getLineOfOffset(p.getOffset());
- if (line < startLine)
- return false;
- if (line == startLine)
- return true;
-
- int endLine= document.getLineOfOffset(p.getOffset() + Math.max(p.getLength() -1, 0));
- return (startLine < line && line <= endLine) ;
-
- } catch (BadLocationException x) {
- }
-
- return false;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerColumn#createControl(org.eclipse.jface.text.source.CompositeRuler, org.eclipse.swt.widgets.Composite)
- */
- public Control createControl(CompositeRuler parentRuler, Composite parentControl) {
- Control control= super.createControl(parentRuler, parentControl);
- Display display= parentControl.getDisplay();
- Color background= display.getSystemColor(SWT.COLOR_LIST_BACKGROUND);
- control.setBackground(background);
- return control;
- }
-}
diff --git a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/ProjectionAnnotation.java b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/ProjectionAnnotation.java
deleted file mode 100644
index 822b3a7..0000000
--- a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/ProjectionAnnotation.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.source;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Canvas;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.Position;
-
-/**
- * Annotation used to represent the projection of a master document onto
- * a <code>ProjectionDocument</code>. A projection annotation can be either
- * expanded or collapsed. If expaned it corresponds to a fragment of the
- * projection document. If collapsed, it represents a region of the master document
- * that does not have a corresponding fragment in the projection document. <p>
- * Draws itself in a tree like fashion.<p>
- * This class if for internal use only.
- *
- * @since 2.1
- * @deprecated
- */
-public class ProjectionAnnotation extends Annotation implements IAnnotationPresentation {
-
- private static final int OUTER_MARGIN= 1;
- private static final int INNER_MARGIN= 1;
- private static final int PIXELS= 1;
- private static final int LEGS= 2;
- private static final int MIDDLE= PIXELS + INNER_MARGIN + LEGS;
- private static final int SIZE= 2 * MIDDLE + PIXELS;
-
- /** The range in the master document */
- private Position fProjectionRange;
- /** The state of this annotation */
- private boolean fIsFolded= false;
-
- /**
- * Creates a new projection annotation for the given range of the master document.
- *
- * @param range the range.
- */
- public ProjectionAnnotation(Position range) {
- fProjectionRange= range;
- }
-
- /*
- * @see org.eclipse.jface.text.source.Annotation#paint(org.eclipse.swt.graphics.GC, org.eclipse.swt.widgets.Canvas, org.eclipse.swt.graphics.Rectangle)
- */
- public void paint(GC gc, Canvas canvas, Rectangle rectangle) {
- Color fg= gc.getForeground();
- gc.setForeground(canvas.getDisplay().getSystemColor(SWT.COLOR_BLUE));
-
-
- Rectangle r= new Rectangle(rectangle.x + OUTER_MARGIN, rectangle.y + OUTER_MARGIN, SIZE -1 , SIZE -1);
- gc.drawRectangle(r);
- gc.drawLine(r.x + PIXELS + INNER_MARGIN, r.y + MIDDLE, r.x + r.width - PIXELS - INNER_MARGIN , r.y + MIDDLE);
- if (fIsFolded) {
- gc.drawLine(r.x + MIDDLE, r.y + PIXELS + INNER_MARGIN, r.x + MIDDLE, r.y + r.height - PIXELS - INNER_MARGIN);
- } else {
- gc.drawLine(r.x + MIDDLE, r.y + r.height, r.x + MIDDLE, rectangle.y + rectangle.height - OUTER_MARGIN);
- gc.drawLine(r.x + MIDDLE, rectangle.y + rectangle.height - OUTER_MARGIN, r.x + r.width - INNER_MARGIN, rectangle.y + rectangle.height - OUTER_MARGIN);
- }
-
- gc.setForeground(fg);
- }
-
- /**
- * Toogles the state of this annotation and updates the given viewer accordingly.
- *
- * @param viewer the viewer
- */
- public void run(ITextViewer viewer) {
-
- if (viewer instanceof ProjectionSourceViewer) {
- ProjectionSourceViewer projectionViewer= (ProjectionSourceViewer) viewer;
-
- if (fIsFolded) {
-
- fIsFolded= false;
- projectionViewer.expand(fProjectionRange.getOffset(), fProjectionRange.getLength());
-
- } else {
-
- try {
- IDocument document= projectionViewer.getDocument();
- int line= document.getLineOfOffset(fProjectionRange.getOffset());
- int offset= document.getLineOffset(line + 1);
-
- int length= fProjectionRange.getLength() - (offset - fProjectionRange.getOffset());
- if (length > 0) {
- fIsFolded= true;
- projectionViewer.collapse(offset, length);
- }
- } catch (BadLocationException x) {
- }
- }
- }
- }
-
- /**
- * Returns the state of this annotation.
- *
- * @return <code>true</code> if collapsed
- */
- public boolean isFolded() {
- return fIsFolded;
- }
-}
diff --git a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/ProjectionSourceViewer.java b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/ProjectionSourceViewer.java
deleted file mode 100644
index 855283d..0000000
--- a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/ProjectionSourceViewer.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.source;
-
-
-import java.util.Iterator;
-
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.VerifyEvent;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Composite;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ISlaveDocumentManager;
-import org.eclipse.jface.text.ITextViewerExtension3;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.ProjectionDocument;
-import org.eclipse.jface.text.ProjectionDocumentManager;
-
-
-/**
- * A projection source viewer is a source viewer which does not support the concept of a visible region. Instead it supports
- * to dynamically hide and show regions of its document. Uses <code>ProjectionDocumentManager</code> as it internal slave document manager.<p>
- * This class is for internal use only.
- *
- * @since 2.1
- * @deprecated
- */
-public class ProjectionSourceViewer extends SourceViewer implements ISourceViewer, ITextViewerExtension3 {
-
- /** The projection annotation model */
- private IAnnotationModel fProjectionAnnotationModel;
-
- /**
- * Creates a new projection source viewer.
- *
- * @param parent the SWT parent control
- * @param ruler the vertical ruler
- * @param styles the SWT style bits
- */
- public ProjectionSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
- super(parent, ruler, styles);
- }
-
- /*
- * @see ISourceViewer#setDocument(IDocument, IAnnotationModel, int, int)
- */
- public void setDocument(IDocument document, IAnnotationModel annotationModel, int visibleRegionOffset, int visibleRegionLength) {
- if (getDocument() != null && fProjectionAnnotationModel != null)
- fProjectionAnnotationModel.disconnect(getDocument());
-
- super.setDocument(document, annotationModel, visibleRegionOffset, visibleRegionLength);
-
- if (getDocument() != null && fProjectionAnnotationModel != null)
- fProjectionAnnotationModel.connect(getDocument());
- }
-
- /*
- * @see TextViewer#handleDispose()
- */
- protected void handleDispose() {
-
- if (getDocument() != null && fProjectionAnnotationModel != null) {
- fProjectionAnnotationModel.disconnect(getDocument());
- fProjectionAnnotationModel= null;
- }
-
- super.handleDispose();
- }
-
- /**
- * Returns the projection annotation model.
- *
- * @return the projection annotation model
- */
- public IAnnotationModel getProjectionAnnotationModel() {
- return fProjectionAnnotationModel;
- }
-
- /**
- * Sets the projection annotation model.
- *
- * @param projectionAnnotationModel the projection annotation model
- */
- public void setProjectionAnnotationModel(IAnnotationModel projectionAnnotationModel) {
- fProjectionAnnotationModel= projectionAnnotationModel;
- }
-
- /*
- * @see org.eclipse.jface.text.TextViewer#createSlaveDocumentManager()
- */
- protected ISlaveDocumentManager createSlaveDocumentManager() {
- return new ProjectionDocumentManager();
- }
-
- /*
- * @see org.eclipse.jface.text.TextViewer#updateVisibleDocument(org.eclipse.jface.text.IDocument, int, int)
- */
- protected boolean updateVisibleDocument(IDocument visibleDocument, int visibleRegionOffset, int visibleRegionLength) throws BadLocationException {
- if (visibleDocument instanceof ProjectionDocument) {
- ProjectionDocument document= (ProjectionDocument) visibleDocument;
- document.addFragment(visibleRegionOffset, visibleRegionLength);
- }
- return true;
- }
-
- /**
- * Hides the given range by collapsing it.
- *
- * @param offset the offset of the range to hide
- * @param length the length of the range to hide
- */
- public void collapse(int offset, int length) {
-
- IDocument previous= getVisibleDocument();
- IDocument slave= createSlaveDocument(previous);
-
- if (slave instanceof ProjectionDocument) {
-
- StyledText textWidget= getTextWidget();
- try {
-
- if (textWidget != null)
- textWidget.setRedraw(false);
-
-
- int topIndex= getTopIndex();
- Point selection= getSelectedRange();
-
- // adapt selection
- int selectionEnd= selection.x + selection.y;
- if (offset < selectionEnd && selectionEnd <= offset + length) {
-
- int lineEnd= offset;
-
- try {
- IDocument document= getDocument();
- int line= document.getLineOfOffset(offset);
- IRegion lineInfo= document.getLineInformation(Math.max(line -1, 0));
- lineEnd= lineInfo.getOffset() + lineInfo.getLength();
- } catch (BadLocationException x) {
- }
-
- if (offset <= selection.x && selection.x < offset + length) {
- selection.x= lineEnd;
- selection.y= 0;
- } else {
- selection.y= Math.max(lineEnd - selection.x, 0);
- }
-
- } else if (offset <= selection.x && selection.x < offset + length) {
- int delta= offset + length - selection.x;
- selection.x= offset + length;
- selection.y -= delta;
- }
-
- ((ProjectionDocument) slave).hide(offset, length);
- setVisibleDocument(slave);
-
- setSelectedRange(selection.x, selection.y);
- setTopIndex(topIndex);
-
- } finally {
- if(textWidget != null)
- textWidget.setRedraw(true);
- }
- }
- }
-
- /**
- * Makes all hidden ranges in the given range visible again.
- *
- * @param offset the offset of the range
- * @param length the length of the range
- */
- public void expand(int offset, int length) {
- if (getVisibleDocument() instanceof ProjectionDocument) {
- ProjectionDocument document= (ProjectionDocument) getVisibleDocument();
-
- StyledText textWidget= getTextWidget();
- try {
-
- if (textWidget != null)
- textWidget.setRedraw(false);
-
- Point selection= getSelectedRange();
- int topIndex= getTopIndex();
-
- document.show(offset, length);
- setVisibleDocument(document);
-
- setSelectedRange(selection.x, selection.y);
- setTopIndex(topIndex);
-
- } finally {
- if (textWidget != null)
- textWidget.setRedraw(true);
- }
- }
- }
-
- /*
- * @see org.eclipse.jface.text.ITextViewer#getVisibleRegion()
- */
- public IRegion getVisibleRegion() {
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.TextViewer#getVisibleRegionOffset()
- */
- protected int getVisibleRegionOffset() {
- return -1;
- }
-
- /*
- * @see org.eclipse.jface.text.TextViewer#internalGetVisibleRegion()
- */
- protected IRegion internalGetVisibleRegion() {
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.ITextViewer#overlapsWithVisibleRegion(int,int)
- */
- public boolean overlapsWithVisibleRegion(int offset, int length) {
- return false;
- }
-
- /*
- * @see org.eclipse.jface.text.TextViewer#getVisibleDocument()
- */
- public IDocument getVisibleDocument() {
- return super.getVisibleDocument();
- }
-
- /*
- * @see org.eclipse.jface.text.TextViewer#handleVerifyEvent(org.eclipse.swt.events.VerifyEvent)
- */
- protected void handleVerifyEvent(VerifyEvent e) {
- IRegion modelRange= event2ModelRange(e);
- Iterator iterator= fProjectionAnnotationModel.getAnnotationIterator();
- while (iterator.hasNext()) {
- ProjectionAnnotation annotation= (ProjectionAnnotation) iterator.next();
- if (annotation.isFolded()) {
- Position position= fProjectionAnnotationModel.getPosition(annotation);
- if (position.overlapsWith(modelRange.getOffset(), modelRange.getLength()) /* || is a delete at the boundary */ ) {
- e.doit= false;
- annotation.run(this);
- }
- }
- }
- }
-}
diff --git a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionAnnotation.java b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionAnnotation.java
deleted file mode 100644
index 2a0a7dc..0000000
--- a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionAnnotation.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.source.projection;
-
-import org.eclipse.swt.SWT;
-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.widgets.Canvas;
-
-import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.jface.text.source.IAnnotationPresentation;
-
-/**
- * Annotation used to represent the projection of a master document onto a
- * <code>ProjectionDocument</code>. A projection annotation can be either
- * expanded or collapsed. If expanded it corresponds to a segment of the
- * projection document. If collapsed, it represents a region of the master
- * document that does not have a corresponding segment in the projection
- * document.
- * <p>
- * Internal class. Do not use. Public only for testing purposes.
- *
- * @since 3.0
- */
-public class ProjectionAnnotation extends Annotation implements IAnnotationPresentation {
-
- /**
- * The type of projection annotations.
- */
- public static final String TYPE= "org.eclipse.projection";
-
- private static final boolean PLUS= false;
- private static final int COLOR= SWT.COLOR_DARK_GRAY;
-
- private static final int OUTER_MARGIN= 1;
- private static final int INNER_MARGIN= 1;
- private static final int PIXELS= 1;
- private static final int LEGS= 2;
- private static final int MIDDLE= PIXELS + INNER_MARGIN + LEGS;
- private static final int SIZE= 2 * MIDDLE + PIXELS;
-
- /** The state of this annotation */
- private boolean fIsCollapsed= false;
- /** Indicates whether this annotation should be painted as range */
- private boolean fIsRangeIndication= false;
-
- /**
- * Creates a new projection annotation.
- */
- public ProjectionAnnotation() {
- super(TYPE, false, null);
- }
-
- public void setRangeIndication(boolean rangeIndication) {
- fIsRangeIndication= rangeIndication;
- }
-
- private void paintPlus(GC gc, Canvas canvas, Rectangle rectangle) {
- Color fg= gc.getForeground();
- gc.setForeground(canvas.getDisplay().getSystemColor(COLOR));
-
-
- Rectangle r= new Rectangle(rectangle.x + OUTER_MARGIN, rectangle.y + OUTER_MARGIN, SIZE -1 , SIZE -1);
- gc.drawRectangle(r);
- gc.drawLine(r.x + PIXELS + INNER_MARGIN, r.y + MIDDLE, r.x + r.width - PIXELS - INNER_MARGIN , r.y + MIDDLE);
- if (fIsCollapsed) {
- gc.drawLine(r.x + MIDDLE, r.y + PIXELS + INNER_MARGIN, r.x + MIDDLE, r.y + r.height - PIXELS - INNER_MARGIN);
- } else {
- gc.drawLine(r.x + MIDDLE, r.y + r.height, r.x + MIDDLE, rectangle.y + rectangle.height - OUTER_MARGIN);
- gc.drawLine(r.x + MIDDLE, rectangle.y + rectangle.height - OUTER_MARGIN, r.x + r.width - INNER_MARGIN, rectangle.y + rectangle.height - OUTER_MARGIN);
- }
-
- gc.setForeground(fg);
- }
-
- private int[] computePolygon(Rectangle rectangle) {
-
- int leftX= rectangle.x;
- int rightX= rectangle.x + rectangle.width;
- int middleX= (leftX + rightX)/2;
-
- int upperY= rectangle.y;
- int lowerY= rectangle.y + rectangle.height;
- int middleY= (upperY + lowerY)/2;
-
- if (isCollapsed()) {
- Point upperLeft= new Point(leftX, upperY-1);
- Point middleRight= new Point(rightX, middleY);
- Point lowerLeft= new Point(leftX, lowerY);
- return new int[] {upperLeft.x, upperLeft.y, middleRight.x, middleRight.y, lowerLeft.x, lowerLeft.y};
- } else {
- Point middleLeft= new Point(leftX, upperY);
- Point middleRight= new Point(rightX, upperY);
- Point lowerMiddle= new Point(middleX, lowerY);
- return new int[] {middleLeft.x, middleLeft.y, middleRight.x , middleRight.y, lowerMiddle.x, lowerMiddle.y };
- }
- }
-
- private Rectangle computeRectangle(Rectangle rectangle, int lineHeight) {
- final int MARGIN= 1;
- int leftX= rectangle.x + MARGIN;
- int length= rectangle.width - 2*MARGIN;
- int yDelta= (lineHeight - length)/2;
- int upperY= rectangle.y + yDelta;
- return new Rectangle(leftX, upperY, length, length);
- }
-
- private Point paintTriangle(GC gc, Canvas canvas, Rectangle rectangle) {
- Point endPoint= null;
- int lineHeight= gc.getFontMetrics().getHeight();
- int[] polygon= computePolygon(computeRectangle(rectangle, lineHeight));
- if (isCollapsed()) {
- Color bg= gc.getBackground();
- gc.setBackground(canvas.getDisplay().getSystemColor(COLOR));
- gc.fillPolygon(polygon);
- gc.setBackground(bg);
- } else {
- Color fg= gc.getForeground();
- gc.setForeground(canvas.getDisplay().getSystemColor(COLOR));
- gc.drawPolygon(polygon);
- gc.setForeground(fg);
- endPoint= new Point(polygon[polygon.length -2], polygon[polygon.length -1]);
- }
- return endPoint;
- }
-
- private void paintRangeIndication(GC gc, Canvas canvas, Rectangle rectangle, Point startPoint) {
- final int MARGIN= 1;
- Color fg= gc.getForeground();
- gc.setForeground(canvas.getDisplay().getSystemColor(COLOR));
- gc.drawLine(startPoint.x, startPoint.y, startPoint.x, rectangle.y + rectangle.height - MARGIN);
- gc.drawLine(startPoint.x, rectangle.y + rectangle.height - MARGIN, rectangle.x + rectangle.width - MARGIN, rectangle.y + rectangle.height - MARGIN);
- gc.setForeground(fg);
- }
-
- /*
- * @see org.eclipse.jface.text.source.Annotation#paint(org.eclipse.swt.graphics.GC, org.eclipse.swt.widgets.Canvas, org.eclipse.swt.graphics.Rectangle)
- */
- public void paint(GC gc, Canvas canvas, Rectangle rectangle) {
- if (PLUS)
- paintPlus(gc, canvas, rectangle);
- else {
- Point p= paintTriangle(gc, canvas, rectangle);
- if (p != null && fIsRangeIndication)
- paintRangeIndication(gc, canvas, rectangle, p);
- }
- }
-
- /**
- * Returns the state of this annotation.
- *
- * @return <code>true</code> if collapsed
- */
- public boolean isCollapsed() {
- return fIsCollapsed;
- }
-
- /**
- * Marks this annotation as being collapsed.
- */
- public void markCollapsed() {
- fIsCollapsed= true;
- }
-
- /**
- * Marks this annotation as being unfolded.
- */
- public void markExpanded() {
- fIsCollapsed= false;
- }
-}
diff --git a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionAnnotationHover.java b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionAnnotationHover.java
deleted file mode 100644
index 91bf1c7..0000000
--- a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionAnnotationHover.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.source.projection;
-
-import java.util.Iterator;
-
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.jface.resource.JFaceResources;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IInformationControl;
-import org.eclipse.jface.text.IInformationControlCreator;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.source.IAnnotationHover;
-import org.eclipse.jface.text.source.IAnnotationHoverExtension;
-import org.eclipse.jface.text.source.IAnnotationModel;
-import org.eclipse.jface.text.source.IAnnotationModelExtension;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.text.source.ISourceViewerExtension2;
-
-/**
- * Annotation hover for projection annotations.
- * <p>
- * Internal class. Do not use. Public for testing purposes only.
- *
- * @since 3.0
- */
-public class ProjectionAnnotationHover implements IAnnotationHover, IAnnotationHoverExtension {
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationHover#getHoverInfo(org.eclipse.jface.text.source.ISourceViewer, int)
- */
- public String getHoverInfo(ISourceViewer sourceViewer, int lineNumber) {
- // this is a no-op as semantics is defined by the implementation of the annotation hover extension
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationHoverExtension#getLineRange(org.eclipse.jface.text.source.ISourceViewer, int, int, int)
- */
- public ITextSelection getLineRange(ISourceViewer viewer, int line, int first, int number) {
- return null; // go for the default behavior
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationHoverExtension#getInformationControlCreator()
- */
- public IInformationControlCreator getInformationControlCreator() {
- return new IInformationControlCreator() {
- public IInformationControl createInformationControl(Shell parent) {
- return new SourceViewerInformationControl(parent, JFaceResources.TEXT_FONT);
- }
- };
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationHoverExtension#getHoverInfo(org.eclipse.jface.text.source.ISourceViewer, int, int, int)
- */
- public String getHoverInfo(ISourceViewer sourceViewer, int lineNumber, int first, int number) {
- return getProjectionTextAtLine(sourceViewer, lineNumber, number);
- }
-
- private int compareRulerLine(Position position, IDocument document, int line) {
- if (position.getOffset() > -1 && position.getLength() > -1) {
- try {
- int startLine= document.getLineOfOffset(position.getOffset());
- if (line == startLine)
- return 1;
- if (startLine <= line && line <= document.getLineOfOffset(position.getOffset() + position.getLength()))
- return 2;
- } catch (BadLocationException x) {
- }
- }
- return 0;
- }
-
- private String getProjectionTextAtLine(ISourceViewer viewer, int line, int numberOfLines) {
-
- IAnnotationModel model= null;
- if (viewer instanceof ISourceViewerExtension2) {
- ISourceViewerExtension2 viewerExtension= (ISourceViewerExtension2) viewer;
- IAnnotationModel visual= viewerExtension.getVisualAnnotationModel();
- if (visual instanceof IAnnotationModelExtension) {
- IAnnotationModelExtension modelExtension= (IAnnotationModelExtension) visual;
- model= modelExtension.getAnnotationModel(ProjectionViewer.PROJECTION_ANNOTATION_MODEL);
- }
- }
-
- if (model != null) {
- try {
- IDocument document= viewer.getDocument();
- Iterator e= model.getAnnotationIterator();
- while (e.hasNext()) {
- ProjectionAnnotation annotation= (ProjectionAnnotation) e.next();
- if (!annotation.isCollapsed())
- continue;
-
- Position position= model.getPosition(annotation);
- if (position == null)
- continue;
-
- if (1 == compareRulerLine(position, document, line))
- return getText(document, position.getOffset(), position.getLength(), numberOfLines);
-
- }
- } catch (BadLocationException x) {
- }
- }
-
- return null;
- }
-
- private String getText(IDocument document, int offset, int length, int numberOfLines) throws BadLocationException {
- int endLine= document.getLineOfOffset(offset) + Math.max(0, numberOfLines -1);
- IRegion lineInfo= document.getLineInformation(endLine);
- int endOffset= Math.min(offset + length, lineInfo.getOffset() + lineInfo.getLength());
- return document.get(offset, endOffset - offset);
- }
-}
diff --git a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionAnnotationModel.java b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionAnnotationModel.java
deleted file mode 100644
index aac5b27..0000000
--- a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionAnnotationModel.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.source.projection;
-
-import java.util.Iterator;
-
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.jface.text.source.AnnotationModel;
-
-
-/**
- * A projection annotation model.
- * <p>
- * Internal class. Do not use. Public only for testing purposes.
- *
- * @since 3.0
- */
-public class ProjectionAnnotationModel extends AnnotationModel {
-
- /**
- * Changes the state of the given annotation to collapsed. An appropriate
- * annotation model change event is sent out.
- *
- * @param annotation the annotation
- */
- public void collapse(Annotation annotation) {
- if (annotation instanceof ProjectionAnnotation) {
- ProjectionAnnotation projection= (ProjectionAnnotation) annotation;
- if (!projection.isCollapsed()) {
- projection.markCollapsed();
- modifyAnnotation(projection, true);
- }
- }
- }
-
- /**
- * Changes the state of the given annotation to expanded. An appropriate
- * annotation model change event is sent out.
- *
- * @param annotation the annotation
- */
- public void expand(Annotation annotation) {
- if (annotation instanceof ProjectionAnnotation) {
- ProjectionAnnotation projection= (ProjectionAnnotation) annotation;
- if (projection.isCollapsed()) {
- projection.markExpanded();
- modifyAnnotation(projection, true);
- }
- }
- }
-
- /**
- * Toggles the expansion state of the given annotation. An appropriate
- * annotation model change event is sent out.
- *
- * @param annotation the annotation
- */
- public void toggleExpansionState(Annotation annotation) {
- if (annotation instanceof ProjectionAnnotation) {
- ProjectionAnnotation projection= (ProjectionAnnotation) annotation;
-
- if (projection.isCollapsed())
- projection.markExpanded();
- else
- projection.markCollapsed();
-
- modifyAnnotation(projection, true);
- }
- }
-
- /**
- * Expands all annotations that overlap with the given range and are collapsed.
- *
- * @param offset the range offset
- * @param length the range length
- * @return <code>true</code> if any annotation has been expanded, <code>false</code> otherwise
- */
- public boolean expandAll(int offset, int length) {
-
- boolean expanding= false;
-
- Iterator iterator= getAnnotationIterator();
- while (iterator.hasNext()) {
- ProjectionAnnotation annotation= (ProjectionAnnotation) iterator.next();
- if (annotation.isCollapsed()) {
- Position position= getPosition(annotation);
- if (position.overlapsWith(offset, length) /* || is a delete at the boundary */ ) {
- annotation.markExpanded();
- modifyAnnotation(annotation, false);
- expanding= true;
- }
- }
- }
-
- if (expanding)
- fireModelChanged();
-
- return expanding;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionRulerColumn.java b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionRulerColumn.java
deleted file mode 100644
index faa45b6..0000000
--- a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionRulerColumn.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.source.projection;
-
-
-import java.util.Iterator;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseMoveListener;
-import org.eclipse.swt.events.MouseTrackAdapter;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.source.AnnotationRulerColumn;
-import org.eclipse.jface.text.source.CompositeRuler;
-import org.eclipse.jface.text.source.IAnnotationAccess;
-import org.eclipse.jface.text.source.IAnnotationModel;
-
-
-/**
- * A ruler column for controlling the behavior of a
- * <code>ProjectionSourceViewer</code>.
- * <p>
- * Internal class. Do not use. Public only for testing purposes.
- *
- * @since 3.0
- */
-public class ProjectionRulerColumn extends AnnotationRulerColumn {
-
- private ProjectionAnnotation fCurrentAnnotation;
-
- /**
- * Creates a new outliner ruler column.
- *
- * @param model the column's annotation model
- * @param width the width in pixels
- */
- public ProjectionRulerColumn(IAnnotationModel model, int width, IAnnotationAccess annotationAccess) {
- super(model, width, annotationAccess);
- }
-
- /*
- * @see org.eclipse.jface.text.source.AnnotationRulerColumn#mouseClicked(int)
- */
- protected void mouseClicked(int line) {
- clearCurrentAnnotation();
- ProjectionAnnotation annotation= findAnnotation(line);
- if (annotation != null) {
- ProjectionAnnotationModel model= (ProjectionAnnotationModel) getModel();
- model.toggleExpansionState(annotation);
- }
- }
-
- /**
- * Returns the projection annotation of the column's annotation
- * model that contains the given line.
- *
- * @param line the line
- * @return the projection annotation containing the given line
- */
- private ProjectionAnnotation findAnnotation(int line) {
-
- ProjectionAnnotation previousAnnotation= null;
-
- IAnnotationModel model= getModel();
- if (model != null) {
- IDocument document= getCachedTextViewer().getDocument();
-
- int previousDistance= Integer.MAX_VALUE;
-
- Iterator e= model.getAnnotationIterator();
- while (e.hasNext()) {
- Object next= e.next();
- if (next instanceof ProjectionAnnotation) {
- ProjectionAnnotation annotation= (ProjectionAnnotation) next;
- Position p= model.getPosition(annotation);
-
- int distance= getDistance(p, document, line);
- if (distance == -1)
- continue;
-
- if (distance < previousDistance) {
- previousAnnotation= annotation;
- previousDistance= distance;
- }
- }
- }
-
- }
-
- return previousAnnotation;
- }
-
- /**
- * Returns the distance of the given line to the the start line of the given position in the given document. The distance is
- * <code>-1</code> when the line is not included in the given position.
- *
- * @param position the position
- * @param document the document
- * @param line the line
- * @return <code>-1</code> if line is not contained, a position number otherwise
- */
- private int getDistance(Position position, IDocument document, int line) {
- if (position.getOffset() > -1 && position.getLength() > -1) {
- try {
- int startLine= document.getLineOfOffset(position.getOffset());
- int endLine= document.getLineOfOffset(position.getOffset() + position.getLength());
- if (startLine <= line && line < endLine)
- return line - startLine;
- } catch (BadLocationException x) {
- }
- }
- return -1;
- }
-
- private boolean clearCurrentAnnotation() {
- if (fCurrentAnnotation != null) {
- fCurrentAnnotation.setRangeIndication(false);
- fCurrentAnnotation= null;
- return true;
- }
- return false;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerColumn#createControl(org.eclipse.jface.text.source.CompositeRuler, org.eclipse.swt.widgets.Composite)
- */
- public Control createControl(CompositeRuler parentRuler, Composite parentControl) {
- Control control= super.createControl(parentRuler, parentControl);
- // set background
- Display display= parentControl.getDisplay();
- Color background= display.getSystemColor(SWT.COLOR_LIST_BACKGROUND);
- control.setBackground(background);
- // install hover listener
- control.addMouseTrackListener(new MouseTrackAdapter() {
- public void mouseHover(MouseEvent e) {
- boolean redraw= clearCurrentAnnotation();
- ProjectionAnnotation annotation= findAnnotation(toDocumentLineNumber(e.y));
- if (annotation != null && !annotation.isCollapsed()) {
- annotation.setRangeIndication(true);
- fCurrentAnnotation= annotation;
- redraw= true;
- }
- if (redraw)
- redraw();
-
- }
- public void mouseExit(MouseEvent e) {
- if (clearCurrentAnnotation())
- redraw();
- }
- });
- // install mouse move listener
- control.addMouseMoveListener(new MouseMoveListener() {
- public void mouseMove(MouseEvent e) {
- if (clearCurrentAnnotation())
- redraw();
- }
- });
- return control;
- }
-}
diff --git a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionSupport.java b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionSupport.java
deleted file mode 100644
index d860349..0000000
--- a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionSupport.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.source.projection;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.custom.StyledTextContent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontMetrics;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Display;
-
-import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.jface.text.source.AnnotationPainter;
-import org.eclipse.jface.text.source.IAnnotationAccess;
-import org.eclipse.jface.text.source.IAnnotationModel;
-import org.eclipse.jface.text.source.ISharedTextColors;
-import org.eclipse.jface.text.source.ISourceViewer;
-
-/**
- * Supports the configuration of projection capabilities for projection viewers.
- * <p>
- * API in progress. Do not yet use.
- *
- * @since 3.0
- */
-public class ProjectionSupport {
-
-
- private static class ProjectionAnnotationsPainter extends AnnotationPainter {
- public ProjectionAnnotationsPainter(ISourceViewer sourceViewer, IAnnotationAccess access) {
- super(sourceViewer, access);
- }
-
- /*
- * @see org.eclipse.jface.text.source.AnnotationPainter#isRepaintReason(int)
- */
- protected boolean isRepaintReason(int reason) {
- return true;
- }
-
- /*
- * @see org.eclipse.jface.text.source.AnnotationPainter#findAnnotationModel(org.eclipse.jface.text.source.ISourceViewer)
- */
- protected IAnnotationModel findAnnotationModel(ISourceViewer sourceViewer) {
- if (sourceViewer instanceof ProjectionViewer) {
- ProjectionViewer projectionViewer= (ProjectionViewer) sourceViewer;
- return projectionViewer.getProjectionAnnotationModel();
- }
- return null;
- }
- }
-
- private static class ProjectionDrawingStrategy implements AnnotationPainter.IDrawingStrategy {
- /*
- * @see org.eclipse.jface.text.source.AnnotationPainter.IDrawingStrategy#draw(org.eclipse.swt.graphics.GC, org.eclipse.swt.custom.StyledText, int, int, org.eclipse.swt.graphics.Color)
- */
- public void draw(Annotation annotation, GC gc, StyledText textWidget, int offset, int length, Color color) {
- if (gc != null && annotation instanceof ProjectionAnnotation) {
- ProjectionAnnotation projectionAnnotation= (ProjectionAnnotation) annotation;
- if (projectionAnnotation.isCollapsed()) {
-
- StyledTextContent content= textWidget.getContent();
- int line= content.getLineAtOffset(offset);
- int lineStart= content.getOffsetAtLine(line);
- String text= content.getLine(line);
- int lineLength= text == null ? 0 : text.length();
- int lineEnd= lineStart + lineLength;
- Point p= textWidget.getLocationAtOffset(lineEnd);
-
- Color c= gc.getForeground();
- gc.setForeground(color);
-
- FontMetrics metrics= gc.getFontMetrics();
- int lineHeight= metrics.getHeight();
- int verticalMargin= lineHeight/10;
- int height= lineHeight - 2*verticalMargin;
- int width= metrics.getAverageCharWidth();
- gc.drawRectangle(p.x, p.y + verticalMargin, width, height);
- int third= width/3;
- int dotsVertical= p.y + metrics.getLeading() + metrics.getAscent();
- gc.drawPoint(p.x + third, dotsVertical);
- gc.drawPoint(p.x + 2*third, dotsVertical);
-
- gc.setForeground(c);
- }
- }
- }
- }
-
- private final static Object PROJECTION= new Object();
-
- private static RGB getColor() {
- // TODO read out preference settings
- Color c= Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY);
- return c.getRGB();
- }
-
- /**
- * Enable projection for the given viewer
- *
- * @param viewer the viewer
- * @param annotationAccess the annotation access
- * @param sharedTextColors the shared text colors
- */
- public static void enableProjection(ISourceViewer viewer, IAnnotationAccess annotationAccess, ISharedTextColors sharedTextColors) {
-
- if (viewer instanceof ProjectionViewer) {
- ProjectionViewer projectionViewer= (ProjectionViewer) viewer;
-
- AnnotationPainter painter= new ProjectionAnnotationsPainter(projectionViewer, annotationAccess);
- painter.addDrawingStrategy(PROJECTION, new ProjectionDrawingStrategy());
- painter.addAnnotationType(ProjectionAnnotation.TYPE, PROJECTION);
- painter.setAnnotationTypeColor(ProjectionAnnotation.TYPE, sharedTextColors.getColor(getColor()));
- projectionViewer.addPainter(painter);
-
- ProjectionRulerColumn column= new ProjectionRulerColumn(projectionViewer.getProjectionAnnotationModel(), 9, annotationAccess);
- column.addAnnotationType(ProjectionAnnotation.TYPE);
- column.setHover(new ProjectionAnnotationHover());
- projectionViewer.addVerticalRulerColumn(column);
- }
- }
-
- /**
- * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
- */
- public static Object getAdapter(ISourceViewer viewer, Class required) {
- if (ProjectionAnnotationModel.class.equals(required)) {
- if (viewer instanceof ProjectionViewer) {
- ProjectionViewer projectionViewer= (ProjectionViewer) viewer;
- return projectionViewer.getProjectionAnnotationModel();
- }
- }
- return null;
- }
-}
diff --git a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java
deleted file mode 100644
index d82a10e..0000000
--- a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java
+++ /dev/null
@@ -1,522 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.source.projection;
-
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.VerifyEvent;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Composite;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ISlaveDocumentManager;
-import org.eclipse.jface.text.ITextViewerExtension5;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.projection.ProjectionDocument;
-import org.eclipse.jface.text.projection.ProjectionDocumentManager;
-import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.jface.text.source.AnnotationModelEvent;
-import org.eclipse.jface.text.source.CompositeRuler;
-import org.eclipse.jface.text.source.IAnnotationModel;
-import org.eclipse.jface.text.source.IAnnotationModelExtension;
-import org.eclipse.jface.text.source.IAnnotationModelListener;
-import org.eclipse.jface.text.source.IAnnotationModelListenerExtension;
-import org.eclipse.jface.text.source.IOverviewRuler;
-import org.eclipse.jface.text.source.IVerticalRuler;
-import org.eclipse.jface.text.source.IVerticalRulerColumn;
-import org.eclipse.jface.text.source.SourceViewer;
-
-
-/**
- * A projection source viewer is a source viewer which does not support the
- * concept of a single visible region. Instead it supports multiple visible
- * regions which can dynamically be changed.
- * <p>
- * A projection source viewer uses a <code>ProjectionDocumentManager</code>
- * for the management of the visible document.
- * <p>
- * API in progress. Do not yet use.
- *
- * @since 3.0
- */
-public class ProjectionViewer extends SourceViewer implements ITextViewerExtension5 {
-
- /**
- * Internal listener to changes of the projection annotation model.
- */
- private class ProjectionAnnotationModelListener implements IAnnotationModelListener, IAnnotationModelListenerExtension {
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationModelListener#modelChanged(org.eclipse.jface.text.source.IAnnotationModel)
- */
- public void modelChanged(IAnnotationModel model) {
- catchupWithProjectionAnnotationModel(null);
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationModelListenerExtension#modelChanged(org.eclipse.jface.text.source.AnnotationModelEvent)
- */
- public void modelChanged(AnnotationModelEvent event) {
- catchupWithProjectionAnnotationModel(event);
- }
- }
-
- /**
- * Key of the projection annotation model inside the visual annotation model.
- */
- protected final static Object PROJECTION_ANNOTATION_MODEL= new Object();
-
-
- /** The projection annotation model used by this viewer. */
- private ProjectionAnnotationModel fProjectionAnnotationModel;
- /** The projection annotation model listener */
- private IAnnotationModelListener fProjectionAnnotationModelListener= new ProjectionAnnotationModelListener();
-
-
- /**
- * Creates a new projection source viewer.
- *
- * @param parent the SWT parent control
- * @param ruler the vertical ruler
- * @param styles the SWT style bits
- */
- public ProjectionViewer(Composite parent, IVerticalRuler ruler, IOverviewRuler overviewRuler, boolean showsAnnotationOverview, int styles) {
- super(parent, ruler, overviewRuler, showsAnnotationOverview, styles);
- }
-
- /**
- * Adds the projection annotation model to the given annotation model.
- *
- * @param model the model to which the projection annotation model is added
- */
- private void addProjectionAnnotationModel(IAnnotationModel model) {
- if (model instanceof IAnnotationModelExtension) {
- IAnnotationModelExtension extension= (IAnnotationModelExtension) model;
- extension.addAnnotationModel(PROJECTION_ANNOTATION_MODEL, fProjectionAnnotationModel);
- fProjectionAnnotationModel.addAnnotationModelListener(fProjectionAnnotationModelListener);
- }
- }
-
- /**
- * Removes the projection annotation model from the given annotation model.
- *
- * @param model the mode from which the projection annotation model is removed
- */
- private void removeProjectionAnnotationModel(IAnnotationModel model) {
- if (model instanceof IAnnotationModelExtension) {
- fProjectionAnnotationModel.removeAnnotationModelListener(fProjectionAnnotationModelListener);
- IAnnotationModelExtension extension= (IAnnotationModelExtension) model;
- extension.removeAnnotationModel(PROJECTION_ANNOTATION_MODEL);
- }
- }
-
- /*
- * @see org.eclipse.jface.text.source.SourceViewer#createVisualAnnotationModel(org.eclipse.jface.text.source.IAnnotationModel)
- */
- protected IAnnotationModel createVisualAnnotationModel(IAnnotationModel annotationModel) {
- IAnnotationModel model= super.createVisualAnnotationModel(annotationModel);
- fProjectionAnnotationModel= new ProjectionAnnotationModel();
- addProjectionAnnotationModel(model);
- return model;
- }
-
- /**
- * Returns the projection annotation model.
- *
- * @return the projection annotation model
- */
- public ProjectionAnnotationModel getProjectionAnnotationModel() {
- IAnnotationModel model= getVisualAnnotationModel();
- if (model instanceof IAnnotationModelExtension) {
- IAnnotationModelExtension extension= (IAnnotationModelExtension) model;
- return (ProjectionAnnotationModel) extension.getAnnotationModel(PROJECTION_ANNOTATION_MODEL);
- }
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.TextViewer#createSlaveDocumentManager()
- */
- protected ISlaveDocumentManager createSlaveDocumentManager() {
- return new ProjectionDocumentManager();
- }
-
- /*
- * @see org.eclipse.jface.text.TextViewer#updateSlaveDocument(org.eclipse.jface.text.IDocument, int, int)
- */
- protected boolean updateSlaveDocument(IDocument slaveDocument, int modelRangeOffset, int modelRangeLength) throws BadLocationException {
- if (slaveDocument instanceof ProjectionDocument) {
- ProjectionDocument document= (ProjectionDocument) slaveDocument;
- document.replaceMasterDocumentRanges(modelRangeOffset, modelRangeLength);
- return true;
- }
- return false;
- }
-
- /**
- * Returns whether this viewer is in projection mode.
- *
- * @return <code>true</code> if this viewer is in projection mode,
- * <code>false</code> otherwise
- */
- private boolean isProjectionMode() {
- return getProjectionAnnotationModel() != null;
- }
-
- /**
- * Disables the projection mode.
- */
- private void disableProjection() {
- if (isProjectionMode()) {
- removeProjectionAnnotationModel(getVisualAnnotationModel());
- fProjectionAnnotationModel.removeAllAnnotations();
- }
- }
-
- /**
- * Enables the projection mode.
- */
- private void enableProjection() {
- if (!isProjectionMode())
- addProjectionAnnotationModel(getVisualAnnotationModel());
- }
-
- /*
- * @see org.eclipse.jface.text.TextViewer#setVisibleRegion(int, int)
- */
- public void setVisibleRegion(int start, int length) {
- disableProjection();
- super.setVisibleRegion(start, length);
- }
-
- /*
- * @see org.eclipse.jface.text.TextViewer#resetVisibleRegion()
- */
- public void resetVisibleRegion() {
- super.resetVisibleRegion();
- enableProjection();
- }
-
- /*
- * @see org.eclipse.jface.text.ITextViewer#getVisibleRegion()
- */
- public IRegion getVisibleRegion() {
- disableProjection();
- return super.getVisibleRegion();
- }
-
- /*
- * @see org.eclipse.jface.text.ITextViewer#overlapsWithVisibleRegion(int,int)
- */
- public boolean overlapsWithVisibleRegion(int offset, int length) {
- disableProjection();
- return super.overlapsWithVisibleRegion(offset, length);
- }
-
- /**
- * Replace the visible document with the given document. Maintains the
- * scroll offset and the selection.
- *
- * @param visibleDocument the visible document
- */
- private void replaceVisibleDocument(IDocument visibleDocument) {
- StyledText textWidget= getTextWidget();
- try {
- if (textWidget != null && !textWidget.isDisposed())
- textWidget.setRedraw(false);
-
- int topIndex= getTopIndex();
- Point selection= getSelectedRange();
- setVisibleDocument(visibleDocument);
- setSelectedRange(selection.x, selection.y);
- setTopIndex(topIndex);
-
- } finally {
- if (textWidget != null && !textWidget.isDisposed())
- textWidget.setRedraw(true);
- }
- }
-
- /**
- * Hides the given range by collapsing it. If requested, a redraw request is issued.
- *
- * @param offset the offset of the range to hide
- * @param length the length of the range to hide
- * @param fireRedraw <code>true</code> if a redraw request should be issued, <code>false</code> otherwise
- * @throws BadLocationException in case the range is invalid
- */
- private void collapse(int offset, int length, boolean fireRedraw) throws BadLocationException {
- ProjectionDocument projection= null;
-
- IDocument visibleDocument= getVisibleDocument();
- if (visibleDocument instanceof ProjectionDocument)
- projection= (ProjectionDocument) visibleDocument;
- else {
- IDocument master= getDocument();
- IDocument slave= createSlaveDocument(getDocument());
- if (slave instanceof ProjectionDocument) {
- projection= (ProjectionDocument) slave;
- projection.addMasterDocumentRange(0, master.getLength());
- replaceVisibleDocument(projection);
- }
- }
-
- if (projection != null) {
- projection.removeMasterDocumentRange(offset, length);
- if (fireRedraw) {
- // repaint line above
- IDocument document= getDocument();
- int line= document.getLineOfOffset(offset);
- if (line > 0) {
- IRegion info= document.getLineInformation(line - 1);
- invalidateTextPresentation(info.getOffset(), info.getLength());
- }
- }
- }
- }
-
- /**
- * Makes the given range visible again while keeping the given collapsed
- * ranges. If requested, a redraw request is issued.
- *
- * @param expanded the range to be expanded
- * @param collapsed a sequence of collapsed ranges completely contained by
- * the expanded range
- * @param fireRedraw <code>true</code> if a redraw request should be
- * issued, <code>false</code> otherwise
- * @throws BadLocationException in case the range is invalid
- */
- private void expand(Position expanded, Position[] collapsed, boolean fireRedraw) throws BadLocationException {
- IDocument slave= getVisibleDocument();
- if (slave instanceof ProjectionDocument) {
- ProjectionDocument projection= (ProjectionDocument) slave;
-
- StyledText textWidget= getTextWidget();
- try {
-
- if (textWidget != null && !textWidget.isDisposed())
- textWidget.setRedraw(false);
-
- // expand
- projection.addMasterDocumentRange(expanded.getOffset(), expanded.getLength());
-
- // collapse contained regions
- if (collapsed != null) {
- for (int i= 0; i < collapsed.length; i++) {
- IRegion p= adaptCollapsedRegion(collapsed[i]);
- projection.removeMasterDocumentRange(p.getOffset(), p.getLength());
- }
- }
-
- } finally {
- if (textWidget != null && !textWidget.isDisposed())
- textWidget.setRedraw(true);
- }
-
-
-
- IDocument master= getDocument();
- if (slave.getLength() == master.getLength()) {
- replaceVisibleDocument(master);
- freeSlaveDocument(slave);
- } else if (fireRedraw){
- invalidateTextPresentation(expanded.getOffset(), expanded.getLength());
- }
- }
- }
-
- /**
- * Adapts the slave visual document of this viewer to the changes described
- * in the annotation model event. When the event is <code>null</code>,
- * this is identical to a world change event.
- *
- * @param event the annotation model event or <code>null</code>
- */
- protected final void catchupWithProjectionAnnotationModel(AnnotationModelEvent event) {
- try {
- if (event == null || event.isWorldChange()) {
-
- reinitializeProjection();
-
- } else {
-
- boolean fireRedraw= true;
-
- processDeletions(event, fireRedraw);
- processAdditions(event, fireRedraw);
- processModifications(event, fireRedraw);
-
- if (!fireRedraw) {
- //TODO compute minimal scope for invalidation
- invalidateTextPresentation();
- }
- }
- } catch (BadLocationException e) {
- throw new IllegalArgumentException();
- }
- }
-
- private boolean includes(Position expanded, Position position) {
- if (!expanded.equals(position) && !position.isDeleted())
- return expanded.getOffset() <= position.getOffset() && position.getOffset() + position.getLength() <= expanded.getOffset() + expanded.getLength();
- return false;
- }
-
- private Position[] computeCollapsedRanges(Position expanded) {
- List positions= new ArrayList(5);
- Iterator e= fProjectionAnnotationModel.getAnnotationIterator();
- while (e.hasNext()) {
- ProjectionAnnotation annotation= (ProjectionAnnotation) e.next();
- if (annotation.isCollapsed()) {
- Position position= fProjectionAnnotationModel.getPosition(annotation);
- if (includes(expanded, position))
- positions.add(position);
- }
- }
-
- if (positions.size() > 0) {
- Position[] result= new Position[positions.size()];
- positions.toArray(result);
- return result;
- }
-
- return null;
- }
-
- private void processDeletions(AnnotationModelEvent event, boolean fireRedraw) throws BadLocationException {
- Annotation[] annotations= event.getRemovedAnnotations();
- for (int i= 0; i < annotations.length; i++) {
- ProjectionAnnotation annotation= (ProjectionAnnotation) annotations[i];
- if (annotation.isCollapsed()) {
- Position expanded= fProjectionAnnotationModel.getPosition(annotation);
- Position[] collapsed= computeCollapsedRanges(expanded);
- expand(expanded, collapsed, false);
- if (fireRedraw)
- invalidateTextPresentation(expanded.getOffset(), expanded.getLength());
- }
- }
- }
-
- private IRegion adaptCollapsedRegion(Position position) {
- try {
- IDocument document= getDocument();
- int line= document.getLineOfOffset(position.getOffset());
- int offset= document.getLineOffset(line + 1);
-
- int length= position.getLength() - (offset - position.getOffset());
- if (length > 0)
- return new Region(offset, length);
- } catch (BadLocationException x) {
- }
-
- return null;
- }
-
- private void processAdditions(AnnotationModelEvent event, boolean fireRedraw) throws BadLocationException {
- Annotation[] annotations= event.getAddedAnnotations();
- for (int i= 0; i < annotations.length; i++) {
- ProjectionAnnotation annotation= (ProjectionAnnotation) annotations[i];
- if (annotation.isCollapsed()) {
- Position position= fProjectionAnnotationModel.getPosition(annotation);
- IRegion region= adaptCollapsedRegion(position);
- if (region != null)
- collapse(region.getOffset(), region.getLength(), fireRedraw);
- }
- }
- }
-
- private void processModifications(AnnotationModelEvent event, boolean fireRedraw) throws BadLocationException {
- Annotation[] annotations= event.getChangedAnnotations();
- for (int i= 0; i < annotations.length; i++) {
- ProjectionAnnotation annotation= (ProjectionAnnotation) annotations[i];
- Position position= fProjectionAnnotationModel.getPosition(annotation);
- if (annotation.isCollapsed()) {
- IRegion region= adaptCollapsedRegion(position);
- if (region != null)
- collapse(region.getOffset(), region.getLength(), fireRedraw);
- } else {
- Position[] collapsed= computeCollapsedRanges(position);
- expand(position, collapsed, false);
- if (fireRedraw)
- invalidateTextPresentation(position.getOffset(), position.getLength());
- }
- }
- }
-
- private void reinitializeProjection() throws BadLocationException {
-
- ProjectionDocument projection= null;
-
- ISlaveDocumentManager manager= getSlaveDocumentManager();
- if (manager != null) {
- IDocument master= getDocument();
- if (master != null) {
- IDocument slave= manager.createSlaveDocument(master);
- if (slave instanceof ProjectionDocument) {
- projection= (ProjectionDocument) slave;
- projection.addMasterDocumentRange(0, master.getLength());
- }
- }
- }
-
- if (projection != null) {
- Iterator e= fProjectionAnnotationModel.getAnnotationIterator();
- while (e.hasNext()) {
- ProjectionAnnotation annotation= (ProjectionAnnotation) e.next();
- if (annotation.isCollapsed()) {
- Position position= fProjectionAnnotationModel.getPosition(annotation);
- projection.removeMasterDocumentRange(position.getOffset(), position.getLength());
- }
- }
-
- }
-
- replaceVisibleDocument(projection);
- }
-
- /*
- * @see org.eclipse.jface.text.TextViewer#handleVerifyEvent(org.eclipse.swt.events.VerifyEvent)
- */
- protected void handleVerifyEvent(VerifyEvent e) {
- IRegion modelRange= event2ModelRange(e);
- if (exposeModelRange(modelRange))
- e.doit= false;
- }
-
- /**
- * Adds the give column as last column to this viewer's vertical ruler.
- *
- * @param column the column to be added
- */
- public void addVerticalRulerColumn(IVerticalRulerColumn column) {
- IVerticalRuler ruler= getVerticalRuler();
- if (ruler instanceof CompositeRuler) {
- CompositeRuler compositeRuler= (CompositeRuler) ruler;
- compositeRuler.addDecorator(99, column);
- }
- }
-
- /*
- * @see org.eclipse.jface.text.ITextViewerExtension5#exposeModelRange(org.eclipse.jface.text.IRegion)
- */
- public boolean exposeModelRange(IRegion modelRange) {
- if (isProjectionMode())
- return fProjectionAnnotationModel.expandAll(modelRange.getOffset(), modelRange.getLength());
- return false;
- }
-}
diff --git a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/SourceViewerInformationControl.java b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/SourceViewerInformationControl.java
deleted file mode 100644
index 5528e75..0000000
--- a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/SourceViewerInformationControl.java
+++ /dev/null
@@ -1,330 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.source.projection;
-
-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;
-
-import org.eclipse.jface.resource.JFaceResources;
-
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IInformationControl;
-import org.eclipse.jface.text.IInformationControlExtension;
-import org.eclipse.jface.text.source.SourceViewer;
-import org.eclipse.jface.text.source.SourceViewerConfiguration;
-
-/**
- * Source viewer based implementation of <code>IInformationControl</code>.
- * Displays information in a source viewer.
- * <p>
- * Internal class. Do not use. Public only for testing purposes.
- *
- * @since 3.0
- */
-public class SourceViewerInformationControl implements IInformationControl, IInformationControlExtension, DisposeListener {
-
- /** 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 control's source viewer */
- private SourceViewer fViewer;
- /** The optional status field. */
- private Label fStatusField;
- /** The separator for the optional status field. */
- private Label fSeparator;
- /** The font of the optional status text label.*/
- private Font fStatusTextFont;
-
-
- /**
- * Creates a source viewer information control with the given shell as
- * parent and the given font.
- *
- * @param parent the parent shell
- * @param symbolicFontName the symbolic font name
- */
- public SourceViewerInformationControl(Shell parent, String symbolicFontName) {
- this(parent, SWT.NO_TRIM, SWT.NONE, symbolicFontName, null);
- }
-
- /**
- * Creates a source viewer information control with the given shell as
- * parent. The given shell styles are applied to the created shell. The
- * given styles are applied to the created styled text widget. The text
- * widget will be initialized with the given font. The status field will
- * contain the given text or be hidden.
- *
- * @param parent the parent shell
- * @param shellStyle the additional styles for the shell
- * @param style the additional styles for the styled text widget
- * @param symbolicFontName the symbolic font name
- * @param statusFieldText the text to be used in the optional status field
- * or <code>null</code> if the status field should be hidden
- */
- public SourceViewerInformationControl(Shell parent, int shellStyle, int style, String symbolicFontName, 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_HORIZONTAL);
- 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));
- }
-
- // Source viewer
- fViewer= new SourceViewer(composite, null, style);
- fViewer.configure(new SourceViewerConfiguration());
- fViewer.setEditable(false);
-
- fText= fViewer.getTextWidget();
- gd= new GridData(GridData.BEGINNING | GridData.FILL_BOTH);
- fText.setLayoutData(gd);
- fText.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
- fText.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
- fText.setFont(JFaceResources.getFont(symbolicFontName));
-
- fText.addKeyListener(new KeyListener() {
-
- public void keyPressed(KeyEvent e) {
- if (e.character == 0x1B) // ESC
- fShell.dispose();
- }
-
- public void keyReleased(KeyEvent e) {}
- });
-
- // Status field
- if (statusFieldText != null) {
-
- // Horizontal separator line
- fSeparator= new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL | SWT.LINE_DOT);
- fSeparator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- // Status field label
- fStatusField= new Label(composite, SWT.RIGHT);
- fStatusField.setText(statusFieldText);
- Font font= fStatusField.getFont();
- FontData[] fontDatas= font.getFontData();
- for (int i= 0; i < fontDatas.length; i++)
- fontDatas[i].setHeight(fontDatas[i].getHeight() * 9 / 10);
- fStatusTextFont= new Font(fStatusField.getDisplay(), fontDatas);
- fStatusField.setFont(fStatusTextFont);
- GridData gd2= new GridData(GridData.FILL_VERTICAL | GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING);
- fStatusField.setLayoutData(gd2);
-
- // Regarding the color see bug 41128
- fStatusField.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW));
-
- fStatusField.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
- }
-
- addDisposeListener(this);
- }
-
- /*
- * @see org.eclipse.jface.text.IInformationControlExtension2#setInput(java.lang.Object)
- */
- public void setInput(Object input) {
- if (input instanceof String)
- setInformation((String)input);
- else
- setInformation(null);
- }
-
- /*
- * @see IInformationControl#setInformation(String)
- */
- public void setInformation(String content) {
- if (content == null) {
- fViewer.setInput(null);
- return;
- }
-
- IDocument doc= new Document(content);
- fViewer.setInput(doc);
- }
-
- /*
- * @see IInformationControl#setVisible(boolean)
- */
- public void setVisible(boolean visible) {
- fShell.setVisible(visible);
- }
-
- /*
- * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent)
- */
- public void widgetDisposed(DisposeEvent event) {
- if (fStatusTextFont != null && !fStatusTextFont.isDisposed())
- fStatusTextFont.dispose();
-
- fStatusTextFont= null;
- fShell= null;
- fText= null;
- }
-
- /*
- * @see org.eclipse.jface.text.IInformationControl#dispose()
- */
- public final void dispose() {
- if (fShell != null && !fShell.isDisposed())
- fShell.dispose();
- else
- widgetDisposed(null);
- }
-
- /*
- * @see IInformationControl#setSize(int, int)
- */
- public void setSize(int width, int height) {
-
- if (fStatusField != null) {
- GridData gd= (GridData)fViewer.getTextWidget().getLayoutData();
- Point statusSize= fStatusField.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
- Point separatorSize= fSeparator.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
- gd.heightHint= height - statusSize.y - separatorSize.y;
- }
- fShell.setSize(width, height);
-
- if (fStatusField != null)
- fShell.pack(true);
- }
-
- /*
- * @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) {
- maxWidth= maxHeight;
- }
-
- /*
- * @see IInformationControl#computeSizeHint()
- */
- public Point computeSizeHint() {
- return fShell.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- }
-
- /*
- * @see IInformationControl#addDisposeListener(DisposeListener)
- */
- public void addDisposeListener(DisposeListener listener) {
- fShell.addDisposeListener(listener);
- }
-
- /*
- * @see IInformationControl#removeDisposeListener(DisposeListener)
- */
- public void removeDisposeListener(DisposeListener listener) {
- fShell.removeDisposeListener(listener);
- }
-
- /*
- * @see IInformationControl#setForegroundColor(Color)
- */
- public void setForegroundColor(Color foreground) {
- fText.setForeground(foreground);
- }
-
- /*
- * @see IInformationControl#setBackgroundColor(Color)
- */
- public void setBackgroundColor(Color background) {
- fText.setBackground(background);
- }
-
- /*
- * @see IInformationControl#isFocusControl()
- */
- public boolean isFocusControl() {
- return fText.isFocusControl();
- }
-
- /*
- * @see IInformationControl#setFocus()
- */
- public void setFocus() {
- fShell.forceFocus();
- fText.setFocus();
- }
-
- /*
- * @see IInformationControl#addFocusListener(FocusListener)
- */
- public void addFocusListener(FocusListener listener) {
- fText.addFocusListener(listener);
- }
-
- /*
- * @see IInformationControl#removeFocusListener(FocusListener)
- */
- public void removeFocusListener(FocusListener listener) {
- fText.removeFocusListener(listener);
- }
-
- /*
- * @see IInformationControlExtension#hasContents()
- */
- public boolean hasContents() {
- return fText.getCharCount() > 0;
- }
-}
diff --git a/org.eclipse.jface.text/scripts/exportplugin.xml b/org.eclipse.jface.text/scripts/exportplugin.xml
deleted file mode 100644
index 9db702b..0000000
--- a/org.eclipse.jface.text/scripts/exportplugin.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<project name="Export JFace Text" default="export" basedir="..">
- <target name="init">
- <tstamp/>
- <property name="destdir" value="../../plugin-export" />
- <property name="plugin" value="org.eclipse.jface.text" />
- <property name="version" value="_3.0.0" />
- <property name="dest" value="${destdir}/${plugin}${version}" />
- </target>
-
- <target name="build" depends="init">
- <eclipse.incrementalBuild project="${plugin}" kind="incr"/>
- </target>
-
- <target name="export" depends="build">
- <mkdir dir="${destdir}" />
- <delete dir="${dest}" />
- <mkdir dir="${dest}" />
- <jar
- jarfile="${dest}/jfacetext.jar"
- basedir="bin"
- />
- <copy file="plugin.xml" todir="${dest}"/>
- <copy file="plugin.properties" todir="${dest}"/>
- <zip zipfile="${dest}/jfacetextsrc.zip">
- <fileset dir="src" />
- <fileset dir="projection"/>
- </zip>
- </target>
-</project>
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 068f0bf..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/AdditionalInfoController2.java
+++ /dev/null
@@ -1,255 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.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, JFaceTextMessages2.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 3ec68df..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/CompletionProposalPopup2.java
+++ /dev/null
@@ -1,882 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.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.ICompletionProposalExtension3;
-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);
- }
-
- // adjust replacement length - this is a HACK
- if (p instanceof ICompletionProposalExtension3) {
- int replacementLength= ((ICompletionProposalExtension3) p).getReplacementString().length();
- for (int i= 0; i < fComputedProposals.length; i++) {
- if (fComputedProposals[i] instanceof ICompletionProposalExtension3) {
- ((ICompletionProposalExtension3)fComputedProposals[i]).updateReplacementLength(replacementLength);
- }
- }
- }
-
- 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/ContentAssistant2.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java
deleted file mode 100644
index cad15b4..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java
+++ /dev/null
@@ -1,1595 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.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.IContentAssistSubject;
-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, JFaceTextMessages2.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: > infopops, < 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 IContentAssistantExtension#install(IContentAssistSubject)
- */
- public void install(IContentAssistSubject contentAssistSubject) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * @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);
- 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 49f517c..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContextInformationPopup2.java
+++ /dev/null
@@ -1,629 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.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 78d0ea3..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/HTML2TextReader.java
+++ /dev/null
@@ -1,300 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.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 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 + "\t" + "-"; //$NON-NLS-1$ TODO internationalize
-
- 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 29ebb64..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/HTMLTextPresenter.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.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, "...", presentation); // TODO get the message from somewhere
- }
-
- 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 acc8749..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/Helper2.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.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 f455369..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/IContentAssistListener2.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.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 6a376ed..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/IProposalListener.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.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/JFaceTextMessages2.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/JFaceTextMessages2.java
deleted file mode 100644
index 9c5d4a4..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/JFaceTextMessages2.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.internal.text.link.contentassist;
-
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-class JFaceTextMessages2 {
-
- private static final String RESOURCE_BUNDLE= "org.eclipse.jface.text.JFaceTextMessages";//$NON-NLS-1$
-
- private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
-
- private JFaceTextMessages2() {
- }
-
- 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/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 acdabe3..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/LineBreakingReader.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.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 58b6254..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/PopupCloser2.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.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 f7d5311..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/SingleCharReader.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.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 dd865f5..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/SubstitutionTextReader.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.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 b1d9f48..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/package.html
+++ /dev/null
@@ -1,16 +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.
-<br>
-Use at your own risk.
-</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 bf000bd..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractHoverInformationControlManager.java
+++ /dev/null
@@ -1,485 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.ControlListener;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.MouseMoveListener;
-import org.eclipse.swt.events.MouseTrackAdapter;
-import org.eclipse.swt.events.MouseTrackListener;
-import org.eclipse.swt.events.ShellAdapter;
-import org.eclipse.swt.events.ShellEvent;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-
-
-/**
- * An information control manager that shows information on mouse hover events.
- * The mouse hover events are caught by registering a <code>MouseTrackListener</code>
- * on the manager's subject control. The manager has by default an information control closer
- * that closes the information control as soon as the mouse pointer leaves the subject area, the
- * user presses a key, or the subject control is resized, moved, or deactivated.<p>
- * When being activated by a mouse hover event, the manager disables itself, until the mouse
- * leaves the subject area. Thus, the manager is usually still disabled, when the information control
- * has already been closed by the closer.
- *
- * @see org.eclipse.swt.events.MouseTrackListener
- * @since 2.0
- */
-abstract public class AbstractHoverInformationControlManager extends AbstractInformationControlManager {
-
-
- /**
- * The information control closer for the hover information. Closes the information control as
- * soon as the mouse pointer leaves the subject area, a mouse button is pressed, the user presses a key,
- * or the subject control is resized or moved.
- */
- class Closer extends MouseTrackAdapter
- implements IInformationControlCloser, MouseListener, MouseMoveListener, ControlListener, KeyListener {
-
- /** The closer's subject control */
- private Control fSubjectControl;
- /** The subject area */
- private Rectangle fSubjectArea;
- /** Indicates whether this closer is active */
- private boolean fIsActive= false;
-
- /**
- * Creates a new information control closer.
- */
- public Closer() {
- }
-
- /*
- * @see IInformationControlCloser#setSubjectControl(Control)
- */
- public void setSubjectControl(Control control) {
- fSubjectControl= control;
- }
-
- /*
- * @see IInformationControlCloser#setHoverControl(IHoverControl)
- */
- public void setInformationControl(IInformationControl control) {
- }
-
- /*
- * @see IInformationControlCloser#start(Rectangle)
- */
- public void start(Rectangle subjectArea) {
-
- if (fIsActive) return;
- fIsActive= true;
-
- fSubjectArea= subjectArea;
-
- if (fSubjectControl != null && !fSubjectControl.isDisposed()) {
- fSubjectControl.addMouseListener(this);
- fSubjectControl.addMouseMoveListener(this);
- fSubjectControl.addMouseTrackListener(this);
- fSubjectControl.addControlListener(this);
- fSubjectControl.addKeyListener(this);
- }
- }
-
- /*
- * @see IInformationControlCloser#stop()
- */
- public void stop() {
- stop(false);
- }
-
- /**
- * Stops the information control and if <code>delayRestart</code> is set
- * allows restart only after a certain delay.
- *
- * @param delayRestart <code>true</code> if restart should be delayed
- */
- protected void stop(boolean delayRestart) {
-
- if (!fIsActive) return;
- fIsActive= false;
-
- hideInformationControl();
-
- if (fSubjectControl != null && !fSubjectControl.isDisposed()) {
- fSubjectControl.removeMouseListener(this);
- fSubjectControl.removeMouseMoveListener(this);
- fSubjectControl.removeMouseTrackListener(this);
- fSubjectControl.removeControlListener(this);
- fSubjectControl.removeKeyListener(this);
- }
- }
-
- /*
- * @see org.eclipse.swt.events.MouseMoveListener#mouseMove(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseMove(MouseEvent event) {
- if (!fSubjectArea.contains(event.x, event.y))
- stop();
- }
-
- /*
- * @see org.eclipse.swt.events.MouseListener#mouseUp(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseUp(MouseEvent event) {
- }
-
- /*
- * @see MouseListener#mouseDown(MouseEvent)
- */
- public void mouseDown(MouseEvent event) {
- stop();
- }
-
- /*
- * @see MouseListener#mouseDoubleClick(MouseEvent)
- */
- public void mouseDoubleClick(MouseEvent event) {
- stop();
- }
-
- /*
- * @see MouseTrackAdapter#mouseExit(MouseEvent)
- */
- public void mouseExit(MouseEvent event) {
- stop();
- }
-
- /*
- * @see ControlListener#controlResized(ControlEvent)
- */
- public void controlResized(ControlEvent event) {
- stop();
- }
-
- /*
- * @see ControlListener#controlMoved(ControlEvent)
- */
- public void controlMoved(ControlEvent event) {
- stop();
- }
-
- /*
- * @see KeyListener#keyReleased(KeyEvent)
- */
- public void keyReleased(KeyEvent event) {
- }
-
- /*
- * @see KeyListener#keyPressed(KeyEvent)
- */
- public void keyPressed(KeyEvent event) {
- stop(true);
- }
- }
-
-
- /**
- * To be installed on the manager's subject control. Serves two different purposes:
- * <ul>
- * <li> start function: initiates the computation of the information to be presented. This happens on
- * receipt of a mouse hover event and disables the information control manager,
- * <li> restart function: tracks mouse move and shell activation event to determine when the information
- * control manager needs to be reactivated.
- * </ul>
- */
- class MouseTracker extends ShellAdapter implements MouseTrackListener, MouseMoveListener {
-
- /** Margin around the original hover event location for coputing the hover area. */
- private final static int EPSILON= 3;
-
- /** The area in which the original hover event occurred. */
- private Rectangle fHoverArea;
- /** The area for which is computed information is valid. */
- private Rectangle fSubjectArea;
- /** The tracker's subject control. */
- private Control fSubjectControl;
-
- /** Indicates whether the tracker is in restart mode ignoring hover events. */
- private boolean fIsInRestartMode= false;
- /** Indicates whether the tracker is computing the information to be presented. */
- private boolean fIsComputing= false;
- /** Indicates whether the mouse has been lost. */
- private boolean fMouseLostWhileComputing= false;
- /** Indicates whether the subject control's shell has been deactivated. */
- private boolean fShellDeactivatedWhileComputing= false;
-
- /**
- * Creates a new mouse tracker.
- */
- public MouseTracker() {
- }
-
- /**
- * Sets this mouse tracker's subject area, the area to be tracked in order
- * to re-enable the information control manager.
- *
- * @param subjectArea the subject area
- */
- public void setSubjectArea(Rectangle subjectArea) {
- Assert.isNotNull(subjectArea);
- fSubjectArea= subjectArea;
- }
-
- /**
- * Starts this mouse tracker. The given control becomes this tracker's subject control.
- * Installs itself as mouse track listener on the subject control.
- *
- * @param subjectControl the subject control
- */
- public void start(Control subjectControl) {
- fSubjectControl= subjectControl;
- if (fSubjectControl != null && !fSubjectControl.isDisposed())
- fSubjectControl.addMouseTrackListener(this);
-
- fIsInRestartMode= false;
- fIsComputing= false;
- fMouseLostWhileComputing= false;
- fShellDeactivatedWhileComputing= false;
- }
-
- /**
- * Stops this mouse tracker. Removes itself as mouse track, mouse move, and
- * shell listener from the subject control.
- */
- public void stop() {
- if (fSubjectControl != null && !fSubjectControl.isDisposed()) {
- fSubjectControl.removeMouseTrackListener(this);
- fSubjectControl.removeMouseMoveListener(this);
- fSubjectControl.getShell().removeShellListener(this);
- }
- }
-
- /**
- * Initiates the computation of the information to be presented. Sets the initial hover area
- * to a small rectangle around the hover event location. Adds mouse move and shell activation listeners
- * to track whether the computed information is, after completion, useful for presentation and to
- * implement the restart function.
- *
- * @param event the mouse hover event
- */
- public void mouseHover(MouseEvent event) {
-
- if (fIsComputing || fIsInRestartMode) return;
-
- fIsInRestartMode= true;
- fIsComputing= true;
- fMouseLostWhileComputing= false;
- fShellDeactivatedWhileComputing= false;
-
- fHoverEventStateMask= event.stateMask;
- fHoverEvent= event;
- fHoverArea= new Rectangle(event.x - EPSILON, event.y - EPSILON, 2 * EPSILON, 2 * EPSILON );
- if (fHoverArea.x < 0) fHoverArea.x= 0;
- if (fHoverArea.y < 0) fHoverArea.y= 0;
- setSubjectArea(fHoverArea);
-
- if (fSubjectControl != null && !fSubjectControl.isDisposed()) {
- fSubjectControl.addMouseMoveListener(this);
- fSubjectControl.getShell().addShellListener(this);
- }
- doShowInformation();
- }
-
- /**
- * Deactivates this tracker's restart function and enables the information control
- * manager. Does not have any effect if the tracker is still executing the start function (i.e.
- * computing the information to be presented.
- */
- protected void deactivate() {
- if (fIsComputing) return;
- fIsInRestartMode= false;
- if (fSubjectControl != null && !fSubjectControl.isDisposed()) {
- fSubjectControl.removeMouseMoveListener(this);
- fSubjectControl.getShell().removeShellListener(this);
- }
- }
-
- /*
- * @see MouseTrackListener#mouseEnter(MouseEvent)
- */
- public void mouseEnter(MouseEvent e) {
- }
-
- /*
- * @see MouseTrackListener#mouseExit(MouseEvent)
- */
- public void mouseExit(MouseEvent e) {
- fMouseLostWhileComputing= true;
- deactivate();
- }
-
- /*
- * @see MouseMoveListener#mouseMove(MouseEvent)
- */
- public void mouseMove(MouseEvent event) {
- if (!fSubjectArea.contains(event.x, event.y))
- deactivate();
- }
-
- /*
- * @see ShellListener#shellDeactivated(ShellEvent)
- */
- public void shellDeactivated(ShellEvent e) {
- fShellDeactivatedWhileComputing= true;
- deactivate();
- }
-
- /*
- * @see ShellListener#shellIconified(ShellEvent)
- */
- public void shellIconified(ShellEvent e) {
- fShellDeactivatedWhileComputing= true;
- deactivate();
- }
-
- /**
- * Tells this tracker that the start function processing has been completed.
- */
- public void computationCompleted() {
- fIsComputing= false;
- fMouseLostWhileComputing= false;
- fShellDeactivatedWhileComputing= false;
- }
-
- /**
- * Determines whether the computed information is still useful for presentation.
- * This is not the case, if the shell of the subject control has been deactivated, the mouse
- * left the subject control, or the mouse moved on, so that it is no longer in the subject
- * area.
- *
- * @return <code>true</code> if information is still useful for presentation, <code>false</code> otherwise
- */
- public boolean isMouseLost() {
-
- if (fMouseLostWhileComputing || fShellDeactivatedWhileComputing)
- return true;
-
- if (fSubjectControl != null && !fSubjectControl.isDisposed()) {
- Display display= fSubjectControl.getDisplay();
- Point p= display.getCursorLocation();
- p= fSubjectControl.toControl(p);
- if (!fSubjectArea.contains(p) && !fHoverArea.contains(p))
- return true;
- }
-
- return false;
- }
- }
-
- /** The mouse tracker on the subject control */
- private MouseTracker fMouseTracker= new MouseTracker();
- /** The remembered hover event */
- private MouseEvent fHoverEvent= null;
- /** The remembered hover event sate mask of the keyboard modifiers */
- private int fHoverEventStateMask= 0;
-
- /**
- * Creates a new hover information control manager using the given information control creator.
- * By default a <code>Closer</code> instance is set as this manager's closer.
- *
- * @param creator the information control creator
- */
- protected AbstractHoverInformationControlManager(IInformationControlCreator creator) {
- super(creator);
- setCloser(new Closer());
- }
-
- /*
- * @see AbstractInformationControlManager#presentInformation()
- */
- protected void presentInformation() {
- if (fMouseTracker == null) {
- super.presentInformation();
- return;
- }
-
- Rectangle area= getSubjectArea();
- if (area != null)
- fMouseTracker.setSubjectArea(area);
-
- if (fMouseTracker.isMouseLost()) {
- fMouseTracker.computationCompleted();
- fMouseTracker.deactivate();
- } else {
- fMouseTracker.computationCompleted();
- super.presentInformation();
- }
- }
-
- /*
- * @see AbstractInformationControlManager#setEnabled(boolean)
- */
- public void setEnabled(boolean enabled) {
-
- boolean was= isEnabled();
- super.setEnabled(enabled);
- boolean is= isEnabled();
-
- if (was != is && fMouseTracker != null) {
- if (is)
- fMouseTracker.start(getSubjectControl());
- else
- fMouseTracker.stop();
- }
- }
-
- /**
- * Disposes this manager's information control.
- */
- public void dispose() {
- if (fMouseTracker != null) {
- fMouseTracker.stop();
- fMouseTracker.fSubjectControl= null;
- fMouseTracker= null;
- }
- super.dispose();
- }
-
- /**
- * Returns the location at which the most recent mouse hover event
- * has been issued.
- *
- * @return the location of the most recent mouse hover event
- */
- protected Point getHoverEventLocation() {
- return fHoverEvent != null ? new Point(fHoverEvent.x, fHoverEvent.y) : new Point(-1, -1);
- }
-
- /**
- * Returns the most recent mouse hover event.
- *
- * @return the most recent mouse hover event or <code>null</code>
- * @since 3.0
- */
- protected MouseEvent getHoverEvent() {
- return fHoverEvent;
- }
-
- /**
- * Returns the SWT event state of the most recent mouse hover event.
- *
- * @return the SWT event state of the most recent mouse hover event
- */
- protected int getHoverEventStateMask() {
- return fHoverEventStateMask;
- }
-
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractInformationControlManager.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractInformationControlManager.java
deleted file mode 100644
index a10a2b1..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractInformationControlManager.java
+++ /dev/null
@@ -1,984 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Control;
-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 constants.
- * @since 3.0
- */
- public static final String STORE_LOCATION_X= "location.x"; //$NON-NLS-1$
- public static final String STORE_LOCATION_Y= "location.y"; //$NON-NLS-1$
- public static final String STORE_SIZE_X= "size.x"; //$NON-NLS-1$
- public static final String STORE_SIZE_Y= "size.y"; //$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_X}</li>
- * <li>{@link AbstractInformationControlManager#STORE_SIZE_Y}</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;
- }
-
- /**
- * 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, 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.
- */
- 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_X, bounds.width);
- fDialogSettings.put(STORE_SIZE_Y, 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_X);
- bounds.height= fDialogSettings.getInt(STORE_SIZE_Y);
- } 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 3190fd8..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/CursorLinePainter.java
+++ /dev/null
@@ -1,245 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-
-import org.eclipse.swt.custom.LineBackgroundEvent;
-import org.eclipse.swt.custom.LineBackgroundListener;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Point;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.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;
-
- fCurrentLine.isDeleted= false;
- fCurrentLine.offset= document.getLineOffset(lineNumber);
- if (lineNumber == document.getNumberOfLines() - 1)
- fCurrentLine.length= document.getLength() - fCurrentLine.offset;
- else
- fCurrentLine.length= document.getLineOffset(lineNumber + 1) - fCurrentLine.offset;
-
- fLastLineNumber= lineNumber;
- return true;
-
- }
-
- } catch (BadLocationException e) {
- }
-
- return false;
- }
-
- /**
- * Returns the location of the caret as offset in the source viewer's
- * input document.
- *
- * @return the caret location
- */
- private int getModelCaret() {
- int widgetCaret= fViewer.getTextWidget().getCaretOffset();
- if (fViewer instanceof 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();
- Point upperLeft= textWidget.getLocationAtOffset(widgetOffset);
- int width= textWidget.getClientArea().width + textWidget.getHorizontalPixel();
- int height= textWidget.getLineHeight();
- textWidget.redraw(0, upperLeft.y, width, height, false);
- }
-
- /*
- * @see IPainter#deactivate(boolean)
- */
- public void deactivate(boolean redraw) {
- if (fIsActive) {
- fIsActive= false;
-
- /* on turning off the feature one has to paint the currently
- * highlighted line with the standard background color
- */
- if (redraw)
- drawHighlightLine(fCurrentLine);
-
- fViewer.getTextWidget().removeLineBackgroundListener(this);
-
- if (fPositionManager != null)
- fPositionManager.unmanagePosition(fCurrentLine);
-
- fLastLineNumber= -1;
- }
- }
-
- /*
- * @see IPainter#dispose()
- */
- public void dispose() {
- }
-
- /*
- * @see IPainter#paint(int)
- */
- public void paint(int reason) {
- if (fViewer.getDocument() == null) {
- deactivate(false);
- return;
- }
-
- // check selection
- Point selection= fViewer.getTextWidget().getSelectionRange();
- if (selection.y > 0) {
- deactivate(true);
- return;
- }
-
- // initialization
- if (!fIsActive) {
- fViewer.getTextWidget().addLineBackgroundListener(this);
- fPositionManager.managePosition(fCurrentLine);
- fIsActive= true;
- }
-
- //redraw line highlight only if it hasn't been drawn yet on the respective line
- if (updateHighlightLine()) {
- // clear last line
- drawHighlightLine(fLastLine);
- // draw new line
- drawHighlightLine(fCurrentLine);
- }
- }
-
- /*
- * @see IPainter#setPositionManager(IPaintPositionManager)
- */
- public void setPositionManager(IPaintPositionManager manager) {
- fPositionManager = manager;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultAutoIndentStrategy.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultAutoIndentStrategy.java
deleted file mode 100644
index 742322b..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultAutoIndentStrategy.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-
-
-
-/**
- * Default implementation of <code>IAutoIndentStrategy</code>.
- * This strategy always copies the indentation of the previous line.
- */
-public class DefaultAutoIndentStrategy implements IAutoIndentStrategy {
-
- /**
- * Creates a new default auto indent strategy which can be installed on
- * text viewers.
- */
- public DefaultAutoIndentStrategy() {
- }
-
- /**
- * Returns the first offset greater than <code>offset</code> and smaller than
- * <code>end</code> whose character is not a space or tab character. If no such
- * offset is found, <code>end</code> is returned.
- *
- * @param document the document to search in
- * @param offset the offset at which searching start
- * @param end the offset at which searching stops
- * @return the offset in the specifed range whose character is not a space or tab
- * @exception BadLocationException if position is an invalid range in the given document
- */
- protected int findEndOfWhiteSpace(IDocument document, int offset, int end) throws BadLocationException {
- while (offset < end) {
- char c= document.getChar(offset);
- if (c != ' ' && c != '\t') {
- return offset;
- }
- offset++;
- }
- return end;
- }
-
- /**
- * Copies the indentation of the previous line.
- *
- * @param d the document to work on
- * @param c the command to deal with
- */
- private void autoIndentAfterNewLine(IDocument d, DocumentCommand c) {
-
- if (c.offset == -1 || d.getLength() == 0)
- return;
-
- try {
- // find start of line
- int p= (c.offset == d.getLength() ? c.offset - 1 : c.offset);
- IRegion info= d.getLineInformationOfOffset(p);
- int start= info.getOffset();
-
- // find white spaces
- int end= findEndOfWhiteSpace(d, start, c.offset);
-
- StringBuffer buf= new StringBuffer(c.text);
- if (end > start) {
- // append to input
- buf.append(d.get(start, end - start));
- }
-
- c.text= buf.toString();
-
- } catch (BadLocationException excp) {
- // stop work
- }
- }
-
- /*
- * @see IAutoIndentStrategy#customizeDocumentCommand
- */
- public void customizeDocumentCommand(IDocument d, DocumentCommand c) {
- if (c.length == 0 && c.text != null && TextUtilities.endsWith(d.getLegalLineDelimiters(), c.text) != -1)
- autoIndentAfterNewLine(d, c);
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultInformationControl.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultInformationControl.java
deleted file mode 100644
index 5cf51d4..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultInformationControl.java
+++ /dev/null
@@ -1,415 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.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);
- }
-
- /**
- * {@inheritDoc}
- */
- 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()
- */
- public Rectangle computeTrim() {
- return fShell.computeTrim(0, 0, 0, 0);
- }
-
- /*
- * @see org.eclipse.jface.text.IInformationControlExtension3#getBounds()
- */
- public Rectangle getBounds() {
- return fShell.getBounds();
- }
-
- /*
- * @see org.eclipse.jface.text.IInformationControlExtension3#restoresLocation()
- */
- public boolean restoresLocation() {
- return false;
- }
-
- /*
- * @see org.eclipse.jface.text.IInformationControlExtension3#restoresSize()
- */
- 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 282ebff..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultTextDoubleClickStrategy.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-import java.text.BreakIterator;
-import java.text.CharacterIterator;
-
-
-/**
- * Standard implementation of <code>ITextDoubleClickStrategy</code>.
- * Selects words using <code>java.text.BreakIterator</code> for the
- * default locale. This class is not intended to be subclassed.
- *
- * @see java.text.BreakIterator
- */
-public class DefaultTextDoubleClickStrategy implements ITextDoubleClickStrategy {
-
-
- /**
- * Implements a character iterator that works directly on
- * instances of <code>IDocument</code>. Used to collaborate with
- * the break iterator.
- *
- * @see IDocument
- * @since 2.0
- */
- static class DocumentCharacterIterator implements CharacterIterator {
-
- /** Document to iterate over. */
- private IDocument fDocument;
- /** Start offset of iteration. */
- private int fOffset= -1;
- /** Endoffset of iteration. */
- private int fEndOffset= -1;
- /** Current offset of iteration. */
- private int fIndex= -1;
-
- /** Creates a new document iterator. */
- public DocumentCharacterIterator() {
- }
-
- /**
- * Configures this document iterator with the document section to be iteratored.
- *
- * @param document the document to be iterated
- * @param iteratorRange the range in the document to be iterated
- */
- public void setDocument(IDocument document, IRegion iteratorRange) {
- fDocument= document;
- fOffset= iteratorRange.getOffset();
- fEndOffset= fOffset + iteratorRange.getLength();
- }
-
- /*
- * @see CharacterIterator#first()
- */
- public char first() {
- fIndex= fOffset;
- return current();
- }
-
- /*
- * @see CharacterIterator#last()
- */
- public char last() {
- fIndex= fOffset < fEndOffset ? fEndOffset -1 : fEndOffset;
- return current();
- }
-
- /*
- * @see CharacterIterator#current()
- */
- public char current() {
- if (fOffset <= fIndex && fIndex < fEndOffset) {
- try {
- return fDocument.getChar(fIndex);
- } catch (BadLocationException x) {
- }
- }
- return DONE;
- }
-
- /*
- * @see CharacterIterator#next()
- */
- public char next() {
- if (fIndex == fEndOffset -1)
- return DONE;
-
- if (fIndex < fEndOffset)
- ++ fIndex;
-
- return current();
- }
-
- /*
- * @see CharacterIterator#previous()
- */
- public char previous() {
- if (fIndex == fOffset)
- return DONE;
-
- if (fIndex > fOffset)
- -- fIndex;
-
- return current();
- }
-
- /*
- * @see CharacterIterator#setIndex(int)
- */
- public char setIndex(int index) {
- fIndex= index;
- return current();
- }
-
- /*
- * @see CharacterIterator#getBeginIndex()
- */
- public int getBeginIndex() {
- return fOffset;
- }
-
- /*
- * @see CharacterIterator#getEndIndex()
- */
- public int getEndIndex() {
- return fEndOffset;
- }
-
- /*
- * @see CharacterIterator#getIndex()
- */
- public int getIndex() {
- return fIndex;
- }
-
- /*
- * @see CharacterIterator#clone()
- */
- public Object clone() {
- DocumentCharacterIterator i= new DocumentCharacterIterator();
- i.fDocument= fDocument;
- i.fIndex= fIndex;
- i.fOffset= fOffset;
- i.fEndOffset= fEndOffset;
- return i;
- }
- }
-
-
- /**
- * The document character iterator used by this strategy.
- * @since 2.0
- */
- private DocumentCharacterIterator fDocIter= new DocumentCharacterIterator();
-
-
- /**
- * Creates a new default text double click strategy.
- */
- public DefaultTextDoubleClickStrategy() {
- super();
- }
-
- /*
- * @see ITextDoubleClickStrategy#doubleClicked
- */
- public void doubleClicked(ITextViewer text) {
-
- int position= text.getSelectedRange().x;
-
- if (position < 0)
- return;
-
- try {
-
- IDocument document= text.getDocument();
- IRegion line= document.getLineInformationOfOffset(position);
- if (position == line.getOffset() + line.getLength())
- return;
-
- fDocIter.setDocument(document, line);
-
- BreakIterator breakIter= BreakIterator.getWordInstance();
- breakIter.setText(fDocIter);
-
- int start= breakIter.preceding(position);
- if (start == BreakIterator.DONE)
- start= line.getOffset();
-
- int end= breakIter.following(position);
- if (end == BreakIterator.DONE)
- end= line.getOffset() + line.getLength();
-
- if (breakIter.isBoundary(position)) {
- if (end - position > position- start)
- start= position;
- else
- end= position;
- }
-
- if (start != end)
- text.setSelectedRange(start, end - start);
-
- } catch (BadLocationException x) {
- }
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultUndoManager.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultUndoManager.java
deleted file mode 100644
index 08eb440..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultUndoManager.java
+++ /dev/null
@@ -1,810 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-
-
-/**
- * Standard implementation of <code>IUndoManager</code>.
- * It registers with the connected text viewer as text listeners and logs all changes.
- * It also monitors mouse and keyboard activities in order to partition the stream of
- * text changes into undoable edit commands. <p>
- * This class is not intended to be subclassed.
- *
- * @see ITextViewer
- * @see ITextListener
- * @see MouseListener
- * @see KeyListener
- */
-public class DefaultUndoManager implements IUndoManager {
-
- /**
- * Represents an undoable edit command.
- */
- class TextCommand {
-
- /** The start index of the replaced text */
- protected int fStart= -1;
- /** The end index of the replaced text */
- protected int fEnd= -1;
- /** The newly inserted text */
- protected String fText;
- /** The replaced text */
- protected String fPreservedText;
-
- /**
- * Reinitializes this text command.
- */
- protected void reinitialize() {
- fStart= fEnd= -1;
- fText= fPreservedText= null;
- }
-
- /**
- * Sets the start and the end index of this command.
- *
- * @param start the start index
- * @param end the end index
- */
- protected void set(int start, int end) {
- fStart= start;
- fEnd= end;
- fText= null;
- fPreservedText= null;
- }
-
- /**
- * Undo the change described by this command.
- *
- * @param text the text widget to be modified
- * @since 2.0
- */
- protected void undoTextChange(StyledText text) {
- text.replaceTextRange(fStart, fText.length(), fPreservedText);
- }
-
- /**
- * Undo the change described by this command. Also selects and
- * reveals the change.
- *
- * @param text the text widget to be modified
- */
- protected void undo(StyledText text) {
- undoTextChange(text);
- IRegion modelRange= widgetRange2ModelRange(fStart, fPreservedText == null ? 0 : fPreservedText.length());
- fTextViewer.setSelectedRange(modelRange.getOffset(), modelRange.getLength());
- fTextViewer.revealRange(modelRange.getOffset(), modelRange.getLength());
- }
-
- /**
- * Redo the change described by this command.
- *
- * @param text the text widget to be modified
- * @since 2.0
- */
- protected void redoTextChange(StyledText text) {
- text.replaceTextRange(fStart, fEnd - fStart, fText);
- }
-
- /**
- * Redo the change described by this command that previously been
- * rolled back. Also selects and reveals the change.
- *
- * @param text the text widget to be modified
- */
- protected void redo(StyledText text) {
- redoTextChange(text);
- IRegion modelRange= widgetRange2ModelRange(fStart, fText == null ? 0 : fText.length());
- fTextViewer.setSelectedRange(modelRange.getOffset(), modelRange.getLength());
- fTextViewer.revealRange(modelRange.getOffset(), modelRange.getLength());
- }
-
- /**
- * Translates a given widget range into the corresponding range of the source viewer's input document.
- *
- * @param offset the offset of the widget range
- * @param length the length of the widget range
- * @return the corresponding model range
- * @since 2.1
- */
- protected IRegion widgetRange2ModelRange(int offset, int length) {
- if (fTextViewer instanceof ITextViewerExtension5) {
- ITextViewerExtension5 extension= (ITextViewerExtension5) fTextViewer;
- return extension.widgetRange2ModelRange(new Region(offset, length));
- }
-
- IRegion visible= fTextViewer.getVisibleRegion();
- return new Region(offset + visible.getOffset(), length);
- }
-
- /**
- * Updates the command stack in response to committing
- * the current change into this command.
- */
- protected void updateCommandStack() {
-
- int length= fCommandStack.size();
- for (int i= fCommandCounter + 1; i < length; i++)
- fCommandStack.remove(fCommandCounter + 1);
-
- fCommandStack.add(this);
-
- while (fCommandStack.size() > fUndoLevel)
- fCommandStack.remove(0);
-
- fCommandCounter= fCommandStack.size() - 1;
- }
-
- /**
- * Creates a new uncommitted text command depending on whether
- * a compound change is currently being executed.
- *
- * @return a new, uncommitted text command or a compound text command
- */
- protected TextCommand createCurrent() {
- return fFoldingIntoCompoundChange ? new CompoundTextCommand() : new TextCommand();
- }
-
- /**
- * Commits the current change into this command.
- */
- protected void commit() {
-
- if (fStart < 0) {
- reinitialize();
- } else {
-
- fText= fTextBuffer.toString();
- fTextBuffer.setLength(0);
- fPreservedText= fPreservedTextBuffer.toString();
- fPreservedTextBuffer.setLength(0);
-
- updateCommandStack();
- }
-
- fCurrent= createCurrent();
- }
- }
-
- /**
- * Represents an undoable edit command consisting of several
- * individual edit commands.
- */
- class CompoundTextCommand extends TextCommand {
-
- /** The list of individual commands */
- private List fCommands= new ArrayList();
-
- /**
- * Adds a new individual command to this compound command.
- *
- * @param command the command to be added
- */
- protected void add(TextCommand command) {
- fCommands.add(command);
- }
-
- /*
- * @see TextCommand#undo
- */
- protected void undo(StyledText text) {
- ITextViewerExtension extension= null;
- if (fTextViewer instanceof ITextViewerExtension)
- extension= (ITextViewerExtension) fTextViewer;
-
- if (extension != null)
- extension.setRedraw(false);
-
- try {
-
- int size= fCommands.size();
- if (size > 0) {
-
- TextCommand c;
-
- for (int i= size -1; i > 0; --i) {
- c= (TextCommand) fCommands.get(i);
- c.undoTextChange(text);
- }
-
- c= (TextCommand) fCommands.get(0);
- c.undo(text);
- }
-
- } finally {
- if (extension != null)
- extension.setRedraw(true);
- }
- }
-
- /*
- * @see TextCommand#redo
- */
- protected void redo(StyledText text) {
-
- ITextViewerExtension extension= null;
- if (fTextViewer instanceof ITextViewerExtension)
- extension= (ITextViewerExtension) fTextViewer;
-
- if (extension != null)
- extension.setRedraw(false);
-
- try {
-
- int size= fCommands.size();
- if (size > 0) {
-
- TextCommand c;
-
- for (int i= 0; i < size -1; ++i) {
- c= (TextCommand) fCommands.get(i);
- c.redoTextChange(text);
- }
-
- c= (TextCommand) fCommands.get(size -1);
- c.redo(text);
- }
-
- } finally {
- if (extension != null)
- extension.setRedraw(true);
- }
- }
-
- /*
- * @see TextCommand#updateCommandStack
- */
- protected void updateCommandStack() {
- TextCommand c= new TextCommand();
- c.fStart= fStart;
- c.fEnd= fEnd;
- c.fText= fText;
- c.fPreservedText= fPreservedText;
-
- add(c);
-
- if (!fFoldingIntoCompoundChange)
- super.updateCommandStack();
- }
-
- /*
- * @see TextCommand#createCurrent
- */
- protected TextCommand createCurrent() {
-
- if (!fFoldingIntoCompoundChange)
- return new TextCommand();
-
- reinitialize();
- return this;
- }
-
- /*
- * @see org.eclipse.jface.text.DefaultUndoManager.TextCommand#commit()
- */
- protected void commit() {
- if (fStart < 0) {
- if (fCommands.size() > 0 && !fFoldingIntoCompoundChange) {
- super.updateCommandStack();
- fCurrent= createCurrent();
- return;
- }
- }
- super.commit();
- }
- }
-
- /**
- * Represents pretended <code>UndoManager</code> state.
- */
- class PretendedUndoManagerState {
- /** The counter in the undo stack */
- protected int cmdCounter= -1;
- /** The size of the undo stack */
- protected int stackSize= -1;
- }
-
- /**
- * Internal listener to mouse and key events.
- */
- class KeyAndMouseListener implements MouseListener, KeyListener {
-
- /*
- * @see MouseListener#mouseDoubleClick
- */
- public void mouseDoubleClick(MouseEvent e) {
- }
-
- /*
- * If the right mouse button is pressed, the current editing command is closed
- * @see MouseListener#mouseDown
- */
- public void mouseDown(MouseEvent e) {
- if (e.button == 1)
- commit();
- }
-
- /*
- * @see MouseListener#mouseUp
- */
- public void mouseUp(MouseEvent e) {
- }
-
- /*
- * @see KeyListener#keyPressed
- */
- public void keyReleased(KeyEvent e) {
- }
-
- /*
- * On cursor keys, the current editing command is closed
- * @see KeyListener#keyPressed
- */
- public void keyPressed(KeyEvent e) {
- switch (e.keyCode) {
- case SWT.ARROW_UP:
- case SWT.ARROW_DOWN:
- case SWT.ARROW_LEFT:
- case SWT.ARROW_RIGHT:
- commit();
- break;
- }
- }
- }
-
- /**
- * Internal listener to text changes.
- */
- class TextListener implements ITextListener {
-
- /*
- * @see ITextListener#textChanged
- */
- public void textChanged(TextEvent e) {
- if (e.getDocumentEvent() != null)
- processTextEvent(e);
- }
- }
-
- /** Text buffer to collect text which is inserted into the viewer */
- private StringBuffer fTextBuffer= new StringBuffer();
- /** Text buffer to collect viewer content which has been replaced */
- private StringBuffer fPreservedTextBuffer= new StringBuffer();
- /** Pretended undo manager state */
- private PretendedUndoManagerState fPretendedState= new PretendedUndoManagerState();
-
- /** The internal text listener */
- private ITextListener fTextListener;
- /** The internal key and mouse event listener */
- private KeyAndMouseListener fKeyAndMouseListener;
-
-
- /** Indicates inserting state */
- private boolean fInserting= false;
- /** Indicates overwriting state */
- private boolean fOverwriting= false;
- /** Indicates whether the current change belongs to a compound change */
- private boolean fFoldingIntoCompoundChange= false;
-
- /** The text viewer the undo manager is connected to */
- private ITextViewer fTextViewer;
-
- /** Supported undo level */
- private int fUndoLevel;
- /** The list of undoable edit commands */
- private List fCommandStack;
- /** The currently constructed edit command */
- private TextCommand fCurrent;
- /** The last delete edit command */
- private TextCommand fPreviousDelete;
- /** Command counter into the edit command stack */
- private int fCommandCounter= -1;
-
-
- /**
- * Creates a new undo manager who remembers the specified number of edit commands.
- *
- * @param undoLevel the length of this manager's history
- */
- public DefaultUndoManager(int undoLevel) {
- setMaximalUndoLevel(undoLevel);
- }
-
- /*
- * @see IUndoManager#beginCompoundChange
- */
- public void beginCompoundChange() {
- fFoldingIntoCompoundChange= true;
- commit();
- }
-
- /*
- * @see IUndoManager#endCompoundChange
- */
- public void endCompoundChange() {
- fFoldingIntoCompoundChange= false;
- commit();
- }
-
- /**
- * Registers all necessary listeners with the text viewer.
- */
- private void addListeners() {
- StyledText text= fTextViewer.getTextWidget();
- if (text != null) {
- fKeyAndMouseListener= new KeyAndMouseListener();
- text.addMouseListener(fKeyAndMouseListener);
- text.addKeyListener(fKeyAndMouseListener);
- listenToTextChanges(true);
- }
- }
-
- /**
- * Deregister all previously installed listeners from the text viewer.
- */
- private void removeListeners() {
- StyledText text= fTextViewer.getTextWidget();
- if (text != null && fKeyAndMouseListener != null) {
- text.removeMouseListener(fKeyAndMouseListener);
- text.removeKeyListener(fKeyAndMouseListener);
- listenToTextChanges(false);
- }
- }
-
- /**
- * Switches the state of whether there is a text listener or not.
- *
- * @param listen the state which should be established
- */
- private void listenToTextChanges(boolean listen) {
- if (listen && fTextListener == null) {
- fTextListener= new TextListener();
- fTextViewer.addTextListener(fTextListener);
- } else if (!listen && fTextListener != null) {
- fTextViewer.removeTextListener(fTextListener);
- fTextListener= null;
- }
- }
-
- /**
- * Closes the current editing command and opens a new one.
- */
- private void commit() {
-
- fInserting= false;
- fOverwriting= false;
- fPreviousDelete.reinitialize();
-
- fCurrent.commit();
- }
-
- /**
- * Does redo the previously undone editing command.
- */
- private void internalRedo() {
- StyledText text= fTextViewer.getTextWidget();
- if (text != null) {
-
- ++fCommandCounter;
- TextCommand cmd= (TextCommand) fCommandStack.get(fCommandCounter);
-
- listenToTextChanges(false);
- cmd.redo(text);
- listenToTextChanges(true);
-
- fCurrent= new TextCommand();
- }
- }
-
- /**
- * Does undo the last editing command.
- */
- private void internalUndo() {
- StyledText text= fTextViewer.getTextWidget();
- if (text != null) {
-
- TextCommand cmd= (TextCommand) fCommandStack.get(fCommandCounter);
- -- fCommandCounter;
-
- listenToTextChanges(false);
- cmd.undo(text);
- listenToTextChanges(true);
-
- fCurrent= new TextCommand();
- }
- }
-
- /**
- * Checks whether the given text starts with a line delimiter and
- * subsequently contains a white space only.
- *
- * @param text the text to check
- */
- private boolean isWhitespaceText(String text) {
-
- if (text == null || text.length() == 0)
- return false;
-
- String[] delimiters= fTextViewer.getDocument().getLegalLineDelimiters();
- int index= TextUtilities.startsWith(delimiters, text);
- if (index > -1) {
- char c;
- int length= text.length();
- for (int i= delimiters[index].length(); i < length; i++) {
- c= text.charAt(i);
- if (c != ' ' && c != '\t')
- return false;
- }
- return true;
- }
-
- return false;
- }
-
- /**
- * Returns the state the would result if the current editing command would be closed.
- *
- * @return the pretended state after closing the current editing command
- */
- private PretendedUndoManagerState pretendCommit() {
- if (fCurrent.fStart < 0) {
- fPretendedState.stackSize= fCommandStack.size();
- fPretendedState.cmdCounter= fCommandCounter;
- } else {
- int sz= Math.max(fCommandCounter, 0) + 1;
- if (sz > fUndoLevel)
- sz -= fUndoLevel;
- fPretendedState.stackSize= sz;
- fPretendedState.cmdCounter= sz - 1;
- }
- return fPretendedState;
- }
-
- /**
- * Processes the given text event in order to determine editor command.
- *
- * @param e the text event
- */
- private void processTextEvent(TextEvent e) {
-
- int start= e.getOffset();
- int end= e.getOffset() + e.getLength();
- String newText= e.getText();
- String oldText= e.getReplacedText();
-
-
- if (newText == null)
- newText= ""; //$NON-NLS-1$
-
- if (oldText == null)
- oldText= ""; //$NON-NLS-1$
-
- int length= newText.length();
- int diff= end - start;
-
- // normalize verify command
- if (diff < 0) {
- int tmp= end;
- end= start;
- start= tmp;
- diff= -diff;
- }
-
- if (start == end) {
- // text will be inserted
- if ((length == 1) || isWhitespaceText(newText)) {
- // by typing or model manipulation
- if (!fInserting || (start != fCurrent.fStart + fTextBuffer.length())) {
- commit();
- fInserting= true;
- }
- if (fCurrent.fStart < 0)
- fCurrent.fStart= fCurrent.fEnd= start;
- if (length > 0)
- fTextBuffer.append(newText);
- } else if (length > 0) {
- // by pasting
- commit();
- fCurrent.fStart= fCurrent.fEnd= start;
- fTextBuffer.append(newText);
- commit();
- }
- } else {
- if (length == 0) {
- // text will be deleted by backspace or DEL key or empty clipboard
- length= oldText.length();
- String[] delimiters= fTextViewer.getDocument().getLegalLineDelimiters();
-
- if ((length == 1) || TextUtilities.equals(delimiters, oldText) > -1) {
-
- // whereby selection is empty
-
- if (fPreviousDelete.fStart == start && fPreviousDelete.fEnd == end) {
- // repeated DEL
-
- // correct wrong settings of fCurrent
- if (fCurrent.fStart == end && fCurrent.fEnd == start) {
- fCurrent.fStart= start;
- fCurrent.fEnd= end;
- }
- // append to buffer && extend command range
- fPreservedTextBuffer.append(oldText);
- ++fCurrent.fEnd;
-
- } else if (fPreviousDelete.fStart == end) {
- // repeated backspace
-
- // insert in buffer and extend command range
- fPreservedTextBuffer.insert(0, oldText);
- fCurrent.fStart= start;
-
- } else {
- // either DEL or backspace for the first time
-
- commit();
-
- // as we can not decide whether it was DEL or backspace we initialize for backspace
- fPreservedTextBuffer.append(oldText);
- fCurrent.fStart= start;
- fCurrent.fEnd= end;
- }
-
- fPreviousDelete.set(start, end);
-
- } else if (length > 0) {
- // whereby selection is not empty
- commit();
- fCurrent.fStart= start;
- fCurrent.fEnd= end;
- fPreservedTextBuffer.append(oldText);
- }
- } else {
- // text will be replaced
-
- if (length == 1) {
- length= oldText.length();
- String[] delimiters= fTextViewer.getDocument().getLegalLineDelimiters();
-
- if ((length == 1) || TextUtilities.equals(delimiters, oldText) > -1) {
- // because of overwrite mode or model manipulation
- if (!fOverwriting || (start != fCurrent.fStart + fTextBuffer.length())) {
- commit();
- fOverwriting= true;
- }
-
- if (fCurrent.fStart < 0)
- fCurrent.fStart= start;
-
- fCurrent.fEnd= end;
- fTextBuffer.append(newText);
- fPreservedTextBuffer.append(oldText);
- return;
- }
- }
- // because of typing or pasting whereby selection is not empty
- commit();
- fCurrent.fStart= start;
- fCurrent.fEnd= end;
- fTextBuffer.append(newText);
- fPreservedTextBuffer.append(oldText);
- }
- }
- }
-
- /*
- * @see IUndoManager#setMaximalUndoLevel
- */
- public void setMaximalUndoLevel(int undoLevel) {
- fUndoLevel= undoLevel;
- }
-
- /*
- * @see IUndoManager#connect
- */
- public void connect(ITextViewer textViewer) {
- if (fTextViewer == null) {
- fTextViewer= textViewer;
- fCommandStack= new ArrayList();
- fCurrent= new TextCommand();
- fPreviousDelete= new TextCommand();
- addListeners();
- }
- }
-
- /*
- * @see IUndoManager#disconnect
- */
- public void disconnect() {
- if (fTextViewer != null) {
-
- removeListeners();
-
- fCurrent= null;
- if (fCommandStack != null) {
- fCommandStack.clear();
- fCommandStack= null;
- }
- fTextBuffer= null;
- fPreservedTextBuffer= null;
- fTextViewer= null;
- }
- }
-
- /*
- * @see IUndoManager#reset
- */
- public void reset() {
- if (fCommandStack != null)
- fCommandStack.clear();
- fCommandCounter= -1;
- if (fCurrent != null)
- fCurrent.reinitialize();
- fFoldingIntoCompoundChange= false;
- fInserting= false;
- fOverwriting= false;
- fTextBuffer.setLength(0);
- fPreservedTextBuffer.setLength(0);
- }
-
- /*
- * @see IUndoManager#redoable
- */
- public boolean redoable() {
- if (fCommandStack != null) {
- PretendedUndoManagerState s= pretendCommit();
- return (0 <= s.cmdCounter + 1) && (s.cmdCounter + 1 < s.stackSize);
- }
- return false;
- }
-
- /*
- * @see IUndoManager#undoable
- */
- public boolean undoable() {
- if (fCommandStack != null) {
- PretendedUndoManagerState s= pretendCommit();
- return (0 <= s.cmdCounter) && (s.cmdCounter < s.stackSize);
- }
- return false;
- }
-
- /*
- * @see IUndoManager#redo
- */
- public void redo() {
- if (redoable()) {
- commit();
- internalRedo();
- }
- }
-
- /*
- * @see IUndoManager#undo
- */
- public void undo() {
- if (undoable()) {
- fFoldingIntoCompoundChange= false;
- commit();
- internalUndo();
- }
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/DocumentAdapter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/DocumentAdapter.java
deleted file mode 100644
index f3ff19f..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/DocumentAdapter.java
+++ /dev/null
@@ -1,361 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.TextChangeListener;
-import org.eclipse.swt.custom.TextChangedEvent;
-import org.eclipse.swt.custom.TextChangingEvent;
-
-
-/**
- * Adapts an <code>IDocument</code> to the <code>StyledTextContent</code> interface.
- */
-class DocumentAdapter implements IDocumentAdapter, IDocumentListener, IDocumentAdapterExtension {
-
- /** The adapted document. */
- private IDocument fDocument;
- /** The registered text change listeners */
- private List fTextChangeListeners= new ArrayList(1);
- /**
- * The remembered document event
- * @since 2.0
- */
- private DocumentEvent fEvent;
- /** The line delimiter */
- private String fLineDelimiter= null;
- /**
- * Indicates whether this adapter is forwarding document changes
- * @since 2.0
- */
- private boolean fIsForwarding= true;
- /**
- * Length of document at receipt of <code>documentAboutToBeChanged</code>
- * @since 2.1
- */
- private int fRememberedLengthOfDocument;
- /**
- * Length of first document line at receipt of <code>documentAboutToBeChanged</code>
- * @since 2.1
- */
- private int fRememberedLengthOfFirstLine;
- /**
- * The data of the event at receipt of <code>documentAboutToBeChanged</code>
- * @since 2.1
- */
- private DocumentEvent fOriginalEvent= new DocumentEvent();
-
-
- /**
- * Creates a new document adapter which is initiallly not connected to
- * any document.
- */
- public DocumentAdapter() {
- }
-
- /**
- * Sets the given document as the document to be adapted.
- *
- * @param document the document to be adapted or <code>null</code> if there is no document
- */
- public void setDocument(IDocument document) {
-
- if (fDocument != null)
- fDocument.removePrenotifiedDocumentListener(this);
-
- fDocument= document;
- fLineDelimiter= null;
-
- if (fDocument != null)
- fDocument.addPrenotifiedDocumentListener(this);
- }
-
- /*
- * @see StyledTextContent#addTextChangeListener(TextChangeListener)
- */
- public void addTextChangeListener(TextChangeListener listener) {
- Assert.isNotNull(listener);
- if (! fTextChangeListeners.contains(listener))
- fTextChangeListeners.add(listener);
- }
-
- /*
- * @see StyledTextContent#removeTextChangeListener(TextChangeListener)
- */
- public void removeTextChangeListener(TextChangeListener listener) {
- Assert.isNotNull(listener);
- fTextChangeListeners.remove(listener);
- }
-
- private void repairLineInformation() {
- if (fDocument instanceof IRepairableDocument) {
- IRepairableDocument repairable= (IRepairableDocument) fDocument;
- repairable.repairLineInformation();
- }
- }
-
- private String doGetLine(int line) throws BadLocationException {
- IRegion r= fDocument.getLineInformation(line);
- return fDocument.get(r.getOffset(), r.getLength());
- }
-
- /*
- * @see StyledTextContent#getLine(int)
- */
- public String getLine(int line) {
- try {
- return doGetLine(line);
- } catch (BadLocationException x) {
- repairLineInformation();
- try {
- return doGetLine(line);
- } catch (BadLocationException x2) {
- }
- }
-
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- return null;
- }
-
- /*
- * @see StyledTextContent#getLineAtOffset(int)
- */
- public int getLineAtOffset(int offset) {
- try {
- return fDocument.getLineOfOffset(offset);
- } catch (BadLocationException x) {
- repairLineInformation();
- try {
- return fDocument.getLineOfOffset(offset);
- } catch (BadLocationException x2) {
- }
- }
-
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- return -1;
- }
-
- /*
- * @see StyledTextContent#getLineCount()
- */
- public int getLineCount() {
- return fDocument.getNumberOfLines();
- }
-
- /*
- * @see StyledTextContent#getOffsetAtLine(int)
- */
- public int getOffsetAtLine(int line) {
- try {
- return fDocument.getLineOffset(line);
- } catch (BadLocationException x) {
- repairLineInformation();
- try {
- return fDocument.getLineOffset(line);
- } catch (BadLocationException x2) {
- }
- }
-
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- return -1;
- }
-
- /*
- * @see StyledTextContent#getTextRange(int, int)
- */
- public String getTextRange(int offset, int length) {
- try {
- return fDocument.get(offset, length);
- } catch (BadLocationException x) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- return null;
- }
- }
-
- /*
- * @see StyledTextContent#replaceTextRange(int, int, String)
- */
- public void replaceTextRange(int pos, int length, String text) {
- try {
- fDocument.replace(pos, length, text);
- } catch (BadLocationException x) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- }
-
- /*
- * @see StyledTextContent#setText(String)
- */
- public void setText(String text) {
- fDocument.set(text);
- }
-
- /*
- * @see StyledTextContent#getCharCount()
- */
- public int getCharCount() {
- return fDocument.getLength();
- }
-
- /*
- * @see StyledTextContent#getLineDelimiter()
- */
- public String getLineDelimiter() {
- if (fLineDelimiter == null)
- fLineDelimiter= TextUtilities.getDefaultLineDelimiter(fDocument);
- return fLineDelimiter;
- }
-
- /*
- * @see IDocumentListener#documentChanged(DocumentEvent)
- */
- public void documentChanged(DocumentEvent event) {
- // check whether the given event is the one which was remembered
- if (fEvent == null || event != fEvent)
- return;
-
- if (isPatchedEvent(event) || (event.getOffset() == 0 && event.getLength() == fRememberedLengthOfDocument)) {
- fLineDelimiter= null;
- fireTextSet();
- } else {
- if (event.getOffset() < fRememberedLengthOfFirstLine)
- fLineDelimiter= null;
- fireTextChanged();
- }
- }
-
- /*
- * @see IDocumentListener#documentAboutToBeChanged(DocumentEvent)
- */
- public void documentAboutToBeChanged(DocumentEvent event) {
-
- fRememberedLengthOfDocument= fDocument.getLength();
- try {
- fRememberedLengthOfFirstLine= fDocument.getLineLength(0);
- } catch (BadLocationException e) {
- fRememberedLengthOfFirstLine= -1;
- }
-
- fEvent= event;
- rememberEventData(fEvent);
- fireTextChanging();
- }
-
- /**
- * Checks whether this event has been changed between <code>documentAboutToBeChanged</code> and
- * <code>documentChanged</code>.
- *
- * @param event the event to be checked
- * @return <code>true</code> if the event has been changed, <code>false</code> otherwise
- */
- private boolean isPatchedEvent(DocumentEvent event) {
- return fOriginalEvent.fOffset != event.fOffset || fOriginalEvent.fLength != event.fLength || fOriginalEvent.fText != event.fText;
- }
-
- /**
- * Makes a copy of the given event and remembers it.
- *
- * @param event the event to be copied
- */
- private void rememberEventData(DocumentEvent event) {
- fOriginalEvent.fOffset= event.fOffset;
- fOriginalEvent.fLength= event.fLength;
- fOriginalEvent.fText= event.fText;
- }
-
- /**
- * Sends a text changed event to all registered listeners.
- */
- private void fireTextChanged() {
-
- if (!fIsForwarding)
- return;
-
- TextChangedEvent event= new TextChangedEvent(this);
-
- if (fTextChangeListeners != null && fTextChangeListeners.size() > 0) {
- Iterator e= new ArrayList(fTextChangeListeners).iterator();
- while (e.hasNext())
- ((TextChangeListener) e.next()).textChanged(event);
- }
- }
-
- /**
- * Sends a text set event to all registered listeners.
- */
- private void fireTextSet() {
-
- if (!fIsForwarding)
- return;
-
- TextChangedEvent event = new TextChangedEvent(this);
-
- if (fTextChangeListeners != null && fTextChangeListeners.size() > 0) {
- Iterator e= new ArrayList(fTextChangeListeners).iterator();
- while (e.hasNext())
- ((TextChangeListener) e.next()).textSet(event);
- }
- }
-
- /**
- * Sends the text changing event to all registered listeners.
- */
- private void fireTextChanging() {
-
- if (!fIsForwarding)
- return;
-
- try {
- IDocument document= fEvent.getDocument();
- if (document == null)
- return;
-
- TextChangingEvent event= new TextChangingEvent(this);
- event.start= fEvent.fOffset;
- event.replaceCharCount= fEvent.fLength;
- event.replaceLineCount= document.getNumberOfLines(fEvent.fOffset, fEvent.fLength) - 1;
- event.newText= fEvent.fText;
- event.newCharCount= (fEvent.fText == null ? 0 : fEvent.fText.length());
- event.newLineCount= (fEvent.fText == null ? 0 : document.computeNumberOfLines(fEvent.fText));
-
- if (fTextChangeListeners != null && fTextChangeListeners.size() > 0) {
- Iterator e= new ArrayList(fTextChangeListeners).iterator();
- while (e.hasNext())
- ((TextChangeListener) e.next()).textChanging(event);
- }
-
- } catch (BadLocationException e) {
- }
- }
-
- /*
- * @see IDocumentAdapterExtension#resumeForwardingDocumentChanges()
- * @since 2.0
- */
- public void resumeForwardingDocumentChanges() {
- fIsForwarding= true;
- fireTextSet();
- }
-
- /*
- * @see IDocumentAdapterExtension#stopForwardingDocumentChanges()
- * @since 2.0
- */
- public void stopForwardingDocumentChanges() {
- fIsForwarding= false;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/DocumentCommand.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/DocumentCommand.java
deleted file mode 100644
index 1e71715..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/DocumentCommand.java
+++ /dev/null
@@ -1,467 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.NoSuchElementException;
-
-import org.eclipse.swt.events.VerifyEvent;
-
-
-/**
- * Represents a text modification as a document replace command. The text modification is given
- * as a <code>VerifyEvent</code> and translated into a document replace command relative
- * to a given offset. A document command can also be used to initialize a given <code>VerifyEvent</code>.<p>
- * A document command can also represent a list of related changes.
- */
-public class DocumentCommand {
-
- /**
- * A command which is added to document commands.
- * @since 2.1
- */
- private static class Command implements Comparable {
- /** The offset of the range to be replaced */
- private final int fOffset;
- /** The length of the range to be replaced. */
- private final int fLength;
- /** The replacement text */
- private final String fText;
- /** The listern who owns this command */
- private final IDocumentListener fOwner;
-
- /**
- * 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 05f4068..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IAutoEditStrategy.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-
-/**
- * An auto edit strategy can adapt changes that will be applied to
- * a text viewer's document. The strategy is informed by the text viewer
- * about each upcoming change in form of a document command. By manipulating
- * this document command, the strategy can influence in which way the text
- * viewer's document is changed. Clients may implement this interface.
- *
- * @since 2.1
- */
-public interface IAutoEditStrategy {
-
- /**
- * Allows the strategy to manipulate the document command.
- *
- * @param document the document that will be changed
- * @param command the document command describing the change
- */
- void customizeDocumentCommand(IDocument document, DocumentCommand command);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IAutoIndentStrategy.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IAutoIndentStrategy.java
deleted file mode 100644
index 53cf935..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IAutoIndentStrategy.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-
-
-/**
- * Exists for backward compatibility.
- * Please use <code>IAutoEditStrategy</code> directly.
- */
-public interface IAutoIndentStrategy extends IAutoEditStrategy {
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IDocumentAdapter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IDocumentAdapter.java
deleted file mode 100644
index 2c91b6b..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IDocumentAdapter.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-
-
-import org.eclipse.swt.custom.StyledTextContent;
-
-
-/**
- * Adapts an <code>IDocument</code> to the <code>StyledTextContent</code> interface.
- * The document adapter is used by <code>TextViewer</code> to translate document changes
- * into styled text content changes and vice versa.
- * Clients may implement this interface and override <code>TextViewer.createDocumentAdapter</code>
- * if they want to intercept the communication between the viewer's text widget and
- * the viewer's document.
- *
- * @see IDocument
- * @see StyledTextContent
- */
-public interface IDocumentAdapter extends StyledTextContent {
-
- /**
- * Sets the adapters document.
- *
- * @param document the document to be adapted
- */
- void setDocument(IDocument document);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IDocumentAdapterExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IDocumentAdapterExtension.java
deleted file mode 100644
index 96906c3..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IDocumentAdapterExtension.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-/**
- * Extension interface for <code>IDocumentAdapter</code>. Introduces the concepts of
- * batching a series of document changes into one styled text content change. Batching start
- * when a client calls <code>stopForwardingDocumentChanges</code>. After that call this document
- * adapter does not send out any styled text content change until
- * <code>resumeForwardingDocumentChanges</code> is called. Then, it sends out one styled text
- * content change that covers all changes that have been applied to the document since calling
- * <code>stopForwardingDocumentChanges</code>.
- *
- * @since 2.0
- */
-public interface IDocumentAdapterExtension {
-
- /**
- * Stops forwarding document changes to the styled text.
- */
- void stopForwardingDocumentChanges();
-
- /**
- * Resumes forwarding document changes to the styled text.
- * Also forces the styled text to catch up with all the changes
- * that have been applied since <code>stopForwardingDocumentChanges</code>
- * has been called.
- */
- void resumeForwardingDocumentChanges();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IEventConsumer.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IEventConsumer.java
deleted file mode 100644
index b3985e4..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IEventConsumer.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-
-
-import org.eclipse.swt.events.VerifyEvent;
-
-/**
- * Implementers can register with a text viewer and
- * receive <code>VerifyEvent</code>s before the text viewer
- * they are registered with. If the event consumer marks events
- * as processed by turning their <code>doit</code> field to
- * <code>false</code> the text viewer subsequently ignores them.
- * Clients may implement this interface.<p>
- *
- * <code>ITextViewerExtension2</code> allows clients to manage the
- * <code>VerifyListener</code>s of a <code>TextViewer</code>. This makes
- * <code>IEventConsumer</code> obsolete.
- *
- * @see ITextViewer
- * @see org.eclipse.swt.events.VerifyEvent
- */
-public interface IEventConsumer {
-
- /**
- * Processes the given event and marks it as done if it should
- * be ignored by subsequent receivers.
- *
- * @param event the verify event which will be investigated
- */
- public void processEvent(VerifyEvent event);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IFindReplaceTarget.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IFindReplaceTarget.java
deleted file mode 100644
index 94bf978..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IFindReplaceTarget.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-
-
-import org.eclipse.swt.graphics.Point;
-
-
-/**
- * Defines the interface for finding and replacing strings.
- */
-public interface IFindReplaceTarget {
-
- /**
- * Returns whether a find operation can be performed.
- *
- * @return whether a find operation can be performed
- */
- boolean canPerformFind();
-
- /**
- * Searches for a string starting at the given offset and using the specified search
- * directives. If a string has been found it is selected and its start offset is
- * returned.
- *
- * @param offset the offset at which searching starts
- * @param findString the string which should be found
- * @param searchForward <code>true</code> searches forward, <code>false</code> backwards
- * @param caseSensitive <code>true</code> performes a case sensitve search, <code>false</code> an insensitive search
- * @param wholeWord if <code>true</code> only occurences are reported in which the findString stands as a word by itself
- * @return the position of the specified string, or -1 if the string has not been found
- */
- int findAndSelect(int offset, String findString, boolean searchForward, boolean caseSensitive, boolean wholeWord);
-
- /**
- * Returns the currently selected range of characters as a offset and length.
- *
- * @return the currently selected character range
- */
- Point getSelection();
-
- /**
- * Returns the currently selected characters as a string.
- *
- * @return the currently selected characters
- */
- String getSelectionText();
-
- /**
- * Returns whether this target can be modified.
- *
- * @return <code>true</code> if target can be modified
- */
- boolean isEditable();
-
- /**
- * Replaces the currently selected range of characters with the given text.
- * This target must be editable. Otherwise nothing happens.
- *
- * @param text the substitution text
- */
- void replaceSelection(String text);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IFindReplaceTargetExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IFindReplaceTargetExtension.java
deleted file mode 100644
index 50b2476..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IFindReplaceTargetExtension.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Point;
-
-
-/**
- * Extension interface for <code>IFindReplaceTarget</code>. Extends the find replace target with
- * the concept of searching in a limiting scope and introduces a replace-all mode.
- *
- * @since 2.0
- */
-public interface IFindReplaceTargetExtension {
-
- /**
- * Indicates that a session with the target begins.
- * All calls except <code>beginSession()</code> and <code>endSession()</code> to
- * <code>IFindReplaceTarget</code> and
- * <code>IFindReplaceTargetExtension</code> must be embedded within calls to
- * <code>beginSession()</code> and <code>endSession()</code>.
- *
- * @see #endSession()
- */
- void beginSession();
-
- /**
- * Indicates that a session with the target ends.
- *
- * @see #beginSession()
- */
- void endSession();
-
- /**
- * Returns the find scope of the target, <code>null</code> for global scope.
- *
- * @return returns the find scope of the target, may be <code>null</code>
- */
- IRegion getScope();
-
- /**
- * Sets the find scope of the target to operate on. <code>null</code>
- * indicates that the global scope should be used.
- *
- * @param scope the find scope of the target, may be <code>null</code>
- */
- void setScope(IRegion scope);
-
- /**
- * Returns the currently selected range of lines as a offset and length.
- *
- * @return the currently selected line range
- */
- Point getLineSelection();
-
- /**
- * Sets a selection.
- *
- * @param offset the offset of the selection
- * @param length the length of the selection
- */
- void setSelection(int offset, int length);
-
- /**
- * Sets the scope highlight color
- *
- * @param color the color of the scope highlight
- */
- void setScopeHighlightColor(Color color);
-
-
- /**
- * Sets the target's replace-all mode.
- *
- * @param replaceAll <code>true</code> if this target should switch into replace-all mode,
- * <code>false</code> if it should leave the replace-all state
- */
- void setReplaceAllMode(boolean replaceAll);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IFindReplaceTargetExtension3.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IFindReplaceTargetExtension3.java
deleted file mode 100644
index aa282e9..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IFindReplaceTargetExtension3.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-/**
- * Extension interface for <code>IFindReplaceTarget</code>. Extends the find replace target's
- * findAndSelect method to allow regular expression find/replace.
- *
- * @since 3.0
- */
-public interface IFindReplaceTargetExtension3 {
-
- /**
- * Searches for a string starting at the given offset and using the specified search
- * directives. If a string has been found it is selected and its start offset is
- * returned. If regExSearch is <code>true</code> the findString is
- * interpreted as a regular expression for searching.
- *
- * @param offset the offset at which searching starts
- * @param findString the string which should be found
- * @param searchForward <code>true</code> searches forward, <code>false</code> backwards
- * @param caseSensitive <code>true</code> performes a case sensitve search, <code>false</code> an insensitive search
- * @param wholeWord if <code>true</code> only occurences are reported in which the findString stands as a word by itself.
- * Must not be used in combination with <code>regExSearch</code>.
- * @param regExSearch if <code>true</code> findString represents a regular expression
- * Must not be used in combination with <code>wholeWord</code>.
- * @return the position of the specified string, or -1 if the string has not been found
- * @throws PatternSyntaxException if regExSearch is <code>true</code> and findString is an invalid regular expression
- */
- int findAndSelect(int offset, String findString, boolean searchForward, boolean caseSensitive, boolean wholeWord, boolean regExSearch);
-
- /**
- * Replaces the currently selected range of characters with the given text.
- * If regExReplace is <code>true</code> the text is interpreted as a regular
- * expression for searching.
- * This target must be editable. Otherwise nothing happens.
- *
- * @param text the substitution text
- * @param regExReplace if <code>true</code> text represents a regular expression
- * @throws IllegalStateException if a REPLACE or REPLACE_FIND operation is not preceded by a successful FIND operation
- * @throws PatternSyntaxException if regExReplace is <code>true</code> and text is an invalid regular expression
- */
- void replaceSelection(String text, boolean regExReplace);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControl.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControl.java
deleted file mode 100644
index a4b9858..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControl.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-
-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 1af2737..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControlCreator.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-
-import org.eclipse.swt.widgets.Shell;
-
-
-/**
- * Interface of a factory of information controls.
- *
- * @since 2.0
- */
-public interface IInformationControlCreator {
-
- /**
- * Creates a new information control with the given shell as the control's parent.
- *
- * @param parent the parent shell
- * @return the created information control
- */
- IInformationControl createInformationControl(Shell parent);
-}
-
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControlCreatorExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControlCreatorExtension.java
deleted file mode 100644
index a68948e..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControlCreatorExtension.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-/**
- * Extension to <code>IInformationControlCreator</code> which
- * tests if an existing information control can be reused.
- *
- * @see org.eclipse.jface.text.IInformationControlCreator
- * @see org.eclipse.jface.text.IInformationControl
- * @since 3.0
- */
-public interface IInformationControlCreatorExtension {
-
- /**
- * Tests if an existing information control can be reused.
- *
- * @param control the information control to test
- * @return <code>true</code> if the control can be reused
- */
- boolean canReuse(IInformationControl control);
-
- /**
- * Tests whether the given information provider can replace the given information provide. This is
- * the case if the two creators create the same kind of information controls.
- *
- * @param creator the creator to be checked
- * @return <code>true</code> if the given creator can be replaced
- */
- boolean canReplace(IInformationControlCreator creator);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControlExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControlExtension.java
deleted file mode 100644
index 0720fb4..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControlExtension.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-/**
- * Extension interface for <code>IInformationControl</code>. As it is the responsibility of
- * the implementer of <code>IInformationControl</code> to specify whether the information
- * set is the information itself or a description of the information, only the information control
- * can decide whether there is something that must be displayed.
- *
- * @since 2.0
- */
-public interface IInformationControlExtension {
-
- /**
- * Returns whether this information control has contents to be displayed.
- * @return <code>true</code> if there is contents to be displayed.
- */
- boolean hasContents();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControlExtension2.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControlExtension2.java
deleted file mode 100644
index bc2b4b5..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControlExtension2.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-
-/**
- * Extension interface for <code>IInformationControl</code>. Replaces the concept of
- * textual information to be displayed with the more general concept of an input of the
- * information control. Text to be displayed set with <code>setInformation(String)</code>
- * is ignored.
- *
- * @see org.eclipse.jface.text.IInformationControl
- * @since 2.1
- */
-public interface IInformationControlExtension2 {
-
- /**
- * Sets the input to be presented in this information control.
- *
- * @param input the object to be used as input for this control
- */
- void setInput(Object input);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControlExtension3.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControlExtension3.java
deleted file mode 100644
index a566a1f..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControlExtension3.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.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 88e358b..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IMarkRegionTarget.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-/**
- * A mark region target to support marked regions as found in emacs.
- *
- * @since 2.0
- */
-public interface IMarkRegionTarget {
-
- /**
- * Sets or clears a mark at the current cursor position.
- *
- * @param set sets the mark if <code>true</code>, clears otherwise.
- */
- void setMarkAtCursor(boolean set);
-
- /**
- * Swaps the mark and cursor position if the mark is in the visible region.
- */
- void swapMarkAndCursor();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IMarkSelection.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IMarkSelection.java
deleted file mode 100644
index 3bc7aa1..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IMarkSelection.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-
-import org.eclipse.jface.viewers.ISelection;
-
-
-/**
- * A mark selection. Can be returned by text viewers implementing the
- * <code>IMarkRegionTarget</code> interface.
- *
- * @since 2.0
- */
-public interface IMarkSelection extends ISelection {
-
- /**
- * Returns the marked document.
- *
- * @return the marked document
- */
- IDocument getDocument();
-
- /**
- * Returns the mark position. The offset may be <code>-1</code> if there's no marked region.
- *
- * @return the mark position or <code>-1</code> if there is no marked region
- */
- int getOffset();
-
- /**
- * Returns the length of the mark selection. The length may be negative, if the caret
- * is before the mark position. The length has no meaning if <code>getOffset()</code>
- * returns <code>-1</code>.
- *
- * @return the length of the mark selection. Result is undefined for <code>getOffset == -1</code>
- */
- int getLength();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IPaintPositionManager.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IPaintPositionManager.java
deleted file mode 100644
index 00b1977..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IPaintPositionManager.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-
-import org.eclipse.jface.text.Position;
-
-/**
- * Manager that manages and updates positions used by <code>IPainter</code>s.
- *
- * @see org.eclipse.jface.text.IPainter
- * @since 2.1
- */
-public interface IPaintPositionManager {
-
- /**
- * Starts managing the given position until <code>unmanagePosition</code> is called.
- *
- * @param position the position to manage
- * @see #unmanagePosition(Position)
- */
- void managePosition(Position position);
-
- /**
- * Stops managing the given position. If the position is not managed
- * by this managed, this call has no effect.
- *
- * @param position the position that should no longer be managed
- */
- void unmanagePosition(Position position);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IPainter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IPainter.java
deleted file mode 100644
index 26b5109..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IPainter.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-
-/**
- * A painter is responsible for creating, managing, updating, and removing visual decorations of an <code>ITextViewer</code>. Examples are
- * the highlighting of the cursor line, the print marging, or the highlighting of matching peer characters such as pairs of brackets. Clients
- * may implement this interface. Painters should be registered with a <code>PaintManager</code>. The paint manager tracks several classes
- * of events issued by an <code>ITextViewer</code> and reacts by appropriately invoking the registered painters.<p>
- * Painters can be activated or deactivated. Usually, painters are initially deactivated and are activated by the first call to their <code>paint</code>
- * method. Painters can be deactivated by calling <code>deactivate</code>. Deactivated painter can be reactivated by calling <code>paint</code>
- * again.<p>
- * Painters usually have to manage state information. E.g., a painter painting a cursor line highlight must redraw the previous and the actual cursor
- * line in the advent of a change of the cursor position. This state information must usually be adapted to changes of the viewer's content. In order
- * to support this common scenario, the <code>PaintManager</code> gives a painter access to a <code>IPaintPositionUpdater</code>. The painter
- * can use this updater to manage its state information.<p>
- *
- * @see org.eclipse.jface.text.PaintManager
- * @since 2.1
- */
-public interface IPainter {
-
- /**
- * Constant describing the reason of a repaint request: selection changed.
- */
- int SELECTION= 0;
- /**
- * Constant describing the reason of a repaint request: text changed.
- */
- int TEXT_CHANGE= 1;
- /**
- * Constant describing the reason of a repaint request: key pressed.
- */
- int KEY_STROKE= 2;
- /**
- * Constant describing the reason of a repaint request: mouse button pressed.
- */
- int MOUSE_BUTTON= 4;
- /**
- * Constant describing the reason of a repaint request: paint manager internal change.
- */
- int INTERNAL= 8;
- /**
- * Constant describing the reason of a repaint request: paint manager or painter configuration changed.
- */
- int CONFIGURATION= 16;
-
-
- /**
- * Disposes this painter. Prior to disposing, a painter should be deactivated. A disposed
- * painter can not be reactivated.
- *
- * @see #deactivate(boolean)
- */
- void dispose();
-
- /**
- * Requests this painter to repaint because of the given reason. Based on the given reason
- * the painter can decide whether it will repaint or not. If it repaints and is not yet activated,
- * it wil activate itself.
- *
- * @param reason the repaint reason, value is one of the constants defined in this interface
- */
- void paint(int reason);
-
- /**
- * Deactivates this painter. If the painter has not been activated before, this call does not
- * have any effect. <code>redraw</code> indicates whether the painter should remove
- * any decoration it previously applied. A deactivated painter can be reactivated by calling
- * <code>paint</code>.
- *
- * @param redraw <code>true</code> if any previously applied decoration should be removed
- * @see #paint(int)
- */
- void deactivate(boolean redraw);
-
- /**
- * Sets the paint position manager that can be used by this painter or removes any previously
- * set paint position manager.
- *
- * @param manager the paint position manager or <code>null</code>
- */
- void setPositionManager(IPaintPositionManager manager);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IRewriteTarget.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IRewriteTarget.java
deleted file mode 100644
index 317721e..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IRewriteTarget.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
- /**
- * A target publishing the required functions to modify a document that is displayed
- * in the ui, such as in a text viewer. It provides access to the document and control
- * over the redraw behavior and the batching of document changes into undo commands.
- *
- * @see org.eclipse.jface.text.ITextViewer
- * @see org.eclipse.jface.text.IDocument
- * @see org.eclipse.jface.text.IUndoManager
- * @since 2.0
- */
-public interface IRewriteTarget {
-
- /**
- * Returns the document of this target.
- *
- * @return the document of this target
- */
- IDocument getDocument();
-
- /**
- * Disables/enables redrawing of the ui while modifying the target's document.
- *
- * @param redraw <code>true</code> if the document's ui presentation should
- * be updated, <code>false</code> otherwise
- */
- void setRedraw(boolean redraw);
-
- /**
- * If an undo manager is connected to the document's ui presentation, this
- * method tells the undo manager to fold all subsequent changes into
- * one single undo command until <code>endCompoundChange</code> is called.
- */
- void beginCompoundChange();
-
- /**
- * If an undo manager is connected to the document's ui presentation, this method
- * tells the undo manager to stop the folding of changes into a single undo command.
- * After this call, all subsequent changes are considered to be individually undoable.
- */
- void endCompoundChange();
-}
-
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/ISelectionValidator.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/ISelectionValidator.java
deleted file mode 100644
index 17080f0..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ISelectionValidator.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-import org.eclipse.jface.viewers.ISelection;
-
-/**
- * A 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/ISynchronizable.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/ISynchronizable.java
deleted file mode 100644
index f604aee..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ISynchronizable.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-/**
- * Interface for objects which can be set into a synchronized mode when needed.
- * For that, the lock object must be set.
- *
- * @since 3.0
- */
-public interface ISynchronizable {
-
- /**
- * Sets the lock object for this object. If the lock object is not <code>null</code>
- * subsequent calls to methods of this object are synchronized on this lock
- * object.
- *
- * @param lockObject the lock object. May be <code>null</code>.
- */
- void setLockObject(Object lockObject);
-
- /**
- * Returns the lock object or <code>null</code> if there is none.
- *
- * @return the lock object or <code>null</code>
- */
- Object getLockObject();
-}
\ No newline at end of file
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 b9ee145..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextDoubleClickStrategy.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-
-
-/**
- * A text double click strategy defines the reaction of a text viewer
- * to mouse double click events. For that the strategy must be installed
- * on the text viewer.<p>
- * Clients may implements this interface or use the standard implementation
- * <code>DefaultTextDoubleClickStrategy</code>.
- *
- * @see org.eclipse.jface.text.ITextViewer
- * @see org.eclipse.swt.events.MouseListener#mouseDoubleClick(MouseEvent)
- */
-public interface ITextDoubleClickStrategy {
-
- /**
- * The mouse has been double clicked on the given text viewer.
- *
- * @param viewer the viewer into which has been double clicked
- */
- void doubleClicked(ITextViewer viewer);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextHover.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextHover.java
deleted file mode 100644
index dce5cd7..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextHover.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-
-
-/**
- * Provides a hover popup which appears on top of the text viewer with
- * relevant display information. If the text hover does not provide information
- * no hover popup is shown. Any implementer of this interface must be capable of
- * operating in a non-UI thread.<p>
- * Clients may implement this interface.
- *
- * @see org.eclipse.jface.text.ITextViewer
- */
-public interface ITextHover {
-
- /**
- * Returns the text which should be presented if a hover popup is shown
- * for the specified hover region. The hover region has the same semantics
- * as the region returned by <code>getHoverRegion</code>. If the returned
- * string is <code>null</code> or empty no hover popup will be shown.
- *
- * @param textViewer the viewer on which the hover popup should be shown
- * @param hoverRegion the text range in the viewer which is used to determine
- * the hover display information
- * @return the hover popup display information
- */
- String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion);
-
- /**
- * Returns the text region which should serve as the source of information
- * to compute the hover popup display information. The popup has been requested
- * for the given offset.<p>
- * For example, if hover information can be provided on a per method basis in a
- * source viewer, the offset should be used to find the enclosing method and the
- * source range of the method should be returned.
- *
- * @param textViewer the viewer on which the hover popup should be shown
- * @param offset the offset for which the hover request has been issued
- * @return the hover region used to compute the hover display information
- */
- IRegion getHoverRegion(ITextViewer textViewer, int offset);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextHoverExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextHoverExtension.java
deleted file mode 100644
index e1257cc..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextHoverExtension.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-/**
- * Extension to <code>ITextHover</code> for providing its own information
- * control creator.
- *
- * @see org.eclipse.jface.text.IInformationControlCreator
- * @see org.eclipse.jface.text.ITextHover
- * @since 3.0
- */
-public interface ITextHoverExtension {
-
- /**
- * Returns the information control creator of this text hover.
- *
- * @return the information control creator
- */
- IInformationControlCreator getInformationControlCreator();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextInputListener.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextInputListener.java
deleted file mode 100644
index 2e7b505..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextInputListener.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-
-
-/**
- * Text input listeners registered with an text viewer are informed
- * if the document serving as the text viewer's model is replaced.
- * Clients may implement this interface.
- *
- * @see org.eclipse.jface.text.ITextViewer
- * @see org.eclipse.jface.text.IDocument
- */
-public interface ITextInputListener {
-
- /**
- * Called before the input document is replaced.
- *
- * @param oldInput the text viewer's previous input document
- * @param newInput the text viewer's new input document
- */
- void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput);
-
- /**
- * Called after the input document has been replaced.
- *
- * @param oldInput the text viewer's previous input document
- * @param newInput the text viewer's new input document
- */
- void inputDocumentChanged(IDocument oldInput, IDocument newInput);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextListener.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextListener.java
deleted file mode 100644
index b967c61..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextListener.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-
-
-/**
- * Text listeners registered with 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 1608ff5..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextOperationTarget.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-
-
-/**
- * Defines the target for a text operation.
- */
-public interface ITextOperationTarget {
-
-
- /**
- * Text operation code for undoing the last edit command.
- */
- static final int UNDO= 1;
-
- /**
- * Text operation code for redoing the last undone edit command.
- */
- static final int REDO= 2;
-
- /**
- * Text operation code for moving the selected text to the clipboard.
- */
- static final int CUT= 3;
-
- /**
- * Text operation code for copying the selected text to the clipboard.
- */
- static final int COPY= 4;
-
- /**
- * Text operation code for inserting the clipboard content at the
- * current position.
- */
- static final int PASTE= 5;
-
- /**
- * Text operation code for deleting the selected text or if selection
- * is empty the character at the right of the current position.
- */
- static final int DELETE= 6;
-
- /**
- * Text operation code for selecting the complete text.
- */
- static final int SELECT_ALL= 7;
-
- /**
- * Text operation code for shifting the selected text block to the right.
- */
- static final int SHIFT_RIGHT= 8;
-
- /**
- * Text operation code for unshifting the selected text block to the left.
- */
- static final int SHIFT_LEFT= 9;
-
- /**
- * Text operation code for printing the complete text.
- */
- static final int PRINT= 10;
-
- /**
- * Text operation code for prefixing the selected text block.
- */
- static final int PREFIX= 11;
-
- /**
- * Text operation code for removing the prefix from the selected text block.
- */
- static final int STRIP_PREFIX= 12;
-
-
- /**
- * Returns whether the operation specified by the given operation code
- * can be performed.
- *
- * @param operation the operation code
- * @return <code>true</code> if the specified operation can be performed
- */
- boolean canDoOperation(int operation);
-
- /**
- * Performs the operation specified by the operation code on the target.
- * <code>doOperation</code> must only be called if <code>canDoOperation</code>
- * returns <code>true</code>.
- *
- * @param operation the operation code
- */
- void doOperation(int operation);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextOperationTargetExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextOperationTargetExtension.java
deleted file mode 100644
index 4e0be75..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextOperationTargetExtension.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-
-/**
- * Extension interface to <code>ITextOperationTarget</code>. Allows a client to control
- * the enable state of operations provided by this target.
- *
- * @see org.eclipse.jface.text.ITextOperationTarget
- * @since 2.0
- */
-public interface ITextOperationTargetExtension {
-
- /**
- * Enables/disabled the given text operation.
- *
- * @param operation the operation to enable/disable
- * @param enable <code>true</code> to enable the operation otherwise <code>false</code>
- */
- void enableOperation(int operation, boolean enable);
-}
-
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextPresentationListener.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextPresentationListener.java
deleted file mode 100644
index 82b57b2..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextPresentationListener.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-/**
- * 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 2ddcc07..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextSelection.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-
-
-import org.eclipse.jface.viewers.ISelection;
-
-
-/**
- * This interface represents a textual selection. A text selection is
- * a range of characters. Although a text selection is a snapshot taken
- * at a particular point in time, it must not copy the line information
- * and the selected text from the selection provider.<p>
- * If, for example, the selection provider is a source viewer, and a text
- * selection is created for the range [5, 10], the line formation for
- * the 5th character must not be determined and remembered at the point
- * of creation. It can rather be determined at the point, when
- * <code>getStartLine</code> is called. If the source viewer range [0, 15]
- * has been changed in the meantime between the creation of the text
- * selection object and the invocation of <code>getStartLine</code>, the returned
- * line number may differ from the line number of the 5th character at the
- * point of creation of the text selection object.<p> The contract of this
- * interface is that weak in order to allow for efficient implementations.<p>
- * Clients may implement this interface or use the default implementation provided
- * by <code>TextSelection</code>.
- *
- * @see org.eclipse.jface.text.TextSelection
- */
-public interface ITextSelection extends ISelection {
-
- /**
- * Returns the offset of the selected text.
- *
- * @return the offset of the selected text
- */
- int getOffset();
-
- /**
- * Returns the length of the selected text.
- *
- * @return the length of the selected text
- */
- int getLength();
-
- /**
- * Returns number of the line containing the offset of the selected text.
- * If the underlying text has been changed between the creation of this
- * selection object and the call of this method, the value returned might
- * differ from what it would have been at the point of creation.
- *
- * @return the start line of this selection or -1 if there is no valid line information
- */
- int getStartLine();
-
- /**
- * Returns the number of the line containing the last character of the selected text.
- * If the underlying text has been changed between the creation of this
- * selection object and the call of this method, the value returned might
- * differ from what it would have been at the point of creation.
- *
- * @return the end line of this selection or -1 if there is no valid line information
- */
- int getEndLine();
-
- /**
- * Returns the selected text.
- * If the underlying text has been changed between the creation of this
- * selection object and the call of this method, the value returned might
- * differ from what it would have been at the point of creation.
- *
- * @return the selected text or <code>null</code> if there is no valid text information
- */
- String getText();
-}
-
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewer.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewer.java
deleted file mode 100644
index 73614cf..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewer.java
+++ /dev/null
@@ -1,435 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Point;
-
-import org.eclipse.jface.viewers.ISelectionProvider;
-
-
-/**
- * A text viewer turns a text widget into a document-based text widget.
- * It supports the following kinds of listeners:
- * <ul>
- * <li> 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.
- * @deprecated use <code>ITextViewerExtension5</code> instead
- */
- 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
- * @deprecated use <code>ITextViewerExtension5</code> instead
- */
- IRegion getVisibleRegion();
-
- /**
- * Returns whether a given range overlaps with the visible region of this viewer's document.
- *
- * @return <code>true</code> if the specified range overlaps with the visible region
- * @deprecated use <code>ITextViewerExtension5</code> instead
- */
- 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 9a5b745..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-
-import org.eclipse.swt.custom.VerifyKeyListener;
-import org.eclipse.swt.widgets.Control;
-
-
-/**
- * Extension interface for <code>ITextViewer</code>. Extends <code>ITextViewer</code> with
- * <ul>
- * <li> a replacement of the event consumer mechanism (methods dealing with <code>VerifyKeyListener</code>)
- * <li> access to the control of this viewer
- * <li> marked region support a la emacs
- * <li> control of the viewer's redraw behavior (@see #setRedraw)
- * <li> access to the viewer's rewrite target
- * </ul>
- *
- * @since 2.0
- */
-public interface ITextViewerExtension {
-
- /**
- * Inserts the verify key listener at the beginning of the viewer's
- * list of verify key listeners. If the listener is already registered
- * with the viewer this call moves the listener to the beginnng of
- * the list.
- *
- * @param listener the listener to be inserted
- */
- void prependVerifyKeyListener(VerifyKeyListener listener);
-
- /**
- * Appends a verify key listener to the viewer's list of verify
- * key listeners. If the listener is already registered with the viewer
- * this call moves the listener to the end of the list.
- *
- * @param listener the listener to be added
- */
- void appendVerifyKeyListener(VerifyKeyListener listener);
-
- /**
- * Removes the verify key listener from the viewer's list of verify key listeners.
- * If the listener is not registered with this viewer, this call has no effect.
- *
- * @param listener the listener to be removed
- */
- void removeVerifyKeyListener(VerifyKeyListener listener);
-
- /**
- * Returns the control of this viewer.
- *
- * @return the control of this viewer
- */
- Control getControl();
-
- /**
- * Sets or clears the mark. If offset is <code>-1</code>, the mark is cleared.
- * If a mark is set and the selection is empty, cut and copy actions performed on this
- * text viewer peform on the region limited by the positions of the mark and the cursor.
- *
- * @param offset the offset of the mark
- */
- void setMark(int offset);
-
- /**
- * Returns the mark position, <code>-1</code> if mark is not set.
- *
- * @return the mark position or <code>-1</code> if no mark is set
- */
- int getMark();
-
- /**
- * Enables/disables the redrawing of this text viewer. This temporarily disconnects
- * the viewer from its underlying StyledText widget. While being disconnected only
- * the viewer's selection may be changed using <code>setSelectedRange</code>.
- * Any direct manipulation of the widget as well as calls to methods that change the viewer's
- * presentation state (such as enabling the segmented view) are not allowed.
- * When redrawing is disabled the viewer does not send out any selection or
- * view port change notification. When redrawing is enabled again, a selection
- * change notification is sent out for the selected range and this range is revealed.
- *
- * @param redraw <code>true</code> to enable redrawing, <code>false</code> otherwise
- */
- void setRedraw(boolean redraw);
-
- /**
- * Returns the viewer's rewrite target.
- *
- * @return the viewer's rewrite target
- */
- IRewriteTarget getRewriteTarget();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension2.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension2.java
deleted file mode 100644
index 80187c3..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension2.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-import org.eclipse.swt.graphics.Point;
-
-/**
- * Extension interface for <code>ITextViewer</code>. Extends <code>ITextViewer</code> with
- * <ul>
- * <li> a replacement of the <code>ITextViewer.invalidateTextPresentation</code> method
- * <li> a replacement of the <code>ITextViewer.setTextHover</code> method now accepting state masks
- * </ul>
- *
- * @since 2.1
- */
-public interface ITextViewerExtension2 {
-
- /**
- * The state mask of the default hover (value <code>0xff</code>).
- */
- final int DEFAULT_HOVER_STATE_MASK= 0xff;
-
- /**
- * Invalidates the viewer's text presentation for the given range.
- *
- * @param offset the offset of the first character to be redrawn
- * @param length the length of the range to be redrawn
- */
- void invalidateTextPresentation(int offset, int length);
-
- /**
- * Sets this viewer's text hover for the given content type and the given state mask. If the given text hower
- * is <code>null</code>, any hover installed for the given content type and state mask is uninstalled.
- *
- * @param textViewerHover the new hover or <code>null</code>
- * @param contentType the type for which the hover is to be registered or unregistered
- * @param stateMask the SWT event state mask; <code>DEFAULT_HOVER_STATE_MASK</code> indicates that
- * the hover is installed as the default hover.
- */
- void setTextHover(ITextHover textViewerHover, String contentType, int stateMask);
-
- /**
- * Removes all text hovers for the given content type.
- * <p>
- * Note: To remove a hover for a given content type and state mask
- * use {@link #setTextHover(ITextHover, String, int)} with <code>null</code>
- * as parameter for the text hover.
- * </p>
- * @param contentType the type for which all text hovers are to be unregistered
- */
- void removeTextHovers(String contentType);
-
- /**
- * Returns the currently displayed text hover if any, <code>null</code> otherwise.
- */
- ITextHover getCurrentTextHover();
-
- /**
- * Returns the location at which the most recent mouse hover event
- * has been issued.
- *
- * @return the location of the most recent mouse hover event
- */
- Point getHoverEventLocation();
-
- /**
- * Prepends the given auto edit strategy to the existing list of strategies for the
- * specified content type. The strategies are called in the order in which they appear in the
- * list of strategies.
- *
- * @param strategy the auto edit strategy
- * @param contentType the content type
- */
- void prependAutoEditStrategy(IAutoEditStrategy strategy, String contentType);
-
- /**
- * Removes the first occurrence of the given auto edit strategy in the list of strategies
- * registered under the specified content type.
- *
- * @param strategy the auto edit strategy
- * @param contentType the content type
- */
- void removeAutoEditStrategy(IAutoEditStrategy strategy, String contentType);
-
- /**
- * Adds the given painter to this viewer.
- *
- * @param painter the painter to be added
- */
- void addPainter(IPainter painter);
-
- /**
- * Removes the given painter from this viewer. If the painter has not been
- * added to this viewer, this call is without effect.
- *
- * @param painter the painter to be removed
- */
- void removePainter(IPainter painter);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension3.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension3.java
deleted file mode 100644
index 624c44e..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension3.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-
-/**
- * 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 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.
- *
- * @return the minimal region of the viewer's document comprising the contents of the viewer's widget
- */
- 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 e83cc45..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension4.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/**********************************************************************
-Copyright (c) 2000, 2003 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-
-Contributors:
- IBM Corporation - Initial implementation
-**********************************************************************/
-package org.eclipse.jface.text;
-
-
-/**
- * Extension interface for <code>ITextViewer</code>. Adds the following functionality:
- * <ul>
- * <li>focus handling for widget token keepers</li>
- * <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 59b1fbe..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension5.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-/**
- * 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.
- *
- * @return the minimal region of the viewer's document comprising the contents of the viewer's widget
- */
- 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);
-
- /**
- * 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 48a9644..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IUndoManager.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-
-
-/**
- * An undo manager is connected to at most one text viewer.
- * It monitors the text viewer and keeps a history of the
- * changes applied to the viewer. The undo manager groups those
- * changes into user interactions which on an undo request are
- * rolled back in one atomic change. <p>
- * Clients may implement this interface or use the standard
- * implementation <code>DefaultUndoManager</code>.
- *
- * @see org.eclipse.jface.text.DefaultUndoManager
- */
-public interface IUndoManager {
-
- /**
- * Connects this undo manager to the given text viewer.
- *
- * @param viewer the viewer the undo manager is connected to
- */
- void connect(ITextViewer viewer);
-
- /**
- * Disconnects this undo manager from its text viewer.
- * If this undo manager hasn't been connected before this
- * operation has no effect.
- */
- void disconnect();
-
- /**
- * Signals the undo manager that all subsequent changes until
- * <code>endCompoundChange</code> is called are to be undone in one piece.
- */
- void beginCompoundChange();
-
- /**
- * Signals the undo manager that the sequence of changes which started with
- * <code>beginCompoundChange</code> has been finished. All subsequent changes
- * are considered to be individually undoable.
- */
- void endCompoundChange();
-
- /**
- * Resets the history of the undo manager. After that call,
- * there aren't any undoable or redoable text changes.
- */
- void reset();
-
- /**
- * The given parameter determines the maximal length of the history
- * remembered by the undo manager.
- *
- * @param undoLevel the length of this undo manager's history
- */
- void setMaximalUndoLevel(int undoLevel);
-
- /**
- * Returns whether at least one text change can be rolled back.
- *
- * @return <code>true</code> if at least one text change can be rolled back
- */
- boolean undoable();
-
- /**
- * Returns whether at least one text change can be repeated. A text change
- * can be repeated only if it was executed and rolled back.
- *
- * @return <code>true</code> if at least on text change can be repeated
- */
- boolean redoable();
-
- /**
- * Rolls back the most recently executed text change.
- */
- void undo();
-
- /**
- * Repeats the most recently rolled back text change.
- */
- void redo();
-
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IViewportListener.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IViewportListener.java
deleted file mode 100644
index 65e5de9..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IViewportListener.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-
-
-/**
- * Registered with a text viewer, viewport listeners are
- * informed about changes of a text viewer's viewport. The view port is that
- * portion of the viewer's document which is visible in the viewer. <p>
- * Clients may implement this interface.
- *
- * @see org.eclipse.jface.text.ITextViewer
- */
-public interface IViewportListener {
-
- /**
- * Informs about viewport changes. The given vertical position
- * is the new vertical scrolling offset measured in pixels.
- */
- void viewportChanged(int verticalOffset);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IWidgetTokenKeeper.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IWidgetTokenKeeper.java
deleted file mode 100644
index 6507ddb..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IWidgetTokenKeeper.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-/**
- * A widget token keeper may require a widget token from an
- * <code>IWidgetTokenOwner</code> and release the token
- * to the owner after usage. A widget token owner may request
- * the token from the token keeper. The keeper may deny that.
- *
- * @since 2.0
- */
-public interface IWidgetTokenKeeper {
-
- /**
- * The given widget token owner requests the widget token from
- * this token keeper. Returns <code>true</code> if the token is released
- * by this token keeper. Note, the keeper must not call
- * <code>releaseWidgetToken(IWidgetTokenKeeper)</code> explicitly.
- *
- * @param owner the token owner
- * @return <code>true</code> if token has been released <code>false</code> otherwise
- */
- boolean requestWidgetToken(IWidgetTokenOwner owner);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IWidgetTokenKeeperExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IWidgetTokenKeeperExtension.java
deleted file mode 100644
index 4b6d09a..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IWidgetTokenKeeperExtension.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**********************************************************************
-Copyright (c) 2000, 2003 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-
-Contributors:
- IBM Corporation - Initial implementation
-**********************************************************************/
-package org.eclipse.jface.text;
-
-/**
- * Extension interface to <code>IWidgetTokenKeeper</code>. Replaces the original
- * <code>requestWidgetToken</code> functionality with a new priority based approach.
- * Adds the concept of focus handling.
- *
- * @since 3.0
- */
-public interface IWidgetTokenKeeperExtension {
-
- /**
- * The given widget token owner requests the widget token from
- * this token keeper. Returns <code>true</code> if the token is released
- * by this token keeper. Note, the keeper must not call
- * <code>releaseWidgetToken(IWidgetTokenKeeper)</code> explicitly.
- *
- * <p>The general contract is that the receiver should release the token
- * if <code>priority</code> exceeds the receiver's priority.</p>
- *
- * @param owner the token owner
- * @param priority the priority of the request
- * @return <code>true</code> if token has been released <code>false</code> otherwise
- */
- boolean requestWidgetToken(IWidgetTokenOwner owner, int priority);
-
- /**
- * Requests the receiver to give focus to its popup shell, hover, or similar. There is
- * no assumption made whether the receiver actually succeeded in taking the focus. The return
- * value gives a hint whether the receiver tried to take focus.
- *
- * @param owner the token owner
- * @return <code>true</code> if the receiver tried to take focus, <code>false</code> if it did not.
- */
- boolean setFocus(IWidgetTokenOwner owner);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IWidgetTokenOwner.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IWidgetTokenOwner.java
deleted file mode 100644
index 7fee31d..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IWidgetTokenOwner.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-
-/**
- * A widget token must be aquired in order to display
- * information in a temporary window. The intent behind this concept is that
- * only one temporary window should be presented at any moment in time and
- * also to avoid overlapping temporary windows.
- *
- * @since 2.0
- */
-public interface IWidgetTokenOwner {
-
- /**
- * Requests the widget token from this token owner. Returns
- * <code>true</code> if the token has been aquired or is
- * already owned by the requester. This method is non-blocking.
- *
- * @param requester the token requester
- * @return <code>true</code> if requester aquires the token,
- * <code>false</code> otherwise
- */
- boolean requestWidgetToken(IWidgetTokenKeeper requester);
-
- /**
- * The given token keeper releases the token to this
- * token owner. If the token has previously not been held
- * by the given token keeper, nothing happens. This
- * method is non-blocking.
- *
- * @param tokenKeeper the token keeper
- */
- void releaseWidgetToken(IWidgetTokenKeeper tokenKeeper);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IWidgetTokenOwnerExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IWidgetTokenOwnerExtension.java
deleted file mode 100644
index ea77557..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IWidgetTokenOwnerExtension.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/**********************************************************************
-Copyright (c) 2000, 2003 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-
-Contributors:
- IBM Corporation - Initial implementation
-**********************************************************************/
-package org.eclipse.jface.text;
-
-/**
- * Extension interface to <code>IWidgetTokenOwner</code>. Replaces the original
- * <code>requestWidgetToken</code> functionality with a new priority based approach.
- *
- * @since 3.0
- */
-public interface IWidgetTokenOwnerExtension {
-
- /**
- * Requests the widget token from this token owner. Returns
- * <code>true</code> if the token has been aquired or is
- * already owned by the requester. This method is non-blocking.
- *
- * <p><code>priority</code> is forwarded to any existing token keeper
- * to give it an estimate on whether the request has higher priority than
- * the current keeper's. There is, however, no guarantee that another keeper
- * will release the token even if it has a high priority.</p>
- *
- * @param requester the token requester
- * @param priority the priority of the request
- * @return <code>true</code> if requester aquires the token,
- * <code>false</code> otherwise
- */
- boolean requestWidgetToken(IWidgetTokenKeeper requester, int priority);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/JFaceTextMessages.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/JFaceTextMessages.java
deleted file mode 100644
index bff498f..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/JFaceTextMessages.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-class JFaceTextMessages {
-
- private static final String RESOURCE_BUNDLE= "org.eclipse.jface.text.JFaceTextMessages";//$NON-NLS-1$
-
- private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
-
- private JFaceTextMessages() {
- }
-
- public static String getString(String key) {
- try {
- return fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/JFaceTextMessages.properties b/org.eclipse.jface.text/src/org/eclipse/jface/text/JFaceTextMessages.properties
deleted file mode 100644
index f95e16d..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/JFaceTextMessages.properties
+++ /dev/null
@@ -1,37 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2003 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-
-TextViewer.error.bad_location.WidgetCommand.setEvent=TextViewer.WidgetCommand.setEvent: BadLocationException
-TextViewer.error.bad_location.findAndSelect=TextViewer.findAndSelect: BadLocationException
-TextViewer.error.bad_location.getBottomIndex=TextViewer.getBottomIndex: BadLocationException
-TextViewer.error.bad_location.getBottomIndexEndOffset=TextViewer.getBottomIndexEndOffset: BadLocationException
-TextViewer.error.bad_location.getFirstCompleteLineOfRegion=TextViewer.getFirstCompleteLineOfRegion: BadLocationException
-TextViewer.error.bad_location.getTopIndex=TextViewer.getTopIndex: BadLocationException
-TextViewer.error.bad_location.getTopIndexStartOffset=TextViewer.getTopIndexStartOffset: BadLocationException
-TextViewer.error.bad_location.selectContentTypePlugin=TextViewer.selectContentTypePlugin: BadLocationException
-TextViewer.error.bad_location.setTopIndex_1=TextViewer.setTopIndex: BadLocationException
-TextViewer.error.bad_location.setTopIndex_2=TextViewer.setTopIndex: BadLocationException
-TextViewer.error.bad_location.shift_1=TextViewer.shift: BadLocationException
-TextViewer.error.bad_location.shift_2=TextViewer.shift: BadLocationException
-TextViewer.error.bad_location.verifyText=TextViewer.verifyText: BadLocationException
-TextViewer.error.invalid_range=Invalid range argument
-TextViewer.error.invalid_visible_region_1=Invalid visible region argument
-TextViewer.error.invalid_visible_region_2=Invalid visible region argument
-
-InfoPopup.info_delay_timer_name=AdditionalInfo Delay
-
-ContentAssistant.assist_delay_timer_name=AutoAssist Delay
-
-AbstractHoverInformationControlManager.hover.restarter=Hover Restart Delay
-
-# The first parameter is the annotation type label and the second is the number of annotations
-OverviewRulerHeader.toolTipTextEntry= {0}: {1}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/MarginPainter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/MarginPainter.java
deleted file mode 100644
index 5e6bcf5..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/MarginPainter.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Rectangle;
-
-
-/**
- * Paints a vertical line (margin line) after a given column respecting the text viewer's font.
- * Clients usually instantiate and configure objects of this class. <p>
- * This class is not intended to be subclassed.
- *
- * @since 2.1
- */
-public class MarginPainter implements IPainter, PaintListener {
-
- /** The widget of the text viewer */
- private StyledText fTextWidget;
-
- /** The column after which to paint the line, default value <code>80</code> */
- private int fMarginWidth= 80;
- /** The color in which to paint the line */
- private Color fColor;
- /** The line style of the line to be painted, default value <code>SWT.LINE_SOLID</code> */
- private int fLineStyle= SWT.LINE_SOLID;
- /** The line width of the line to be painted, default value <code>1</code> */
- private int fLineWidth= 1;
- /** The cached x-offset of the <code>fMarginWidth</code> for the current font */
- private int fCachedWidgetX= -1;
- /** The active state of this painter */
- private boolean fIsActive= false;
-
- /**
- * Creates a new painter for the given text viewer.
- *
- * @param textViewer the text viewer
- */
- public MarginPainter(ITextViewer textViewer) {
- fTextWidget= textViewer.getTextWidget();
- }
-
- /**
- * Sets the column after which to draw the margin line.
- *
- * @param width the column
- */
- public void setMarginRulerColumn(int width) {
- fMarginWidth= width;
- initialize();
- }
-
- /**
- * Sets the line style of the margin line.
- *
- * @param lineStyle a <code>SWT</code> style constant describing the line style
- */
- public void setMarginRulerStyle(int lineStyle) {
- fLineStyle= lineStyle;
- }
-
- /**
- * Sets the line width of the margin line.
- *
- * @param lineWidth the line width
- */
- public void setMarginRulerWidth(int lineWidth) {
- fLineWidth= lineWidth;
- }
-
- /**
- * Sets the color of the margin line. Must be called before <code>paint</code> is called the first time.
- *
- * @param color the color
- */
- public void setMarginRulerColor(Color color) {
- fColor= color;
- }
-
- /**
- * Initializes this painter, by flushing and recomputing all caches and causing
- * the widget to be redrawn. Must be called explicitly when font of text widget changes.
- */
- public void initialize() {
- computeWidgetX();
- fTextWidget.redraw();
- }
-
- /**
- * Computes and remembers the x-offset of the margin column for the
- * current widget font.
- */
- private void computeWidgetX() {
- GC gc= new GC(fTextWidget);
- int pixels= gc.getFontMetrics().getAverageCharWidth();
- gc.dispose();
-
- fCachedWidgetX= pixels * fMarginWidth;
- }
-
- /*
- * @see IPainter#deactivate(boolean)
- */
- public void deactivate(boolean redraw) {
- if (fIsActive) {
- fIsActive= false;
- fCachedWidgetX= -1;
- fTextWidget.removePaintListener(this);
- if (redraw)
- fTextWidget.redraw();
- }
- }
-
- /*
- * @see IPainter#dispose()
- */
- public void dispose() {
- fTextWidget= null;
- }
-
- /*
- * @see IPainter#paint(int)
- */
- public void paint(int reason) {
- if (!fIsActive) {
- fIsActive= true;
- fTextWidget.addPaintListener(this);
- if (fCachedWidgetX == -1)
- computeWidgetX();
- fTextWidget.redraw();
- } else if (CONFIGURATION == reason || INTERNAL == reason)
- fTextWidget.redraw();
- }
-
- /*
- * @see org.eclipse.swt.events.PaintListener#paintControl(org.eclipse.swt.events.PaintEvent)
- */
- public void paintControl(PaintEvent e) {
- if (fTextWidget != null) {
- int x= fCachedWidgetX - fTextWidget.getHorizontalPixel();
- if (x >= 0) {
- Rectangle area= fTextWidget.getClientArea();
- e.gc.setForeground(fColor);
- e.gc.setLineStyle(fLineStyle);
- e.gc.setLineWidth(fLineWidth);
- e.gc.drawLine(x, 0, x, area.height);
- }
- }
- }
-
- /*
- * @see org.eclipse.jface.text.IPainter#setPositionManager(org.eclipse.jface.text.IPaintPositionManager)
- */
- public void setPositionManager(IPaintPositionManager manager) {
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/MarkSelection.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/MarkSelection.java
deleted file mode 100644
index 6463e61..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/MarkSelection.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-
-/**
- * Default implementation of <code>IMarkSelection</code>.
- * @since 2.0
- */
-public class MarkSelection implements IMarkSelection {
-
- /** The marked document. */
- private final IDocument fDocument;
- /** The offset of the mark selection. */
- private final int fOffset;
- /** The length of the mark selection. */
- private final int fLength;
-
- /**
- * Creates a MarkSelection.
- *
- * @param document the marked document
- * @param offset the offset of the mark
- * @param length the length of the mark, may be negative if caret before offset
- */
- public MarkSelection(IDocument document, int offset, int length) {
- fDocument= document;
- fOffset= offset;
- fLength= length;
- }
-
- /*
- * @see IMarkSelection#getDocument()
- */
- public IDocument getDocument() {
- return fDocument;
- }
-
- /*
- * @see IMarkSelection#getOffset()
- */
- public int getOffset() {
- return fOffset;
- }
-
- /*
- * @see IMarkSelection#getLength()
- */
- public int getLength() {
- return fLength;
- }
-
- /*
- * @see ISelection#isEmpty()
- */
- public boolean isEmpty() {
- return fLength == 0;
- }
-
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/PaintManager.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/PaintManager.java
deleted file mode 100644
index 2119ba8..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/PaintManager.java
+++ /dev/null
@@ -1,378 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.widgets.Control;
-
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-
-
-/**
- * Manages the painters of a text viewer. Clients usually instantiate and configure
- * objects of this type.
- *
- * @since 2.1
- */
-public final class PaintManager implements KeyListener, MouseListener, ISelectionChangedListener, ITextListener, ITextInputListener {
-
- /**
- * Position updater used by the position manager. This position updater differes from the default position
- * updater in that it extends a position when an insertion happens at the position's offset and right behind
- * the position.
- */
- static class PaintPositionUpdater extends DefaultPositionUpdater {
-
- /**
- * Creates the position updater for the given category.
- *
- * @param category the position category
- */
- protected PaintPositionUpdater(String category) {
- super(category);
- }
-
- /**
- * If an insertion happens at a position's offset, the
- * position is extended rather than shifted. Also, if something is added
- * right behind the end of the position, the position is extended rather
- * than kept stable.
- */
- protected void adaptToInsert() {
-
- int myStart= fPosition.offset;
- int myEnd= fPosition.offset + fPosition.length;
- myEnd= Math.max(myStart, myEnd);
-
- int yoursStart= fOffset;
- int yoursEnd= fOffset + fReplaceLength;// - 1;
- yoursEnd= Math.max(yoursStart, yoursEnd);
-
- if (myEnd < yoursStart)
- return;
-
- if (myStart <= yoursStart)
- fPosition.length += fReplaceLength;
- else
- fPosition.offset += fReplaceLength;
- }
- }
-
- /**
- * The paint position manager used by this paint manager. The paint position
- * manager is installed on a single document and control the creation/disposed
- * and updating of a position category that will be used for managing positions.
- */
- static class PositionManager implements IPaintPositionManager {
-
- /** The document this positon manager works on */
- private IDocument fDocument;
- /** The position updater used for the managing position category */
- private IPositionUpdater fPositionUpdater;
- /** The managing position category */
- private String fCategory;
-
- /**
- * Creates a new position manager. Initializes the managing
- * position category using its class name and its hash value.
- */
- public PositionManager() {
- fCategory= getClass().getName() + hashCode();
- fPositionUpdater= new PaintPositionUpdater(fCategory);
- }
-
- /**
- * Installs this position manager in the given document. The position manager stays
- * active until <code>uninstall</code> or <code>dispose</code>
- * is called.
- *
- * @param document the document to be installed on
- */
- public void install(IDocument document) {
- fDocument= document;
- fDocument.addPositionCategory(fCategory);
- fDocument.addPositionUpdater(fPositionUpdater);
- }
-
- /**
- * Diposes this position manager. The position manager is automatically
- * uninstalled from the document it has previously been installed
- * on.
- */
- public void dispose() {
- uninstall(fDocument);
- }
-
- /**
- * Uninstalls this position manager form the given document. If the position
- * manager has no been installed on this document, this method is without effect.
- *
- * @param document the document form which to uninstall
- */
- public void uninstall(IDocument document) {
- if (document == fDocument && document != null) {
- try {
- fDocument.removePositionUpdater(fPositionUpdater);
- fDocument.removePositionCategory(fCategory);
- } catch (BadPositionCategoryException x) {
- // should not happen
- }
- fDocument= null;
- }
- }
-
- /*
- * @see IPositionManager#addManagedPosition(Position)
- */
- public void managePosition(Position position) {
- try {
- fDocument.addPosition(fCategory, position);
- } catch (BadPositionCategoryException x) {
- // should not happen
- } catch (BadLocationException x) {
- // should not happen
- }
- }
-
- /*
- * @see IPositionManager#removeManagedPosition(Position)
- */
- public void unmanagePosition(Position position) {
- try {
- fDocument.removePosition(fCategory, position);
- } catch (BadPositionCategoryException x) {
- // should not happen
- }
- }
- }
-
-
- /** The painters managed by this paint manager. */
- private List fPainters= new ArrayList(2);
- /** The position manager used by this paint manager */
- private PositionManager fManager;
- /** The associated text viewer */
- private ITextViewer fTextViewer;
-
- /**
- * Creates a new paint manager for the given text viewer.
- *
- * @param textViewer the text viewer associated to this newly created paint manager
- */
- public PaintManager(ITextViewer textViewer) {
- fTextViewer= textViewer;
- }
-
-
- /**
- * Adds the given painter to the list of painters managed by this paint manager.
- * If the painter is already registered with this paint manager, this method is
- * without effect.
- *
- * @param painter the painter to be added
- */
- public void addPainter(IPainter painter) {
- if (!fPainters.contains(painter)) {
- fPainters.add(painter);
- if (fPainters.size() == 1)
- install();
- painter.setPositionManager(fManager);
- painter.paint(IPainter.INTERNAL);
- }
- }
-
- /**
- * Removes the given painter from the list of painters managed by this
- * paint manager. If the painter has not previously been added to this
- * paint manager, this method is without effect.
- *
- * @param painter the painter to be removed
- */
- public void removePainter(IPainter painter) {
- if (fPainters.remove(painter))
- painter.setPositionManager(null);
- if (fPainters.size() == 0)
- dispose();
- }
-
- /**
- * Installs/activates this paint manager. Is called as soon as the
- * first painter is to be managed by this paint manager.
- */
- private void install() {
-
- fManager= new PositionManager();
- if (fTextViewer.getDocument() != null)
- fManager.install(fTextViewer.getDocument());
-
- fTextViewer.addTextInputListener(this);
-
- 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 78b9c9b..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/PropagatingFontFieldEditor.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-
-import org.eclipse.jface.preference.FontFieldEditor;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-
-
-/**
- * This font field editor implements chaining between a source preference
- * store and a target preference store. Any time the source preference
- * store changes, the change is propagated to the target store. Propagation
- * means that the actual value stored in the source store is set as default
- * value in the target store. If the target store does not contain a value
- * other than the default value, the new default value is immediately
- * effective.
- *
- * @see FontFieldEditor
- * @since 2.0
- */
-public class PropagatingFontFieldEditor extends FontFieldEditor {
-
- /** The editor's parent widget */
- private Composite fParent;
- /** The representation of the default font choice */
- private String fDefaultFontLabel;
-
- /**
- * Creates a new font field editor with the given parameters.
- *
- * @param name the editor's name
- * @param labelText the text shown as editor description
- * @param parent the editor's parent widget
- * @param defaultFontLabel the label shown in the editor value field when the default value should be taken
- */
- public PropagatingFontFieldEditor(String name, String labelText, Composite parent, String defaultFontLabel) {
- super(name, labelText, parent);
- fParent= parent;
- fDefaultFontLabel= defaultFontLabel == null ? "" : defaultFontLabel; //$NON-NLS-1$
- }
-
- /*
- * @see FontFieldEditor#doLoad()
- */
- protected void doLoad() {
- if (getPreferenceStore().isDefault(getPreferenceName()))
- loadDefault();
- super.doLoad();
- checkForDefault();
- }
-
- /*
- * @see FontFieldEditor#doLoadDefault()
- */
- protected void doLoadDefault() {
- super.doLoadDefault();
- checkForDefault();
- }
-
- /**
- * Checks whether this editor presents the default value "inheritated"
- * from the workbench rather than its own font.
- */
- private void checkForDefault() {
- if (presentsDefaultValue()) {
- Control c= getValueControl(fParent);
- if (c instanceof Label)
- ((Label) c).setText(fDefaultFontLabel);
- }
- }
-
- /**
- * Propagates the font set in the source store to the
- * target store using the given keys.
- *
- * @param source the store from which to read the text font
- * @param sourceKey the key under which the font can be found
- * @param target the store to which to propagate the font
- * @param targetKey the key under which to store the font
- */
- private static void propagateFont(IPreferenceStore source, String sourceKey, IPreferenceStore target, String targetKey) {
- FontData fd= PreferenceConverter.getFontData(source, sourceKey);
- if (fd != null) {
- boolean isDefault= target.isDefault(targetKey); // save old state!
- PreferenceConverter.setDefault(target, targetKey, fd);
- if (isDefault) {
- // restore old state
- target.setToDefault(targetKey);
- }
- }
- }
-
- /**
- * Starts the propagation of the font preference stored in the source preference
- * store under the source key to the target preference store using the target
- * preference key.
- *
- * @param source the source preference store
- * @param sourceKey the key to be used in the source preference store
- * @param target the target preference store
- * @param targetKey the key to be used in the target preference store
- */
- public static void startPropagate(final IPreferenceStore source, final String sourceKey, final IPreferenceStore target, final String targetKey) {
- source.addPropertyChangeListener(new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- if (sourceKey.equals(event.getProperty()))
- propagateFont(source, sourceKey, target, targetKey);
- }
- });
-
- propagateFont(source, sourceKey, target, targetKey);
- }
-}
-
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextAttribute.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/TextAttribute.java
deleted file mode 100644
index dbc1dc0..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextAttribute.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-
-
-/**
- * Description of textual attributes such as color and style.
- * Text attributes are considered value objects.
- */
-public class TextAttribute {
-
- /** Foreground color */
- private Color foreground;
-
- /** Background color */
- private Color background;
-
- /** The text style */
- private int style;
-
- /**
- * Creates a text attribute with the given colors and style.
- *
- * @param foreground the foreground color
- * @param background the background color
- * @param style the style
- */
- public TextAttribute(Color foreground, Color background, int style) {
- this.foreground= foreground;
- this.background= background;
- this.style= style;
- }
-
- /**
- * Creates a text attribute for the given foreground color, no background color and
- * with the SWT normal style.
- *
- * @param foreground the foreground color
- */
- public TextAttribute(Color foreground) {
- this(foreground, null, SWT.NORMAL);
- }
-
- /*
- * @see Object#equals(Object)
- */
- public boolean equals(Object object) {
-
- if (object == this)
- return true;
-
- if (!(object instanceof TextAttribute))
- return false;
-
- TextAttribute a= (TextAttribute) object;
- return (a.style == style && equals(a.foreground, foreground) && equals(a.background, background));
- }
-
- /**
- * Returns whether the two given objects are equal.
- *
- * @param o1 the first object, can be <code>null</code>
- * @param o2 the second object, can be <code>null</code>
- * @return <code>true</code> if the given objects are equals
- * @since 2.0
- */
- private boolean equals(Object o1, Object o2) {
- if (o1 != null)
- return o1.equals(o2);
- return (o2 == null);
- }
-
- /*
- * @see Object#hashCode()
- */
- public int hashCode() {
- int foregroundHash= foreground == null ? 0 : foreground.hashCode();
- int backgroundHash= background == null ? 0 : background.hashCode();
- return (foregroundHash << 24) | (backgroundHash << 16) | style;
- }
-
- /**
- * Returns the attribute's foreground color.
- *
- * @return the attribute's foreground color
- */
- public Color getForeground() {
- return foreground;
- }
-
- /**
- * Returns the attribute's background color.
- *
- * @return the attribute's background color
- */
- public Color getBackground() {
- return background;
- }
-
- /**
- * Returns the attribute's style.
- *
- * @return the attribute's style
- */
- public int getStyle() {
- return style;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextEvent.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/TextEvent.java
deleted file mode 100644
index 59a8837..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextEvent.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-
-/**
- * This event is sent to implementers of <code>ITextListener</code>. It represents a
- * change applied to text viewer. The change is specified as a replace command using
- * offset, length, inserted text, and replaced text. The text viewer issues a text event
- * after the viewer has been changed either in response to a change of the viewer's document
- * or when the viewer's visual content has been changed. In the first case, the text event
- * also carries the original document event. Depending on the viewer's presentation mode,
- * the text event coordinates are different from the document event's coordinates.
- * 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 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 65bad5f..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextPresentation.java
+++ /dev/null
@@ -1,617 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-import org.eclipse.swt.SWT;
-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 syle information for the range covered by the whole presentation */
- private StyleRange fDefaultRange;
- /** The member ranges of the presentation */
- private ArrayList fRanges;
- /** A clipping region against which the presentation can be clipped when asked for results */
- private IRegion fResultWindow;
- /**
- * 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 decribing the default region
- */
- public void setDefaultStyleRange(StyleRange range) {
- fDefaultRange= range;
- }
-
- /**
- * Returns this presentation's default style range. The returned <code>StyleRange</code>
- * is relative to the start of the result window.
- *
- * @return this presentation's default style range
- */
- public StyleRange getDefaultStyleRange() {
- 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);
- }
-
- /**
- * 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) {
- 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);
- 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);
- fRanges.add(defaultRange);
- return;
- }
-
- int last= getFirstIndexAfterWindow(rangeRegion);
- ArrayList rangesCopy= new ArrayList(fRanges);
- int insertOffset= 0;
- for (int i= first; i < last && length > 0; i++) {
-
- StyleRange current= (StyleRange)rangesCopy.get(i);
- int currentStart= current.start;
- int currentEnd= currentStart + current.length;
-
- if (end <= currentStart) {
- fRanges.add(i + insertOffset, 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);
- fRanges.add(i + insertOffset, defaultRange);
- insertOffset++;
-
-
- // Apply background to first part of current range
- current.length= Math.min(end, currentEnd) - currentStart;
- applyStyle(range, current);
- }
-
- 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();
- insertOffset++;
- fRanges.add(i + insertOffset, current);
- }
- applyStyle(range, current);
- 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;
- insertOffset++;
- fRanges.add(i + insertOffset, 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 + insertOffset, defaultRange);
- }
- }
- }
-
- /**
- * Applies the template's style to the target.
- *
- * @since 3.0
- */
- private void applyStyle(StyleRange template, StyleRange target) {
- if (template.foreground != null)
- target.foreground= template.foreground;
- if (template.background != null)
- target.background= template.background;
- if (template.fontStyle != SWT.NORMAL)
- 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) {
- int i= 0;
- if (window != null) {
- int start= window.getOffset();
- while (i < fRanges.size()) {
- StyleRange r= (StyleRange) fRanges.get(i++);
- if (r.start + r.length > start) {
- -- i;
- break;
- }
- }
- }
- return i;
- }
-
- /**
- * Returns the index of the first range which comes after the specified window and does
- * not overlap with this window.
- *
- * @param window the window to be used for searching
- * @return the index of the first range behind the window and not overlapping with the window
- */
- private int getFirstIndexAfterWindow(IRegion window) {
- int i= fRanges.size();
- if (window != null) {
- int end= window.getOffset() + window.getLength();
- while (i > 0) {
- StyleRange r= (StyleRange) fRanges.get(--i);
- if (r.start < end) {
- ++ i;
- break;
- }
- }
- }
- return i;
- }
-
- /**
- * Returns a style range which is relative to the specified window and
- * appropriately clipped if necessary. The original style range is not
- * modified.
- *
- * @param window the reference window
- * @param range the absolute range
- * @return the window relative range based on the absolute range
- */
- private StyleRange createWindowRelativeRange(IRegion window, StyleRange range) {
- if (window == null || range == null)
- return range;
-
- int start= range.start - window.getOffset();
- if (start < 0)
- start= 0;
-
- int rangeEnd= range.start + range.length;
- int windowEnd= window.getOffset() + window.getLength();
- int end= (rangeEnd > windowEnd ? windowEnd : rangeEnd);
- end -= window.getOffset();
-
- StyleRange newRange= (StyleRange) range.clone();
- newRange.start= start;
- newRange.length= end - start;
- return newRange;
- }
-
- /**
- * Returns the region which is relative to the specified window and
- * appropriately clipped if necessary.
- *
- * @param region 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 interator
- */
- public Iterator getNonDefaultStyleRangeIterator() {
- return new FilterIterator(fDefaultRange != null);
- }
-
- /**
- * Returns an iterator which enumerates all style ranges of this presentation
- * except the default style range. The returned <code>StyleRange</code>s
- * are relative to the start of the presentation's result window.
- *
- * @return a style range iterator
- */
- public Iterator getAllStyleRangeIterator() {
- return new FilterIterator(false);
- }
-
- /**
- * Returns whether this collection contains any style range including
- * the default style range.
- *
- * @return <code>true</code> if there is no style range in this presentation
- */
- public boolean isEmpty() {
- return (fDefaultRange == null && getDenumerableRanges() == 0);
- }
-
- /**
- * Returns the number of style ranges in the presentation not counting the default
- * style range.
- *
- * @return the number of style ranges in the presentation excluding the default style range
- */
- public int getDenumerableRanges() {
- int size= getFirstIndexAfterWindow(fResultWindow) - getFirstIndexInWindow(fResultWindow);
- return (size < 0 ? 0 : size);
- }
-
- /**
- * Returns the style range with the smallest offset ignoring the default style range or null
- * if the presentation is empty.
- *
- * @return the style range with the smalled offset different from the default style range
- */
- public StyleRange getFirstStyleRange() {
- try {
-
- StyleRange range= (StyleRange) fRanges.get(getFirstIndexInWindow(fResultWindow));
- return createWindowRelativeRange(fResultWindow, range);
-
- } catch (NoSuchElementException x) {
- }
-
- return null;
- }
-
- /**
- * Returns the style range with the highest offset ignoring the default style range.
- *
- * @return the style range with the highest offset different from the default style range
- */
- public StyleRange getLastStyleRange() {
- try {
-
- StyleRange range= (StyleRange) fRanges.get(getFirstIndexAfterWindow(fResultWindow) - 1);
- return createWindowRelativeRange(fResultWindow, range);
-
- } catch (NoSuchElementException x) {
- }
-
- return null;
- }
-
- /**
- * Returns the coverage of this presentation as clipped by the presentation's
- * result window.
- *
- * @return the coverage of this presentation
- */
- public IRegion getCoverage() {
-
- if (fDefaultRange != null) {
- StyleRange range= getDefaultStyleRange();
- return new Region(range.start, range.length);
- }
-
- StyleRange first= getFirstStyleRange();
- StyleRange last= getLastStyleRange();
-
- if (first == null || last == null)
- return null;
-
- return new Region(first.start, last.start - first. start + last.length);
- }
-
- /**
- * 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 ed8da0e..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextSelection.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-
-
-
-/**
- * Standard implementation of <code>ITextSelection</code>.
- * Makes advantage of the weak contract of correctness of its
- * interface. If generated from a selection provider, it only
- * remembers its offset and length and computes the remaining
- * information on request.
- */
-public class TextSelection implements ITextSelection {
-
- /** Internal empty text selection */
- private final static ITextSelection NULL= new TextSelection();
-
- /**
- * Returns a shared instance of an empty text selection.
- *
- * @return a shared instance of an empty text selection
- */
- public static ITextSelection emptySelection() {
- return NULL;
- }
-
- /** Document which delivers the data of the selection */
- private IDocument fDocument;
- /** Offset of the selection */
- private int fOffset;
- /** Length of the selection */
- private int fLength;
-
-
- /**
- * Creates an empty text selection.
- */
- private TextSelection() {
- this(null, -1, -1);
- }
-
- /**
- * Creates a text selection for the given range. This
- * selection object describes generically a text range and
- * is intended to be an argument for the <code>setSelection</code>
- * method of selection providers.
- *
- * @param offset the offset of the range
- * @param length the length of the range
- */
- public TextSelection(int offset, int length) {
- this(null, offset, length);
- }
-
- /**
- * Creates a text selection for the given range of the given document.
- * This selection object is created by selection providers in responds
- * <code>getSelection</code>.
- *
- * @param document the document whose text range is selected in a viewer
- * @param offset the offset of the selected range
- * @param length the length of the selected range
- */
- public TextSelection(IDocument document, int offset, int length) {
- fDocument= document;
- fOffset= offset;
- fLength= length;
- }
-
- /**
- * Returns true if the offset and length are smaller than 0.
- * A selection of length 0, is a valid text selection as it
- * describes, e.g., the cursor position in a viewer.
- */
- /*
- * @see ISelection#isEmpty()
- */
- public boolean isEmpty() {
- return fOffset < 0 || fLength < 0;
- }
-
- /*
- * @see ITextSelection#getOffset()
- */
- public int getOffset() {
- return fOffset;
- }
-
- /*
- * @see ITextSelection#getLength()
- */
- public int getLength() {
- return fLength;
- }
-
- /*
- * @see ITextSelection#getStartLine()
- */
- public int getStartLine() {
-
- try {
- if (fDocument != null)
- return fDocument.getLineOfOffset(fOffset);
- } catch (BadLocationException x) {
- }
-
- return -1;
- }
-
- /*
- * @see ITextSelection#getEndLine()
- */
- public int getEndLine() {
- try {
- if (fDocument != null) {
- int endOffset= fOffset + fLength;
- if (fLength != 0)
- endOffset--;
- return fDocument.getLineOfOffset(endOffset);
- }
- } catch (BadLocationException x) {
- }
-
- return -1;
- }
-
- /*
- * @see ITextSelection#getText()
- */
- public String getText() {
- try {
- if (fDocument != null)
- return fDocument.get(fOffset, fLength);
- } catch (BadLocationException x) {
- }
-
- return null;
- }
-
- /*
- * @see java.lang.Object#equals(Object)
- */
- public boolean equals(Object obj) {
- if (obj == this)
- return true;
-
- if (obj == null || getClass() != obj.getClass())
- return false;
-
- TextSelection s= (TextSelection) obj;
- boolean sameRange= (s.fOffset == fOffset && s.fLength == fLength);
- if (sameRange) {
-
- if (s.fDocument == null && fDocument == null)
- return true;
- if (s.fDocument == null || fDocument == null)
- return false;
-
- try {
- String sContent= s.fDocument.get(fOffset, fLength);
- String content= fDocument.get(fOffset, fLength);
- return sContent.equals(content);
- } catch (BadLocationException x) {
- }
- }
-
- return false;
- }
-
- /*
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- int low= fDocument != null ? fDocument.hashCode() : 0;
- return (fOffset << 24) | (fLength << 16) | low;
- }
-}
-
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java
deleted file mode 100644
index 867be84..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java
+++ /dev/null
@@ -1,4776 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.PatternSyntaxException;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.LineBackgroundEvent;
-import org.eclipse.swt.custom.LineBackgroundListener;
-import org.eclipse.swt.custom.ST;
-import org.eclipse.swt.custom.StyleRange;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.custom.VerifyKeyListener;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.ControlListener;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.events.TraverseEvent;
-import org.eclipse.swt.events.TraverseListener;
-import org.eclipse.swt.events.VerifyEvent;
-import org.eclipse.swt.events.VerifyListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.printing.PrintDialog;
-import org.eclipse.swt.printing.Printer;
-import org.eclipse.swt.printing.PrinterData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.ScrollBar;
-
-import org.eclipse.jface.viewers.IPostSelectionProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.Viewer;
-
-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 {
- preservedText= e.getDocument().get(e.getOffset(), e.getLength());
- } catch (BadLocationException x) {
- preservedText= null;
- if (TRACE_ERRORS)
- System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.WidgetCommand.setEvent")); //$NON-NLS-1$
- }
- } else
- preservedText= null;
- }
- }
-
- /**
- * Connects a text double click strategy to this viewer's text widget.
- * Calls the double click strategy when the mouse has been double clicked
- * inside the text editor.
- */
- class TextDoubleClickStrategyConnector extends MouseAdapter {
-
- /** Internal flag to remember that a double clicked occurred. */
- private boolean fDoubleClicked= false;
-
- public TextDoubleClickStrategyConnector() {
- }
-
- /*
- * @see MouseListener#mouseDoubleClick(MouseEvent)
- */
- public void mouseDoubleClick(MouseEvent e) {
- fDoubleClicked= true;
- }
-
- /*
- * @see MouseListener#mouseUp(MouseEvent)
- */
- public void mouseUp(MouseEvent e) {
- if (fDoubleClicked) {
- fDoubleClicked= false;
- ITextDoubleClickStrategy s= (ITextDoubleClickStrategy) selectContentTypePlugin(getSelectedRange().x, fDoubleClickStrategies);
- if (s != null)
- s.doubleClicked(TextViewer.this);
- }
- }
- }
-
- /**
- * Monitors the area of the viewer's document that is visible in the viewer.
- * If the area might have changed, it informs the text viewer about this
- * potential change and its origin. The origin is internally used for optimization
- * purposes.
- */
- class ViewportGuard extends MouseAdapter
- implements ControlListener, KeyListener, SelectionListener {
-
- /*
- * @see ControlListener#controlResized(ControlEvent)
- */
- public void controlResized(ControlEvent e) {
- updateViewportListeners(RESIZE);
- }
-
- /*
- * @see ControlListener#controlMoved(ControlEvent)
- */
- public void controlMoved(ControlEvent e) {
- }
-
- /*
- * @see KeyListener#keyReleased
- */
- public void keyReleased(KeyEvent e) {
- updateViewportListeners(KEY);
- }
-
- /*
- * @see KeyListener#keyPressed
- */
- public void keyPressed(KeyEvent e) {
- updateViewportListeners(KEY);
- }
-
- /*
- * @see MouseListener#mouseUp
- */
- public void mouseUp(MouseEvent e) {
- if (fTextWidget != null)
- fTextWidget.removeSelectionListener(this);
- updateViewportListeners(MOUSE_END);
- }
-
- /*
- * @see MouseListener#mouseDown
- */
- public void mouseDown(MouseEvent e) {
- if (fTextWidget != null)
- fTextWidget.addSelectionListener(this);
- }
-
- /*
- * @see SelectionListener#widgetSelected
- */
- public void widgetSelected(SelectionEvent e) {
- if (e.widget == fScroller)
- updateViewportListeners(SCROLLER);
- else
- updateViewportListeners(MOUSE);
- }
-
- /*
- * @see SelectionListener#widgetDefaultSelected
- */
- public void widgetDefaultSelected(SelectionEvent e) {}
- }
-
- /**
- * This position updater is used to keep the selection during text shift operations.
- */
- static class ShiftPositionUpdater extends DefaultPositionUpdater {
-
- /**
- * Creates the position updater for the given category.
- *
- * @param category the category this updater takes care of
- */
- protected ShiftPositionUpdater(String category) {
- super(category);
- }
-
- /**
- * If an insertion happens at the selection's start offset,
- * the position is extended rather than shifted.
- */
- protected void adaptToInsert() {
-
- int myStart= fPosition.offset;
- int myEnd= fPosition.offset + fPosition.length -1;
- myEnd= Math.max(myStart, myEnd);
-
- int yoursStart= fOffset;
- int yoursEnd= fOffset + fReplaceLength -1;
- yoursEnd= Math.max(yoursStart, yoursEnd);
-
- if (myEnd < yoursStart)
- return;
-
- if (myStart <= yoursStart) {
- fPosition.length += fReplaceLength;
- return;
- }
-
- if (myStart > yoursStart)
- fPosition.offset += fReplaceLength;
- }
- }
-
- /**
- * Internal document listener.
- */
- class DocumentListener implements IDocumentListener {
-
- /*
- * @see IDocumentListener#documentAboutToBeChanged
- */
- public void documentAboutToBeChanged(DocumentEvent e) {
- if (e.getDocument() == getVisibleDocument())
- fWidgetCommand.setEvent(e);
- }
-
- /*
- * @see IDocumentListener#documentChanged
- */
- public void documentChanged(final DocumentEvent e) {
- if (fWidgetCommand.event == e)
- updateTextListeners(fWidgetCommand);
- fLastSentSelectionChange= null;
- }
- }
-
-
- /**
- * Internal verify listener.
- */
- class TextVerifyListener implements VerifyListener {
-
- /**
- * Indicates whether verify events are forwarded or ignored.
- * @since 2.0
- */
- private boolean fForward= true;
-
- /**
- * Tells the listener to forward received events.
- *
- * @param forward <code>true</code> if forwarding should be enabled.
- * @since 2.0
- */
- public void forward(boolean forward) {
- fForward= forward;
- }
-
- /*
- * @see VerifyListener#verifyText(VerifyEvent)
- */
- public void verifyText(VerifyEvent e) {
- if (fForward)
- handleVerifyEvent(e);
- }
- }
-
- /**
- * The viewer's manager responsible for registered verify key listeners.
- * Uses batches rather than robust iterators because of performance issues.
- * <p>
- * The implementation is reentrant, i.e. installed listeners may trigger
- * further <code>VerifyKeyEvent</code>s that may cause other listeners to be
- * installed, but not thread safe.
- * </p>
- * @since 2.0
- */
- class VerifyKeyListenersManager implements VerifyKeyListener {
-
- /**
- * Represents a batched addListener/removeListener command.
- */
- class Batch {
- /** The index at which to insert the listener. */
- int index;
- /** The listener to be inserted. */
- VerifyKeyListener listener;
-
- /**
- * Creates a new batch containing the given listener for the given index.
- *
- * @param l the listener to be added
- * @param i the index at which to insert the listener
- */
- public Batch(VerifyKeyListener l, int i) {
- listener= l;
- index= i;
- }
- }
-
- /** List of registered verify key listeners. */
- private List fListeners= new ArrayList();
- /** List of pending batches. */
- private List fBatched= new ArrayList();
- /** The reentrance count. */
- private int fReentranceCount= 0;
-
- /*
- * @see VerifyKeyListener#verifyKey(VerifyEvent)
- */
- public void verifyKey(VerifyEvent event) {
- if (fListeners.isEmpty())
- return;
-
- try {
- fReentranceCount++;
- Iterator iterator= fListeners.iterator();
- while (iterator.hasNext() && event.doit) {
- VerifyKeyListener listener= (VerifyKeyListener) iterator.next();
- listener.verifyKey(event); // we might trigger reentrant calls on GTK
- }
- } finally {
- fReentranceCount--;
- }
- if (fReentranceCount == 0)
- processBatchedRequests();
- }
-
- /**
- * Processes the pending batched requests.
- */
- private void processBatchedRequests() {
- if (!fBatched.isEmpty()) {
- Iterator e= fBatched.iterator();
- while (e.hasNext()) {
- Batch batch= (Batch) e.next();
- insertListener(batch.listener, batch.index);
- }
- fBatched.clear();
- }
- }
-
- /**
- * Returns the number of registered verify key listeners.
- *
- * @return the number of registered verify key listeners
- */
- public int numberOfListeners() {
- return fListeners.size();
- }
-
- /**
- * Inserts the given listener at the given index or moves it
- * to that index.
- *
- * @param listener the listener to be inserted
- * @param index the index of the listener or -1 for remove
- */
- public void insertListener(VerifyKeyListener listener, int index) {
-
- if (index == -1) {
- removeListener(listener);
- } else if (listener != null) {
-
- if (fReentranceCount > 0) {
-
- fBatched.add(new Batch(listener, index));
-
- } else {
-
- int idx= -1;
-
- // find index based on identity
- int size= fListeners.size();
- for (int i= 0; i < size; i++) {
- if (listener == fListeners.get(i)) {
- idx= i;
- break;
- }
- }
-
- // move or add it
- if (idx != index) {
-
- if (idx != -1)
- fListeners.remove(idx);
-
- if (index > fListeners.size())
- fListeners.add(listener);
- else
- fListeners.add(index, listener);
- }
-
- if (size == 0) // checking old size, i.e. current size == size + 1
- install();
- }
- }
- }
-
- /**
- * Removes the given listener.
- *
- * @param listener the listener to be removed
- */
- public void removeListener(VerifyKeyListener listener) {
- if (listener == null)
- return;
-
- if (fReentranceCount > 0) {
-
- fBatched.add(new Batch(listener, -1));
-
- } else {
-
- int size= fListeners.size();
- for (int i= 0; i < size; i++) {
- if (listener == fListeners.get(i)) {
- fListeners.remove(i);
- if (size == 1) // checking old size, i.e. current size == size - 1
- uninstall();
- return;
- }
- }
- }
- }
-
- /**
- * Installs this manager.
- */
- private void install() {
- StyledText textWidget= getTextWidget();
- if (textWidget != null && !textWidget.isDisposed())
- textWidget.addVerifyKeyListener(this);
- }
-
- /**
- * Uninstalls this manager.
- */
- private void uninstall() {
- StyledText textWidget= getTextWidget();
- if (textWidget != null && !textWidget.isDisposed())
- textWidget.removeVerifyKeyListener(this);
- }
- }
-
-
- /**
- * Reification of a range in which a find replace operation is performed. This range is visually
- * highlighted in the viewer as long as the replace operation is in progress.
- *
- * @since 2.0
- */
- class FindReplaceRange implements LineBackgroundListener, ITextListener, IPositionUpdater {
-
- /** Internal name for the position category used to update the range. */
- private final static String RANGE_CATEGORY= "org.eclipse.jface.text.TextViewer.find.range"; //$NON-NLS-1$
-
- /** The highlight color of this range. */
- private Color fHighlightColor;
- /** The position used to lively update this range's extent. */
- private Position fPosition;
-
- /** Creates a new find/replace range with the given extent.
- *
- * @param range the extent of this range
- */
- public FindReplaceRange(IRegion range) {
- setRange(range);
- }
-
- /**
- * Sets the extent of this range.
- *
- * @param range the extent of this range
- */
- public void setRange(IRegion range) {
- fPosition= new Position(range.getOffset(), range.getLength());
- }
-
- /**
- * Returns the extent of this range.
- *
- * @return the extent of this range
- */
- public IRegion getRange() {
- return new Region(fPosition.getOffset(), fPosition.getLength());
- }
-
- /**
- * Sets the highlight color of this range. Causes the range to be redrawn.
- *
- * @param color the highlight color
- */
- public void setHighlightColor(Color color) {
- fHighlightColor= color;
- paint();
- }
-
- /*
- * @see LineBackgroundListener#lineGetBackground(LineBackgroundEvent)
- * @since 2.0
- */
- public void lineGetBackground(LineBackgroundEvent event) {
- /* Don't use cached line information because of patched redrawing events. */
-
- if (fTextWidget != null) {
- int offset= widgetOffset2ModelOffset(event.lineOffset);
- if (fPosition.includes(offset))
- event.lineBackground= fHighlightColor;
- }
- }
-
- /**
- * Installs this range. The range registers itself as background
- * line painter and text listener. Also, it creates a category with the
- * viewer's document to maintain its own extent.
- */
- public void install() {
- TextViewer.this.addTextListener(this);
- fTextWidget.addLineBackgroundListener(this);
-
- IDocument document= TextViewer.this.getDocument();
- try {
- document.addPositionCategory(RANGE_CATEGORY);
- document.addPosition(RANGE_CATEGORY, fPosition);
- document.addPositionUpdater(this);
- } catch (BadPositionCategoryException e) {
- // should not happen
- } catch (BadLocationException e) {
- // should not happen
- }
-
- paint();
- }
-
- /**
- * Uninstalls this range.
- * @see #install()
- */
- public void uninstall() {
-
- // http://bugs.eclipse.org/bugs/show_bug.cgi?id=19612
-
- IDocument document= TextViewer.this.getDocument();
- if (document != null) {
- document.removePositionUpdater(this);
- document.removePosition(fPosition);
- }
-
- if (fTextWidget != null && !fTextWidget.isDisposed())
- fTextWidget.removeLineBackgroundListener(this);
-
- TextViewer.this.removeTextListener(this);
-
- clear();
- }
-
- /**
- * Clears the highlighting of this range.
- */
- private void clear() {
- if (fTextWidget != null && !fTextWidget.isDisposed())
- fTextWidget.redraw();
- }
-
- /**
- * Paints the highlighting of this range.
- */
- private void paint() {
-
- IRegion widgetRegion= modelRange2WidgetRange(fPosition);
- int offset= widgetRegion.getOffset();
- int length= widgetRegion.getLength();
-
- int count= fTextWidget.getCharCount();
- if (offset + length >= count) {
- length= count - offset; // clip
-
- Point upperLeft= fTextWidget.getLocationAtOffset(offset);
- Point lowerRight= fTextWidget.getLocationAtOffset(offset + length);
- int width= fTextWidget.getClientArea().width;
- int height= fTextWidget.getLineHeight() + lowerRight.y - upperLeft.y;
- fTextWidget.redraw(upperLeft.x, upperLeft.y, width, height, false);
- }
-
- fTextWidget.redrawRange(offset, length, true);
- }
-
- /*
- * @see ITextListener#textChanged(TextEvent)
- * @since 2.0
- */
- public void textChanged(TextEvent event) {
- if (event.getViewerRedrawState())
- paint();
- }
-
- /*
- * @see IPositionUpdater#update(DocumentEvent)
- * @since 2.0
- */
- public void update(DocumentEvent event) {
- int offset= event.getOffset();
- int length= event.getLength();
- int delta= event.getText().length() - length;
-
- if (offset < fPosition.getOffset())
- fPosition.setOffset(fPosition.getOffset() + delta);
- else if (offset < fPosition.getOffset() + fPosition.getLength())
- fPosition.setLength(fPosition.getLength() + delta);
- }
- }
-
- /**
- * This viewer's find/replace target.
- */
- class FindReplaceTarget implements IFindReplaceTarget, IFindReplaceTargetExtension, IFindReplaceTargetExtension3 {
-
- /** The range for this target. */
- private FindReplaceRange fRange;
- /** The highlight color of the range of this target. */
- private Color fScopeHighlightColor;
- /** The document partitioner remembered in case of a "Replace All". */
- private Map fRememberedPartitioners;
-
- /**
- * Resets the find/replace document adapter.
- *
- * @since 3.0
- */
- void resetFindRepalceDocumentAdapter() {
- fFindRepalceDocumentAdapter= new FindReplaceDocumentAdapter(TextViewer.this.getVisibleDocument());
- }
-
- /*
- * @see IFindReplaceTarget#getSelectionText()
- */
- public String getSelectionText() {
- Point s= TextViewer.this.getSelectedRange();
- if (s.x > -1 && s.y > -1) {
- try {
- IDocument document= TextViewer.this.getDocument();
- return document.get(s.x, s.y);
- } catch (BadLocationException x) {
- }
- }
- return null;
- }
-
- /*
- * @see IFindReplaceTarget#replaceSelection(String)
- */
- public void replaceSelection(String text) {
- replaceSelection(text, false);
- }
-
- /*
- * @see IFindReplaceTarget#replaceSelection(String)
- */
- public void replaceSelection(String text, boolean regExReplace) {
- Point s= TextViewer.this.getSelectedRange();
- if (s.x > -1 && s.y > -1) {
- try {
- IRegion matchRegion= TextViewer.this.getFindRepalceDocumentAdapter().replace(text, regExReplace);
- int length= -1;
- if (matchRegion != null)
- length= matchRegion.getLength();
-
- if (text != null && length > 0)
- TextViewer.this.setSelectedRange(s.x, length);
- } catch (BadLocationException x) {
- }
- }
- }
-
- /*
- * @see IFindReplaceTarget#isEditable()
- */
- public boolean isEditable() {
- return TextViewer.this.isEditable();
- }
-
- /*
- * @see IFindReplaceTarget#getSelection()
- */
- public Point getSelection() {
- Point point= TextViewer.this.getSelectedRange();
- return modelSelection2WidgetSelection(point);
- }
-
- /*
- * @see IFindReplaceTarget#findAndSelect(int, String, boolean, boolean, boolean)
- */
- public int findAndSelect(int offset, String findString, boolean searchForward, boolean caseSensitive, boolean wholeWord) {
- try {
- return findAndSelect(offset, findString, searchForward, caseSensitive, wholeWord, false);
- } catch (PatternSyntaxException ex) {
- return -1;
- }
- }
-
- /*
- * @see IFindReplaceTarget#findAndSelect(int, String, boolean, boolean, boolean)
- */
- public int findAndSelect(int offset, String findString, boolean searchForward, boolean caseSensitive, boolean wholeWord, boolean regExSearch) {
-
- int modelOffset= offset == -1 ? -1 : widgetOffset2ModelOffset(offset);
-
- if (fRange != null) {
- IRegion range= fRange.getRange();
- modelOffset= TextViewer.this.findAndSelectInRange(modelOffset, findString, searchForward, caseSensitive, wholeWord, range.getOffset(), range.getLength(), regExSearch);
- } else {
- modelOffset= TextViewer.this.findAndSelect(modelOffset, findString, searchForward, caseSensitive, wholeWord, regExSearch);
- }
-
- offset= modelOffset == -1 ? -1 : modelOffset2WidgetOffset(modelOffset);
- return offset;
- }
-
- /*
- * @see IFindReplaceTarget#canPerformFind()
- */
- public boolean canPerformFind() {
- return TextViewer.this.canPerformFind();
- }
-
- /*
- * @see IFindReplaceTargetExtension#beginSession()
- * @since 2.0
- */
- public void beginSession() {
- fRange= null;
- }
-
- /*
- * @see IFindReplaceTargetExtension#endSession()
- * @since 2.0
- */
- public void endSession() {
- if (fRange != null) {
- fRange.uninstall();
- fRange= null;
- }
- }
-
- /*
- * @see IFindReplaceTargetExtension#getScope()
- * @since 2.0
- */
- public IRegion getScope() {
- return fRange == null ? null : fRange.getRange();
- }
-
- /*
- * @see IFindReplaceTargetExtension#getLineSelection()
- * @since 2.0
- */
- public Point getLineSelection() {
- Point point= TextViewer.this.getSelectedRange();
-
- try {
- IDocument document= TextViewer.this.getDocument();
-
- // beginning of line
- int line= document.getLineOfOffset(point.x);
- int offset= document.getLineOffset(line);
-
- // end of line
- IRegion lastLineInfo= document.getLineInformationOfOffset(point.x + point.y);
- int lastLine= document.getLineOfOffset(point.x + point.y);
- int length;
- if (lastLineInfo.getOffset() == point.x + point.y && lastLine > 0)
- length= document.getLineOffset(lastLine - 1) + document.getLineLength(lastLine - 1) - offset;
- else
- length= lastLineInfo.getOffset() + lastLineInfo.getLength() - offset;
-
- return new Point(offset, length);
-
- } catch (BadLocationException e) {
- // should not happen
- return new Point(point.x, 0);
- }
- }
-
- /*
- * @see IFindReplaceTargetExtension#setSelection(int, int)
- * @since 2.0
- */
- public void setSelection(int modelOffset, int modelLength) {
- TextViewer.this.setSelectedRange(modelOffset, modelLength);
- }
-
- /*
- * @see IFindReplaceTargetExtension#setScope(IRegion)
- * @since 2.0
- */
- public void setScope(IRegion scope) {
- if (fRange != null)
- fRange.uninstall();
-
- if (scope == null) {
- fRange= null;
- return;
- }
-
- fRange= new FindReplaceRange(scope);
- fRange.setHighlightColor(fScopeHighlightColor);
- fRange.install();
- }
-
- /*
- * @see IFindReplaceTargetExtension#setScopeHighlightColor(Color)
- * @since 2.0
- */
- public void setScopeHighlightColor(Color color) {
- if (fRange != null)
- fRange.setHighlightColor(color);
- fScopeHighlightColor= color;
- }
-
- /*
- * @see IFindReplaceTargetExtension#setReplaceAllMode(boolean)
- * @since 2.0
- */
- public void setReplaceAllMode(boolean replaceAll) {
-
- // http://bugs.eclipse.org/bugs/show_bug.cgi?id=18232
-
- if (replaceAll) {
-
- TextViewer.this.setRedraw(false);
- TextViewer.this.startSequentialRewriteMode(false);
-
- if (fUndoManager != null)
- fUndoManager.beginCompoundChange();
-
- IDocument document= TextViewer.this.getDocument();
- fRememberedPartitioners= TextUtilities.removeDocumentPartitioners(document);
-
- } else {
-
- TextViewer.this.setRedraw(true);
- TextViewer.this.stopSequentialRewriteMode();
-
- if (fUndoManager != null)
- fUndoManager.endCompoundChange();
-
- if (fRememberedPartitioners != null) {
- IDocument document= TextViewer.this.getDocument();
- TextUtilities.addDocumentPartitioners(document, fRememberedPartitioners);
- }
- }
- }
- }
-
-
- /**
- * The viewer's rewrite target.
- * @since 2.0
- */
- class RewriteTarget implements IRewriteTarget {
-
- /*
- * @see org.eclipse.jface.text.IRewriteTarget#beginCompoundChange()
- */
- public void beginCompoundChange() {
- if (fUndoManager != null)
- fUndoManager.beginCompoundChange();
- }
-
- /*
- * @see org.eclipse.jface.text.IRewriteTarget#endCompoundChange()
- */
- public void endCompoundChange() {
- if (fUndoManager != null)
- fUndoManager.endCompoundChange();
- }
-
- /*
- * @see org.eclipse.jface.text.IRewriteTarget#getDocument()
- */
- public IDocument getDocument() {
- return TextViewer.this.getDocument();
- }
-
- /*
- * @see org.eclipse.jface.text.IRewriteTarget#setRedraw(boolean)
- */
- public void setRedraw(boolean redraw) {
- TextViewer.this.setRedraw(redraw);
- }
- }
-
- /**
- * Value object used as key in the text hover configuration table. It is
- * modifiable only inside this compilation unit to allow the reuse of created
- * objects for efficiency reasons
- *
- * @since 2.1
- */
- protected class TextHoverKey {
-
- /** The content type this key belongs to */
- private String fContentType;
- /** The state mask */
- private int fStateMask;
-
- /**
- * Creates a new text hover key for the given content type and state mask.
- *
- * @param contentType the content type
- * @param stateMask the state mask
- */
- protected TextHoverKey(String contentType, int stateMask) {
- Assert.isNotNull(contentType);
- fContentType= contentType;
- fStateMask= stateMask;
- }
-
- /*
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object obj) {
- if (obj == null || obj.getClass() != getClass())
- return false;
- TextHoverKey textHoverKey= (TextHoverKey)obj;
- return textHoverKey.fContentType.equals(fContentType) && textHoverKey.fStateMask == fStateMask;
- }
-
- /*
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- return fStateMask << 16 | fContentType.hashCode();
- }
-
- /**
- * Sets the state mask of this text hover key.
- *
- * @param stateMask the state mask
- */
- private void setStateMask(int stateMask) {
- fStateMask= stateMask;
- }
- }
-
- /**
- * A position reflecting a viewer selection and the selection anchor.
- * The anchor is represented by the caret.
- *
- * @since 2.1
- */
- static class SelectionPosition extends Position {
-
- /** The flag indicating the anchor of this selection */
- private boolean reverse;
-
- /**
- * Creates a new selection position for the specified selection.
- *
- * @param point the specified selection
- */
- public SelectionPosition(Point point) {
- super();
- reverse= point.y < 0;
- if (reverse) {
- offset= point.x + point.y;
- length= -point.y;
- } else {
- offset= point.x;
- length= point.y;
- }
- }
-
- /**
- * Returns the selection in a format where the selection length
- * is always non-negative.
- *
- * @return the normalized selection
- */
- public Point getNormalizedSelection() {
- return new Point(offset, length);
- }
-
- /**
- * Returns the selection reflecting its anchor.
- *
- * @return the selection reflecting the selection anchor.
- */
- public Point getSelection() {
- return reverse ? new Point(offset - length, -length) : new Point(offset, length);
- }
- }
-
- /**
- * Internal cursor listener i.e. aggregation of mouse and key listener.
- *
- * @since 3.0
- */
- private class CursorListener implements KeyListener, MouseListener {
-
- /**
- * Installs this cursor listener.
- */
- private void install() {
- if (fTextWidget != null && !fTextWidget.isDisposed()) {
- fTextWidget.addKeyListener(this);
- fTextWidget.addMouseListener(this);
- }
- }
-
- /**
- * Uninstalls this cursor listener.
- */
- private void uninstall() {
- if (fTextWidget != null && !fTextWidget.isDisposed()) {
- fTextWidget.removeKeyListener(this);
- fTextWidget.removeMouseListener(this);
- }
- }
-
- /*
- * @see KeyListener#keyPressed(org.eclipse.swt.events.KeyEvent)
- */
- public void keyPressed(KeyEvent event) {
- }
-
- /*
- * @see KeyListener#keyPressed(org.eclipse.swt.events.KeyEvent)
- */
- public void keyReleased(KeyEvent e) {
- if (fTextWidget.getSelectionCount() == 0)
- queuePostSelectionChanged();
- }
-
- /*
- * @see MouseListener#mouseDoubleClick(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseDoubleClick(MouseEvent e) {
- }
-
- /*
- * @see MouseListener#mouseDown(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseDown(MouseEvent e) {
- }
-
- /*
- * @see MouseListener#mouseUp(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseUp(MouseEvent event) {
- if (fTextWidget.getSelectionCount() == 0)
- queuePostSelectionChanged();
- }
- }
-
- /**
- * Identifies the scrollbars as originators of a view port change.
- */
- protected static final int SCROLLER= 1;
- /**
- * Identifies mouse moves as originators of a view port change.
- */
- protected static final int MOUSE= 2;
- /**
- * Identifies mouse button up as originator of a view port change.
- */
- protected static final int MOUSE_END= 3;
- /**
- * Identifies key strokes as originators of a view port change.
- */
- protected static final int KEY= 4;
- /**
- * Identifies window resizing as originator of a view port change.
- */
- protected static final int RESIZE= 5;
- /**
- * Identifies internal reasons as originators of a view port change.
- */
- protected static final int INTERNAL= 6;
-
- /** Internal name of the position category used selection preservation during shift. */
- protected static final String SHIFTING= "__TextViewer_shifting"; //$NON-NLS-1$
-
- /** The viewer's text widget */
- private StyledText fTextWidget;
- /** The viewer's input document */
- private IDocument fDocument;
- /** The viewer's visible document */
- private IDocument fVisibleDocument;
- /** The viewer's document adapter */
- private IDocumentAdapter fDocumentAdapter;
- /** The slave document manager */
- private ISlaveDocumentManager fSlaveDocumentManager;
- /** The text viewer's double click strategies connector */
- private TextDoubleClickStrategyConnector fDoubleClickStrategyConnector;
- /**
- * The text viewer's hovering controller
- * @since 2.0
- */
- private TextViewerHoverManager fTextHoverManager;
- /** The text viewer's view port guard */
- private ViewportGuard fViewportGuard;
- /** Caches the graphical coordinate of the first visible line */
- private int fTopInset= 0;
- /** The most recent document modification as widget command */
- private WidgetCommand fWidgetCommand= new WidgetCommand();
- /** The SWT control's scrollbars */
- private ScrollBar fScroller;
- /** Document listener */
- private DocumentListener fDocumentListener= new DocumentListener();
- /** Verify listener */
- private TextVerifyListener fVerifyListener= new TextVerifyListener();
- /** The most recent widget modification as document command */
- private DocumentCommand fDocumentCommand= new DocumentCommand();
- /** The viewer's find/replace target */
- private IFindReplaceTarget fFindReplaceTarget;
- /**
- * The viewer widget token keeper
- * @since 2.0
- */
- private IWidgetTokenKeeper fWidgetTokenKeeper;
- /**
- * The viewer's manager of verify key listeners
- * @since 2.0
- */
- private VerifyKeyListenersManager fVerifyKeyListenersManager= new VerifyKeyListenersManager();
- /**
- * The mark position.
- * @since 2.0
- */
- private Position fMarkPosition;
- /**
- * The mark position category.
- * @since 2.0
- */
- private final String MARK_POSITION_CATEGORY="__mark_category_" + hashCode(); //$NON-NLS-1$
- /**
- * The mark position updater
- * @since 2.0
- */
- private final IPositionUpdater fMarkPositionUpdater= new DefaultPositionUpdater(MARK_POSITION_CATEGORY);
- /**
- * The flag indicating the redraw behavior
- * @since 2.0
- */
- private int fRedrawCounter= 0;
- /**
- * The selection when working in non-redraw state
- * @since 2.0
- */
- private SelectionPosition fDocumentSelection;
- /**
- * The viewer's rewrite target
- * @since 2.0
- */
- private IRewriteTarget fRewriteTarget;
- /**
- * The viewer's cursor listener.
- * @since 3.0
- */
- private CursorListener fCursorListener;
- /**
- * Last selection range sent to selection change listeners.
- * @since 3.0
- */
- private IRegion fLastSentSelectionChange;
- /**
- * The registered post selection changed listeners.
- * @since 3.0
- */
- private List fPostSelectionChangedListeners;
- /**
- * Queued post selection changed events count.
- * @since 3.0
- */
- private final int[] fNumberOfPostSelectionChangedEvents= new int[1];
- /**
- * Last selection range sent to post selection change listeners.
- * @since 3.0
- */
- private IRegion fLastSentPostSelectionChange;
-
- /**
- * The find/replace document adapter.
- *
- * @since 3.0
- */
- private FindReplaceDocumentAdapter fFindRepalceDocumentAdapter;
-
- /** Should the auto indent strategies ignore the next edit operation */
- protected boolean fIgnoreAutoIndent= false;
- /** The strings a line is prefixed with on SHIFT_RIGHT and removed from each line on SHIFT_LEFT */
- protected Map fIndentChars;
- /** The string a line is prefixed with on PREFIX and removed from each line on STRIP_PREFIX */
- protected Map fDefaultPrefixChars;
- /** The text viewer's text double click strategies */
- protected Map fDoubleClickStrategies;
- /** The text viewer's undo manager */
- protected IUndoManager fUndoManager;
- /** The text viewer's auto indent strategies */
- protected Map fAutoIndentStrategies;
- /** The text viewer's text hovers */
- protected Map fTextHovers;
- /**
- * The creator of the text hover control
- * @since 2.0
- */
- protected IInformationControlCreator fHoverControlCreator;
- /** All registered view port listeners> */
- protected List fViewportListeners;
- /** The last visible vertical position of the top line */
- protected int fLastTopPixel;
- /** All registered text listeners */
- protected List fTextListeners;
- /** All registered text input listeners */
- protected List fTextInputListeners;
- /** The text viewer's event consumer */
- protected IEventConsumer fEventConsumer;
- /** Indicates whether the viewer's text presentation should be replaced are modified. */
- protected boolean fReplaceTextPresentation= false;
- /**
- * The mapping between model and visible document.
- * @since 2.1
- */
- protected IDocumentInformationMapping fInformationMapping;
- /**
- * The viewer's paint manager;
- * @since 2.1
- */
- protected PaintManager fPaintManager;
- /**
- * The viewers partitioning, i.e. the partitioning name the viewer uses to access partitioning information of its input document.
- * @since 3.0
- */
- protected String fPartitioning;
- /**
- * All registered text presentation listeners.
- * since 3.0
- */
- protected List fTextPresentationListeners;
-
-
-
- //---- Construction and disposal ------------------
-
-
- /**
- * Internal use only
- */
- protected TextViewer() {
- }
-
- /**
- * Create a new text viewer with the given SWT style bits.
- * The viewer is ready to use but does not have any plug-in installed.
- *
- * @param parent the parent of the viewer's control
- * @param styles the SWT style bits for the viewer's control
- */
- public TextViewer(Composite parent, int styles) {
- createControl(parent, styles);
- }
-
- /**
- * Factory method to create the text widget to be used as the viewer's text widget.
- *
- * @return the text widget to be used
- */
- protected StyledText createTextWidget(Composite parent, int styles) {
- return new StyledText(parent, styles);
- }
-
- /**
- * Factory method to create the document adapter to be used by this viewer.
- *
- * @return the document adapter to be used
- */
- protected IDocumentAdapter createDocumentAdapter() {
- return new DocumentAdapter();
- }
-
- /**
- * Creates the viewer's SWT control. The viewer's text widget either is
- * the control or is a child of the control.
- *
- * @param parent the parent of the viewer's control
- * @param styles the SWT style bits for the viewer's control
- */
- protected void createControl(Composite parent, int styles) {
-
- fTextWidget= createTextWidget(parent, styles);
- fTextWidget.addDisposeListener(
- new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- setDocument(null);
- handleDispose();
- fTextWidget= null;
- }
- }
- );
-
- fTextWidget.setFont(parent.getFont());
- fTextWidget.setDoubleClickEnabled(false);
-
- /*
- * Disable SWT Shift+TAB traversal in this viewer
- * 1GIYQ9K: ITPUI:WINNT - StyledText swallows Shift+TAB
- */
- fTextWidget.addTraverseListener(new TraverseListener() {
- public void keyTraversed(TraverseEvent e) {
- if ((SWT.SHIFT == e.stateMask) && ('\t' == e.character))
- e.doit = false;
- }
- });
-
- // where does the first line start
- fTopInset= -fTextWidget.computeTrim(0, 0, 0, 0).y;
-
- fVerifyListener.forward(true);
- fTextWidget.addVerifyListener(fVerifyListener);
-
- fTextWidget.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent event) {
- selectionChanged(event.x, event.y - event.x);
- }
- public void widgetSelected(SelectionEvent event) {
- selectionChanged(event.x, event.y - event.x);
- }
- });
-
- fCursorListener= new CursorListener();
- fCursorListener.install();
-
- initializeViewportUpdate();
- }
-
- /*
- * @see Viewer#getControl()
- */
- public Control getControl() {
- return fTextWidget;
- }
-
- /*
- * @see ITextViewer#activatePlugins()
- */
- public void activatePlugins() {
-
- if (fDoubleClickStrategies != null && !fDoubleClickStrategies.isEmpty() && fDoubleClickStrategyConnector == null) {
- fDoubleClickStrategyConnector= new TextDoubleClickStrategyConnector();
- fTextWidget.addMouseListener(fDoubleClickStrategyConnector);
- }
-
- ensureHoverControlManagerInstalled();
-
- if (fUndoManager != null) {
- fUndoManager.connect(this);
- fUndoManager.reset();
- }
- }
-
- /**
- * After this method has been executed the caller knows that any installed text hover has been installed.
- */
- private void ensureHoverControlManagerInstalled() {
- if (fTextHovers != null && !fTextHovers.isEmpty() && fHoverControlCreator != null && fTextHoverManager == null) {
- fTextHoverManager= new TextViewerHoverManager(this, fHoverControlCreator);
- fTextHoverManager.install(this.getTextWidget());
- fTextHoverManager.setSizeConstraints(60, 10, false, true);
- }
- }
-
- /*
- * @see ITextViewer#resetPlugins()
- */
- public void resetPlugins() {
- if (fUndoManager != null)
- fUndoManager.reset();
- }
-
- /**
- * Frees all resources allocated by this viewer. Internally called when the viewer's
- * control has been disposed.
- */
- protected void handleDispose() {
-
- if (fPaintManager != null) {
- fPaintManager.dispose();
- fPaintManager= null;
- }
-
- removeViewPortUpdate();
- fViewportGuard= null;
-
- if (fViewportListeners != null) {
- fViewportListeners.clear();
- fViewportListeners= null;
- }
-
- if (fTextListeners != null) {
- fTextListeners.clear();
- fTextListeners= null;
- }
-
- if (fTextInputListeners != null) {
- fTextInputListeners.clear();
- fTextInputListeners= null;
- }
-
- if (fPostSelectionChangedListeners != null) {
- fPostSelectionChangedListeners.clear();
- fPostSelectionChangedListeners= null;
- }
-
- if (fAutoIndentStrategies != null) {
- fAutoIndentStrategies.clear();
- fAutoIndentStrategies= null;
- }
-
- if (fUndoManager != null) {
- fUndoManager.disconnect();
- fUndoManager= null;
- }
-
- if (fDoubleClickStrategies != null) {
- fDoubleClickStrategies.clear();
- fDoubleClickStrategies= null;
- }
-
- if (fTextHovers != null) {
- fTextHovers.clear();
- fTextHovers= null;
- }
-
- fDoubleClickStrategyConnector= null;
-
- if (fTextHoverManager != null) {
- fTextHoverManager.dispose();
- fTextHoverManager= null;
- }
-
- if (fDocumentListener !=null) {
- if (fVisibleDocument != null)
- fVisibleDocument.removeDocumentListener(fDocumentListener);
- fDocumentListener= null;
- }
-
- if (fDocumentAdapter != null) {
- fDocumentAdapter.setDocument(null);
- fDocumentAdapter= null;
- }
-
- if (fSlaveDocumentManager != null) {
- if (fVisibleDocument != null)
- fSlaveDocumentManager.freeSlaveDocument(fVisibleDocument);
- fSlaveDocumentManager= null;
- }
-
- if (fCursorListener != null) {
- fCursorListener.uninstall();
- fCursorListener= null;
- }
-
- fVisibleDocument= null;
- fDocument= null;
- fScroller= null;
- }
-
-
- //---- simple getters and setters
-
- /**
- * Returns viewer's text widget.
- */
- public StyledText getTextWidget() {
- return fTextWidget;
- }
-
- /**
- * The delay in milliseconds before an empty selection
- * changed event is sent by the cursor listener.
- * <p>
- * Note: The return value is used to initialize the cursor
- * listener. To return a non-constant value has no effect.
- * <p>
- * The same value (<code>500</code>) is used in the <code>OpenStrategy</code>.
- * </p>
- * @see CursorListener
- * @see org.eclipse.jface.util.OpenStrategy#TIME
- * @since 3.0
- */
- protected int getEmptySelectionChangedEventDelay() {
- return 500;
- }
-
- /*
- * @see ITextViewer#setAutoIndentStrategy(IAutoIndentStrategy, String)
- */
- public void setAutoIndentStrategy(IAutoIndentStrategy strategy, String contentType) {
-
- if (fAutoIndentStrategies == null)
- fAutoIndentStrategies= new HashMap();
-
- List autoEditStrategies= (List) fAutoIndentStrategies.get(contentType);
-
- if (strategy == null) {
- if (autoEditStrategies == null)
- return;
-
- fAutoIndentStrategies.put(contentType, null);
-
- } else {
- if (autoEditStrategies == null) {
- autoEditStrategies= new ArrayList();
- fAutoIndentStrategies.put(contentType, autoEditStrategies);
- }
-
- autoEditStrategies.clear();
- autoEditStrategies.add(strategy);
- }
- }
-
- /*
- * @see org.eclipse.jface.text.ITextViewerExtension2#prependAutoEditStrategy(org.eclipse.jface.text.IAutoEditStrategy, java.lang.String)
- * @since 2.1
- */
- public void prependAutoEditStrategy(IAutoEditStrategy strategy, String contentType) {
-
- if (strategy == null || contentType == null)
- throw new IllegalArgumentException();
-
- if (fAutoIndentStrategies == null)
- fAutoIndentStrategies= new HashMap();
-
- List autoEditStrategies= (List) fAutoIndentStrategies.get(contentType);
- if (autoEditStrategies == null) {
- autoEditStrategies= new ArrayList();
- fAutoIndentStrategies.put(contentType, autoEditStrategies);
- }
-
- autoEditStrategies.add(0, strategy);
- }
-
- /*
- * @see org.eclipse.jface.text.ITextViewerExtension2#removeAutoEditStrategy(org.eclipse.jface.text.IAutoEditStrategy, java.lang.String)
- * @since 2.1
- */
- public void removeAutoEditStrategy(IAutoEditStrategy strategy, String contentType) {
- if (fAutoIndentStrategies == null)
- return;
-
- List autoEditStrategies= (List) fAutoIndentStrategies.get(contentType);
- if (autoEditStrategies == null)
- return;
-
- for (final Iterator iterator= autoEditStrategies.iterator(); iterator.hasNext(); ) {
- if (iterator.next().equals(strategy)) {
- iterator.remove();
- break;
- }
- }
-
- if (autoEditStrategies.isEmpty())
- fAutoIndentStrategies.put(contentType, null);
- }
-
- /*
- * @see ITextViewer#setEventConsumer(IEventConsumer)
- */
- public void setEventConsumer(IEventConsumer consumer) {
- fEventConsumer= consumer;
- }
-
- /*
- * @see ITextViewer#setIndentPrefixes(String[], String)
- */
- public void setIndentPrefixes(String[] indentPrefixes, String contentType) {
-
- int i= -1;
- boolean ok= (indentPrefixes != null);
- while (ok && ++i < indentPrefixes.length)
- ok= (indentPrefixes[i] != null);
-
- if (ok) {
-
- if (fIndentChars == null)
- fIndentChars= new HashMap();
-
- fIndentChars.put(contentType, indentPrefixes);
-
- } else if (fIndentChars != null)
- fIndentChars.remove(contentType);
- }
-
- /*
- * @see ITextViewer#getTopInset()
- */
- public int getTopInset() {
- return fTopInset;
- }
-
- /*
- * @see ITextViewer#isEditable()
- */
- public boolean isEditable() {
- if (fTextWidget == null)
- return false;
- return fTextWidget.getEditable();
- }
-
- /*
- * @see ITextViewer#setEditable(boolean)
- */
- public void setEditable(boolean editable) {
- if (fTextWidget != null)
- fTextWidget.setEditable(editable);
- }
-
- /*
- * @see ITextViewer#setDefaultPrefixes
- * @since 2.0
- */
- public void setDefaultPrefixes(String[] defaultPrefixes, String contentType) {
-
- if (defaultPrefixes != null && defaultPrefixes.length > 0) {
- if (fDefaultPrefixChars == null)
- fDefaultPrefixChars= new HashMap();
- fDefaultPrefixChars.put(contentType, defaultPrefixes);
- } else if (fDefaultPrefixChars != null)
- fDefaultPrefixChars.remove(contentType);
- }
-
- /*
- * @see ITextViewer#setUndoManager(IUndoManager)
- */
- public void setUndoManager(IUndoManager undoManager) {
- fUndoManager= undoManager;
- }
-
- /*
- * @see ITextViewer#setTextHover(ITextHover, String)
- */
- public void setTextHover(ITextHover hover, String contentType) {
- setTextHover(hover, contentType, ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK);
- }
-
- /*
- * @see ITextViewerExtension2#setTextHover(ITextHover, String, int)
- * @since 2.1
- */
- public void setTextHover(ITextHover hover, String contentType, int stateMask) {
- TextHoverKey key= new TextHoverKey(contentType, stateMask);
- if (hover != null) {
- if (fTextHovers == null) {
- fTextHovers= new HashMap();
- }
- fTextHovers.put(key, hover);
- } else if (fTextHovers != null)
- fTextHovers.remove(key);
-
- ensureHoverControlManagerInstalled();
- }
-
- /*
- * @see ITextViewerExtension2#removeTextHovers(String)
- * @since 2.1
- */
- public void removeTextHovers(String contentType) {
- if (fTextHovers == null)
- return;
-
- Iterator iter= new HashSet(fTextHovers.keySet()).iterator();
- while (iter.hasNext()) {
- TextHoverKey key= (TextHoverKey)iter.next();
- if (key.fContentType.equals(contentType))
- fTextHovers.remove(key);
- }
- }
-
- /**
- * Returns the text hover for a given offset.
- *
- * @param offset the offset for which to return the text hover
- * @return the text hover for the given offset
- */
- protected ITextHover getTextHover(int offset) {
- return getTextHover(offset, ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK);
- }
-
- /**
- * Returns the text hover for a given offset and a given state mask.
- *
- * @param offset the offset for which to return the text hover
- * @param stateMask the SWT event state mask
- * @return the text hover for the given offset and state mask
- * @since 2.1
- */
- protected ITextHover getTextHover(int offset, int stateMask) {
- if (fTextHovers == null)
- return null;
-
- IDocument document= getDocument();
- if (document == null)
- return null;
-
- try {
- TextHoverKey key= new TextHoverKey(TextUtilities.getContentType(document, getDocumentPartitioning(), offset), stateMask);
- Object textHover= fTextHovers.get(key);
- if (textHover == null) {
- // Use default text hover
- key.setStateMask(ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK);
- textHover= fTextHovers.get(key);
- }
- return (ITextHover) textHover;
- } catch (BadLocationException x) {
- if (TRACE_ERRORS)
- System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.selectContentTypePlugin")); //$NON-NLS-1$
- }
- return null;
- }
-
- /**
- * Returns the text hovering controller of this viewer.
- *
- * @return the text hovering controller of this viewer
- * @since 2.0
- */
- protected AbstractInformationControlManager getTextHoveringController() {
- return fTextHoverManager;
- }
-
- /**
- * Sets the creator for the hover controls.
- *
- * @param creator the hover control creator
- * @since 2.0
- */
- public void setHoverControlCreator(IInformationControlCreator creator) {
- fHoverControlCreator= creator;
- }
-
- /*
- * @see IWidgetTokenOwner#requestWidgetToken(IWidgetTokenKeeper)
- * @since 2.0
- */
- public boolean requestWidgetToken(IWidgetTokenKeeper requester) {
- if (fTextWidget != null) {
- if (fWidgetTokenKeeper != null) {
- if (fWidgetTokenKeeper == requester)
- return true;
- if (fWidgetTokenKeeper.requestWidgetToken(this)) {
- fWidgetTokenKeeper= requester;
- return true;
- }
- } else {
- fWidgetTokenKeeper= requester;
- return true;
- }
- }
- return false;
- }
-
- /*
- * @see org.eclipse.jface.text.IWidgetTokenOwnerExtension#requestWidgetToken(org.eclipse.jface.text.IWidgetTokenKeeper, int)
- * @since 3.0
- */
- public boolean requestWidgetToken(IWidgetTokenKeeper requester, int priority) {
- if (fTextWidget != null) {
- if (fWidgetTokenKeeper != null) {
-
- if (fWidgetTokenKeeper == requester)
- return true;
-
- boolean accepted= false;
- if (fWidgetTokenKeeper instanceof IWidgetTokenKeeperExtension) {
- IWidgetTokenKeeperExtension extension= (IWidgetTokenKeeperExtension) fWidgetTokenKeeper;
- accepted= extension.requestWidgetToken(this, priority);
- } else {
- accepted= fWidgetTokenKeeper.requestWidgetToken(this);
- }
-
- if (accepted) {
- fWidgetTokenKeeper= requester;
- return true;
- }
-
- } else {
- fWidgetTokenKeeper= requester;
- return true;
- }
- }
- return false;
- }
-
- /*
- * @see IWidgetTokenOwner#releaseWidgetToken(IWidgetTokenKeeper)
- * @since 2.0
- */
- public void releaseWidgetToken(IWidgetTokenKeeper tokenKeeper) {
- if (fWidgetTokenKeeper == tokenKeeper)
- fWidgetTokenKeeper= null;
- }
-
-
- //---- Selection
-
- /*
- * @see ITextViewer#getSelectedRange()
- */
- public Point getSelectedRange() {
-
- if (!redraws())
- return fDocumentSelection.getNormalizedSelection();
-
- if (fTextWidget != null) {
- Point p= fTextWidget.getSelectionRange();
- return widgetSelection2ModelSelection(p);
- }
-
- return new Point(-1, -1);
- }
-
- /*
- * @see ITextViewer#setSelectedRange(int, int)
- */
- public void setSelectedRange(int selectionOffset, int selectionLength) {
-
- if (!redraws()) {
- if (fDocumentSelection != null) {
- fDocumentSelection.offset= selectionOffset;
- fDocumentSelection.length= selectionLength;
- // http://bugs.eclipse.org/bugs/show_bug.cgi?id=32795
- fDocumentSelection.isDeleted= false;
- }
- return;
- }
-
- if (fTextWidget == null)
- return;
-
- IRegion widgetSelection= modelRange2WidgetRange(new Region(selectionOffset, selectionLength));
- if (widgetSelection != null) {
-
- int[] selectionRange= new int[] { widgetSelection.getOffset(), widgetSelection.getLength() };
- validateSelectionRange(selectionRange);
- if (selectionRange[0] >= 0) {
- fTextWidget.setSelectionRange(selectionRange[0], selectionRange[1]);
- selectionChanged(selectionRange[0], selectionRange[1]);
- }
- }
- }
-
- /**
- * Validates and adapts the given selection range if it is not a valid
- * widget selection. The widget selection is invalid if it starts or ends
- * inside a multi-character line delimiter. If so, the selection is adapted to
- * start <b>after</b> the divided line delimiter and to end <b>before</b>
- * the divided line delimiter. The parameter passed in is changed in-place
- * when being adapted. An adaptation to <code>[-1, -1]</code> indicates
- * that the selection range could not be validated.
- * Subclasses may reimplement this method.
- *
- * @param selectionRange selectionRange[0] is the offset, selectionRange[1]
- * the length of the selection to validate.
- * @since 2.0
- */
- protected void validateSelectionRange(int[] selectionRange) {
-
- IDocument document= getVisibleDocument();
- if (document == null) {
- selectionRange[0]= -1;
- selectionRange[1]= -1;
- return;
- }
-
- int documentLength= document.getLength();
- int offset= selectionRange[0];
- int length= selectionRange[1];
-
- if (length < 0) {
- length= - length;
- offset -= length;
- }
-
- if (offset <0)
- offset= 0;
-
- if (offset > documentLength)
- offset= documentLength;
-
- int delta= (offset + length) - documentLength;
- if (delta > 0)
- length -= delta;
-
- try {
-
- int lineNumber= document.getLineOfOffset(offset);
- IRegion lineInformation= document.getLineInformation(lineNumber);
-
- int lineEnd= lineInformation.getOffset() + lineInformation.getLength();
- delta= offset - lineEnd;
- if (delta > 0) {
- // in the middle of a multi-character line delimiter
- offset= lineEnd;
- String delimiter= document.getLineDelimiter(lineNumber);
- if (delimiter != null)
- offset += delimiter.length();
- }
-
- int end= offset + length;
- lineInformation= document.getLineInformationOfOffset(end);
- lineEnd= lineInformation.getOffset() + lineInformation.getLength();
- delta= end - lineEnd;
- if (delta > 0) {
- // in the middle of a multi-character line delimiter
- length -= delta;
- }
-
- } catch (BadLocationException x) {
- selectionRange[0]= -1;
- selectionRange[1]= -1;
- return;
- }
-
- if (selectionRange[1] < 0) {
- selectionRange[0]= offset + length;
- selectionRange[1]= -length;
- } else {
- selectionRange[0]= offset;
- selectionRange[1]= length;
- }
- }
-
- /*
- * @see Viewer#setSelection(ISelection)
- */
- public void setSelection(ISelection selection, boolean reveal) {
- if (selection instanceof ITextSelection) {
- ITextSelection s= (ITextSelection) selection;
- setSelectedRange(s.getOffset(), s.getLength());
- if (reveal)
- revealRange(s.getOffset(), s.getLength());
- }
- }
-
- /*
- * @see Viewer#getSelection()
- */
- public ISelection getSelection() {
- Point p= getSelectedRange();
- if (p.x == -1 || p.y == -1)
- return TextSelection.emptySelection();
-
- return new TextSelection(getDocument(), p.x, p.y);
- }
-
- /*
- * @see ITextViewer#getSelectionProvider()
- */
- public ISelectionProvider getSelectionProvider() {
- return this;
- }
-
- /*
- * @see org.eclipse.jface.text.IPostSelectionProvider#addPostSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
- * @since 3.0
- */
- public void addPostSelectionChangedListener(ISelectionChangedListener listener) {
-
- Assert.isNotNull(listener);
-
- if (fPostSelectionChangedListeners == null)
- fPostSelectionChangedListeners= new ArrayList();
-
- if (! fPostSelectionChangedListeners.contains(listener))
- fPostSelectionChangedListeners.add(listener);
- }
-
- /*
- * @see org.eclipse.jface.text.IPostSelectionProvider#removePostSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
- * @since 3.0
- */
- public void removePostSelectionChangedListener(ISelectionChangedListener listener) {
-
- Assert.isNotNull(listener);
-
- if (fPostSelectionChangedListeners != null) {
- fPostSelectionChangedListeners.remove(listener);
- if (fPostSelectionChangedListeners.size() == 0)
- fPostSelectionChangedListeners= null;
- }
- }
-
- /**
- * Get the text widget's display.
- *
- * @return the display or <code>null</code> if the display cannot be retrieved or if the display is disposed
- * @since 3.0
- */
- private Display getDisplay() {
- if (fTextWidget == null || fTextWidget.isDisposed())
- return null;
-
- Display display= fTextWidget.getDisplay();
- if (display != null && display.isDisposed())
- return null;
-
- return display;
- }
-
- /**
- * Starts a timer to send out a post selection changed event.
- *
- * @since 3.0
- */
- private void queuePostSelectionChanged() {
- Display display= getDisplay();
- if (display == null)
- return;
-
- fNumberOfPostSelectionChangedEvents[0]++;
- display.timerExec(getEmptySelectionChangedEventDelay(), new Runnable() {
- final int id= fNumberOfPostSelectionChangedEvents[0];
- public void run() {
- if (id == fNumberOfPostSelectionChangedEvents[0]) {
- // Check again because this is executed after the delay
- if (getDisplay() != null) {
- Point selection= fTextWidget.getSelectionRange();
- if (selection != null)
- firePostSelectionChanged(selection.x, selection.y);
- }
- }
- }
- });
- }
-
- /**
- * Sends out a text selection changed event to all registered post selection changed listeners.
- *
- * @param offset the offset of the newly selected range in the visible document
- * @param length the length of the newly selected range in the visible document
- * @since 3.0
- */
- protected void firePostSelectionChanged(int offset, int length) {
- if (redraws()) {
- IRegion r= widgetRange2ModelRange(new Region(offset, length));
- if ((r != null && !r.equals(fLastSentPostSelectionChange)) || r == null) {
- fLastSentPostSelectionChange= r;
- ISelection selection= r != null ? new TextSelection(getDocument(), r.getOffset(), r.getLength()) : TextSelection.emptySelection();
- SelectionChangedEvent event= new SelectionChangedEvent(this, selection);
- firePostSelectionChanged(event);
- }
- }
- }
-
- /**
- * Sends out a text selection changed event to all registered listeners and
- * registers the selection changed event to be send out to all post selection
- * listeners.
- *
- * @param offset the offset of the newly selected range in the visible document
- * @param length the length of the newly selected range in the visible document
- */
- protected void selectionChanged(int offset, int length) {
- queuePostSelectionChanged();
- fireSelectionChanged(offset, length);
- }
-
- /**
- * Sends out a text selection changed event to all registered listeners.
- *
- * @param offset the offset of the newly selected range in the visible document
- * @param length the length of the newly selected range in the visible document
- * @since 3.0
- */
- protected void fireSelectionChanged(int offset, int length) {
- if (redraws()) {
- IRegion r= widgetRange2ModelRange(new Region(offset, length));
- if ((r != null && !r.equals(fLastSentSelectionChange)) || r == null) {
- fLastSentSelectionChange= r;
- ISelection selection= r != null ? new TextSelection(getDocument(), r.getOffset(), r.getLength()) : TextSelection.emptySelection();
- SelectionChangedEvent event= new SelectionChangedEvent(this, selection);
- fireSelectionChanged(event);
- }
- }
- }
-
- /**
- * Sends the given event to all registered post selection changed listeners.
- *
- * @param event the selection event
- * @since 3.0
- */
- private void firePostSelectionChanged(SelectionChangedEvent event) {
- if (fPostSelectionChangedListeners != null) {
- for (int i= 0; i < fPostSelectionChangedListeners.size(); i++) {
- ISelectionChangedListener l= (ISelectionChangedListener) fPostSelectionChangedListeners.get(i);
- l.selectionChanged(event);
- }
- }
- }
-
- /**
- * Sends out a mark selection changed event to all registered listeners.
- *
- * @param offset the offset of the mark selection in the visible document, the offset is <code>-1</code> if the mark was cleared
- * @param length the length of the mark selection, may be negative if the caret is before the mark.
- * @since 2.0
- */
- protected void markChanged(int offset, int length) {
- if (redraws()) {
-
- if (offset != -1) {
- IRegion r= widgetRange2ModelRange(new Region(offset, length));
- offset= r.getOffset();
- length= r.getLength();
- }
-
- ISelection selection= new MarkSelection(getDocument(), offset, length);
- SelectionChangedEvent event= new SelectionChangedEvent(this, selection);
- fireSelectionChanged(event);
- }
- }
-
-
- //---- Text listeners
-
- /*
- * @see ITextViewer#addTextListener(ITextListener)
- */
- public void addTextListener(ITextListener listener) {
-
- Assert.isNotNull(listener);
-
- if (fTextListeners == null)
- fTextListeners= new ArrayList();
-
- if (!fTextListeners.contains(listener))
- fTextListeners.add(listener);
- }
-
- /*
- * @see ITextViewer#removeTextListener(ITextListener)
- */
- public void removeTextListener(ITextListener listener) {
-
- Assert.isNotNull(listener);
-
- if (fTextListeners != null) {
- fTextListeners.remove(listener);
- if (fTextListeners.size() == 0)
- fTextListeners= null;
- }
- }
-
- /**
- * Informs all registered text listeners about the change specified by the
- * widget command. This method does not use a robust iterator.
- *
- * @param cmd the widget command translated into a text event sent to all text listeners
- */
- protected void updateTextListeners(WidgetCommand cmd) {
-
- if (fTextListeners != null) {
-
- DocumentEvent event= cmd.event;
- if (event instanceof SlaveDocumentEvent)
- event= ((SlaveDocumentEvent) event).getMasterEvent();
-
- TextEvent e= new TextEvent(cmd.start, cmd.length, cmd.text, cmd.preservedText, event, redraws());
- for (int i= 0; i < fTextListeners.size(); i++) {
- ITextListener l= (ITextListener) fTextListeners.get(i);
- l.textChanged(e);
- }
- }
- }
-
- //---- Text input listeners
-
- /*
- * @see ITextViewer#addTextInputListener(ITextInputListener)
- */
- public void addTextInputListener(ITextInputListener listener) {
-
- Assert.isNotNull(listener);
-
- if (fTextInputListeners == null)
- fTextInputListeners= new ArrayList();
-
- if (!fTextInputListeners.contains(listener))
- fTextInputListeners.add(listener);
- }
-
- /*
- * @see ITextViewer#removeTextInputListener(ITextInputListener)
- */
- public void removeTextInputListener(ITextInputListener listener) {
-
- Assert.isNotNull(listener);
-
- if (fTextInputListeners != null) {
- fTextInputListeners.remove(listener);
- if (fTextInputListeners.size() == 0)
- fTextInputListeners= null;
- }
- }
-
- /**
- * Informs all registered text input listeners about the forthcoming input change,
- * This method does not use a robust iterator.
- *
- * @param oldInput the old input document
- * @param newInput the new input document
- */
- protected void fireInputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {
- if (fTextInputListeners != null) {
- for (int i= 0; i < fTextInputListeners.size(); i++) {
- ITextInputListener l= (ITextInputListener) fTextInputListeners.get(i);
- l.inputDocumentAboutToBeChanged(oldInput, newInput);
- }
- }
- }
-
- /**
- * Informs all registered text input listeners about the successful input change,
- * This method does not use a robust iterator.
- *
- * @param oldInput the old input document
- * @param newInput the new input document
- */
- protected void fireInputDocumentChanged(IDocument oldInput, IDocument newInput) {
- if (fTextInputListeners != null) {
- for (int i= 0; i < fTextInputListeners.size(); i++) {
- ITextInputListener l= (ITextInputListener) fTextInputListeners.get(i);
- l.inputDocumentChanged(oldInput, newInput);
- }
- }
- }
-
- //---- Document
-
- /*
- * @see Viewer#getInput()
- */
- public Object getInput() {
- return getDocument();
- }
-
- /*
- * @see ITextViewer#getDocument()
- */
- public IDocument getDocument() {
- return fDocument;
- }
-
- /*
- * @see Viewer#setInput(Object)
- */
- public void setInput(Object input) {
-
- IDocument document= null;
- if (input instanceof IDocument)
- document= (IDocument) input;
-
- setDocument(document);
- }
-
- /*
- * @see ITextViewer#setDocument(IDocument)
- */
- public void setDocument(IDocument document) {
-
- fReplaceTextPresentation= true;
- fireInputDocumentAboutToBeChanged(fDocument, document);
-
- IDocument oldDocument= fDocument;
- fDocument= document;
-
- setVisibleDocument(fDocument);
-
- inputChanged(fDocument, oldDocument);
-
- fireInputDocumentChanged(oldDocument, fDocument);
- fLastSentSelectionChange= null;
- fReplaceTextPresentation= false;
- }
-
- /*
- * @see ITextViewer#setDocument(IDocument, int, int)
- */
- public void setDocument(IDocument document, int modelRangeOffset, int modelRangeLength) {
-
- fReplaceTextPresentation= true;
- fireInputDocumentAboutToBeChanged(fDocument, document);
-
- IDocument oldDocument= fDocument;
- fDocument= document;
-
- try {
-
- IDocument slaveDocument= createSlaveDocument(document);
- updateSlaveDocument(slaveDocument, modelRangeOffset, modelRangeLength);
- setVisibleDocument(slaveDocument);
-
- } catch (BadLocationException x) {
- throw new IllegalArgumentException(JFaceTextMessages.getString("TextViewer.error.invalid_visible_region_1")); //$NON-NLS-1$
- }
-
- inputChanged(fDocument, oldDocument);
-
- fireInputDocumentChanged(oldDocument, fDocument);
- fLastSentSelectionChange= null;
- fReplaceTextPresentation= false;
- }
-
- /**
- * Creates a slave document for the given document if there is a slave document manager
- * associated with this viewer.
- *
- * @param document the master document
- * @return the newly created slave document
- * @since 2.1
- */
- protected IDocument createSlaveDocument(IDocument document) {
- ISlaveDocumentManager manager= getSlaveDocumentManager();
- if (manager != null) {
- if (manager.isSlaveDocument(document))
- return document;
- return manager.createSlaveDocument(document);
- }
- return document;
- }
-
- /**
- * Sets the given slave document to the specified range of its master document.
- *
- * @param visibleDocument the slave document
- * @param visibleRegionOffset the offset of the master document range
- * @param visibleRegionLength the length of the master document range
- * @return <code>true</code> if the slave has been adapted successfully
- * @throws BadLocationException in case the specified range is not valid in the master document
- * @since 2.1
- * @deprecated use <code>updateSlaveDocument</code> instead
- */
- protected boolean updateVisibleDocument(IDocument visibleDocument, int visibleRegionOffset, int visibleRegionLength) throws BadLocationException {
- if (visibleDocument instanceof ChildDocument) {
- ChildDocument childDocument= (ChildDocument) visibleDocument;
-
- IDocument document= childDocument.getParentDocument();
- int line= document.getLineOfOffset(visibleRegionOffset);
- int offset= document.getLineOffset(line);
- int length= (visibleRegionOffset - offset) + visibleRegionLength;
-
- Position parentRange= childDocument.getParentDocumentRange();
- if (offset != parentRange.getOffset() || length != parentRange.getLength()) {
- childDocument.setParentDocumentRange(offset, length);
- return true;
- }
- }
- return false;
- }
-
- /**
- * Updates the given slave document to show the specified range of its master document.
- *
- * @param slaveDocument the slave document
- * @param modelRangeOffset the offset of the master document range
- * @param modelRangeLength the length of the master document range
- * @return <code>true</code> if the slave has been adapted successfully
- * @throws BadLocationException in case the specified range is not valid in the master document
- * @since 3.0
- */
- protected boolean updateSlaveDocument(IDocument slaveDocument, int modelRangeOffset, int modelRangeLength) throws BadLocationException {
- return updateVisibleDocument(slaveDocument, modelRangeOffset, modelRangeLength);
- }
-
-
-
- //---- View ports
-
- /**
- * Initializes all listeners and structures required to set up view port listeners.
- */
- private void initializeViewportUpdate() {
-
- if (fViewportGuard != null)
- return;
-
- if (fTextWidget != null) {
-
- fViewportGuard= new ViewportGuard();
- fLastTopPixel= -1;
-
- fTextWidget.addKeyListener(fViewportGuard);
- fTextWidget.addMouseListener(fViewportGuard);
-
- fScroller= fTextWidget.getVerticalBar();
- if (fScroller != null)
- fScroller.addSelectionListener(fViewportGuard);
- }
- }
-
- /**
- * Removes all listeners and structures required to set up view port listeners.
- */
- private void removeViewPortUpdate() {
-
- if (fTextWidget != null) {
-
- fTextWidget.removeKeyListener(fViewportGuard);
- fTextWidget.removeMouseListener(fViewportGuard);
-
- if (fScroller != null && !fScroller.isDisposed()) {
- fScroller.removeSelectionListener(fViewportGuard);
- fScroller= null;
- }
-
- fViewportGuard= null;
- }
- }
-
- /*
- * @see ITextViewer#addViewportListener(IViewportListener)
- */
- public void addViewportListener(IViewportListener listener) {
-
- if (fViewportListeners == null) {
- fViewportListeners= new ArrayList();
- initializeViewportUpdate();
- }
-
- if (!fViewportListeners.contains(listener))
- fViewportListeners.add(listener);
- }
-
- /*
- * @see ITextViewer#removeViewportListener(IVewportListener)
- */
- public void removeViewportListener(IViewportListener listener) {
- if (fViewportListeners != null)
- fViewportListeners.remove(listener);
- }
-
- /**
- * Checks whether the view port changed and if so informs all registered
- * listeners about the change.
- *
- * @param origin describes under which circumstances this method has been called.
- *
- * @see IViewportListener
- */
- protected void updateViewportListeners(int origin) {
-
- if (redraws()) {
- int topPixel= fTextWidget.getTopPixel();
- if (topPixel >= 0 && topPixel != fLastTopPixel) {
- if (fViewportListeners != null) {
- for (int i= 0; i < fViewportListeners.size(); i++) {
- IViewportListener l= (IViewportListener) fViewportListeners.get(i);
- l.viewportChanged(topPixel);
- }
- }
- fLastTopPixel= topPixel;
- }
- }
- }
-
- //---- scrolling and revealing
-
- /*
- * @see ITextViewer#getTopIndex()
- */
- public int getTopIndex() {
-
- if (fTextWidget != null) {
- int top= fTextWidget.getTopIndex();
- return widgetlLine2ModelLine(top);
- }
-
- return -1;
- }
-
- /*
- * @see ITextViewer#setTopIndex(int)
- */
- public void setTopIndex(int index) {
-
- if (fTextWidget != null) {
-
- int widgetLine= modelLine2WidgetLine(index);
- if (widgetLine == -1)
- widgetLine= getClosestWidgetLineForModelLine(index);
-
- if (widgetLine > -1) {
- fTextWidget.setTopIndex(widgetLine);
- updateViewportListeners(INTERNAL);
- }
- }
- }
-
- /**
- * Returns the view port height in lines. The actual visible lines can be fewer if the
- * document is shorter than the view port.
- *
- * @return the view port height in lines
- */
- protected int getVisibleLinesInViewport() {
- if (fTextWidget != null) {
- Rectangle clArea= fTextWidget.getClientArea();
- if (!clArea.isEmpty())
- return clArea.height / fTextWidget.getLineHeight();
- }
- return -1;
- }
-
- /*
- * @see ITextViewer#getBottomIndex()
- */
- public int getBottomIndex() {
-
- if (fTextWidget == null)
- return -1;
-
- IRegion coverage= getModelCoverage();
-
- try {
-
- IDocument d= getDocument();
-
- if (d == null)
- return -1;
-
- int startLine= d.getLineOfOffset(coverage.getOffset());
- int endLine= d.getLineOfOffset(coverage.getOffset() + coverage.getLength() - 1);
- int lines= getVisibleLinesInViewport();
-
- if (startLine + lines < endLine) {
- int widgetTopIndex= fTextWidget.getTopIndex();
- int widgetBottomIndex= widgetTopIndex + lines -1;
- return widgetlLine2ModelLine(widgetBottomIndex);
- }
-
- return endLine;
-
- } catch (BadLocationException x) {
- if (TRACE_ERRORS)
- System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.getBottomIndex")); //$NON-NLS-1$
- }
-
- return -1;
- }
-
- /*
- * @see ITextViewer#getTopIndexStartOffset()
- */
- public int getTopIndexStartOffset() {
-
- if (fTextWidget != null) {
- int top= fTextWidget.getTopIndex();
- try {
- top= getVisibleDocument().getLineOffset(top);
- return widgetlLine2ModelLine(top);
- } catch (BadLocationException ex) {
- if (TRACE_ERRORS)
- System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.getTopIndexStartOffset")); //$NON-NLS-1$
- }
- }
-
- return -1;
- }
-
- /*
- * @see ITextViewer#getBottomIndexEndOffset()
- */
- public int getBottomIndexEndOffset() {
- try {
-
- IRegion line= getDocument().getLineInformation(getBottomIndex());
- int bottomEndOffset= line.getOffset() + line.getLength() - 1;
-
- IRegion coverage= getModelCoverage();
- int coverageEndOffset= coverage.getOffset() + coverage.getLength() - 1;
- return Math.min(coverageEndOffset, bottomEndOffset);
-
- } catch (BadLocationException ex) {
- if (TRACE_ERRORS)
- System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.getBottomIndexEndOffset")); //$NON-NLS-1$
- return getDocument().getLength() - 1;
- }
- }
-
- /*
- * @see ITextViewer#revealRange(int, int)
- */
- public void revealRange(int start, int length) {
-
- if (fTextWidget == null || !redraws())
- return;
-
- IRegion modelRange= new Region(start, length);
- IRegion widgetRange= modelRange2WidgetRange(modelRange);
- if (widgetRange != null) {
-
- int[] range= new int[] { widgetRange.getOffset(), widgetRange.getLength() };
- validateSelectionRange(range);
- if (range[0] >= 0)
- internalRevealRange(range[0], range[0] + range[1]);
-
- } else {
-
- IRegion coverage= getModelCoverage();
- int cursor= start < coverage.getOffset() ? 0 : getVisibleDocument().getLength();
- internalRevealRange(cursor, cursor);
- }
- }
-
- /**
- * Reveals the given range of the visible document.
- *
- * @param start the start offset of the range
- * @param end the end offset of the range
- */
- protected void internalRevealRange(int start, int end) {
-
- try {
-
- IDocument doc= getVisibleDocument();
-
- int startLine= doc.getLineOfOffset(start);
- int endLine= doc.getLineOfOffset(end);
-
- int top= fTextWidget.getTopIndex();
- if (top > -1) {
-
- // scroll vertically
-
- int lines= getVisibleLinesInViewport();
- int bottom= top + lines;
-
- // two lines at the top and the bottom should always be left
- // if window is smaller than 5 lines, always center position is chosen
- int bufferZone= 2;
-
- if (startLine >= top + bufferZone
- && startLine <= bottom - bufferZone
- && endLine >= top + bufferZone
- && endLine <= bottom - bufferZone) {
-
- // do not scroll at all as it is already visible
-
- } else {
-
- int delta= Math.max(0, lines - (endLine - startLine));
- fTextWidget.setTopIndex(startLine - delta/3);
- updateViewportListeners(INTERNAL);
- }
-
- // scroll horizontally
-
- if (endLine < startLine) {
- endLine += startLine;
- startLine= endLine - startLine;
- endLine -= startLine;
- }
-
- int startPixel= -1;
- int endPixel= -1;
-
- if (endLine > startLine) {
- // reveal the beginning of the range in the start line
- IRegion extent= getExtent(start, start);
- startPixel= extent.getOffset() + fTextWidget.getHorizontalPixel();
- endPixel= startPixel;
-
- } else {
- IRegion extent= getExtent(start, end);
- startPixel= extent.getOffset() + fTextWidget.getHorizontalPixel();
- endPixel= startPixel + extent.getLength();
- }
-
- int visibleStart= fTextWidget.getHorizontalPixel();
- int visibleEnd= visibleStart + fTextWidget.getClientArea().width;
-
- // scroll only if not yet visible
- if (startPixel < visibleStart || visibleEnd < endPixel) {
-
- // set buffer zone to 10 pixels
- bufferZone= 10;
-
- int newOffset= visibleStart;
-
- int visibleWidth= visibleEnd - visibleStart;
- int selectionPixelWidth= endPixel - startPixel;
-
- if (startPixel < visibleStart)
- newOffset= startPixel;
- else if (selectionPixelWidth + bufferZone < visibleWidth)
- newOffset= endPixel + bufferZone - visibleWidth;
- else
- newOffset= startPixel;
-
- float index= ((float)newOffset) / ((float)getAverageCharWidth());
-
- fTextWidget.setHorizontalIndex(Math.round(index));
- }
-
- }
- } catch (BadLocationException e) {
- throw new IllegalArgumentException(JFaceTextMessages.getString("TextViewer.error.invalid_range")); //$NON-NLS-1$
- }
- }
-
- /**
- * Returns the width of the text when being drawn into this viewer's widget.
- *
- * @param the string to measure
- * @return the width of the presentation of the given string
- * @deprecated use <code>getWidthInPixels(int, int)</code> instead
- */
- final protected int getWidthInPixels(String text) {
- GC gc= new GC(fTextWidget);
- gc.setFont(fTextWidget.getFont());
- Point extent= gc.textExtent(text);
- gc.dispose();
- return extent.x;
- }
-
- /**
- * Returns the region covered by the given start and end offset.
- * The result is relative to the upper left corner of the widget
- * client area.
- *
- * @param start offset relative to the start of this viewer's view port
- * 0 <= offset <= getCharCount()
- * @param end offset relative to the start of this viewer's view port
- * 0 <= offset <= getCharCount()
- * @return the region covered by start and end offset
- */
- final protected IRegion getExtent(int start, int end) {
- Point left= fTextWidget.getLocationAtOffset(start);
- Point right= new Point(left.x, left.y);
-
- for (int i= start +1; i <= end; i++) {
-
- Point p= fTextWidget.getLocationAtOffset(i);
-
- if (left.x > p.x)
- left.x= p.x;
-
- if (right.x < p.x)
- right.x= p.x;
- }
-
- return new Region(left.x, right.x - left.x);
- }
-
- /**
- * Returns the width of the representation of a text range in the
- * visible region of the viewer's document as drawn in this viewer's
- * widget.
- *
- * @param offset the offset of the text range in the visible region
- * @param length the length of the text range in the visible region
- * @return the width of the presentation of the specified text range
- * @since 2.0
- */
- final protected int getWidthInPixels(int offset, int length) {
-
- Point left= fTextWidget.getLocationAtOffset(offset);
- Point right= new Point(left.x, left.y);
-
- int end= offset + length;
- for (int i= offset +1; i <= end; i++) {
-
- Point p= fTextWidget.getLocationAtOffset(i);
-
- if (left.x > p.x)
- left.x= p.x;
-
- if (right.x < p.x)
- right.x= p.x;
- }
-
- return right.x - left.x;
- }
-
- /**
- * Returns the average character width of this viewer's widget.
- *
- * @return the average character width of this viewer's widget
- */
- final protected int getAverageCharWidth() {
- GC gc= new GC(fTextWidget);
- gc.setFont(fTextWidget.getFont());
- int increment= gc.getFontMetrics().getAverageCharWidth();
- gc.dispose();
- return increment;
- }
-
- /*
- * @see Viewer#refresh()
- */
- public void refresh() {
- setDocument(getDocument());
- }
-
- //---- visible range support
-
- /**
- * Returns the slave document manager
- *
- * @return the slave document manager
- * @since 2.1
- */
- protected ISlaveDocumentManager getSlaveDocumentManager() {
- if (fSlaveDocumentManager == null)
- fSlaveDocumentManager= createSlaveDocumentManager();
- return fSlaveDocumentManager;
- }
-
- /**
- * Creates a new slave document manager. This implementation always
- * returns a <code>ChildDocumentManager</code>.
- *
- * @return ISlaveDocumentManager
- * @since 2.1
- */
- protected ISlaveDocumentManager createSlaveDocumentManager() {
- return new ChildDocumentManager();
- }
-
- /*
- * @see org.eclipse.jface.text.ITextViewer#invalidateTextPresentation()
- */
- public final void invalidateTextPresentation() {
- if (fVisibleDocument != null) {
- fWidgetCommand.event= null;
- fWidgetCommand.start= 0;
- fWidgetCommand.length= fVisibleDocument.getLength();
- fWidgetCommand.text= fVisibleDocument.get();
- updateTextListeners(fWidgetCommand);
- }
- }
-
- /**
- * Invalidates the given range of the text presentation.
- *
- * @param offset the offset of the range to be invalidated
- * @param length the length of the range to be invalidated
- * @since 2.1
- */
- public final void invalidateTextPresentation(int offset, int length) {
- if (fVisibleDocument != null) {
-
- IRegion widgetRange= modelRange2WidgetRange(new Region(offset, length));
- if (widgetRange != null) {
-
- fWidgetCommand.event= null;
- fWidgetCommand.start= widgetRange.getOffset();
- fWidgetCommand.length= widgetRange.getLength();
-
- try {
- fWidgetCommand.text= fVisibleDocument.get(widgetRange.getOffset(), widgetRange.getLength());
- updateTextListeners(fWidgetCommand);
- } catch (BadLocationException x) {
- // can not happen because of previous checking
- }
- }
- }
- }
-
- /**
- * Initializes the text widget with the visual document and
- * invalidates the overall presentation.
- */
- private void initializeWidgetContents() {
-
- if (fTextWidget != null && fVisibleDocument != null) {
-
- // set widget content
- if (fDocumentAdapter == null)
- fDocumentAdapter= createDocumentAdapter();
-
- fDocumentAdapter.setDocument(fVisibleDocument);
- fTextWidget.setContent(fDocumentAdapter);
-
- // invalidate presentation
- invalidateTextPresentation();
- }
- }
-
- /**
- * Frees the given document if it is a slave document.
- *
- * @param slave the potential slave document
- * @since 3.0
- */
- protected void freeSlaveDocument(IDocument slave) {
- ISlaveDocumentManager manager= getSlaveDocumentManager();
- if (manager != null && manager.isSlaveDocument(slave))
- manager.freeSlaveDocument(slave);
- }
-
- /**
- * Sets this viewer's visible document. The visible document represents the
- * visible region of the viewer's input document.
- *
- * @param document the visible document
- */
- protected void setVisibleDocument(IDocument document) {
-
- if (fVisibleDocument == document && fVisibleDocument instanceof ChildDocument) {
- // optimization for new child documents
- resetPlugins();
- return;
- }
-
- if (fVisibleDocument != null) {
- if (fDocumentListener != null)
- fVisibleDocument.removeDocumentListener(fDocumentListener);
- if (fVisibleDocument != document)
- freeSlaveDocument(fVisibleDocument);
- }
-
- fVisibleDocument= document;
- initializeDocumentInformationMapping(fVisibleDocument);
-
- initializeWidgetContents();
- resetPlugins();
-
- if (fVisibleDocument != null) {
- fFindRepalceDocumentAdapter= new FindReplaceDocumentAdapter(getVisibleDocument());
- if (fDocumentListener != null)
- fVisibleDocument.addDocumentListener(fDocumentListener);
- }
- }
-
- /**
- * Initializes the document information mapping between the given slave document and
- * its master document.
- *
- * @param visibleDocument the slave document
- * @since 2.1
- */
- protected void initializeDocumentInformationMapping(IDocument visibleDocument) {
- ISlaveDocumentManager manager= getSlaveDocumentManager();
- fInformationMapping= manager == null ? null : manager.createMasterSlaveMapping(visibleDocument);
- }
-
- /**
- * Returns the viewer's visible document.
- *
- * @return the viewer's visible document
- */
- protected IDocument getVisibleDocument() {
- return fVisibleDocument;
- }
-
- /**
- * Returns the offset of the visible region.
- *
- * @return the offset of the visible region
- */
- protected int _getVisibleRegionOffset() {
-
- IDocument document= getVisibleDocument();
- if (document instanceof ChildDocument) {
- ChildDocument cdoc= (ChildDocument) document;
- return cdoc.getParentDocumentRange().getOffset();
- }
-
- return 0;
- }
-
- /*
- * @see ITextViewer#getVisibleRegion()
- */
- public IRegion getVisibleRegion() {
-
- IDocument document= getVisibleDocument();
- if (document instanceof ChildDocument) {
- Position p= ((ChildDocument) document).getParentDocumentRange();
- return new Region(p.getOffset(), p.getLength());
- }
-
- return new Region(0, document == null ? 0 : document.getLength());
- }
-
- /*
- * @see ITextViewer#overlapsWithVisibleRegion(int, int)
- */
- public boolean overlapsWithVisibleRegion(int start, int length) {
- IDocument document= getVisibleDocument();
- if (document instanceof ChildDocument) {
- ChildDocument cdoc= (ChildDocument) document;
- return cdoc.getParentDocumentRange().overlapsWith(start, length);
- } else if (document != null) {
- int size= document.getLength();
- return (start >= 0 && length >= 0 && start + length <= size);
- }
- return false;
- }
-
- /*
- * @see ITextViewer#setVisibleRegion(int, int)
- */
- public void setVisibleRegion(int start, int length) {
-
- IRegion region= getVisibleRegion();
- if (start == region.getOffset() && length == region.getLength()) {
- // nothing to change
- return;
- }
-
- setRedraw(false);
- try {
-
- IDocument slaveDocument= createSlaveDocument(getVisibleDocument());
- if (updateSlaveDocument(slaveDocument, start, length))
- setVisibleDocument(slaveDocument);
-
- } catch (BadLocationException x) {
- throw new IllegalArgumentException(JFaceTextMessages.getString("TextViewer.error.invalid_visible_region_2")); //$NON-NLS-1$
- } finally {
- setRedraw(true);
- }
- }
-
- /*
- * @see ITextViewer#resetVisibleRegion()
- */
- public void resetVisibleRegion() {
- ISlaveDocumentManager manager= getSlaveDocumentManager();
- if (manager != null) {
- IDocument slave= getVisibleDocument();
- IDocument master= manager.getMasterDocument(slave);
- if (master != null) {
- setVisibleDocument(master);
- manager.freeSlaveDocument(slave);
- }
- }
- }
-
-
- //--------------------------------------
-
- /*
- * @see ITextViewer#setTextDoubleClickStrategy(ITextDoubleClickStrategy, String)
- */
- public void setTextDoubleClickStrategy(ITextDoubleClickStrategy strategy, String contentType) {
-
- if (strategy != null) {
- if (fDoubleClickStrategies == null)
- fDoubleClickStrategies= new HashMap();
- fDoubleClickStrategies.put(contentType, strategy);
- } else if (fDoubleClickStrategies != null)
- fDoubleClickStrategies.remove(contentType);
- }
-
- /**
- * Selects from the given map the one which is registered under
- * the content type of the partition in which the given offset is located.
- *
- * @param plugins the map from which to choose
- * @param offset the offset for which to find the plug-in
- * @return the plug-in registered under the offset's content type
- */
- protected Object selectContentTypePlugin(int offset, Map plugins) {
- try {
- return selectContentTypePlugin(TextUtilities.getContentType(getDocument(), getDocumentPartitioning(), offset), plugins);
- } catch (BadLocationException x) {
- if (TRACE_ERRORS)
- System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.selectContentTypePlugin")); //$NON-NLS-1$
- }
- return null;
- }
-
- /**
- * Selects from the given <code>plug-ins</code> this one which is registered for
- * the given content <code>type</code>.
- *
- * @param type the type to be used as lookup key
- * @param plugins the table to be searched
- */
- private Object selectContentTypePlugin(String type, Map plugins) {
-
- if (plugins == null)
- return null;
-
- return plugins.get(type);
- }
-
- /**
- * Hook called on receipt of a <code>VerifyEvent</code>. The event has
- * been translated into a <code>DocumentCommand</code> which can now be
- * manipulated by interested parties. By default, the hook forwards the command
- * to the installed instances of <code>IAutoEditStrategy</code>.
- *
- * @param command the document command representing the verify event
- */
- protected void customizeDocumentCommand(DocumentCommand command) {
- if (isIgnoringAutoEditStrategies())
- return;
-
- List strategies= (List) selectContentTypePlugin(command.offset, fAutoIndentStrategies);
- if (strategies == null)
- return;
-
- switch (strategies.size()) {
- // optimization
- case 0:
- break;
-
- case 1:
- ((IAutoEditStrategy) strategies.iterator().next()).customizeDocumentCommand(getDocument(), command);
- break;
-
- // make iterator robust against adding/removing strategies from within strategies
- default:
- strategies= new ArrayList(strategies);
-
- IDocument document= getDocument();
- for (final Iterator iterator= strategies.iterator(); iterator.hasNext(); )
- ((IAutoEditStrategy) iterator.next()).customizeDocumentCommand(document, command);
-
- break;
- }
- }
-
- /**
- * @see VerifyListener#verifyText(VerifyEvent)
- */
- protected void handleVerifyEvent(VerifyEvent e) {
-
- if (fEventConsumer != null) {
- fEventConsumer.processEvent(e);
- if (!e.doit)
- return;
- }
-
- IRegion modelRange= event2ModelRange(e);
- fDocumentCommand.setEvent(e, modelRange);
- customizeDocumentCommand(fDocumentCommand);
- if (!fDocumentCommand.fillEvent(e, modelRange)) {
-
- boolean compoundChange= fDocumentCommand.getCommandCount() > 1;
- try {
-
- fVerifyListener.forward(false);
-
- if (compoundChange && fUndoManager != null)
- fUndoManager.beginCompoundChange();
-
- if (fSlaveDocumentManager != null) {
- IDocument visible= getVisibleDocument();
- try {
- fSlaveDocumentManager.setAutoExpandMode(visible, true);
- fDocumentCommand.execute(getDocument());
- } finally {
- fSlaveDocumentManager.setAutoExpandMode(visible, false);
- }
- } else {
- fDocumentCommand.execute(getDocument());
- }
-
- if (fTextWidget != null) {
- int documentCaret= fDocumentCommand.caretOffset;
- if (documentCaret == -1) {
- // old behavior of document command
- documentCaret= fDocumentCommand.offset + (fDocumentCommand.text == null ? 0 : fDocumentCommand.text.length());
- }
-
- int widgetCaret= modelOffset2WidgetOffset(documentCaret);
- if (widgetCaret == -1) {
- // try to move it to the closest spot
- IRegion region= getModelCoverage();
- if (documentCaret <= region.getOffset())
- widgetCaret= 0;
- else if (documentCaret >= region.getOffset() + region.getLength())
- widgetCaret= getVisibleRegion().getLength();
- }
-
- if (widgetCaret != -1) {
- // there is a valid widget caret
- fTextWidget.setCaretOffset(widgetCaret);
- }
-
- fTextWidget.showSelection();
- }
- } catch (BadLocationException x) {
-
- if (TRACE_ERRORS)
- System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.verifyText")); //$NON-NLS-1$
-
- } finally {
-
- if (compoundChange && fUndoManager != null)
- fUndoManager.endCompoundChange();
-
- fVerifyListener.forward(true);
-
- }
- }
- }
-
- //---- text manipulation
-
- /**
- * Returns whether the marked region of this viewer is empty.
- *
- * @return <code>true</code> if the marked region of this viewer is empty, otherwise <code>false</code>
- * @since 2.0
- */
- private boolean isMarkedRegionEmpty() {
- return
- fTextWidget == null ||
- fMarkPosition == null ||
- fMarkPosition.isDeleted() ||
- modelRange2WidgetRange(fMarkPosition) == null;
- }
-
- /*
- * @see ITextViewer#canDoOperation(int)
- */
- public boolean canDoOperation(int operation) {
-
- if (fTextWidget == null || !redraws())
- return false;
-
- switch (operation) {
- case CUT:
- return isEditable() &&(fTextWidget.getSelectionCount() > 0 || !isMarkedRegionEmpty());
- case COPY:
- return fTextWidget.getSelectionCount() > 0 || !isMarkedRegionEmpty();
- case DELETE:
- case PASTE:
- return isEditable();
- case SELECT_ALL:
- return true;
- case SHIFT_LEFT:
- return isEditable() && fIndentChars != null;
- case SHIFT_RIGHT:
- return isEditable() && fIndentChars != null && areMultipleLinesSelected();
- case PREFIX:
- case STRIP_PREFIX:
- return isEditable() && fDefaultPrefixChars != null;
- case UNDO:
- return fUndoManager != null && fUndoManager.undoable();
- case REDO:
- return fUndoManager != null && fUndoManager.redoable();
- case PRINT:
- return isPrintable();
- }
-
- return false;
- }
-
- /*
- * @see ITextViewer#doOperation(int)
- */
- public void doOperation(int operation) {
-
- if (fTextWidget == null || !redraws())
- return;
-
- Point selection= null;
-
- switch (operation) {
-
- case UNDO:
- if (fUndoManager != null) {
- ignoreAutoEditStrategies(true);
- fUndoManager.undo();
- ignoreAutoEditStrategies(false);
- }
- break;
- case REDO:
- if (fUndoManager != null) {
- ignoreAutoEditStrategies(true);
- fUndoManager.redo();
- ignoreAutoEditStrategies(false);
- }
- break;
- case CUT:
- if (fTextWidget.getSelectionCount() == 0)
- copyMarkedRegion(true);
- else
- fTextWidget.cut();
-
- selection= fTextWidget.getSelectionRange();
- fireSelectionChanged(selection.x, selection.y);
-
- break;
- case COPY:
- if (fTextWidget.getSelectionCount() == 0)
- copyMarkedRegion(false);
- else
- fTextWidget.copy();
- break;
- case PASTE:
-// ignoreAutoEditStrategies(true);
- fTextWidget.paste();
- selection= fTextWidget.getSelectionRange();
- fireSelectionChanged(selection.x, selection.y);
-// ignoreAutoEditStrategies(false);
- break;
- case DELETE:
- deleteText();
- selection= fTextWidget.getSelectionRange();
- fireSelectionChanged(selection.x, selection.y);
- break;
- case SELECT_ALL: {
- if (getDocument() != null)
- setSelectedRange(0, getDocument().getLength());
- break;
- }
- case SHIFT_RIGHT:
- shift(false, true, false);
- break;
- case SHIFT_LEFT:
- shift(false, false, false);
- break;
- case PREFIX:
- shift(true, true, true);
- break;
- case STRIP_PREFIX:
- shift(true, false, true);
- break;
- case PRINT:
- print();
- break;
- }
- }
-
- /**
- * Tells this viewer whether the registered auto edit strategies should be ignored.
- *
- * @param ignore <code>true</code> if the strategies should be ignored.
- * @since 2.1
- */
- protected void ignoreAutoEditStrategies(boolean ignore) {
-
- fIgnoreAutoIndent= ignore;
-
- IDocument document= getDocument();
- if (document instanceof IDocumentExtension2) {
- IDocumentExtension2 extension= (IDocumentExtension2) document;
- if (ignore)
- extension.ignorePostNotificationReplaces();
- else
- extension.acceptPostNotificationReplaces();
- }
- }
-
- /**
- * Returns whether this viewer ignores the registered auto edit strategies.
- *
- * @return <code>true</code> if the strategies are ignored
- * @since 2.1
- */
- protected boolean isIgnoringAutoEditStrategies() {
- return fIgnoreAutoIndent;
- }
-
- /*
- * @see ITextOperationTargetExtension#enableOperation(int, boolean)
- * @since 2.0
- */
- public void enableOperation(int operation, boolean enable) {
- /*
- * No-op by default.
- * Will be changed to regularly disable the known operations.
- */
- }
-
- /**
- * Copies/cuts the marked region.
- *
- * @param delete <code>true</code> if the region should be deleted rather than copied.
- * @since 2.0
- */
- private void copyMarkedRegion(boolean delete) {
-
- if (fTextWidget == null)
- return;
-
- if (fMarkPosition == null || fMarkPosition.isDeleted() || modelRange2WidgetRange(fMarkPosition) == null)
- return;
-
- int widgetMarkOffset= modelOffset2WidgetOffset(fMarkPosition.offset);
- Point selection= fTextWidget.getSelection();
- if (selection.x <= widgetMarkOffset)
- fTextWidget.setSelection(selection.x, widgetMarkOffset);
- else
- fTextWidget.setSelection(widgetMarkOffset, selection.x);
-
- if (delete) {
- fTextWidget.cut();
- } else {
- fTextWidget.copy();
- fTextWidget.setSelection(selection.x); // restore old cursor position
- }
- }
-
- /**
- * Deletes the current selection. If the selection has the length 0
- * the selection is automatically extended to the right - either by 1
- * or by the length of line delimiter if at the end of a line.
- *
- * @deprecated use <code>StyledText.invokeAction</code> instead
- */
- protected void deleteText() {
- fTextWidget.invokeAction(ST.DELETE_NEXT);
- }
-
- /**
- * A block is selected if the character preceding the start of the
- * selection is a new line character.
- *
- * @return <code>true</code> if a block is selected
- */
- protected boolean isBlockSelected() {
-
- Point s= getSelectedRange();
- if (s.y == 0)
- return false;
-
- try {
-
- IDocument document= getDocument();
- int line= document.getLineOfOffset(s.x);
- int start= document.getLineOffset(line);
- return (s.x == start);
-
- } catch (BadLocationException x) {
- }
-
- return false;
- }
-
- /**
- * Returns <code>true</code> if one line is completely selected or if multiple lines are selected.
- * Being completely selected means that all characters except the new line characters are
- * selected.
- *
- * @return <code>true</code> if one or multiple lines are selected
- * @since 2.0
- */
- protected boolean areMultipleLinesSelected() {
- Point s= getSelectedRange();
- if (s.y == 0)
- return false;
-
- try {
-
- IDocument document= getDocument();
- int startLine= document.getLineOfOffset(s.x);
- int endLine= document.getLineOfOffset(s.x + s.y);
- IRegion line= document.getLineInformation(startLine);
- return startLine != endLine || (s.x == line.getOffset() && s.y == line.getLength());
-
- } catch (BadLocationException x) {
- }
-
- return false;
- }
-
- /**
- * Returns the index of the first line whose start offset is in the given text range.
- *
- * @param region the text range in characters where to find the line
- * @return the first line whose start index is in the given range, -1 if there is no such line
- */
- private int getFirstCompleteLineOfRegion(IRegion region) {
-
- try {
-
- IDocument d= getDocument();
-
- int startLine= d.getLineOfOffset(region.getOffset());
-
- int offset= d.getLineOffset(startLine);
- if (offset >= region.getOffset())
- return startLine;
-
- offset= d.getLineOffset(startLine + 1);
- return (offset > region.getOffset() + region.getLength() ? -1 : startLine + 1);
-
- } catch (BadLocationException x) {
- if (TRACE_ERRORS)
- System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.getFirstCompleteLineOfRegion")); //$NON-NLS-1$
- }
-
- return -1;
- }
-
-
- /**
- * Creates a region describing the text block (something that starts at
- * the beginning of a line) completely containing the current selection.
- *
- * @param selection the selection to use
- * @return the region describing the text block comprising the given selection
- * @since 2.0
- */
- private IRegion getTextBlockFromSelection(Point selection) {
-
- try {
- IDocument document= getDocument();
- IRegion line= document.getLineInformationOfOffset(selection.x);
- int length= selection.y == 0 ? line.getLength() : selection.y + (selection.x - line.getOffset());
- return new Region(line.getOffset(), length);
-
- } catch (BadLocationException x) {
- }
-
- return null;
- }
-
- /**
- * Shifts a text block to the right or left using the specified set of prefix characters.
- * The prefixes must start at the beginning of the line.
- *
- * @param useDefaultPrefixes says whether the configured default or indent prefixes should be used
- * @param right says whether to shift to the right or the left
- *
- * @deprecated use shift(boolean, boolean, boolean) instead
- */
- protected void shift(boolean useDefaultPrefixes, boolean right) {
- shift(useDefaultPrefixes, right, false);
- }
-
- /**
- * Shifts a text block to the right or left using the specified set of prefix characters.
- * If white space should be ignored the prefix characters must not be at the beginning of
- * the line when shifting to the left. There may be whitespace in front of the prefixes.
- *
- * @param useDefaultPrefixes says whether the configured default or indent prefixes should be used
- * @param right says whether to shift to the right or the left
- * @param ignoreWhitespace says whether whitespace in front of prefixes is allowed
- * @since 2.0
- */
- protected void shift(boolean useDefaultPrefixes, boolean right, boolean ignoreWhitespace) {
-
- if (fUndoManager != null)
- fUndoManager.beginCompoundChange();
-
- setRedraw(false);
- startSequentialRewriteMode(true);
-
- IDocument d= getDocument();
- Map partitioners= null;
-
- try {
-
- Point selection= getSelectedRange();
- IRegion block= getTextBlockFromSelection(selection);
- ITypedRegion[] regions= TextUtilities.computePartitioning(d, getDocumentPartitioning(), block.getOffset(), block.getLength());
-
- int lineCount= 0;
- int[] lines= new int[regions.length * 2]; // [startline, endline, startline, endline, ...]
- for (int i= 0, j= 0; i < regions.length; i++, j+= 2) {
- // start line of region
- lines[j]= getFirstCompleteLineOfRegion(regions[i]);
- // end line of region
- int length= regions[i].getLength();
- int offset= regions[i].getOffset() + length;
- if (length > 0)
- offset--;
- lines[j + 1]= (lines[j] == -1 ? -1 : d.getLineOfOffset(offset));
- lineCount += lines[j + 1] - lines[j] + 1;
- }
-
- if (lineCount >= 20)
- partitioners= TextUtilities.removeDocumentPartitioners(d);
-
- // Remember the selection range.
- IPositionUpdater positionUpdater= new ShiftPositionUpdater(SHIFTING);
- Position rememberedSelection= new Position(selection.x, selection.y);
- d.addPositionCategory(SHIFTING);
- d.addPositionUpdater(positionUpdater);
- try {
- d.addPosition(SHIFTING, rememberedSelection);
- } catch (BadPositionCategoryException ex) {
- // should not happen
- }
-
- // Perform the shift operation.
- Map map= (useDefaultPrefixes ? fDefaultPrefixChars : fIndentChars);
- for (int i= 0, j= 0; i < regions.length; i++, j += 2) {
- String[] prefixes= (String[]) selectContentTypePlugin(regions[i].getType(), map);
- if (prefixes != null && prefixes.length > 0 && lines[j] >= 0 && lines[j + 1] >= 0) {
- if (right)
- shiftRight(lines[j], lines[j + 1], prefixes[0]);
- else
- shiftLeft(lines[j], lines[j + 1], prefixes, ignoreWhitespace);
- }
- }
-
- // Restore the selection.
- setSelectedRange(rememberedSelection.getOffset(), rememberedSelection.getLength());
-
- try {
- d.removePositionUpdater(positionUpdater);
- d.removePositionCategory(SHIFTING);
- } catch (BadPositionCategoryException ex) {
- // should not happen
- }
-
- } catch (BadLocationException x) {
- if (TRACE_ERRORS)
- System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.shift_1")); //$NON-NLS-1$
-
- } finally {
-
- if (partitioners != null)
- TextUtilities.addDocumentPartitioners(d, partitioners);
-
- stopSequentialRewriteMode();
- setRedraw(true);
-
- if (fUndoManager != null)
- fUndoManager.endCompoundChange();
- }
- }
-
- /**
- * Shifts the specified lines to the right inserting the given prefix
- * at the beginning of each line
- *
- * @param prefix the prefix to be inserted
- * @param startLine the first line to shift
- * @param endLine the last line to shift
- * @since 2.0
- */
- private void shiftRight(int startLine, int endLine, String prefix) {
-
- try {
-
- IDocument d= getDocument();
- while (startLine <= endLine) {
- d.replace(d.getLineOffset(startLine++), 0, prefix);
- }
-
- } catch (BadLocationException x) {
- if (TRACE_ERRORS)
- System.out.println("TextViewer.shiftRight: BadLocationException"); //$NON-NLS-1$
- }
- }
-
- /**
- * Shifts the specified lines to the right or to the left. On shifting to the right
- * it insert <code>prefixes[0]</code> at the beginning of each line. On shifting to the
- * left it tests whether each of the specified lines starts with one of the specified
- * prefixes and if so, removes the prefix.
- *
- * @param prefixes the prefixes to be used for shifting
- * @param right if <code>true</code> shift to the right otherwise to the left
- * @param startLine the first line to shift
- * @param endLine the last line to shift
- * @since 2.0
- */
- private void shiftLeft(int startLine, int endLine, String[] prefixes, boolean ignoreWhitespace) {
-
- IDocument d= getDocument();
-
- try {
-
- IRegion[] occurrences= new IRegion[endLine - startLine + 1];
-
- // find all the first occurrences of prefix in the given lines
- for (int i= 0; i < occurrences.length; i++) {
-
- IRegion line= d.getLineInformation(startLine + i);
- String text= d.get(line.getOffset(), line.getLength());
-
- int index= -1;
- int[] found= TextUtilities.indexOf(prefixes, text, 0);
- if (found[0] != -1) {
- if (ignoreWhitespace) {
- String s= d.get(line.getOffset(), found[0]);
- s= s.trim();
- if (s.length() == 0)
- index= line.getOffset() + found[0];
- } else if (found[0] == 0)
- index= line.getOffset();
- }
-
- if (index > -1) {
- // remember where prefix is in line, so that it can be removed
- int length= prefixes[found[1]].length();
- if (length == 0 && !ignoreWhitespace && line.getLength() > 0) {
- // found a non-empty line which cannot be shifted
- return;
- } else
- occurrences[i]= new Region(index, length);
- } else {
- // found a line which cannot be shifted
- return;
- }
- }
-
- // ok - change the document
- int decrement= 0;
- for (int i= 0; i < occurrences.length; i++) {
- IRegion r= occurrences[i];
- d.replace(r.getOffset() - decrement, r.getLength(), ""); //$NON-NLS-1$
- decrement += r.getLength();
- }
-
- } catch (BadLocationException x) {
- if (TRACE_ERRORS)
- System.out.println("TextViewer.shiftLeft: BadLocationException"); //$NON-NLS-1$
- }
- }
-
- /**
- * Returns whether the shown text can be printed.
- *
- * @return the viewer's printable mode
- */
- protected boolean isPrintable() {
- /*
- * 1GK7Q10: ITPUI:WIN98 - internal error after invoking print at editor view
- * Changed from returning true to testing the length of the printer queue
- */
- PrinterData[] printerList= Printer.getPrinterList();
- return (printerList != null && printerList.length > 0);
- }
-
- /**
- * Brings up a print dialog and calls <code>printContents(Printer)</code> which
- * performs the actual print.
- */
- protected void print() {
-
- final PrintDialog dialog= new PrintDialog(fTextWidget.getShell(), SWT.PRIMARY_MODAL);
- final PrinterData data= dialog.open();
-
- if (data != null) {
-
- final Printer printer= new Printer(data);
- final Runnable styledTextPrinter= fTextWidget.print(printer);
-
- Thread printingThread= new Thread("Printing") { //$NON-NLS-1$
- public void run() {
- styledTextPrinter.run();
- printer.dispose();
- }
- };
- printingThread.start();
- }
- }
-
-
- //------ find support
-
- /**
- * @see IFindReplaceTarget#canPerformFind
- */
- protected boolean canPerformFind() {
- IDocument d= getVisibleDocument();
- return (fTextWidget != null && d != null && d.getLength() > 0);
- }
-
- /**
- * @see IFindReplaceTarget#findAndSelect(int, String, boolean, boolean, boolean)
- * @deprecated as of 3.0 use {@link #findAndSelect(int, String, boolean, boolean, boolean, boolean)
- */
- protected int findAndSelect(int startPosition, String findString, boolean forwardSearch, boolean caseSensitive, boolean wholeWord) {
- try {
- return findAndSelect(startPosition, findString, forwardSearch, caseSensitive, wholeWord, false);
- } catch (IllegalStateException ex) {
- return -1;
- } catch (PatternSyntaxException ex) {
- return -1;
- }
- }
-
- /**
- * @see IFindReplaceTargetExtension3#findAndSelect(int, String, boolean, boolean, boolean, boolean)
- */
- protected int findAndSelect(int startPosition, String findString, boolean forwardSearch, boolean caseSensitive, boolean wholeWord, boolean regExSearch) {
- if (fTextWidget == null)
- return -1;
-
- try {
-
- int widgetOffset= (startPosition == -1 ? startPosition : modelOffset2WidgetOffset(startPosition));
- IRegion matchRegion= getFindRepalceDocumentAdapter().search(widgetOffset, findString, forwardSearch, caseSensitive, wholeWord, regExSearch);
- if (matchRegion != null) {
- int widgetPos= matchRegion.getOffset();
- int length= matchRegion.getLength();
- if (redraws()) {
- fTextWidget.setSelectionRange(widgetPos, length);
- internalRevealRange(widgetPos, widgetPos + length);
- selectionChanged(widgetPos, length);
- } else {
- setSelectedRange(widgetOffset2ModelOffset(widgetPos), length);
- }
-
- return widgetOffset2ModelOffset(widgetPos);
- }
-
- } catch (BadLocationException x) {
- if (TRACE_ERRORS)
- System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.findAndSelect")); //$NON-NLS-1$
- }
-
- return -1;
- }
-
- /**
- * @see IFindReplaceTargetExtension3#findAndSelect(int, String, boolean, boolean, boolean, boolean)
- * @since 3.0
- */
- private int findAndSelectInRange(int startPosition, String findString, boolean forwardSearch, boolean caseSensitive, boolean wholeWord, int rangeOffset, int rangeLength, boolean regExSearch) {
- if (fTextWidget == null)
- return -1;
-
- try {
-
- int modelOffset;
- if (forwardSearch && (startPosition == -1 || startPosition < rangeOffset)) {
- modelOffset= rangeOffset;
- } else if (!forwardSearch && (startPosition == -1 || startPosition > rangeOffset + rangeLength)) {
- modelOffset= rangeOffset + rangeLength;
- } else {
- modelOffset= startPosition;
- }
-
- int widgetOffset= modelOffset2WidgetOffset(modelOffset);
- if (widgetOffset == -1)
- return -1;
-
- IRegion matchRegion= getFindRepalceDocumentAdapter().search(widgetOffset, findString, forwardSearch, caseSensitive, wholeWord, regExSearch);
- int widgetPos= -1;
- int length= 0;
- if (matchRegion != null) {
- widgetPos= matchRegion.getOffset();
- length= matchRegion.getLength();
- }
- int modelPos= widgetPos == -1 ? -1 : widgetOffset2ModelOffset(widgetPos);
-
- if (widgetPos != -1 && (modelPos < rangeOffset || modelPos + length > rangeOffset + rangeLength))
- widgetPos= -1;
-
- if (widgetPos > -1) {
-
- if (redraws()) {
- fTextWidget.setSelectionRange(widgetPos, length);
- internalRevealRange(widgetPos, widgetPos + length);
- selectionChanged(widgetPos, length);
- } else {
- setSelectedRange(modelPos, length);
- }
-
- return modelPos;
- }
-
-
- } catch (BadLocationException x) {
- if (TRACE_ERRORS)
- System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.findAndSelect")); //$NON-NLS-1$
- }
-
- return -1;
- }
-
- //---------- text presentation support
-
- /*
- * @see ITextViewer#setTextColor(Color)
- */
- public void setTextColor(Color color) {
- if (color != null)
- setTextColor(color, 0, getDocument().getLength(), true);
- }
-
- /*
- * @see ITextViewer#setTextColor(Color, start, length, boolean)
- */
- public void setTextColor(Color color, int start, int length, boolean controlRedraw) {
-
- if (fTextWidget != null) {
-
- if (controlRedraw)
- fTextWidget.setRedraw(false);
-
- StyleRange s= new StyleRange();
- s.foreground= color;
- s.start= start;
- s.length= length;
-
- s= modelStyleRange2WidgetStyleRange(s);
- if (s != null) {
-
- if (controlRedraw)
- fTextWidget.setRedraw(false);
-
- fTextWidget.setStyleRange(s);
-
- if (controlRedraw)
- fTextWidget.setRedraw(true);
- }
- }
- }
-
- /**
- * Adds the given presentation to the viewer's style information.
- *
- * @param presentation the presentation to be added
- */
- private void addPresentation(TextPresentation presentation) {
-
- StyleRange range= presentation.getDefaultStyleRange();
- if (range != null) {
-
- range= modelStyleRange2WidgetStyleRange(range);
- if (range != null)
- fTextWidget.setStyleRange(range);
-
- Iterator e= presentation.getNonDefaultStyleRangeIterator();
- while (e.hasNext()) {
- range= (StyleRange) e.next();
- range= modelStyleRange2WidgetStyleRange(range);
- if (range != null)
- fTextWidget.setStyleRange(range);
- }
-
- } else {
- IRegion region= modelRange2WidgetRange(presentation.getCoverage());
- if (region == null)
- return;
-
- List list= new ArrayList();
- Iterator e= presentation.getAllStyleRangeIterator();
- while (e.hasNext()) {
- range= (StyleRange) e.next();
- range= modelStyleRange2WidgetStyleRange(range);
- if (range != null)
- list.add(range);
- }
-
- if (!list.isEmpty()) {
- StyleRange[] ranges= new StyleRange[list.size()];
- list.toArray(ranges);
- fTextWidget.replaceStyleRanges(region.getOffset(), region.getLength(), ranges);
- }
- }
- }
-
- /**
- * Applies the given presentation to the given text widget. Helper method.
- *
- * @param presentation the style information
- * @since 2.1
- */
- private void applyTextPresentation(TextPresentation presentation) {
-
- List list= new ArrayList(presentation.getDenumerableRanges());
- Iterator e= presentation.getAllStyleRangeIterator();
- while (e.hasNext()) {
- StyleRange range= (StyleRange) e.next();
- range= modelStyleRange2WidgetStyleRange(range);
- if (range != null)
- list.add(range);
- }
-
- if (!list.isEmpty()) {
- StyleRange[] ranges= new StyleRange[list.size()];
- list.toArray(ranges);
- fTextWidget.setStyleRanges(ranges);
- }
- }
-
- /**
- * Returns the visible region if it is not equal to the whole document.
- * Otherwise returns <code>null</code>.
- *
- * @return the viewer's visible region if smaller than input document, otherwise <code>null</code>
- */
- protected IRegion _internalGetVisibleRegion() {
-
- IDocument document= getVisibleDocument();
- if (document instanceof ChildDocument) {
- Position p= ((ChildDocument) document).getParentDocumentRange();
- return new Region(p.getOffset(), p.getLength());
- }
-
- return null;
- }
-
- /*
- * @see ITextViewer#changeTextPresentation(TextPresentation, boolean)
- */
- public void changeTextPresentation(TextPresentation presentation, boolean controlRedraw) {
-
- if (presentation == null || !redraws())
- return;
-
- if (fTextWidget == null)
- return;
-
-
- /*
- * Call registered text presentation listeners
- * and let them apply their presentation.
- */
- if (fTextPresentationListeners != null) {
- ArrayList listeners= new ArrayList(fTextPresentationListeners);
- for (int i= 0, size= listeners.size(); i < size; i++) {
- ITextPresentationListener listener= (ITextPresentationListener)listeners.get(i);
- listener.applyTextPresentation(presentation);
- }
- }
-
- if (presentation.isEmpty())
- return;
-
- if (controlRedraw)
- fTextWidget.setRedraw(false);
-
- if (fReplaceTextPresentation)
- applyTextPresentation(presentation);
- else
- addPresentation(presentation);
-
- if (controlRedraw)
- fTextWidget.setRedraw(true);
- }
-
- /*
- * @see ITextViewer#getFindReplaceTarget()
- */
- public IFindReplaceTarget getFindReplaceTarget() {
- if (fFindReplaceTarget == null)
- fFindReplaceTarget= new FindReplaceTarget();
- return fFindReplaceTarget;
- }
-
- /**
- * Returns the find/replace document adapter.
- *
- * @return the find/replace document adapter.
- * @since 3.0
- */
- private FindReplaceDocumentAdapter getFindRepalceDocumentAdapter() {
- if (fFindRepalceDocumentAdapter == null)
- fFindRepalceDocumentAdapter= new FindReplaceDocumentAdapter(getVisibleDocument());
- return fFindRepalceDocumentAdapter;
- }
-
- /*
- * @see ITextViewer#getTextOperationTarget()
- */
- public ITextOperationTarget getTextOperationTarget() {
- return this;
- }
-
- /*
- * @see ITextViewerExtension#appendVerifyKeyListener(VerifyKeyListener)
- * @since 2.0
- */
- public void appendVerifyKeyListener(VerifyKeyListener listener) {
- int index= fVerifyKeyListenersManager.numberOfListeners();
- fVerifyKeyListenersManager.insertListener(listener, index);
- }
-
- /*
- * @see ITextViewerExtension#prependVerifyKeyListener(VerifyKeyListener)
- * @since 2.0
- */
- public void prependVerifyKeyListener(VerifyKeyListener listener) {
- fVerifyKeyListenersManager.insertListener(listener, 0);
-
- }
-
- /*
- * @see ITextViewerExtension#removeVerifyKeyListener(VerifyKeyListener)
- * @since 2.0
- */
- public void removeVerifyKeyListener(VerifyKeyListener listener) {
- fVerifyKeyListenersManager.removeListener(listener);
- }
-
- /*
- * @see ITextViewerExtension#getMark()
- * @since 2.0
- */
- public int getMark() {
- return fMarkPosition == null || fMarkPosition.isDeleted() ? -1 : fMarkPosition.getOffset();
- }
-
- /*
- * @see ITextViewerExtension#setMark(int)
- * @since 2.0
- */
- public void setMark(int offset) {
-
- // clear
- if (offset == -1) {
- if (fMarkPosition != null && !fMarkPosition.isDeleted()) {
-
- IDocument document= getDocument();
- if (document != null)
- document.removePosition(fMarkPosition);
- }
-
- fMarkPosition= null;
-
- markChanged(-1, 0);
-
- // set
- } else {
-
- IDocument document= getDocument();
- if (document == null) {
- fMarkPosition= null;
- return;
- }
-
- if (fMarkPosition != null)
- document.removePosition(fMarkPosition);
-
- fMarkPosition= null;
-
- try {
-
- Position position= new Position(offset);
- document.addPosition(MARK_POSITION_CATEGORY, position);
- fMarkPosition= position;
-
- } catch (BadLocationException e) {
- return;
- } catch (BadPositionCategoryException e) {
- return;
- }
-
- markChanged(modelOffset2WidgetOffset(fMarkPosition.offset), 0);
- }
- }
-
- /*
- * @see Viewer#inputChanged(Object, Object)
- * @since 2.0
- */
- protected void inputChanged(Object newInput, Object oldInput) {
-
- IDocument oldDocument= (IDocument) oldInput;
- if (oldDocument != null) {
- if (fMarkPosition != null && !fMarkPosition.isDeleted())
- oldDocument.removePosition(fMarkPosition);
-
- try {
- oldDocument.removePositionUpdater(fMarkPositionUpdater);
- oldDocument.removePositionCategory(MARK_POSITION_CATEGORY);
-
- } catch (BadPositionCategoryException e) {
- }
- }
-
- fMarkPosition= null;
-
- super.inputChanged(newInput, oldInput);
-
- IDocument newDocument= (IDocument) newInput;
- if (newDocument != null) {
- newDocument.addPositionCategory(MARK_POSITION_CATEGORY);
- newDocument.addPositionUpdater(fMarkPositionUpdater);
- }
- }
-
- /**
- * Informs all text listeners about the change of the viewer's redraw state.
- * @since 2.0
- */
- private void fireRedrawChanged() {
- fWidgetCommand.start= 0;
- fWidgetCommand.length= 0;
- fWidgetCommand.text= null;
- fWidgetCommand.event= null;
- updateTextListeners(fWidgetCommand);
- }
-
- /**
- * Forgets the previously remembered selection position. After that
- * call the selection position can no longer be queried and is longer updated
- * in responds to content changes of the viewer.
- *
- * @return the remembered and updated selection position or <code>null</code> if no selection position has been remembered
- * @since 2.1
- */
- private Point forgetDocumentSelection() {
- if (fDocumentSelection == null)
- return null;
-
- Point selection= fDocumentSelection.isDeleted() ? null : fDocumentSelection.getSelection();
- IDocument document= getDocument();
- if (document != null)
- document.removePosition(fDocumentSelection);
- fDocumentSelection= null;
-
- return selection;
- }
-
- /**
- * Enables the redrawing of this text viewer.
- * @since 2.0
- */
- protected void enabledRedrawing() {
- if (fDocumentAdapter instanceof IDocumentAdapterExtension) {
- IDocumentAdapterExtension extension= (IDocumentAdapterExtension) fDocumentAdapter;
- StyledText textWidget= getTextWidget();
- if (textWidget != null && !textWidget.isDisposed()) {
- int topPixel= textWidget.getTopPixel();
- extension.resumeForwardingDocumentChanges();
- if (topPixel > -1) {
- try {
- textWidget.setTopPixel(topPixel);
- } catch (IllegalArgumentException x) {
- // changes don't allow for the previous top pixel
- }
- }
- }
- }
-
- Point selection= forgetDocumentSelection();
- if (selection != null) {
- setSelectedRange(selection.x, selection.y);
- revealRange(selection.x, selection.y);
- }
-
- if (fTextWidget != null && !fTextWidget.isDisposed())
- fTextWidget.setRedraw(true);
-
- fireRedrawChanged();
- }
-
- /**
- * Remembers the current selection in a <code>SelectionPosition</code> . The selection
- * position can be queried and is updated to changes made to the viewer's contents.
- * @since 2.1
- */
- private void rememberDocumentSelection() {
- Point selection= getSelectedRange();
- if (selection != null) {
- SelectionPosition p= new SelectionPosition(selection);
- IDocument document= getDocument();
- if (document != null) {
- try {
- document.addPosition(p);
- fDocumentSelection= p;
- } catch (BadLocationException x) {
- }
- }
- }
- }
-
- /**
- * Disables the redrawing of this text viewer. Subclasses may extend.
- * @since 2.0
- */
- protected void disableRedrawing() {
-
- rememberDocumentSelection();
-
- if (fDocumentAdapter instanceof IDocumentAdapterExtension) {
- IDocumentAdapterExtension extension= (IDocumentAdapterExtension) fDocumentAdapter;
- extension.stopForwardingDocumentChanges();
- }
-
- if (fTextWidget != null && !fTextWidget.isDisposed())
- fTextWidget.setRedraw(false);
-
- fireRedrawChanged();
- }
-
- /*
- * @see ITextViewerExtension#setRedraw(boolean)
- * @since 2.0
- */
- public final void setRedraw(boolean redraw) {
- if (!redraw) {
- if (fRedrawCounter == 0)
- disableRedrawing();
- ++ fRedrawCounter;
- } else {
- -- fRedrawCounter;
- if (fRedrawCounter == 0)
- enabledRedrawing();
- }
- }
-
- /**
- * Returns whether this viewer redraws itself.
- *
- * @return <code>true</code> if this viewer redraws itself
- * @since 2.0
- */
- protected final boolean redraws() {
- return fRedrawCounter <= 0;
- }
-
- /**
- * Starts the sequential rewrite mode of the viewer's document.
- *
- * @param normalized <code>true</code> if the rewrite is performed from the start to the end of the document
- * @since 2.0
- */
- protected final void startSequentialRewriteMode(boolean normalized) {
- IDocument document= getDocument();
- if (document instanceof IDocumentExtension) {
- IDocumentExtension extension= (IDocumentExtension) document;
- extension.startSequentialRewrite(normalized);
- }
- }
-
- /**
- * Sets the sequential rewrite mode of the viewer's document.
- * @since 2.0
- */
- protected final void stopSequentialRewriteMode() {
- IDocument document= getDocument();
- if (document instanceof IDocumentExtension) {
- IDocumentExtension extension= (IDocumentExtension) document;
- extension.stopSequentialRewrite();
- }
- }
-
- /*
- * @see org.eclipse.jface.text.ITextViewerExtension#getRewriteTarget()
- * @since 2.0
- */
- public IRewriteTarget getRewriteTarget() {
- if (fRewriteTarget == null)
- fRewriteTarget= new RewriteTarget();
- return fRewriteTarget;
- }
-
- /*
- * @see org.eclipse.jface.text.ITextViewerExtension2#getCurrentTextHover()
- */
- public ITextHover getCurrentTextHover() {
- if (fTextHoverManager == null)
- return null;
- return fTextHoverManager.getCurrentTextHover();
- }
-
- /*
- * @see org.eclipse.jface.text.ITextViewerExtension2#getHoverEventLocation()
- */
- public Point getHoverEventLocation() {
- if (fTextHoverManager == null)
- return null;
- return fTextHoverManager.getHoverEventLocation();
- }
-
- /**
- * Returns the paint manager of this viewer.
- *
- * @return the paint manager of this viewer
- * @since 2.1
- */
- protected PaintManager getPaintManager() {
- if (fPaintManager == null)
- fPaintManager= new PaintManager(this);
- return fPaintManager;
- }
-
- /**
- * Adds the given painter to this viewer. If the painter is already registered
- * this method is without effect.
- *
- * @param painter the painter to be added
- * @since 2.1
- */
- public void addPainter(IPainter painter) {
- getPaintManager().addPainter(painter);
- }
-
- /**
- * Removes the given painter from this viewer. If the painter has previously not been
- * added to this viewer this method is without effect.
- *
- * @param painter the painter to be removed
- * @since 2.1
- */
- public void removePainter(IPainter painter) {
- getPaintManager().removePainter(painter);
- }
-
- // ----------------------------------- conversions -------------------------------------------------------
-
- /*
- * @see org.eclipse.jface.text.ITextViewerExtension3#modelLine2WidgetLine(int)
- * @since 2.1
- */
- public int modelLine2WidgetLine(int modelLine) {
- if (fInformationMapping == null)
- return modelLine;
-
- try {
- return fInformationMapping.toImageLine(modelLine);
- } catch (BadLocationException x) {
- }
-
- return -1;
- }
-
- /*
- * @see org.eclipse.jface.text.ITextViewerExtension3#modelOffset2WidgetOffset(int)
- * @since 2.1
- */
- public int modelOffset2WidgetOffset(int modelOffset) {
- if (fInformationMapping == null)
- return modelOffset;
-
- try {
- return fInformationMapping.toImageOffset(modelOffset);
- } catch (BadLocationException x) {
- }
-
- return -1;
- }
-
- /*
- * @see org.eclipse.jface.text.ITextViewerExtension3#modelRange2WidgetRange(org.eclipse.jface.text.IRegion)
- * @since 2.1
- */
- public IRegion modelRange2WidgetRange(IRegion modelRange) {
- if (fInformationMapping == null)
- return modelRange;
-
- try {
-
- if (modelRange.getLength() < 0) {
- Region reversed= new Region(modelRange.getOffset() + modelRange.getLength(), -modelRange.getLength());
- IRegion result= fInformationMapping.toImageRegion(reversed);
- return new Region(result.getOffset() + result.getLength(), -result.getLength());
- } else {
- return fInformationMapping.toImageRegion(modelRange);
- }
-
- } catch (BadLocationException x) {
- }
-
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.ITextViewerExtension3#widgetlLine2ModelLine(int)
- * @since 2.1
- */
- public int widgetlLine2ModelLine(int widgetLine) {
- if (fInformationMapping == null)
- return widgetLine;
-
- try {
- return fInformationMapping.toOriginLine(widgetLine);
- } catch (BadLocationException x) {
- }
-
- return -1;
- }
-
- /*
- * @see org.eclipse.jface.text.ITextViewerExtension3#widgetOffset2ModelOffset(int)
- * @since 2.1
- */
- public int widgetOffset2ModelOffset(int widgetOffset) {
- if (fInformationMapping == null)
- return widgetOffset;
-
- try {
- return fInformationMapping.toOriginOffset(widgetOffset);
- } catch (BadLocationException x) {
- if (widgetOffset == getVisibleDocument().getLength()) {
- IRegion coverage= fInformationMapping.getCoverage();
- return coverage.getOffset() + coverage.getLength();
- }
- }
-
- return -1;
- }
-
- /*
- * @see org.eclipse.jface.text.ITextViewerExtension3#widgetRange2ModelRange(org.eclipse.jface.text.IRegion)
- * @since 2.1
- */
- public IRegion widgetRange2ModelRange(IRegion widgetRange) {
- if (fInformationMapping == null)
- return widgetRange;
-
- try {
-
- if (widgetRange.getLength() < 0) {
- Region reveresed= new Region(widgetRange.getOffset() + widgetRange.getLength(), -widgetRange.getLength());
- IRegion result= fInformationMapping.toOriginRegion(reveresed);
- return new Region(result.getOffset() + result.getLength(), -result.getLength());
- } else {
- return fInformationMapping.toOriginRegion(widgetRange);
- }
-
- } catch (BadLocationException x) {
- int modelOffset= widgetOffset2ModelOffset(widgetRange.getOffset());
- if (modelOffset > -1) {
- int modelEndOffset= widgetOffset2ModelOffset(widgetRange.getOffset() + widgetRange.getLength());
- if (modelEndOffset > -1)
- return new Region(modelOffset, modelEndOffset - modelOffset);
- }
- }
-
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.ITextViewerExtension3#getModelCoverage()
- * @since 2.1
- */
- public IRegion getModelCoverage() {
- if (fInformationMapping == null) {
- IDocument document= getDocument();
- if (document == null)
- return null;
- return new Region(0, document.getLength());
- }
-
- return fInformationMapping.getCoverage();
- }
-
- /**
- * Returns the line of the widget whose corresponding line in the viewer's document
- * is closest to the given line in the viewer's document.
- *
- * @param modelLine the line in the viewer's document
- * @return the line in the widget that corresponds best to the given line in the viewer's document
- * @since 2.1
- */
- protected int getClosestWidgetLineForModelLine(int modelLine) {
- if (fInformationMapping == null)
- return modelLine;
-
- try {
- return fInformationMapping.toClosestImageLine(modelLine);
- } catch (BadLocationException x) {
- }
-
- return -1;
- }
-
- /**
- * Translates a style range given relative to the viewer's document into style
- * ranges relative to the viewer's widget.
- *
- * @param range the style range in the coordinates of the viewer's document
- * @return the style range in the coordinates of the viewer's widget
- * @since 2.1
- */
- protected StyleRange modelStyleRange2WidgetStyleRange(StyleRange range) {
- IRegion region= modelRange2WidgetRange(new Region(range.start, range.length));
- if (region != null) {
- StyleRange result= (StyleRange) range.clone();
- result.start= region.getOffset();
- result.length= region.getLength();
- return result;
- }
- return null;
- }
-
- /**
- * @see #modelRange2WidgetRange(IRegion)
- *
- * @param modelPosition the position describing a range in the viewer's document
- * @return a region describing a range in the viewer's widget
- * @since 2.1
- */
- protected IRegion modelRange2WidgetRange(Position modelPosition) {
- return modelRange2WidgetRange(new Region(modelPosition.getOffset(), modelPosition.getLength()));
- }
-
- /**
- * Translates the widget region of the given verify event into
- * the corresponding region of the viewer's document.
- *
- * @param event the verify event
- * @return the region of the viewer's document corresponding to the verify event
- * @since 2.1
- */
- protected IRegion event2ModelRange(VerifyEvent event) {
-
- Region region= null;
- if (event.start <= event.end)
- region= new Region(event.start, event.end - event.start);
- else
- region= new Region(event.end, event.start - event.end);
-
- return widgetRange2ModelRange(region);
- }
-
- /**
- * Translates the given widget selection into the corresponding region
- * of the viewer's document.
- *
- * @param widgetSelection the widget selection
- * @return the region of the viewer's document corresponding to the widget selection
- * @since 2.1
- */
- protected Point widgetSelection2ModelSelection(Point widgetSelection) {
- IRegion region= new Region(widgetSelection.x, widgetSelection.y);
- region= widgetRange2ModelRange(region);
- return region == null ? null : new Point(region.getOffset(), region.getLength());
- }
-
- /**
- * Translates the given selection range of the viewer's document into
- * the corresponding widget range.
- *
- * @param modelSelection the selection range of the viewer's document
- * @return the widget range corresponding to the selection range
- * @since 2.1
- */
- protected Point modelSelection2WidgetSelection(Point modelSelection) {
- if (fInformationMapping == null)
- return modelSelection;
-
- try {
- IRegion region= new Region(modelSelection.x, modelSelection.y);
- region= fInformationMapping.toImageRegion(region);
- return new Point(region.getOffset(), region.getLength());
- } catch (BadLocationException x) {
- }
-
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.ITextViewerExtension3#widgetLineOfWidgetOffset(int)
- */
- public int widgetLineOfWidgetOffset(int widgetOffset) {
- IDocument document= getVisibleDocument();
- if (document != null) {
- try {
- return document.getLineOfOffset(widgetOffset);
- } catch (BadLocationException e) {
- }
- }
- return -1;
- }
-
- /*
- * @see org.eclipse.jface.text.ITextViewerExtension4#moveFocusToWidgetToken()
- * @since 3.0
- */
- public boolean moveFocusToWidgetToken() {
- if (fWidgetTokenKeeper instanceof IWidgetTokenKeeperExtension) {
- IWidgetTokenKeeperExtension extension= (IWidgetTokenKeeperExtension) fWidgetTokenKeeper;
- return extension.setFocus(this);
- } else {
- return false;
- }
- }
-
- /**
- * Sets the document partitioning of this viewer. The partitioning is used by this viewer to
- * access partitioning information of the viewers input document.
- *
- * @param partitioning the partitioning name
- * @since 3.0
- */
- public void setDocumentPartitioning(String partitioning) {
- fPartitioning= partitioning;
- }
-
- /**
- * Returns the document partitioning for this viewer.
- *
- * @return the document partitioning for this viewer
- * @since 3.0
- */
- protected String getDocumentPartitioning() {
- return fPartitioning;
- }
-
- //---- Text presentation listeners ----
-
- /*
- * @see ITextViewerExtension4#addTextPresentationListener(ITextPresentationListener)
- * @since 3.0
- */
- public void addTextPresentationListener(ITextPresentationListener listener) {
-
- Assert.isNotNull(listener);
-
- if (fTextPresentationListeners == null)
- fTextPresentationListeners= new ArrayList();
-
- if (!fTextPresentationListeners.contains(listener))
- fTextPresentationListeners.add(listener);
- }
-
- /*
- * @see ITextViewerExtension4#removeTextPresentationListener(ITextPresentationListener)
- * @since 3.0
- */
- public void removeTextPresentationListener(ITextPresentationListener listener) {
-
- Assert.isNotNull(listener);
-
- if (fTextPresentationListeners != null) {
- fTextPresentationListeners.remove(listener);
- if (fTextPresentationListeners.size() == 0)
- fTextPresentationListeners= null;
- }
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewerHoverManager.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewerHoverManager.java
deleted file mode 100644
index 43bd41c..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewerHoverManager.java
+++ /dev/null
@@ -1,416 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseMoveListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Display;
-
-
-/**
- * This manager controls the layout, content, and visibility of an information
- * control in reaction to mouse hover events issued by the text widget of a
- * text viewer. It overrides <code>computeInformation</code>, so that the
- * computation is performed in a dedicated background thread. This implies
- * that the used <code>ITextHover</code> objects must be capable of
- * operating in a non-UI thread.
- *
- * @since 2.0
- */
-class TextViewerHoverManager extends AbstractHoverInformationControlManager implements IWidgetTokenKeeper, IWidgetTokenKeeperExtension {
-
-
- /**
- * Priority of the hovers managed by this manager.
- * Default value: <code>0</code>;
- * @since 3.0
- */
- public final static int WIDGET_PRIORITY= 0;
-
-
- /** The text viewer */
- private TextViewer fTextViewer;
- /** The hover information computation thread */
- private Thread fThread;
- /** The stopper of the computation thread */
- private ITextListener fStopper;
- /** Internal monitor */
- private Object fMutex= new Object();
- /** The currently shown text hover. */
- private volatile ITextHover fTextHover;
- /**
- * Tells whether the next mouse hover event
- * should be processed.
- * @since 3.0
- */
- private boolean fProcessMouseHoverEvent= true;
- /**
- * Internal mouse move listener.
- * @since 3.0
- */
- private MouseMoveListener fMouseMoveListener;
- /**
- * Internal viewport listener.
- * @since 3.0
- */
- private IViewportListener fViewportListener;
-
-
- /**
- * Creates a new text viewer hover manager specific for the given text viewer.
- * The manager uses the given information control creator.
- *
- * @param textViewer the viewer for which the controller is created
- * @param creator the information control creator
- */
- public TextViewerHoverManager(TextViewer textViewer, IInformationControlCreator creator) {
- super(creator);
- fTextViewer= textViewer;
- fStopper= new ITextListener() {
- public void textChanged(TextEvent event) {
- synchronized (fMutex) {
- if (fThread != null) {
- fThread.interrupt();
- fThread= null;
- }
- }
- }
- };
- fViewportListener= new IViewportListener() {
- /*
- * @see org.eclipse.jface.text.IViewportListener#viewportChanged(int)
- */
- public void viewportChanged(int verticalOffset) {
- fProcessMouseHoverEvent= false;
- }
- };
- fTextViewer.addViewportListener(fViewportListener);
- fMouseMoveListener= new MouseMoveListener() {
- /*
- * @see MouseMoveListener#mouseMove(MouseEvent)
- */
- public void mouseMove(MouseEvent event) {
- fProcessMouseHoverEvent= true;
- }
- };
- fTextViewer.getTextWidget().addMouseMoveListener(fMouseMoveListener);
- }
-
- /**
- * Determines all necessary details and delegates the computation into
- * a background thread.
- */
- protected void computeInformation() {
-
- if (!fProcessMouseHoverEvent) {
- setInformation(null, null);
- return;
- }
-
- Point location= getHoverEventLocation();
- int offset= computeOffsetAtLocation(location.x, location.y);
- if (offset == -1) {
- setInformation(null, null);
- return;
- }
-
- final ITextHover hover= fTextViewer.getTextHover(offset, getHoverEventStateMask());
- if (hover == null) {
- setInformation(null, null);
- return;
- }
-
- final IRegion region= hover.getHoverRegion(fTextViewer, offset);
- if (region == null) {
- setInformation(null, null);
- return;
- }
-
- final Rectangle area= computeArea(region);
- if (area == null || area.isEmpty()) {
- setInformation(null, null);
- return;
- }
-
- if (fThread != null) {
- setInformation(null, null);
- return;
- }
-
- fThread= new Thread("Text Viewer Hover Presenter") { //$NON-NLS-1$
- public void run() {
- // http://bugs.eclipse.org/bugs/show_bug.cgi?id=17693
- boolean hasFinished= false;
- try {
- if (fThread != null) {
- String information;
- try {
- information= hover.getHoverInfo(fTextViewer, region);
- } catch (ArrayIndexOutOfBoundsException x) {
- /*
- * This code runs in a separate thread which can
- * lead to text offsets being out of bounds when
- * computing the hover info (see bug 32848).
- */
- information= null;
- }
-
- if (hover instanceof ITextHoverExtension)
- setCustomInformationControlCreator(((ITextHoverExtension) hover).getInformationControlCreator());
- else
- setCustomInformationControlCreator(null);
-
- setInformation(information, area);
- if (information != null && area != null)
- fTextHover= hover;
- } else {
- setInformation(null, null);
- }
- hasFinished= true;
- } finally {
- synchronized (fMutex) {
- if (fTextViewer != null)
- fTextViewer.removeTextListener(fStopper);
- fThread= null;
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=44756
- if (!hasFinished)
- setInformation(null, null);
- }
- }
- }
- };
-
- fThread.setDaemon(true);
- fThread.setPriority(Thread.MIN_PRIORITY);
- synchronized (fMutex) {
- fTextViewer.addTextListener(fStopper);
- fThread.start();
- }
- }
-
- /**
- * As computation is done in the background, this method is
- * also called in the background thread. Delegates the control
- * flow back into the ui thread, in order to allow displaying the
- * information in the information control.
- */
- protected void presentInformation() {
- if (fTextViewer == null)
- return;
-
- StyledText textWidget= fTextViewer.getTextWidget();
- if (textWidget != null && !textWidget.isDisposed()) {
- Display display= textWidget.getDisplay();
- if (display == null)
- return;
-
- display.asyncExec(new Runnable() {
- public void run() {
- doPresentInformation();
- }
- });
- }
- }
-
- /*
- * @see AbstractInformationControlManager#presentInformation()
- */
- protected void doPresentInformation() {
- super.presentInformation();
- }
-
- /**
- * Computes the document offset underlying the given text widget coordinates.
- * This method uses a linear search as it cannot make any assumption about
- * how the document is actually presented in the widget. (Covers cases such
- * as bidi text.)
- *
- * @param x the x coordinate inside the text widget
- * @param y the y coordinate inside the text widget
- * @return the document offset corresponding to the given point
- */
- private int computeOffsetAtLocation(int x, int y) {
-
- try {
-
- StyledText styledText= fTextViewer.getTextWidget();
- int widgetOffset= styledText.getOffsetAtLocation(new Point(x, y));
-
- if (fTextViewer instanceof ITextViewerExtension5) {
- ITextViewerExtension5 extension= (ITextViewerExtension5) fTextViewer;
- return extension.widgetOffset2ModelOffset(widgetOffset);
- }
-
- return widgetOffset + fTextViewer._getVisibleRegionOffset();
-
- } catch (IllegalArgumentException e) {
- return -1;
- }
- }
-
- /**
- * Determines graphical area covered by the given text region.
- *
- * @param region the region whose graphical extend must be computed
- * @return the graphical extend of the given region
- */
- private Rectangle computeArea(IRegion region) {
-
- IRegion widgetRegion= modelRange2WidgetRange(region);
- int start= widgetRegion.getOffset();
- int end= widgetRegion.getOffset() + widgetRegion.getLength();
-
- StyledText styledText= fTextViewer.getTextWidget();
- Point upperLeft= styledText.getLocationAtOffset(start);
- Point lowerRight= new Point(upperLeft.x, upperLeft.y);
-
- for (int i= start +1; i < end; i++) {
-
- Point p= styledText.getLocationAtOffset(i);
-
- if (upperLeft.x > p.x)
- upperLeft.x= p.x;
-
- if (upperLeft.y > p.y)
- upperLeft.y= p.y;
-
- if (lowerRight.x < p.x)
- lowerRight.x= p.x;
-
- if (lowerRight.y < p.y)
- lowerRight.y= p.y;
- }
-
- lowerRight.x += fTextViewer.getAverageCharWidth();
- lowerRight.y += styledText.getLineHeight();
-
- int width= lowerRight.x - upperLeft.x;
- int height= lowerRight.y - upperLeft.y;
- return new Rectangle(upperLeft.x, upperLeft.y, width, height);
- }
-
- /**
- * Translates a given region of the text viewer's document into
- * the corresponding region of the viewer's widget.
- *
- * @param region the document region
- * @return the corresponding widget region
- * @since 2.1
- */
- private IRegion modelRange2WidgetRange(IRegion region) {
- if (fTextViewer instanceof ITextViewerExtension5) {
- ITextViewerExtension5 extension= (ITextViewerExtension5) fTextViewer;
- return extension.modelRange2WidgetRange(region);
- }
-
- IRegion visibleRegion= fTextViewer.getVisibleRegion();
- int start= region.getOffset() - visibleRegion.getOffset();
- int end= start + region.getLength();
- if (end > visibleRegion.getLength())
- end= visibleRegion.getLength();
-
- return new Region(start, end - start);
- }
-
- /*
- * @see AbstractInformationControlManager#showInformationControl(Rectangle)
- */
- protected void showInformationControl(Rectangle subjectArea) {
- if (fTextViewer != null && fTextViewer.requestWidgetToken(this, WIDGET_PRIORITY))
- super.showInformationControl(subjectArea);
- }
-
- /*
- * @see AbstractInformationControlManager#hideInformationControl()
- */
- protected void hideInformationControl() {
- try {
- fTextHover= null;
- super.hideInformationControl();
- } finally {
- if (fTextViewer != null)
- fTextViewer.releaseWidgetToken(this);
- }
- }
-
- /*
- * @see AbstractInformationControlManager#handleInformationControlDisposed()
- */
- protected void handleInformationControlDisposed() {
- try {
- super.handleInformationControlDisposed();
- } finally {
- if (fTextViewer != null)
- fTextViewer.releaseWidgetToken(this);
- }
- }
-
- /*
- * @see IWidgetTokenKeeper#requestWidgetToken(IWidgetTokenOwner)
- */
- public boolean requestWidgetToken(IWidgetTokenOwner owner) {
- fTextHover= null;
- super.hideInformationControl();
- return true;
- }
-
- /*
- * @see org.eclipse.jface.text.IWidgetTokenKeeperExtension#requestWidgetToken(org.eclipse.jface.text.IWidgetTokenOwner, int)
- * @since 3.0
- */
- public boolean requestWidgetToken(IWidgetTokenOwner owner, int priority) {
- if (priority > WIDGET_PRIORITY) {
- fTextHover= null;
- super.hideInformationControl();
- return true;
- }
- return false;
- }
-
- /*
- * @see org.eclipse.jface.text.IWidgetTokenKeeperExtension#setFocus(org.eclipse.jface.text.IWidgetTokenOwner)
- * @since 3.0
- */
- public boolean setFocus(IWidgetTokenOwner owner) {
- return false;
- }
-
- /**
- * Returns the currently shown text hover or <code>null</code> if no text
- * hover is shown.
- *
- * @return the currently shown text hover or <code>null</code>
- */
- protected ITextHover getCurrentTextHover() {
- return fTextHover;
- }
-
- /*
- * @see org.eclipse.jface.text.AbstractHoverInformationControlManager#dispose()
- */
- public void dispose() {
- if (fTextViewer != null) {
- fTextViewer.removeViewportListener(fViewportListener);
- fViewportListener= null;
-
- StyledText st= fTextViewer.getTextWidget();
- if (st != null && !st.isDisposed())
- st.removeMouseMoveListener(fMouseMoveListener);
- fMouseMoveListener= null;
- }
- super.dispose();
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AbstractControlContentAssistSubjectAdapter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AbstractControlContentAssistSubjectAdapter.java
deleted file mode 100644
index 6eb1d59..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AbstractControlContentAssistSubjectAdapter.java
+++ /dev/null
@@ -1,900 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.contentassist;
-
-import java.util.ArrayList;
-import java.util.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.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseMoveListener;
-import org.eclipse.swt.events.MouseTrackAdapter;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-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.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-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.Label;
-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.text.IEventConsumer;
-
-
-/**
- * An <code>AbstractControlContentAssistSubjectAdapter</code> delegates assistance requests from a
- * {@link org.eclipse.jface.text.contentassist.IContentAssistantExtension content assistant}
- * to a <code>Control</code>.
- *
- * @since 3.0
- */
-public abstract class AbstractControlContentAssistSubjectAdapter implements IContentAssistSubject {
-
- 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}.
- *
- * @param control the control
- **/
- public AbstractControlContentAssistSubjectAdapter(Control control) {
- this(control, false);
- }
-
- /**
- * Creates a new {@link AbstractControlContentAssistSubjectAdapter}.
- *
- * @param control the control
- * @param showCue show cue on the left side of control
- */
- AbstractControlContentAssistSubjectAdapter(Control control, boolean showCue) {
- fVerifyKeyListeners= new ArrayList(1);
- fKeyListeners= new HashSet(1);
- setShowContentAssistCue(control, showCue);
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubject#getControl()
- */
- public abstract Control getControl();
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubject#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$
- }
-
- /**
- * Uninstalls this control content assist subject adapter.
- */
- public void uninstall() {
- setShowContentAssistCue(getControl(), false);
- }
-
- /**
- * Controls visibility of the visual cue for content assist.
- *
- * @param enable iff <code>true</code>, show cue
- */
- public void enableContentAssistCue(boolean enable) {
- }
-
- /**
- * Controls visibility of the visual cue for content assist.
- *
- * @param control the <code>Control</code>
- * @param enable iff <code>true</code>, show cue
- */
- private void setShowContentAssistCue(Control control, boolean enable) {
- SmartFieldController.setSmartCue(control, enable ? "Content Assist Available" : null);
- }
-
- /**
- * Sets the given error message in the field message hover.
- *
- * @param message the message, or <code>null</code> to clear
- */
- public void setErrorMessage(String message) {
- SmartFieldController.setErrorMessage(getControl(), message);
-
- }
-
- /**
- * The controller for cues and error messages on <code>Text</code> and <code>Combo</code> <code>Control</code>s.
- *
- * XXX: This is work in progress and can change anytime until API for 3.0 is frozen.
- *
- * @since 3.0
- */
- private static class SmartFieldController {
-
- class Hover {
- // info hover metrics
- private int HD= 10; // distance of arrow from left side
- private int HW= 8; // width of info hover arrow
- private int HH= 10; // height of info hover arrow
- private int MARGIN= 2;
-
- Shell fHoverShell;
- 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, MARGIN, MARGIN);
- if (!fgCarbon)
- pe.gc.drawPolygon(getPolygon(true));
- }
- });
- fHoverShell.addMouseListener(new MouseAdapter() {
- public void mouseDown(MouseEvent e) {
- updateHover2(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 };
- 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+= MARGIN*2;
- e.y+= MARGIN*2;
- return e;
- }
- }
-
- class Annotation {
-
- private Control fControl; // put icon relative to this control
- private Image fImage; // visual representation of this annotation
- private int fDx, fDy; // place icon relative to top-left corner of control
- private String fText; // the information shown in hover
-
- Annotation(Control control, Image image, int dy, String text) {
- fControl= control;
- fImage= image;
- fText= text;
- fDx= -5;
- fDy= dy;
- if (fgCarbon) {
- if (control instanceof Text) {
- fDy+= 3;
- } else if (control instanceof Combo) {
- fDx= -9;
- }
- } else if (fgWin32) {
- if (control instanceof Text) {
- fDx= -7;
- fDy-= 2;
- }
- }
- }
-
- void paintControl(PaintEvent e) {
- if (!fControl.isDisposed() && !fImage.isDisposed()) {
- Point global= fControl.toDisplay(fDx, fDy);
- Point local= ((Control) e.widget).toControl(global);
- e.gc.drawImage(fImage, local.x, local.y);
- }
- }
-
- boolean handleEvent(MouseEvent e) {
- if (!fImage.isDisposed()) {
- Rectangle r= fImage.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)) {
- updateHover2(fControl, fText);
- return true;
- }
- }
- return false;
- }
- }
-
- /**
- * One AnnotationHandler is registered for a given Control.
- */
- class AnnotationHandler extends MouseTrackAdapter implements MouseMoveListener, PaintListener {
-
- ArrayList fAnnotations= new ArrayList();
-
- public void paintControl(PaintEvent e) {
- Iterator iter= fAnnotations.iterator();
- while (iter.hasNext()) {
- Annotation a= (Annotation) iter.next();
- a.paintControl(e);
- }
- }
-
- void add(Annotation a) {
- fAnnotations.add(a);
- }
-
- boolean remove(Annotation a) {
- fAnnotations.remove(a);
- return fAnnotations.size() <= 0;
- }
-
- public void mouseEnter(MouseEvent e) {
- if (isTooltipVisible())
- update(e);
- }
-
- public void mouseHover(MouseEvent e) {
- update(e);
- }
-
- public void mouseMove(MouseEvent e) {
- if (isTooltipVisible())
- update(e);
- }
-
- public void mouseExit(MouseEvent e) {
- if (isTooltipVisible())
- update(e);
- }
-
- void update(MouseEvent e) {
- Iterator iter= fAnnotations.iterator();
- while (iter.hasNext()) {
- Annotation a= (Annotation) iter.next();
- if (a.handleEvent(e))
- return;
- }
- Control c= e.widget.getDisplay().getFocusControl();
- if (c != null)
- updateHover(c);
- else
- updateHover2(c, null);
- }
- }
-
- class ErrorAnnotationFocusListener implements FocusListener {
- public void focusGained(FocusEvent e) {
- updateHover((Control)e.widget);
- }
- public void focusLost(FocusEvent e) {
- updateHover2((Control)e.widget, null);
- }
- }
-
- class SmartAnnotationFocusListener implements FocusListener {
- Control fControl;
- Annotation fAnnotation;
-
- SmartAnnotationFocusListener(Control c, Annotation a) {
- fControl= c;
- fAnnotation= a;
- }
-
- public void focusGained(FocusEvent e) {
- addAnnotation(fControl, fAnnotation);
- }
-
- public void focusLost(FocusEvent e) {
- removeAnnotation(fControl, fAnnotation);
- }
- }
-
- private static final String FIELDCONTROLLER= "org.eclipse.SmartFieldController"; //$NON-NLS-1$
- private static final String SMARTFOCUSLISTENER= "org.eclipse.SmartFieldController.smartFocusListener"; //$NON-NLS-1$
- private static final String ANNOTATIONHANDLER= "org.eclipse.SmartFieldController.Listener"; //$NON-NLS-1$
- private static final String INFO_ANNOTATION= "org.eclipse.SmartFieldController.InfoAnnotation"; //$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 Image fBulb;
- private Shell fShell;
- private Hover fHover;
- private Control fHoverControl;
- private Image fErrorImage;
- private ErrorAnnotationFocusListener fErrorAnnotationFocusListener= new ErrorAnnotationFocusListener();
-
-
- /**
- * Shows or clears a message for the given control.
- *
- * @param control the control
- * @param message the error message
- */
- public static void setErrorMessage(Control control, String message) {
- getSmartFieldController(control).setInfo(control, message);
- }
-
- /**
- * Installs or deinstalls a visual cue indicating availability of content assist on the given control.
- *
- * @param control the control on which to install or uninstall the cue
- * @param message the tool tip message or <code>null</code> to uninstall the cue
- */
- public static void setSmartCue(Control control, String message) {
- getSmartFieldController(control).setSmartCue2(control, message);
- }
-
- //---- private implementation
-
- private SmartFieldController(Shell shell) {
- fShell= shell;
- fShell.setData(FIELDCONTROLLER, 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(FIELDCONTROLLER);
- if (data == SmartFieldController.this) {
- fShell.setData(FIELDCONTROLLER, null);
- handleDispose();
- }
- break;
- //case SWT.Activate:
- case SWT.Deactivate:
- case SWT.Close:
- case SWT.Iconify:
- //case SWT.Deiconify:
- updateHover2(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;
- if (fHover != null) {
- fHover.dispose();
- fHover= null;
- }
- if (fBulb != null) {
- fBulb.dispose();
- fBulb= null;
- }
- if (fErrorImage != null) {
- fErrorImage.dispose();
- fErrorImage= null;
- }
- }
-
- private static SmartFieldController getSmartFieldController(Control control) {
- Shell shell= control.getShell();
- Object data= shell.getData(FIELDCONTROLLER);
- if (! (data instanceof SmartFieldController))
- data= new SmartFieldController(shell);
- return (SmartFieldController) data;
- }
-
- private void setSmartCue2(final Control control, String message) {
-
- SmartAnnotationFocusListener focuslistener= null;
- Object data= control.getData(SMARTFOCUSLISTENER);
- if (data instanceof SmartAnnotationFocusListener)
- focuslistener= (SmartAnnotationFocusListener)data;
-
- if (message != null) {
- // add smart stuff
- Annotation annotation= null;
- if (focuslistener == null) {
- annotation= new Annotation(control, getLightBulb(), 10, message);
- focuslistener= new SmartAnnotationFocusListener(control, annotation);
- control.setData(SMARTFOCUSLISTENER, focuslistener);
- control.addFocusListener(focuslistener);
- } else {
- annotation= focuslistener.fAnnotation;
- annotation.fText= message;
- }
-
- if (hasFocus(control))
- addAnnotation(control, annotation);
- } else {
- // remove smart stuff
- Annotation annotation= null;
- if (focuslistener != null) {
- annotation= focuslistener.fAnnotation;
- control.removeFocusListener(focuslistener);
- }
- control.setData(SMARTFOCUSLISTENER, null);
-
- if (hasFocus(control) && annotation != null)
- removeAnnotation(control, annotation);
- }
- }
-
- private void setInfo(final Control control, String text) {
- if (text != null) {
- Annotation a= (Annotation) control.getData(INFO_ANNOTATION);
- if (a == null) {
- control.addFocusListener(fErrorAnnotationFocusListener);
- a= new Annotation(control, getErrorImage(), 0, text);
- control.setData(INFO_ANNOTATION, a);
- addAnnotation(control, a);
- } else {
- a.fText= text;
- }
- } else {
- control.removeFocusListener(fErrorAnnotationFocusListener);
- Object data= control.getData(INFO_ANNOTATION);
- if (data instanceof Annotation) {
- removeAnnotation(control, (Annotation) data);
- control.setData(INFO_ANNOTATION, null);
- }
- }
-
- if (hasFocus(control))
- updateHover(control);
- }
-
- private void updateHover(Control control) {
- String text= null;
- Annotation a= (Annotation) control.getData(INFO_ANNOTATION);
- if (a != null)
- text= a.fText;
- updateHover2(control, text);
- }
-
- private void updateHover2(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 isTooltipVisible() {
- return fHover != null && fHover.isVisible();
- }
-
- private static boolean hasFocus(Control control) {
- return control.getDisplay().getFocusControl() == control;
- }
-
- private Image getLightBulb() {
- if (fBulb == null) {
- ImageDescriptor bulbID= ImageDescriptor.createFromFile(SmartFieldController.class, "images/content_assist_cue.gif"); //$NON-NLS-1$
- fBulb= bulbID.createImage(fShell.getDisplay());
- }
- return fBulb;
- }
-
- private Image getErrorImage() {
- if (fErrorImage == null) {
- ImageDescriptor errorID= ImageDescriptor.createFromFile(SmartFieldController.class, "images/error_small.gif"); //$NON-NLS-1$
- fErrorImage= errorID.createImage(fShell.getDisplay());
- }
- return fErrorImage;
- }
-
- private void addAnnotation(Control control, Annotation a) {
- for (Control c= control.getParent(); c != null; c= c.getParent()) {
- AnnotationHandler pl= (AnnotationHandler) c.getData(ANNOTATIONHANDLER);
- if (pl == null) {
- pl= new AnnotationHandler();
- c.addPaintListener(pl);
- c.addMouseTrackListener(pl);
- c.addMouseMoveListener(pl);
- c.setData(ANNOTATIONHANDLER, pl);
- }
- pl.add(a);
- c.redraw();
- }
- }
-
- private void removeAnnotation(Control control, Annotation a) {
- for (Control c= control.getParent(); c != null; c= c.getParent()) {
- AnnotationHandler pl= (AnnotationHandler) c.getData(ANNOTATIONHANDLER);
- if (pl != null) {
- if (pl.remove(a)) {
- c.removePaintListener(pl);
- c.removeMouseTrackListener(pl);
- c.removeMouseMoveListener(pl);
- c.setData(ANNOTATIONHANDLER, null);
- }
- }
- c.redraw();
- }
- }
-
- static int fgCount;
-
- public static void main(String[] args) {
- Display display= new Display();
- Shell shell= new Shell(display);
- GridLayout gl= new GridLayout(2, false);
- shell.setLayout(gl);
-
- new Label(shell, SWT.NONE).setText("Smart Text:"); //$NON-NLS-1$
- final Text t= new Text(shell, SWT.BORDER);
- t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- t.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- String tx= t.getText();
- if (tx.indexOf(' ') >= 0)
- SmartFieldController.setErrorMessage(t, "spaces not allowed in " + tx); //$NON-NLS-1$
- else
- SmartFieldController.setErrorMessage(t, null);
- }
- });
- SmartFieldController.setSmartCue(t, "Content assist available"); //$NON-NLS-1$
-
- new Label(shell, SWT.NONE).setText("Smart Combo:"); //$NON-NLS-1$
- final Combo c= new Combo(shell, SWT.BORDER);
- c.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- c.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- String tx= c.getText();
- if (tx.indexOf('.') >= 0)
- SmartFieldController.setErrorMessage(c, "dots not allowed in " + tx); //$NON-NLS-1$
- else
- SmartFieldController.setErrorMessage(c, null);
- }
- });
- SmartFieldController.setSmartCue(c, "Quick assist available"); //$NON-NLS-1$
-
- new Label(shell, SWT.NONE).setText("Dumb Text:"); //$NON-NLS-1$
- final Text tt= new Text(shell, SWT.BORDER);
- tt.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- tt.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- String tx= tt.getText();
- if (tx.indexOf(' ') >= 0)
- SmartFieldController.setErrorMessage(tt, "spaces not allowed in " + tx); //$NON-NLS-1$
- else
- SmartFieldController.setErrorMessage(tt, null);
- }
- });
-
- new Label(shell, SWT.NONE).setText("Be Smart:"); //$NON-NLS-1$
- final Button b= new Button(shell, SWT.CHECK);
- b.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- boolean smart= b.getSelection();
- if (smart)
- SmartFieldController.setSmartCue(tt, "Content assist available " + fgCount++); //$NON-NLS-1$
- else
- SmartFieldController.setSmartCue(tt, null);
- }
- });
-
-
- shell.setLocation(200, 200);
- shell.open();
-
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
- }
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AdditionalInfoController.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AdditionalInfoController.java
deleted file mode 100644
index 7dae311..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AdditionalInfoController.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.contentassist;
-
-
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-
-import org.eclipse.jface.text.AbstractInformationControlManager;
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.IInformationControl;
-import org.eclipse.jface.text.IInformationControlCreator;
-import org.eclipse.jface.text.IInformationControlExtension3;
-
-
-
-/**
- * Displays the additional information available for a completion proposal.
- *
- * @since 2.0
- */
-class AdditionalInfoController extends AbstractInformationControlManager implements Runnable {
-
- /**
- * Internal table selection listener.
- */
- private class TableSelectionListener implements SelectionListener {
-
- /*
- * @see SelectionListener#widgetSelected(SelectionEvent)
- */
- public void widgetSelected(SelectionEvent e) {
- handleTableSelectionChanged();
- }
-
- /*
- * @see SelectionListener#widgetDefaultSelected(SelectionEvent)
- */
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- }
-
-
- /** The proposal table */
- private Table fProposalTable;
- /** The thread controlling the delayed display of the additional info */
- private Thread fThread;
- /** Indicates whether the display delay has been reset */
- private boolean fIsReset= false;
- /** Object to synchronize display thread and table selection changes */
- private final Object fMutex= new Object();
- /** Thread access lock. */
- private final Object fThreadAccess= new Object();
- /** Object to synchronize initial display of additonal info */
- private Object fStartSignal;
- /** The table selection listener */
- private SelectionListener fSelectionListener= new TableSelectionListener();
- /** The delay after which additional information is displayed */
- private int fDelay;
-
-
- /**
- * Creates a new additional information controller.
- *
- * @param creator the information control creator to be used by this controller
- * @param delay time in milliseconds after which additional info should be displayed
- */
- AdditionalInfoController(IInformationControlCreator creator, int delay) {
- super(creator);
- fDelay= delay;
- setAnchor(ANCHOR_RIGHT);
- setFallbackAnchors(new Anchor[] { ANCHOR_LEFT, ANCHOR_BOTTOM, ANCHOR_RIGHT });
- }
-
- /*
- * @see AbstractInformationControlManager#install(Control)
- */
- public void install(Control control) {
-
- if (fProposalTable == control) {
- // already installed
- return;
- }
-
- super.install(control);
-
- Assert.isTrue(control instanceof Table);
- fProposalTable= (Table) control;
- fProposalTable.addSelectionListener(fSelectionListener);
- synchronized (fThreadAccess) {
- if (fThread != null)
- fThread.interrupt();
- fThread= new Thread(this, JFaceTextMessages.getString("InfoPopup.info_delay_timer_name")); //$NON-NLS-1$
-
- fStartSignal= new Object();
- synchronized (fStartSignal) {
- fThread.start();
- try {
- // wait until thread is ready
- fStartSignal.wait();
- } catch (InterruptedException x) {
- }
- }
- }
- }
-
- /*
- * @see AbstractInformationControlManager#disposeInformationControl()
- */
- public void disposeInformationControl() {
-
- synchronized (fThreadAccess) {
- if (fThread != null) {
- fThread.interrupt();
- fThread= null;
- }
- }
-
- if (fProposalTable != null && !fProposalTable.isDisposed()) {
- fProposalTable.removeSelectionListener(fSelectionListener);
- fProposalTable= null;
- }
-
- super.disposeInformationControl();
- }
-
- /*
- * @see java.lang.Runnable#run()
- */
- public void run() {
- try {
- while (true) {
-
- synchronized (fMutex) {
-
- if (fStartSignal != null) {
- synchronized (fStartSignal) {
- fStartSignal.notifyAll();
- fStartSignal= null;
- }
- }
-
- // Wait for a selection event to occur.
- fMutex.wait();
-
- while (true) {
- fIsReset= false;
- // Delay before showing the popup.
- fMutex.wait(fDelay);
- if (!fIsReset)
- break;
- }
- }
-
- if (fProposalTable != null && !fProposalTable.isDisposed()) {
- fProposalTable.getDisplay().asyncExec(new Runnable() {
- public void run() {
- if (!fIsReset)
- showInformation();
- }
- });
- }
-
- }
- } catch (InterruptedException e) {
- }
-
- synchronized (fThreadAccess) {
- // only null fThread if it is us!
- if (Thread.currentThread() == fThread)
- fThread= null;
- }
- }
-
- /**
- *Handles a change of the line selected in the associated selector.
- */
- public void handleTableSelectionChanged() {
-
- if (fProposalTable != null && !fProposalTable.isDisposed() && fProposalTable.isVisible()) {
- synchronized (fMutex) {
- fIsReset= true;
- fMutex.notifyAll();
- }
- }
- }
-
- /*
- * @see AbstractInformationControlManager#computeInformation()
- */
- protected void computeInformation() {
-
- if (fProposalTable == null || fProposalTable.isDisposed())
- return;
-
- TableItem[] selection= fProposalTable.getSelection();
- if (selection != null && selection.length > 0) {
-
- TableItem item= selection[0];
-
- // compute information
- String information= null;
- Object d= item.getData();
-
- if (d instanceof ICompletionProposal) {
- ICompletionProposal p= (ICompletionProposal) d;
- information= p.getAdditionalProposalInfo();
- }
-
- if (d instanceof ICompletionProposalExtension3)
- setCustomInformationControlCreator(((ICompletionProposalExtension3) d).getInformationControlCreator());
- else
- setCustomInformationControlCreator(null);
-
- // compute subject area
- setMargins(4, -2);
- Rectangle area= fProposalTable.getBounds();
- area.x= 0; // subject area is the whole subject control
- area.y= 0;
-
- // set information & subject area
- setInformation(information, area);
- }
- }
-
- /*
- * @see org.eclipse.jface.text.AbstractInformationControlManager#computeSizeConstraints(Control, IInformationControl)
- */
- protected Point computeSizeConstraints(Control subjectControl, IInformationControl informationControl) {
- Point sizeConstraint= super.computeSizeConstraints(subjectControl, informationControl);
- Point size= subjectControl.getSize();
-
- Rectangle otherTrim= subjectControl.getShell().computeTrim(0, 0, 0, 0);
- size.x += otherTrim.width;
- size.y += otherTrim.height;
-
- if (informationControl instanceof IInformationControlExtension3) {
- Rectangle thisTrim= ((IInformationControlExtension3)informationControl).computeTrim();
- size.x -= thisTrim.width;
- size.y -= thisTrim.height;
- }
-
- if (sizeConstraint.x < size.x)
- sizeConstraint.x= size.x;
- if (sizeConstraint.y < size.y)
- sizeConstraint.y= size.y;
- return sizeConstraint;
- }
-}
-
-
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ComboContentAssistSubjectAdapter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ComboContentAssistSubjectAdapter.java
deleted file mode 100644
index dac3279..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ComboContentAssistSubjectAdapter.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.contentassist;
-
-import java.util.HashMap;
-
-import 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>IContentAssistSubject</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.text.contentassist.IContentAssistSubject
- * @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 adapter for the given combo.
- *
- * @param combo the combo to adapt
- */
- public ComboContentAssistSubjectAdapter(Combo combo) {
- this(combo, true);
- }
-
- /**
- * Creates a content assist subject adapter for the given combo.
- *
- * @param combo the combo to adapt
- * @param showCue show cue on the left side of control
- */
- public ComboContentAssistSubjectAdapter(Combo combo, boolean showCue) {
- super(combo, showCue);
- Assert.isNotNull(combo);
- fCombo= combo;
- fModifyListeners= new HashMap();
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubject#getControl()
- */
- public Control getControl() {
- return fCombo;
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubject#getLineHeight()
- */
- public int getLineHeight() {
- return fCombo.getTextHeight();
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubject#getCaretOffset()
- */
- public int getCaretOffset() {
- return fCombo.getSelection().y;
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubject#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.IContentAssistSubject#getSelectionRange()
- */
- public Point getWidgetSelectionRange() {
- return new Point(fCombo.getSelection().x, Math.abs(fCombo.getSelection().y - fCombo.getSelection().x));
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubject#getSelectedRange()
- */
- public Point getSelectedRange() {
- return new Point(fCombo.getSelection().x, Math.abs(fCombo.getSelection().y - fCombo.getSelection().x));
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubject#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.IContentAssistSubject#setSelectedRange(int, int)
- */
- public void setSelectedRange(int i, int j) {
- fCombo.setSelection(new Point(i, i+j));
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubject#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.IContentAssistSubject#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.IContentAssistSubject#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/text/contentassist/CompletionProposal.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposal.java
deleted file mode 100644
index a8957dd..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposal.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.contentassist;
-
-
-
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-
-
-
-/**
- * The standard implementation of the <code>ICompletionProposal</code> interface.
- */
-public final class CompletionProposal implements ICompletionProposal {
-
- /** The string to be displayed in the completion proposal popup */
- private String fDisplayString;
- /** The replacement string */
- private String fReplacementString;
- /** The replacement offset */
- private int fReplacementOffset;
- /** The replacement length */
- private int fReplacementLength;
- /** The cursor position after this proposal has been applied */
- private int fCursorPosition;
- /** The image to be displayed in the completion proposal popup */
- private Image fImage;
- /** The context information of this proposal */
- private IContextInformation fContextInformation;
- /** The additional info of this proposal */
- private String fAdditionalProposalInfo;
-
- /**
- * Creates a new completion proposal based on the provided information. The replacement string is
- * considered being the display string too. All remaining fields are set to <code>null</code>.
- *
- * @param replacementString the actual string to be inserted into the document
- * @param replacementOffset the offset of the text to be replaced
- * @param replacementLength the length of the text to be replaced
- * @param cursorPosition the position of the cursor following the insert relative to replacementOffset
- */
- public CompletionProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition) {
- this(replacementString, replacementOffset, replacementLength, cursorPosition, null, null, null, null);
- }
-
- /**
- * Creates a new completion proposal. All fields are initialized based on the provided information.
- *
- * @param replacementString the actual string to be inserted into the document
- * @param replacementOffset the offset of the text to be replaced
- * @param replacementLength the length of the text to be replaced
- * @param cursorPosition the position of the cursor following the insert relative to replacementOffset
- * @param image the image to display for this proposal
- * @param displayString the string to be displayed for the proposal
- * @param contextInformation the context information associated with this proposal
- * @param additionalProposalInfo the additional information associated with this proposal
- */
- public CompletionProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition, Image image, String displayString, IContextInformation contextInformation, String additionalProposalInfo) {
- Assert.isNotNull(replacementString);
- Assert.isTrue(replacementOffset >= 0);
- Assert.isTrue(replacementLength >= 0);
- Assert.isTrue(cursorPosition >= 0);
-
- fReplacementString= replacementString;
- fReplacementOffset= replacementOffset;
- fReplacementLength= replacementLength;
- fCursorPosition= cursorPosition;
- fImage= image;
- fDisplayString= displayString;
- fContextInformation= contextInformation;
- fAdditionalProposalInfo= additionalProposalInfo;
- }
-
- /*
- * @see ICompletionProposal#apply(IDocument)
- */
- public void apply(IDocument document) {
- try {
- document.replace(fReplacementOffset, fReplacementLength, fReplacementString);
- } catch (BadLocationException x) {
- // ignore
- }
- }
-
- /*
- * @see ICompletionProposal#getSelection(IDocument)
- */
- public Point getSelection(IDocument document) {
- return new Point(fReplacementOffset + fCursorPosition, 0);
- }
-
- /*
- * @see ICompletionProposal#getContextInformation()
- */
- public IContextInformation getContextInformation() {
- return fContextInformation;
- }
-
- /*
- * @see ICompletionProposal#getImage()
- */
- public Image getImage() {
- return fImage;
- }
-
- /*
- * @see ICompletionProposal#getDisplayString()
- */
- public String getDisplayString() {
- if (fDisplayString != null)
- return fDisplayString;
- return fReplacementString;
- }
-
- /*
- * @see ICompletionProposal#getAdditionalProposalInfo()
- */
- public String getAdditionalProposalInfo() {
- return fAdditionalProposalInfo;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java
deleted file mode 100644
index ad88d34..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java
+++ /dev/null
@@ -1,1089 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.contentassist;
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.ControlListener;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.events.VerifyEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentListener;
-import org.eclipse.jface.text.IRewriteTarget;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.ITextViewerExtension;
-import org.eclipse.jface.text.TextUtilities;
-
-
-
-/**
- * This class is used to present proposals to the user. If additional
- * information exists for a proposal, then selecting that proposal
- * will result in the information being displayed in a secondary
- * window.
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal
- * @see org.eclipse.jface.text.contentassist.AdditionalInfoController
- */
-class CompletionProposalPopup implements IContentAssistListener {
-
- private final class MyKeyListener implements KeyListener {
- public void keyPressed(KeyEvent e) {
- if (!Helper.okToUse(fProposalShell))
- return;
-
- if (e.character == 0 && e.keyCode == SWT.MOD1) {
- // http://dev.eclipse.org/bugs/show_bug.cgi?id=34754
- int index= fProposalTable.getSelectionIndex();
- if (index >= 0)
- selectProposal(index, true);
- }
- }
-
- public void keyReleased(KeyEvent e) {
- if (!Helper.okToUse(fProposalShell))
- return;
-
- if (e.character == 0 && e.keyCode == SWT.MOD1) {
- // http://dev.eclipse.org/bugs/show_bug.cgi?id=34754
- int index= fProposalTable.getSelectionIndex();
- if (index >= 0)
- selectProposal(index, false);
- }
- }
- }
-
- /** The associated text viewer */
- private ITextViewer fViewer;
- /** The associated content assistant */
- private ContentAssistant fContentAssistant;
- /** The used additional info controller */
- private AdditionalInfoController fAdditionalInfoController;
- /** The closing strategy for this completion proposal popup */
- private PopupCloser fPopupCloser= new PopupCloser();
- /** The popup shell */
- private Shell fProposalShell;
- /** The proposal table */
- private Table fProposalTable;
- /** Indicates whether a completion proposal is being inserted */
- private boolean fInserting= false;
- /** The key listener to control navigation */
- private 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 proposals have been filtered */
- private int fFilterOffset;
- /** The default line delimiter of the viewer's widget */
- private String fLineDelimiter;
- /** The most recently selected proposal. */
- private ICompletionProposal fLastProposal;
- /**
- * The content assist subject.
- * This replaces <code>fViewer</code>
- *
- * @since 3.0
- */
- private IContentAssistSubject fContentAssistSubject;
- /**
- * The content assist subject adapter.
- * This replaces <code>fViewer</code>
- *
- * @since 3.0
- */
- private ContentAssistSubjectAdapter fContentAssistSubjectAdapter;
- /**
- * Remembers the size for this completion proposal popup.
- * @since 3.0
- */
- private Point fSize;
-
- /**
- * Creates a new completion proposal popup for the given elements.
- *
- * @param contentAssistant the content assistant feeding this popup
- * @param viewer the viewer on top of which this popup appears
- * @param infoController the information control collaborating with this popup
- * @since 2.0
- * @deprecated, as of 3.0 use {@link #CompletionProposalPopup(ContentAssistant, IContentAssistSubject, AdditionalInfoController)
- */
- public CompletionProposalPopup(ContentAssistant contentAssistant, ITextViewer viewer, AdditionalInfoController infoController) {
- fContentAssistant= contentAssistant;
- fViewer= viewer;
- fAdditionalInfoController= infoController;
- fContentAssistSubjectAdapter= new ContentAssistSubjectAdapter(fViewer);
- }
-
- /**
- * Creates a new completion proposal popup for the given elements.
- *
- * @param contentAssistant the content assistant feeding this popup
- * @param contentAssistSubject the content assist subject on top of which this popup appears
- * @param infoController the information control collaborating with this popup
- * @since 3.0
- */
- public CompletionProposalPopup(ContentAssistant contentAssistant, IContentAssistSubject contentAssistSubject, AdditionalInfoController infoController) {
- fContentAssistant= contentAssistant;
- fContentAssistSubject= contentAssistSubject;
- fAdditionalInfoController= infoController;
- fContentAssistSubjectAdapter= new ContentAssistSubjectAdapter(fContentAssistSubject);
- }
-
- /**
- * Computes and presents completion proposals. The flag indicates whether this call has
- * be made out of an auto activation context.
- *
- * @param autoActivated <code>true</code> if auto activation context
- * @return an error message or <code>null</code> in case of no error
- */
- public String showProposals(final boolean autoActivated) {
-
- if (fKeyListener == null) {
- fKeyListener= new MyKeyListener();
- }
-
- final Control control= fContentAssistSubjectAdapter.getControl();
-
- // add the listener before computing the proposals so we don't move the caret
- // when the user types fast.
- if (!Helper.okToUse(fProposalShell) && control != null && !control.isDisposed())
- fContentAssistSubjectAdapter.addKeyListener(fKeyListener);
-
- BusyIndicator.showWhile(control.getDisplay(), new Runnable() {
- public void run() {
-
- fInvocationOffset= fContentAssistSubjectAdapter.getSelectedRange().x;
- fFilterOffset= fInvocationOffset;
- fComputedProposals= computeProposals(fInvocationOffset);
-
- int count= (fComputedProposals == null ? 0 : fComputedProposals.length);
- if (count == 0) {
-
- if (!autoActivated)
- control.getDisplay().beep();
-
- hide();
-
- } else {
-
- if (count == 1 && !autoActivated && fContentAssistant.isAutoInserting()) {
-
- insertProposal(fComputedProposals[0], (char) 0, 0, fInvocationOffset);
- hide();
-
- } else {
-
- if (fLineDelimiter == null)
- fLineDelimiter= fContentAssistSubjectAdapter.getLineDelimiter();
-
- createProposalSelector();
- setProposals(fComputedProposals);
- displayProposals();
- }
- }
- }
- });
-
- return getErrorMessage();
- }
-
- /**
- * Returns the completion proposal available at the given offset of the
- * viewer's document. Delegates the work to the content assistant.
- *
- * @param offset the offset
- * @return the completion proposals available at this offset
- */
- private ICompletionProposal[] computeProposals(int offset) {
- if (fContentAssistSubject != null)
- return fContentAssistant.computeCompletionProposals(fContentAssistSubject, offset);
- else
- return fContentAssistant.computeCompletionProposals(fViewer, offset);
- }
-
- /**
- * Returns the error message.
- *
- * @return the error message
- */
- private String getErrorMessage() {
- return fContentAssistant.getErrorMessage();
- }
-
- /**
- * Creates the proposal selector.
- */
- private void createProposalSelector() {
- if (Helper.okToUse(fProposalShell))
- return;
-
- Control control= fContentAssistSubjectAdapter.getControl();
- fProposalShell= new Shell(control.getShell(), SWT.ON_TOP | SWT.RESIZE );
- fProposalTable= new Table(fProposalShell, SWT.H_SCROLL | SWT.V_SCROLL);
-
- fProposalTable.setLocation(0, 0);
- if (fAdditionalInfoController != null)
- fAdditionalInfoController.setSizeConstraints(50, 10, true, false);
-
- GridLayout layout= new GridLayout();
- layout.marginWidth= 0;
- layout.marginHeight= 0;
- fProposalShell.setLayout(layout);
-
- GridData data= new GridData(GridData.FILL_BOTH);
-
-
- Point size= fContentAssistant.restoreCompletionProposalPopupSize();
- if (size != null) {
- fProposalTable.setLayoutData(data);
- fProposalShell.setSize(size);
- } else {
- data.heightHint= fProposalTable.getItemHeight() * 10;
- data.widthHint= 300;
- fProposalTable.setLayoutData(data);
- fProposalShell.pack();
- }
-
- fProposalShell.addControlListener(new ControlListener() {
-
- public void controlMoved(ControlEvent e) {}
-
- public void controlResized(ControlEvent e) {
- if (fAdditionalInfoController != null) {
- // reset the cached resize constraints
- fAdditionalInfoController.setSizeConstraints(50, 10, true, false);
- }
-
- fSize= fProposalShell.getSize();
- }
- });
-
- if (!"carbon".equals(SWT.getPlatform())) //$NON-NLS-1$
- fProposalShell.setBackground(control.getDisplay().getSystemColor(SWT.COLOR_BLACK));
-
- Color c= fContentAssistant.getProposalSelectorBackground();
- if (c == null)
- c= control.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND);
- fProposalTable.setBackground(c);
-
- c= fContentAssistant.getProposalSelectorForeground();
- if (c == null)
- c= control.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND);
- fProposalTable.setForeground(c);
-
- fProposalTable.addSelectionListener(new SelectionListener() {
-
- public void widgetSelected(SelectionEvent e) {}
-
- public void widgetDefaultSelected(SelectionEvent e) {
- selectProposalWithMask(e.stateMask);
- }
- });
-
- fPopupCloser.install(fContentAssistant, fProposalTable);
-
- fProposalShell.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- unregister(); // but don't dispose the shell, since we're being called from its disposal event!
- }
- });
-
- fProposalTable.setHeaderVisible(false);
- fContentAssistant.addToLayout(this, fProposalShell, ContentAssistant.LayoutManager.LAYOUT_PROPOSAL_SELECTOR, fContentAssistant.getSelectionOffset());
- }
-
- /**
- * Returns the proposal selected in the proposal selector.
- *
- * @return the selected proposal
- * @since 2.0
- */
- private ICompletionProposal getSelectedProposal() {
- int i= fProposalTable.getSelectionIndex();
- if (fFilteredProposals == null || i < 0 || i >= fFilteredProposals.length)
- return null;
- return fFilteredProposals[i];
- }
-
- /**
- * Takes the selected proposal and applies it.
- *
- * @param stateMask the state mask
- * @since 2.1
- */
- private void selectProposalWithMask(int stateMask) {
- ICompletionProposal p= getSelectedProposal();
- hide();
- if (p != null)
- insertProposal(p, (char) 0, stateMask, fContentAssistSubjectAdapter.getSelectedRange().x);
- }
-
- /**
- * Applies the given proposal at the given offset. The given character is the
- * one that triggered the insertion of this proposal.
- *
- * @param p the completion proposal
- * @param trigger the trigger character
- * @param stateMask the state mask
- * @param offset the offset
- * @since 2.1
- */
- private void insertProposal(ICompletionProposal p, char trigger, int stateMask, int offset) {
-
- fInserting= true;
- IRewriteTarget target= null;
-
- try {
-
- IDocument document= fContentAssistSubjectAdapter.getDocument();
-
- if (fViewer instanceof ITextViewerExtension) {
- ITextViewerExtension extension= (ITextViewerExtension) fViewer;
- target= extension.getRewriteTarget();
- }
-
- if (target != null)
- target.beginCompoundChange();
-
- if (p instanceof ICompletionProposalExtension2 && fViewer != null) {
- ICompletionProposalExtension2 e= (ICompletionProposalExtension2) p;
- e.apply(fViewer, trigger, stateMask, offset);
- } else if (p instanceof ICompletionProposalExtension) {
- ICompletionProposalExtension e= (ICompletionProposalExtension) p;
- e.apply(document, trigger, offset);
- } else {
- p.apply(document);
- }
-
- Point selection= p.getSelection(document);
- if (selection != null) {
- fContentAssistSubjectAdapter.setSelectedRange(selection.x, selection.y);
- fContentAssistSubjectAdapter.revealRange(selection.x, selection.y);
- }
-
- IContextInformation info= p.getContextInformation();
- if (info != null) {
-
- int position;
- if (p instanceof ICompletionProposalExtension) {
- ICompletionProposalExtension e= (ICompletionProposalExtension) p;
- position= e.getContextInformationPosition();
- } else {
- if (selection == null)
- selection= fContentAssistSubjectAdapter.getSelectedRange();
- position= selection.x + selection.y;
- }
-
- fContentAssistant.showContextInformation(info, position);
- }
-
- } finally {
- if (target != null)
- target.endCompoundChange();
- fInserting= false;
- }
- }
-
- /**
- * Returns whether this popup has the focus.
- *
- * @return <code>true</code> if the popup has the focus
- */
- public boolean hasFocus() {
- if (Helper.okToUse(fProposalShell))
- return (fProposalShell.isFocusControl() || fProposalTable.isFocusControl());
-
- return false;
- }
-
- /**
- * Hides this popup.
- */
- public void hide() {
-
- unregister();
-
- if (Helper.okToUse(fProposalShell)) {
-
- fContentAssistant.removeContentAssistListener(this, ContentAssistant.PROPOSAL_SELECTOR);
-
- fPopupCloser.uninstall();
- fProposalShell.setVisible(false);
- fProposalShell.dispose();
- fProposalShell= null;
- }
- }
-
- private void unregister() {
- if (fDocumentListener != null) {
- IDocument document= fContentAssistSubjectAdapter.getDocument();
- if (document != null)
- document.removeDocumentListener(fDocumentListener);
- fDocumentListener= null;
- }
- fDocumentEvents.clear();
-
- if (fKeyListener != null && fContentAssistSubjectAdapter.getControl() != null && !fContentAssistSubjectAdapter.getControl().isDisposed()) {
- fContentAssistSubjectAdapter.removeKeyListener(fKeyListener);
- fKeyListener= null;
- }
-
- if (fLastProposal != null) {
- if (fLastProposal instanceof ICompletionProposalExtension2 && fViewer != null) {
- ICompletionProposalExtension2 extension= (ICompletionProposalExtension2) fLastProposal;
- extension.unselected(fViewer);
- }
- fLastProposal= null;
- }
-
- fFilteredProposals= null;
- fComputedProposals= null;
-
- fContentAssistant.possibleCompletionsClosed();
- }
-
- /**
- *Returns whether this popup is active. It is active if the propsal selector is visible.
- *
- * @return <code>true</code> if this popup is active
- */
- public boolean isActive() {
- return fProposalShell != null && !fProposalShell.isDisposed();
- }
-
- /**
- * Initializes the proposal selector with these given proposals.
- *
- * @param proposals the proposals
- */
- private void setProposals(ICompletionProposal[] proposals) {
- if (Helper.okToUse(fProposalTable)) {
-
- ICompletionProposal oldProposal= getSelectedProposal();
- if (oldProposal instanceof ICompletionProposalExtension2 && fViewer != null)
- ((ICompletionProposalExtension2) oldProposal).unselected(fViewer);
-
- fFilteredProposals= proposals;
-
- fProposalTable.setRedraw(false);
- fProposalTable.removeAll();
-
- TableItem item;
- ICompletionProposal p;
- for (int i= 0; i < proposals.length; i++) {
- p= proposals[i];
- item= new TableItem(fProposalTable, SWT.NULL);
- if (p.getImage() != null)
- item.setImage(p.getImage());
- item.setText(p.getDisplayString());
- item.setData(p);
- }
-
- Point currentLocation= fProposalShell.getLocation();
- Point newLocation= getLocation();
- if ((newLocation.x < currentLocation.x && newLocation.y == currentLocation.y) || newLocation.y < currentLocation.y)
- fProposalShell.setLocation(newLocation);
-
- selectProposal(0, false);
- fProposalTable.setRedraw(true);
- }
- }
-
- /**
- * Returns the graphical location at which this popup should be made visible.
- *
- * @return the location of this popup
- */
- private Point getLocation() {
- int caret= fContentAssistSubjectAdapter.getCaretOffset();
- Point p= fContentAssistSubjectAdapter.getLocationAtOffset(caret);
- if (p.x < 0) p.x= 0;
- if (p.y < 0) p.y= 0;
- p= new Point(p.x, p.y + fContentAssistSubjectAdapter.getLineHeight());
- p= fContentAssistSubjectAdapter.getControl().toDisplay(p);
- if (p.x < 0) p.x= 0;
- if (p.y < 0) p.y= 0;
- return p;
- }
-
- Point getSize() {
- return fSize;
- }
-
- /**
- * Displays this popup and install the additional info controller, so that additional info
- * is displayed when a proposal is selected and additional info is available.
- */
- private void displayProposals() {
-
- if (!Helper.okToUse(fProposalShell) || !Helper.okToUse(fProposalTable))
- return;
-
- if (fContentAssistant.addContentAssistListener(this, ContentAssistant.PROPOSAL_SELECTOR)) {
-
- if (fDocumentListener == null)
- fDocumentListener= new IDocumentListener() {
- public void documentAboutToBeChanged(DocumentEvent event) {
- if (!fInserting)
- fDocumentEvents.add(event);
- }
-
- public void documentChanged(DocumentEvent event) {
- if (!fInserting)
- filterProposals();
- }
- };
- IDocument document= fContentAssistSubjectAdapter.getDocument();
- if (document != null)
- document.addDocumentListener(fDocumentListener);
-
- /* https://bugs.eclipse.org/bugs/show_bug.cgi?id=52646
- * on GTK, setVisible and such may run the event loop
- * (see also https://bugs.eclipse.org/bugs/show_bug.cgi?id=47511)
- * Since the user may have already canceled the popup or selected
- * an entry (ESC or RETURN), we have to double check whether
- * the table is still okToUse. See comments below
- */
- fProposalShell.setVisible(true); // may run event loop on GTK
- // XXX: transfer focus since no verify key listern can be attached
- if (!fContentAssistSubjectAdapter.supportsVerifyKeyListener() && Helper.okToUse(fProposalShell))
- fProposalShell.setFocus(); // may run event loop on GTK ??
-
- if (fAdditionalInfoController != null && Helper.okToUse(fProposalTable)) {
- fAdditionalInfoController.install(fProposalTable);
- fAdditionalInfoController.handleTableSelectionChanged();
- }
- }
- }
-
- /*
- * @see IContentAssistListener#verifyKey(VerifyEvent)
- */
- public boolean verifyKey(VerifyEvent e) {
- if (!Helper.okToUse(fProposalShell))
- return true;
-
- char key= e.character;
- if (key == 0) {
- int newSelection= fProposalTable.getSelectionIndex();
- int visibleRows= (fProposalTable.getSize().y / fProposalTable.getItemHeight()) - 1;
- boolean smartToggle= false;
- switch (e.keyCode) {
-
- case SWT.ARROW_LEFT :
- case SWT.ARROW_RIGHT :
- filterProposals();
- return true;
-
- case SWT.ARROW_UP :
- newSelection -= 1;
- if (newSelection < 0)
- newSelection= fProposalTable.getItemCount() - 1;
- break;
-
- case SWT.ARROW_DOWN :
- newSelection += 1;
- if (newSelection > fProposalTable.getItemCount() - 1)
- newSelection= 0;
- break;
-
- case SWT.PAGE_DOWN :
- newSelection += visibleRows;
- if (newSelection >= fProposalTable.getItemCount())
- newSelection= fProposalTable.getItemCount() - 1;
- break;
-
- case SWT.PAGE_UP :
- newSelection -= visibleRows;
- if (newSelection < 0)
- newSelection= 0;
- break;
-
- case SWT.HOME :
- newSelection= 0;
- break;
-
- case SWT.END :
- newSelection= fProposalTable.getItemCount() - 1;
- break;
-
- default :
- if (e.keyCode != SWT.MOD1 && e.keyCode != SWT.MOD2 && e.keyCode != SWT.MOD3 && e.keyCode != SWT.MOD4)
- hide();
- return true;
- }
-
- selectProposal(newSelection, smartToggle);
-
- e.doit= false;
- return false;
-
- } else {
-
- switch (key) {
- case 0x1B: // Esc
- e.doit= false;
- hide();
- break;
-
- case '\n': // Ctrl-Enter on w2k
- case '\r': // Enter
- e.doit= false;
- selectProposalWithMask(e.stateMask);
- break;
-
- case '\t':
- e.doit= false;
- fProposalShell.setFocus();
- return false;
-
- default:
- ICompletionProposal p= getSelectedProposal();
- if (p instanceof ICompletionProposalExtension) {
- ICompletionProposalExtension t= (ICompletionProposalExtension) p;
- char[] triggers= t.getTriggerCharacters();
- if (contains(triggers, key)) {
- e.doit= false;
- hide();
- insertProposal(p, key, e.stateMask, fContentAssistSubjectAdapter.getSelectedRange().x);
- }
- }
- }
- }
-
- return true;
- }
-
- /**
- * Selects the entry with the given index in the proposal selector and feeds
- * the selection to the additional info controller.
- *
- * @param index the index in the list
- * @param smartToggle <code>true</code> if the smart toogle key has been pressed
- * @since 2.1
- */
- private void selectProposal(int index, boolean smartToggle) {
-
- if (fFilteredProposals == null)
- return;
-
- ICompletionProposal oldProposal= getSelectedProposal();
- if (oldProposal instanceof ICompletionProposalExtension2 && fViewer != null)
- ((ICompletionProposalExtension2) oldProposal).unselected(fViewer);
-
- ICompletionProposal proposal= fFilteredProposals[index];
- if (proposal instanceof ICompletionProposalExtension2 && fViewer != null)
- ((ICompletionProposalExtension2) proposal).selected(fViewer, smartToggle);
-
- fLastProposal= proposal;
-
- fProposalTable.setSelection(index);
- fProposalTable.showSelection();
- if (fAdditionalInfoController != null)
- fAdditionalInfoController.handleTableSelectionChanged();
- }
-
- /**
- * Returns whether the given character is contained in the given array of
- * characters.
- *
- * @param characters the list of characters
- * @param c the character to look for in the list
- * @return <code>true</code> if character belongs to the list
- * @since 2.0
- */
- private boolean contains(char[] characters, char c) {
-
- if (characters == null)
- return false;
-
- for (int i= 0; i < characters.length; i++) {
- if (c == characters[i])
- return true;
- }
-
- return false;
- }
-
- /*
- * @see IEventConsumer#processEvent(VerifyEvent)
- */
- public void processEvent(VerifyEvent e) {
- }
-
- /**
- * Filters the displayed proposal based on the given cursor position and the
- * offset of the original invocation of the content assistant.
- */
- private void filterProposals() {
- ++ fInvocationCounter;
- final Control control= fContentAssistSubjectAdapter.getControl();
- control.getDisplay().asyncExec(new Runnable() {
- long fCounter= fInvocationCounter;
- public void run() {
-
- if (fCounter != fInvocationCounter)
- return;
-
- if (control.isDisposed())
- return;
-
- int offset= fContentAssistSubjectAdapter.getSelectedRange().x;
- ICompletionProposal[] proposals= null;
- try {
- if (offset > -1) {
- DocumentEvent event= TextUtilities.mergeProcessedDocumentEvents(fDocumentEvents);
- proposals= computeFilteredProposals(offset, event);
- }
- } catch (BadLocationException x) {
- } finally {
- fDocumentEvents.clear();
- }
- fFilterOffset= offset;
-
- if (proposals != null && proposals.length > 0)
- setProposals(proposals);
- else
- hide();
- }
- });
- }
-
- /**
- * Computes the subset of already computed proposals that are still valid for
- * the given offset.
- *
- * @param offset the offset
- * @param event the merged document event
- * @return the set of filtered proposals
- * @since 2.0
- */
- private ICompletionProposal[] computeFilteredProposals(int offset, DocumentEvent event) {
-
- if (offset == fInvocationOffset && event == null)
- return fComputedProposals;
-
- if (offset < fInvocationOffset) {
- fInvocationOffset= offset;
- fComputedProposals= computeProposals(fInvocationOffset);
- return fComputedProposals;
- }
-
- ICompletionProposal[] proposals= fComputedProposals;
- if (offset > fFilterOffset)
- proposals= fFilteredProposals;
-
- if (proposals == null)
- return null;
-
- IDocument document= fContentAssistSubjectAdapter.getDocument();
- int length= proposals.length;
- List filtered= new ArrayList(length);
- for (int i= 0; i < length; i++) {
-
- if (proposals[i] instanceof ICompletionProposalExtension2) {
-
- ICompletionProposalExtension2 p= (ICompletionProposalExtension2) proposals[i];
- if (p.validate(document, offset, event))
- filtered.add(p);
-
- } else if (proposals[i] instanceof ICompletionProposalExtension) {
-
- ICompletionProposalExtension p= (ICompletionProposalExtension) proposals[i];
- if (p.isValidFor(document, offset))
- filtered.add(p);
-
- } else {
- // restore original behavior
- fInvocationOffset= offset;
- fComputedProposals= computeProposals(fInvocationOffset);
- return fComputedProposals;
- }
- }
-
- ICompletionProposal[] p= new ICompletionProposal[filtered.size()];
- filtered.toArray(p);
- return p;
- }
-
- /**
- * Requests the proposal shell to take focus.
- *
- * @since 3.0
- */
- public void setFocus() {
- if (Helper.okToUse(fProposalShell)) {
- fProposalShell.setFocus();
- }
- }
-
- /**
- * Completes the common prefix of all proposals directly in the code. If no
- * common prefix can be found, the proposal popup is shown.
- *
- * @return an error message if completion failed.
- * @since 3.0
- */
- public String incrementalComplete() {
- if (Helper.okToUse(fProposalShell) && fFilteredProposals != null) {
- completeCommonPrefix();
- } else {
- final Control control= fContentAssistSubjectAdapter.getControl();
-
- if (fKeyListener == null)
- fKeyListener= new MyKeyListener();
-
- if (!Helper.okToUse(fProposalShell) && !control.isDisposed())
- fContentAssistSubjectAdapter.addKeyListener(fKeyListener);
-
- BusyIndicator.showWhile(control.getDisplay(), new Runnable() {
- public void run() {
-
- fInvocationOffset= fContentAssistSubjectAdapter.getSelectedRange().x;
- fFilterOffset= fInvocationOffset;
- fFilteredProposals= computeProposals(fInvocationOffset);
-
- int count= (fFilteredProposals == null ? 0 : fFilteredProposals.length);
- if (count == 0) {
- control.getDisplay().beep();
- hide();
- } else if (count == 1 && fContentAssistant.isAutoInserting()) {
- insertProposal(fFilteredProposals[0], (char) 0, 0, fInvocationOffset);
- hide();
- } else {
- if (fLineDelimiter == null)
- fLineDelimiter= fContentAssistSubjectAdapter.getLineDelimiter();
-
- if (completeCommonPrefix())
- hide(); // TODO add some caching? for now: just throw away the completions
- else {
- fComputedProposals= fFilteredProposals;
- createProposalSelector();
- setProposals(fComputedProposals);
- displayProposals();
- }
- }
- }
- });
- }
- return getErrorMessage();
- }
-
- /**
- * Acts upon <code>fFilteredProposals</code>: if there is just one valid
- * proposal, it is inserted, otherwise, the common prefix of all proposals
- * is inserted into the document. If there is no common prefix, <code>false</code>
- * is returned.
- *
- * @return <code>true</code> if common prefix insertion was successful, <code>false</code> otherwise
- * @since 3.0
- */
- private boolean completeCommonPrefix() {
-
- // 0: insert single proposals
- if (fFilteredProposals.length == 1) {
- insertProposal(fFilteredProposals[0], (char) 0, 0, fInvocationOffset);
- hide();
- return true;
- }
-
- // 1: get the common ignore-case prefix of all remaining proposals
- // note that the prefix still
- StringBuffer prefix= null; // the common prefix
- boolean isCaseCompatible= true;
- IDocument document= fContentAssistSubjectAdapter.getDocument();
- int startOffset= -1; // the location where the proposals would insert (< fInvocationOffset if invoked in the middle of an ident)
- String currentPrefix= null; // the prefix already in the document
- int currentPrefixLen= -1; // the length of the current prefix
- List caseFiltered= new ArrayList();
-
- for (int i= 0; i < fFilteredProposals.length; i++) {
- ICompletionProposal proposal= fFilteredProposals[i];
- CharSequence insertion= getReplacementString(proposal);
-
- if (currentPrefix == null) {
- startOffset= getReplacementOffset(proposal);
- currentPrefixLen= fFilterOffset - startOffset;
- try {
- // make sure we get the right case
- currentPrefix= document.get(startOffset, currentPrefixLen);
- } catch (BadLocationException e1) {
- // bail out silently
- return false;
- }
- }
-
- // prune ignore-case matches
- if (isCaseSensitive() && !insertion.toString().startsWith(currentPrefix))
- continue;
-
- caseFiltered.add(proposal);
-
- if (prefix == null)
- prefix= new StringBuffer(insertion.toString()); // initial
- else
- isCaseCompatible &= truncatePrefix(prefix, insertion);
-
- // early break computation if there is nothing left to check
- if (prefix.length() == 0)
- break;
- }
-
- if (prefix == null || currentPrefixLen > prefix.length() || prefix.toString().equals(currentPrefix))
- return false;
-
- // 2: replace / insert the common prefix in the document
-
- if (caseFiltered.size() == 1) {
- insertProposal((ICompletionProposal) caseFiltered.get(0), (char) 0, 0, fInvocationOffset);
- hide();
- return true;
- }
-
- try {
- String presentPart= prefix.substring(0, currentPrefixLen);
- int replaceOffset;
- int replaceLen;
- if (isCaseCompatible && !currentPrefix.equals(presentPart)) {
- // update case
- currentPrefixLen= 0;
- replaceOffset= startOffset;
- replaceLen= fFilterOffset - startOffset;
- } else {
- // only insert remaining part
- replaceOffset= fFilterOffset;
- replaceLen= 0;
- }
-
- int remainingLen= prefix.length() - currentPrefixLen;
- String remainingPrefix= prefix.subSequence(currentPrefixLen, currentPrefixLen + remainingLen).toString();
-
- document.replace(replaceOffset, replaceLen, remainingPrefix);
-
- fContentAssistSubjectAdapter.setSelectedRange(replaceOffset + remainingLen, 0);
- fContentAssistSubjectAdapter.revealRange(replaceOffset + remainingLen, 0);
-
- return true;
- } catch (BadLocationException e) {
- // ignore and return false
- return false;
- }
- }
-
- /**
- * Truncates <code>prefix</code> to the longest prefix it has in common with
- * <code>sequence</code> and returns <code>true</code> if the common prefix
- * has the same case for <code>prefix</code> and <code>sequence</code>.
- *
- * @param prefix the previous prefix that will get truncated to the prefix it has in common with <code>sequence</code>
- * @param sequence the character sequence to match
- * @return <code>true</code> if the match is case compatible, <code>false</code> if the common prefix differs in case
- * @since 3.0
- */
- private boolean truncatePrefix(StringBuffer prefix, CharSequence sequence) {
- // find common prefix
- int min= Math.min(prefix.length(), sequence.length());
- boolean caseCompatible= true;
- for (int c= 0; c < min; c++) {
- char compareChar= sequence.charAt(c);
- char prefixChar= prefix.charAt(c);
- if (prefixChar != compareChar) {
- if (isCaseSensitive() || Character.toLowerCase(prefixChar) != Character.toLowerCase(compareChar)) {
- prefix.delete(c, prefix.length());
- return caseCompatible;
- } else
- caseCompatible= false;
- }
- }
-
- prefix.delete(min, prefix.length());
- return caseCompatible;
- }
-
- /**
- * Returns whether common prefix completion should be case sensitive or not.
- * Returns <code>true</code> if no proposal popup is currently showing, <code>false</code> if there is.
- *
- * @return <code>true</code> if common prefix completion should be case sensitive, <code>false</code> otherwise
- * @since 3.0
- */
- private boolean isCaseSensitive() {
- return !Helper.okToUse(fProposalShell);
- }
-
- /**
- * Extracts the completion offset of an <code>ICompletionProposal</code>. If
- * <code>proposal</code> is a <code>ICompletionProposalExtension3</code>, its
- * <code>getCompletionOffset</code> method is called, otherwise, the invocation
- * offset of this popup is shown.
- *
- * @param proposal the proposal to extract the offset from
- * @return the proposals completion offset, or <code>fInvocationOffset</code>
- */
- private int getReplacementOffset(ICompletionProposal proposal) {
- if (proposal instanceof ICompletionProposalExtension3)
- return ((ICompletionProposalExtension3) proposal).getCompletionOffset();
- else
- return fInvocationOffset;
- }
-
- /**
- * Extracts the replacement string from an <code>ICompletionProposal</code>.
- * If <code>proposal</code> is a <code>ICompletionProposalExtension3</code>, its
- * <code>getCompletionText</code> method is called, otherwise, the display
- * string is used.
- *
- * @param proposal the proposal to extract the text from
- * @return the proposals completion text
- * @since 3.0
- */
- private CharSequence getReplacementString(ICompletionProposal proposal) {
- CharSequence insertion= null;
- if (proposal instanceof ICompletionProposalExtension3)
- insertion= ((ICompletionProposalExtension3) proposal).getCompletionText();
-
- if (insertion == null)
- insertion= proposal.getDisplayString();
-
- return insertion;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistSubjectAdapter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistSubjectAdapter.java
deleted file mode 100644
index 16afcdf..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistSubjectAdapter.java
+++ /dev/null
@@ -1,406 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.contentassist;
-
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.custom.VerifyKeyListener;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Control;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IEventConsumer;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.ITextViewerExtension;
-import org.eclipse.jface.text.contentassist.ContextInformationPopup.ContextFrame;
-
-/**
- * This content assist adapter delegates the calles either to
- * a text viewer or to a content assist subject.
- *
- * @since 3.0
- */
-final class ContentAssistSubjectAdapter implements IContentAssistSubject {
-
- /**
- * The text viewer which is used as content assist subject.
- */
- private ITextViewer fViewer;
-
- /**
- * The content assist subject.
- */
- private IContentAssistSubject fContentAssistSubject;
-
-
- /**
- * Creates an adapter for the given content assist subject.
- *
- * @param contentAssistSubject the content assist subject
- */
- public ContentAssistSubjectAdapter(IContentAssistSubject contentAssistSubject) {
- Assert.isNotNull(contentAssistSubject);
- fContentAssistSubject= contentAssistSubject;
- }
-
- /**
- * Creates an adapter for the given text viewer.
- *
- * @param viewer the text viewer
- */
- public ContentAssistSubjectAdapter(ITextViewer viewer) {
- Assert.isNotNull(viewer);
- fViewer= viewer;
- }
-
- /*
- * @see IContentAssistSubject#getLineHeight()
- */
- public int getLineHeight() {
- if (fContentAssistSubject != null)
- return fContentAssistSubject.getLineHeight();
- else
- return fViewer.getTextWidget().getLineHeight();
- }
-
- /*
- * @see IContentAssistSubject#getControl()
- */
- public Control getControl() {
- if (fContentAssistSubject != null)
- return fContentAssistSubject.getControl();
- else
- return fViewer.getTextWidget();
- }
-
- /*
- * @see IContentAssistSubject#getLocationAtOffset(int)
- */
- public Point getLocationAtOffset(int offset) {
- if (fContentAssistSubject != null)
- return fContentAssistSubject.getLocationAtOffset(offset);
- else
- return fViewer.getTextWidget().getLocationAtOffset(offset);
- }
-
- /*
- * @see IContentAssistSubject#getWidgetSelectionRange()
- */
- public Point getWidgetSelectionRange() {
- if (fContentAssistSubject != null)
- return fContentAssistSubject.getWidgetSelectionRange();
- else
- return fViewer.getTextWidget().getSelectionRange();
- }
-
- /*
- * @see IContentAssistSubject#getSelectedRange()
- */
- public Point getSelectedRange() {
- if (fContentAssistSubject != null)
- return fContentAssistSubject.getSelectedRange();
- else
- return fViewer.getSelectedRange();
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubject#getCaretOffset()
- */
- public int getCaretOffset() {
- if (fContentAssistSubject != null)
- return fContentAssistSubject.getCaretOffset();
- else
- return fViewer.getTextWidget().getCaretOffset();
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubject#getLineDelimiter()
- */
- public String getLineDelimiter() {
- if (fContentAssistSubject != null)
- return fContentAssistSubject.getLineDelimiter();
- else
- return fViewer.getTextWidget().getLineDelimiter();
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubject#addKeyListener(org.eclipse.swt.events.KeyListener)
- */
- public void addKeyListener(KeyListener keyListener) {
- if (fContentAssistSubject != null)
- fContentAssistSubject.addKeyListener(keyListener);
- else
- fViewer.getTextWidget().addKeyListener(keyListener);
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubject#removeKeyListener(org.eclipse.swt.events.KeyListener)
- */
- public void removeKeyListener(KeyListener keyListener) {
- if (fContentAssistSubject != null)
- fContentAssistSubject.removeKeyListener(keyListener);
- else
- fViewer.getTextWidget().removeKeyListener(keyListener);
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubject#getDocument()
- */
- public IDocument getDocument() {
- if (fContentAssistSubject != null)
- return fContentAssistSubject.getDocument();
- else
- return fViewer.getDocument();
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubject#prependVerifyKeyListener(VerifyKeyListener)
- */
- public boolean prependVerifyKeyListener(VerifyKeyListener verifyKeyListener) {
- if (fContentAssistSubject != null) {
- return fContentAssistSubject.prependVerifyKeyListener(verifyKeyListener);
- } else if (fViewer instanceof ITextViewerExtension) {
- ITextViewerExtension e= (ITextViewerExtension) fViewer;
- e.prependVerifyKeyListener(verifyKeyListener);
- return true;
- } else {
-
- StyledText textWidget= fViewer.getTextWidget();
- if (Helper.okToUse(textWidget)) {
- textWidget.addVerifyKeyListener(verifyKeyListener);
- return true;
- }
- }
- return false;
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubject#appendVerifyKeyListener(org.eclipse.swt.custom.VerifyKeyListener)
- */
- public boolean appendVerifyKeyListener(VerifyKeyListener verifyKeyListener) {
- if (fContentAssistSubject != null)
- return fContentAssistSubject.appendVerifyKeyListener(verifyKeyListener);
- else if (fViewer instanceof ITextViewerExtension) {
- ITextViewerExtension extension= (ITextViewerExtension)fViewer;
- extension.appendVerifyKeyListener(verifyKeyListener);
- return true;
- } else {
- StyledText textWidget= fViewer.getTextWidget();
- if (Helper.okToUse(textWidget)) {
- textWidget.addVerifyKeyListener(verifyKeyListener);
- return true;
- }
- }
- return false;
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubject#removeVerifyKeyListener(org.eclipse.swt.custom.VerifyKeyListener)
- */
- public void removeVerifyKeyListener(VerifyKeyListener verifyKeyListener) {
- if (fContentAssistSubject != null) {
- fContentAssistSubject.removeVerifyKeyListener(verifyKeyListener);
- } else if (fViewer instanceof ITextViewerExtension) {
- ITextViewerExtension extension= (ITextViewerExtension) fViewer;
- extension.removeVerifyKeyListener(verifyKeyListener);
- } else {
- StyledText textWidget= fViewer.getTextWidget();
- if (Helper.okToUse(textWidget))
- textWidget.removeVerifyKeyListener(verifyKeyListener);
- }
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubject#setEventConsumer(org.eclipse.jface.text.contentassist.ContentAssistant.InternalListener)
- */
- public void setEventConsumer(IEventConsumer eventConsumer) {
- if (fContentAssistSubject != null)
- fContentAssistSubject.setEventConsumer(eventConsumer);
- else
- fViewer.setEventConsumer(eventConsumer);
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubject#setSelectedRange(int, int)
- */
- public void setSelectedRange(int i, int j) {
- if (fContentAssistSubject != null)
- fContentAssistSubject.setSelectedRange(i, j);
- else
- fViewer.setSelectedRange(i, j);
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubject#revealRange(int, int)
- */
- public void revealRange(int i, int j) {
- if (fContentAssistSubject != null)
- fContentAssistSubject.revealRange(i, j);
- else
- fViewer.revealRange(i, j);
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubject#canAddVerifyKeyListener()
- */
- public boolean supportsVerifyKeyListener() {
- if (fContentAssistSubject != null)
- return fContentAssistSubject.supportsVerifyKeyListener();
- else
- return true;
- }
- /**
- * Returns the characters which when typed by the user should automatically
- * initiate proposing completions. The position is used to determine the
- * appropriate content assist processor to invoke.
- *
- * @param contentAssistant the content assistant
- * @param offset a document offset
- * @return the auto activation characters
- * @see IContentAssistProcessor#getCompletionProposalAutoActivationCharacters
- */
- public char[] getCompletionProposalAutoActivationCharacters(ContentAssistant contentAssistant, int offset) {
- if (fContentAssistSubject != null)
- return contentAssistant.getCompletionProposalAutoActivationCharacters(fContentAssistSubject, offset);
- else
- return contentAssistant.getCompletionProposalAutoActivationCharacters(fViewer, offset);
- }
-
- /**
- * Returns the characters which when typed by the user should automatically
- * initiate the presentation of context information. The position is used
- * to determine the appropriate content assist processor to invoke.
- *
- * @param contentAssistant the content assistant
- * @param offset a document offset
- * @return the auto activation characters
- *
- * @see IContentAssistProcessor#getContextInformationAutoActivationCharacters
- */
- char[] getContextInformationAutoActivationCharacters(ContentAssistant contentAssistant, int offset) {
- if (fContentAssistSubject != null)
- return contentAssistant.getContextInformationAutoActivationCharacters(fContentAssistSubject, offset);
- else
- return contentAssistant.getContextInformationAutoActivationCharacters(fViewer, offset);
- }
-
- /**
- * Creates and returns a completion proposal popup for the given content assistant.
- *
- * @param contentAssistant the content assistant
- * @param controller the additional info controller
- * @return the completion proposal popup
- */
- CompletionProposalPopup createCompletionProposalPopup(ContentAssistant contentAssistant, AdditionalInfoController controller) {
- if (fContentAssistSubject != null)
- return new CompletionProposalPopup(contentAssistant, fContentAssistSubject, controller);
- else
- return new CompletionProposalPopup(contentAssistant, fViewer, controller);
-
- }
-
- /**
- * Creates and returns a context info popup for the given content assistant.
- *
- * @param contentAssistant the content assistant
- * @return the context info popup or <code>null</code>
- */
- ContextInformationPopup createContextInfoPopup(ContentAssistant contentAssistant) {
- if (fContentAssistSubject != null)
- return new ContextInformationPopup(contentAssistant, fContentAssistSubject);
- else
- return new ContextInformationPopup(contentAssistant, fViewer);
-
- }
-
- /**
- * @param contentAssistant
- * @param offset
- * @return
- */
- public IContextInformationValidator getContextInformationValidator(ContentAssistant contentAssistant, int offset) {
- if (fContentAssistSubject != null)
- return contentAssistant.getContextInformationValidator(fContentAssistSubject, offset);
- else
- return contentAssistant.getContextInformationValidator(fViewer, offset);
- }
-
- /**
- * @param contentAssistant
- * @param offset
- * @return
- */
- public IContextInformationPresenter getContextInformationPresenter(ContentAssistant contentAssistant, int offset) {
- if (fContentAssistSubject != null)
- return contentAssistant.getContextInformationPresenter(fContentAssistSubject, offset);
- else
- return contentAssistant.getContextInformationPresenter(fViewer, offset);
- }
-
- /**
- * @param frame
- */
- public void installValidator(ContextFrame frame) {
- if (fContentAssistSubject != null) {
- if (frame.fValidator instanceof IContextInformationValidatorExtension)
- ((IContextInformationValidatorExtension)frame.fValidator).install(frame.fInformation, fContentAssistSubject, frame.fOffset);
- } else
- frame.fValidator.install(frame.fInformation, fViewer, frame.fOffset);
- }
-
- /**
- * @param frame
- */
- public void installContextInformationPresenter(ContextFrame frame) {
- if (fContentAssistSubject != null) {
- if (frame.fPresenter instanceof IContextInformationPresenterExtension)
- ((IContextInformationPresenterExtension)frame.fValidator).install(frame.fInformation, fContentAssistSubject, frame.fBeginOffset);
- } else
- frame.fPresenter.install(frame.fInformation, fViewer, frame.fBeginOffset);
- }
-
- /**
- * @param contentAssistant
- * @param position
- * @return
- */
- public IContextInformation[] computeContextInformation(ContentAssistant contentAssistant, int position) {
- if (fContentAssistSubject != null)
- return contentAssistant.computeContextInformation(fContentAssistSubject, position);
- else
- return contentAssistant.computeContextInformation(fViewer, position);
- }
-
- /*
- * @see IContentAssistSubject#addSelectionListener(SelectionListener)
- */
- public boolean addSelectionListener(SelectionListener selectionListener) {
- if (fContentAssistSubject != null)
- return fContentAssistSubject.addSelectionListener(selectionListener);
- else {
- fViewer.getTextWidget().addSelectionListener(selectionListener);
- return true;
- }
- }
-
- /*
- * @see IContentAssistSubject#removeSelectionListener(SelectionListener)
- */
- public void removeSelectionListener(SelectionListener selectionListener) {
- if (fContentAssistSubject != null)
- fContentAssistSubject.removeSelectionListener(selectionListener);
- else
- fViewer.getTextWidget().removeSelectionListener(selectionListener);
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java
deleted file mode 100644
index db811e6..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java
+++ /dev/null
@@ -1,1772 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.contentassist;
-
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.SWTError;
-import org.eclipse.swt.custom.VerifyKeyListener;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.ControlListener;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.VerifyEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Widget;
-
-import org.eclipse.jface.dialogs.IDialogSettings;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentExtension3;
-import org.eclipse.jface.text.IEventConsumer;
-import org.eclipse.jface.text.IInformationControlCreator;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.IViewportListener;
-import org.eclipse.jface.text.IWidgetTokenKeeper;
-import org.eclipse.jface.text.IWidgetTokenKeeperExtension;
-import org.eclipse.jface.text.IWidgetTokenOwner;
-import org.eclipse.jface.text.IWidgetTokenOwnerExtension;
-import org.eclipse.jface.text.TextUtilities;
-
-
-
-/**
- * The standard implementation of the <code>IContentAssistant</code> interface.
- * Usually, clients instantiate this class and configure it before using it.
- */
-public class ContentAssistant implements IContentAssistant, IContentAssistantExtension, IWidgetTokenKeeper, IWidgetTokenKeeperExtension {
-
- /**
- * A generic closer class used to monitor various
- * interface events in order to determine whether
- * content-assist should be terminated and all
- * associated windows closed.
- */
- class Closer implements ControlListener, MouseListener, FocusListener, DisposeListener, IViewportListener {
-
- /** The shell that a <code>ControlListener</code> is registered with. */
- private Control fShell;
- /** The control that a <code>MouseListener</code>, a<code>FocusListener</code> and a <code>DisposeListener</code> are registered with. */
- private Control fControl;
-
- /**
- * Installs this closer on it's viewer's text widget.
- */
- protected void install() {
- Control control= fContentAssistSubjectAdapter.getControl();
- fControl= control;
- if (Helper.okToUse(control)) {
-
- Control shell= control.getShell();
- fShell= shell;
- shell.addControlListener(this);
-
- control.addMouseListener(this);
- control.addFocusListener(this);
-
- /*
- * 1GGYYWK: ITPJUI:ALL - Dismissing editor with code assist up causes lots of Internal Errors
- */
- control.addDisposeListener(this);
- }
- if (fViewer != null)
- fViewer.addViewportListener(this);
- }
-
- /**
- * Uninstalls this closer from the viewer's text widget.
- */
- protected void uninstall() {
- Control shell= fShell;
- fShell= null;
- if (Helper.okToUse(shell))
- shell.removeControlListener(this);
-
- Control control= fControl;
- fControl= null;
- if (Helper.okToUse(control)) {
-
- control.removeMouseListener(this);
- control.removeFocusListener(this);
-
- /*
- * 1GGYYWK: ITPJUI:ALL - Dismissing editor with code assist up causes lots of Internal Errors
- */
- control.removeDisposeListener(this);
- }
-
- if (fViewer != null)
- fViewer.removeViewportListener(this);
- }
-
- /*
- * @see ControlListener#controlResized(ControlEvent)
- */
- public void controlResized(ControlEvent e) {
- hide();
- }
-
- /*
- * @see ControlListener#controlMoved(ControlEvent)
- */
- public void controlMoved(ControlEvent e) {
- hide();
- }
-
- /*
- * @see MouseListener#mouseDown(MouseEvent)
- */
- public void mouseDown(MouseEvent e) {
- hide();
- }
-
- /*
- * @see MouseListener#mouseUp(MouseEvent)
- */
- public void mouseUp(MouseEvent e) {
- }
-
- /*
- * @see MouseListener#mouseDoubleClick(MouseEvent)
- */
- public void mouseDoubleClick(MouseEvent e) {
- hide();
- }
-
- /*
- * @see FocusListener#focusGained(FocusEvent)
- */
- public void focusGained(FocusEvent e) {
- }
-
- /*
- * @see FocusListener#focusLost(FocusEvent)
- */
- public void focusLost(FocusEvent e) {
- Control control= fControl;
- if (Helper.okToUse(control)) {
- Display d= control.getDisplay();
- if (d != null) {
- d.asyncExec(new Runnable() {
- public void run() {
- if (!fProposalPopup.hasFocus() && (fContextInfoPopup == null || !fContextInfoPopup.hasFocus()))
- hide();
- }
- });
- }
- }
- }
-
- /*
- * @seeDisposeListener#widgetDisposed(DisposeEvent)
- */
- public void widgetDisposed(DisposeEvent e) {
- /*
- * 1GGYYWK: ITPJUI:ALL - Dismissing editor with code assist up causes lots of Internal Errors
- */
- hide();
- }
-
- /*
- * @see IViewportListener#viewportChanged(int)
- */
- public void viewportChanged(int topIndex) {
- hide();
- }
- }
-
- /**
- * An implementation of <code>IContentAssistListener</code>, this class is
- * used to monitor key events in support of automatic activation
- * of the content assistant. If enabled, the implementation utilizes a
- * thread to watch for input characters matching the activation
- * characters specified by the content assist processor, and if
- * detected, will wait the indicated delay interval before
- * activating the content assistant.
- */
- class AutoAssistListener extends KeyAdapter implements KeyListener, Runnable, VerifyKeyListener {
-
- private Thread fThread;
- private boolean fIsReset= false;
- private Object fMutex= new Object();
- private int fShowStyle;
-
- private final static int SHOW_PROPOSALS= 1;
- private final static int SHOW_CONTEXT_INFO= 2;
-
- protected AutoAssistListener() {
- }
-
- protected void start(int showStyle) {
- fShowStyle= showStyle;
- fThread= new Thread(this, JFaceTextMessages.getString("ContentAssistant.assist_delay_timer_name")); //$NON-NLS-1$
- fThread.start();
- }
-
- public void run() {
- try {
- while (true) {
- synchronized (fMutex) {
- if (fAutoActivationDelay != 0)
- fMutex.wait(fAutoActivationDelay);
- if (fIsReset) {
- fIsReset= false;
- continue;
- }
- }
- showAssist(fShowStyle);
- break;
- }
- } catch (InterruptedException e) {
- }
- fThread= null;
- }
-
- protected void reset(int showStyle) {
- synchronized (fMutex) {
- fShowStyle= showStyle;
- fIsReset= true;
- fMutex.notifyAll();
- }
- }
-
- protected void stop() {
- if (fThread != null) {
- fThread.interrupt();
- }
- }
-
- private boolean contains(char[] characters, char character) {
- if (characters != null) {
- for (int i= 0; i < characters.length; i++) {
- if (character == characters[i])
- return true;
- }
- }
- return false;
- }
-
- public void keyPressed(KeyEvent e) {
- // Only act on typed characters and ignore modifier-only events
- if (e.character == 0 && (e.keyCode & SWT.KEYCODE_BIT) == 0)
- return;
-
- int showStyle;
- int pos= fContentAssistSubjectAdapter.getSelectedRange().x;
- char[] activation;
-
- activation= fContentAssistSubjectAdapter.getCompletionProposalAutoActivationCharacters(ContentAssistant.this, pos);
-
- if (contains(activation, e.character) && !fProposalPopup.isActive())
- showStyle= SHOW_PROPOSALS;
- else {
- activation= fContentAssistSubjectAdapter.getContextInformationAutoActivationCharacters(ContentAssistant.this, pos);
- if (contains(activation, e.character) && fContextInfoPopup != null && !fContextInfoPopup.isActive())
- showStyle= SHOW_CONTEXT_INFO;
- else {
- if (fThread != null && fThread.isAlive())
- stop();
- return;
- }
- }
-
- if (fThread != null && fThread.isAlive())
- reset(showStyle);
- else
- start(showStyle);
- }
-
- /*
- * @see org.eclipse.swt.custom.VerifyKeyListener#verifyKey(org.eclipse.swt.events.VerifyEvent)
- */
- public void verifyKey(VerifyEvent event) {
- keyPressed(event);
- }
-
- protected void showAssist(final int showStyle) {
- Display d= fContentAssistSubjectAdapter.getControl().getDisplay();
- if (d != null) {
- try {
- d.syncExec(new Runnable() {
- public void run() {
- if (showStyle == SHOW_PROPOSALS)
- fProposalPopup.showProposals(true);
- else if (showStyle == SHOW_CONTEXT_INFO && fContextInfoPopup != null)
- fContextInfoPopup.showContextProposals(true);
- }
- });
- } catch (SWTError e) {
- }
- }
- }
- }
-
- /**
- * The laypout manager layouts the various
- * windows associated with the content assistant based on the
- * settings of the content assistant.
- */
- class LayoutManager implements Listener {
-
- // Presentation types.
- /** The presentation type for the proposal selection popup. */
- public final static int LAYOUT_PROPOSAL_SELECTOR= 0;
- /** The presentation type for the context selection popup. */
- public final static int LAYOUT_CONTEXT_SELECTOR= 1;
- /** The presentation type for the context information hover .*/
- public final static int LAYOUT_CONTEXT_INFO_POPUP= 2;
-
- int fContextType= LAYOUT_CONTEXT_SELECTOR;
- Shell[] fShells= new Shell[3];
- Object[] fPopups= new Object[3];
-
- protected void add(Object popup, Shell shell, int type, int offset) {
- Assert.isNotNull(popup);
- Assert.isTrue(shell != null && !shell.isDisposed());
- checkType(type);
-
- if (fShells[type] != shell) {
- if (fShells[type] != null)
- fShells[type].removeListener(SWT.Dispose, this);
- shell.addListener(SWT.Dispose, this);
- fShells[type]= shell;
- }
-
- fPopups[type]= popup;
- if (type == LAYOUT_CONTEXT_SELECTOR || type == LAYOUT_CONTEXT_INFO_POPUP)
- fContextType= type;
-
- layout(type, offset);
- adjustListeners(type);
- }
-
- protected void checkType(int type) {
- Assert.isTrue(type == LAYOUT_PROPOSAL_SELECTOR ||
- type == LAYOUT_CONTEXT_SELECTOR || type == LAYOUT_CONTEXT_INFO_POPUP);
- }
-
- public void handleEvent(Event event) {
- Widget source= event.widget;
- source.removeListener(SWT.Dispose, this);
-
- int type= getShellType(source);
- checkType(type);
- fShells[type]= null;
-
- switch (type) {
- case LAYOUT_PROPOSAL_SELECTOR:
- if (fContextType == LAYOUT_CONTEXT_SELECTOR &&
- Helper.okToUse(fShells[LAYOUT_CONTEXT_SELECTOR])) {
- // Restore event notification to the tip popup.
- addContentAssistListener((IContentAssistListener) fPopups[LAYOUT_CONTEXT_SELECTOR], CONTEXT_SELECTOR);
- }
- break;
-
- case LAYOUT_CONTEXT_SELECTOR:
- if (Helper.okToUse(fShells[LAYOUT_PROPOSAL_SELECTOR])) {
- if (fProposalPopupOrientation == PROPOSAL_STACKED)
- layout(LAYOUT_PROPOSAL_SELECTOR, getSelectionOffset());
- // Restore event notification to the proposal popup.
- addContentAssistListener((IContentAssistListener) fPopups[LAYOUT_PROPOSAL_SELECTOR], PROPOSAL_SELECTOR);
- }
- fContextType= LAYOUT_CONTEXT_INFO_POPUP;
- break;
-
- case LAYOUT_CONTEXT_INFO_POPUP:
- if (Helper.okToUse(fShells[LAYOUT_PROPOSAL_SELECTOR])) {
- if (fContextInfoPopupOrientation == CONTEXT_INFO_BELOW)
- layout(LAYOUT_PROPOSAL_SELECTOR, getSelectionOffset());
- }
- fContextType= LAYOUT_CONTEXT_SELECTOR;
- break;
- }
- }
-
- protected int getShellType(Widget shell) {
- for (int i=0; i<fShells.length; i++) {
- if (fShells[i] == shell)
- return i;
- }
- return -1;
- }
-
- protected void layout(int type, int offset) {
- switch (type) {
- case LAYOUT_PROPOSAL_SELECTOR:
- layoutProposalSelector(offset);
- break;
- case LAYOUT_CONTEXT_SELECTOR:
- layoutContextSelector(offset);
- break;
- case LAYOUT_CONTEXT_INFO_POPUP:
- layoutContextInfoPopup(offset);
- break;
- }
- }
-
- protected void layoutProposalSelector(int offset) {
- if (fContextType == LAYOUT_CONTEXT_INFO_POPUP &&
- fContextInfoPopupOrientation == CONTEXT_INFO_BELOW &&
- Helper.okToUse(fShells[LAYOUT_CONTEXT_INFO_POPUP])) {
- // Stack proposal selector beneath the tip box.
- Shell shell= fShells[LAYOUT_PROPOSAL_SELECTOR];
- Shell parent= fShells[LAYOUT_CONTEXT_INFO_POPUP];
- shell.setLocation(getStackedLocation(shell, parent));
- } else if (fContextType != LAYOUT_CONTEXT_SELECTOR ||
- !Helper.okToUse(fShells[LAYOUT_CONTEXT_SELECTOR])) {
- // There are no other presentations to be concerned with,
- // so place the proposal selector beneath the cursor line.
- Shell shell= fShells[LAYOUT_PROPOSAL_SELECTOR];
- shell.setLocation(getBelowLocation(shell, offset));
- } else {
- switch (fProposalPopupOrientation) {
- case PROPOSAL_REMOVE: {
- // Remove the tip selector and place the
- // proposal selector beneath the cursor line.
- fShells[LAYOUT_CONTEXT_SELECTOR].dispose();
- Shell shell= fShells[LAYOUT_PROPOSAL_SELECTOR];
- shell.setLocation(getBelowLocation(shell, offset));
- break;
- }
- case PROPOSAL_OVERLAY: {
- // Overlay the tip selector with the proposal selector.
- Shell shell= fShells[LAYOUT_PROPOSAL_SELECTOR];
- shell.setLocation(getBelowLocation(shell, offset));
- break;
- }
- case PROPOSAL_STACKED: {
- // Stack the proposal selector beneath the tip selector.
- Shell shell= fShells[LAYOUT_PROPOSAL_SELECTOR];
- Shell parent= fShells[LAYOUT_CONTEXT_SELECTOR];
- shell.setLocation(getStackedLocation(shell, parent));
- break;
- }
- }
- }
- }
-
- protected void layoutContextSelector(int offset) {
- // Always place the context selector beneath the cursor line.
- Shell shell= fShells[LAYOUT_CONTEXT_SELECTOR];
- shell.setLocation(getBelowLocation(shell, offset));
-
- if (Helper.okToUse(fShells[LAYOUT_PROPOSAL_SELECTOR])) {
- switch (fProposalPopupOrientation) {
- case PROPOSAL_REMOVE:
- // Remove the proposal selector.
- fShells[LAYOUT_PROPOSAL_SELECTOR].dispose();
- break;
-
- case PROPOSAL_OVERLAY:
- // The proposal selector has been overlayed by the tip selector.
- break;
-
- case PROPOSAL_STACKED: {
- // Stack the proposal selector beneath the tip selector.
- shell= fShells[LAYOUT_PROPOSAL_SELECTOR];
- Shell parent= fShells[LAYOUT_CONTEXT_SELECTOR];
- shell.setLocation(getStackedLocation(shell, parent));
- break;
- }
- }
- }
- }
-
- protected void layoutContextInfoPopup(int offset) {
- switch (fContextInfoPopupOrientation) {
- case CONTEXT_INFO_ABOVE: {
- // Place the popup above the cursor line.
- Shell shell= fShells[LAYOUT_CONTEXT_INFO_POPUP];
- shell.setLocation(getAboveLocation(shell, offset));
- break;
- }
- case CONTEXT_INFO_BELOW: {
- // Place the popup beneath the cursor line.
- Shell parent= fShells[LAYOUT_CONTEXT_INFO_POPUP];
- parent.setLocation(getBelowLocation(parent, offset));
- if (Helper.okToUse(fShells[LAYOUT_PROPOSAL_SELECTOR])) {
- // Stack the proposal selector beneath the context info popup.
- Shell shell= fShells[LAYOUT_PROPOSAL_SELECTOR];
- shell.setLocation(getStackedLocation(shell, parent));
- }
- break;
- }
- }
- }
-
- protected void shiftHorizontalLocation(Point location, Rectangle shellBounds, Rectangle displayBounds) {
- if (location.x + shellBounds.width > displayBounds.width)
- location.x= displayBounds.width - shellBounds.width;
-
- if (location.x < displayBounds.x)
- location.x= displayBounds.x;
- }
-
- protected void shiftVerticalLocation(Point location, Rectangle shellBounds, Rectangle displayBounds) {
- if (location.y + shellBounds.height > displayBounds.height)
- location.y= displayBounds.height - shellBounds.height;
-
- if (location.y < displayBounds.y)
- location.y= displayBounds.y;
- }
-
- protected Point getAboveLocation(Shell shell, int offset) {
- Point location= fContentAssistSubjectAdapter.getLocationAtOffset(offset);
- location= fContentAssistSubjectAdapter.getControl().toDisplay(location);
-
- Rectangle shellBounds= shell.getBounds();
- Rectangle displayBounds= shell.getDisplay().getClientArea();
-
- location.y=location.y - shellBounds.height;
-
- shiftHorizontalLocation(location, shellBounds, displayBounds);
- shiftVerticalLocation(location, shellBounds, displayBounds);
-
- return location;
- }
-
- protected Point getBelowLocation(Shell shell, int offset) {
- Point location= fContentAssistSubjectAdapter.getLocationAtOffset(offset);
- if (location.x < 0) location.x= 0;
- if (location.y < 0) location.y= 0;
- location= fContentAssistSubjectAdapter.getControl().toDisplay(location);
-
- Rectangle shellBounds= shell.getBounds();
- Rectangle displayBounds= shell.getDisplay().getClientArea();
-
- location.y= location.y + fContentAssistSubjectAdapter.getLineHeight();
- shiftHorizontalLocation(location, shellBounds, displayBounds);
- shiftVerticalLocation(location, shellBounds, displayBounds);
-
- return location;
- }
-
- protected Point getStackedLocation(Shell shell, Shell parent) {
- Point p= parent.getLocation();
- Point size= parent.getSize();
- p.x += size.x / 4;
- p.y += size.y;
-
- p= parent.toDisplay(p);
-
- Rectangle shellBounds= shell.getBounds();
- Rectangle displayBounds= shell.getDisplay().getClientArea();
- shiftHorizontalLocation(p, shellBounds, displayBounds);
- shiftVerticalLocation(p, shellBounds, displayBounds);
-
- return p;
- }
-
- protected void adjustListeners(int type) {
- switch (type) {
- case LAYOUT_PROPOSAL_SELECTOR:
- if (fContextType == LAYOUT_CONTEXT_SELECTOR &&
- Helper.okToUse(fShells[LAYOUT_CONTEXT_SELECTOR]))
- // Disable event notification to the tip selector.
- removeContentAssistListener((IContentAssistListener) fPopups[LAYOUT_CONTEXT_SELECTOR], CONTEXT_SELECTOR);
- break;
- case LAYOUT_CONTEXT_SELECTOR:
- if (Helper.okToUse(fShells[LAYOUT_PROPOSAL_SELECTOR]))
- // Disable event notification to the proposal selector.
- removeContentAssistListener((IContentAssistListener) fPopups[LAYOUT_PROPOSAL_SELECTOR], PROPOSAL_SELECTOR);
- break;
- case LAYOUT_CONTEXT_INFO_POPUP:
- break;
- }
- }
- }
-
- /**
- * Internal key listener and event consumer.
- */
- class InternalListener implements VerifyKeyListener, IEventConsumer {
-
- /**
- * Verifies key events by notifying the registered listeners.
- * Each listener is allowed to indicate that the event has been
- * handled and should not be further processed.
- *
- * @param e the verify event
- * @see VerifyKeyListener#verifyKey(org.eclipse.swt.events.VerifyEvent)
- */
- public void verifyKey(VerifyEvent e) {
- IContentAssistListener[] listeners= (IContentAssistListener[]) fListeners.clone();
- for (int i= 0; i < listeners.length; i++) {
- if (listeners[i] != null) {
- if (!listeners[i].verifyKey(e) || !e.doit)
- break;
- }
- }
- if (fAutoAssistListener != null)
- fAutoAssistListener.keyPressed(e);
- }
-
- /*
- * @see IEventConsumer#processEvent
- */
- public void processEvent(VerifyEvent event) {
-
- installKeyListener();
-
- IContentAssistListener[] listeners= (IContentAssistListener[])fListeners.clone();
- for (int i= 0; i < listeners.length; i++) {
- if (listeners[i] != null) {
- listeners[i].processEvent(event);
- if (!event.doit)
- return;
- }
- }
- }
- }
-
- /**
- * Dialog store constants.
- * @since 3.0
- */
- public static final String STORE_SIZE_X= "size.x"; //$NON-NLS-1$
- public static final String STORE_SIZE_Y= "size.y"; //$NON-NLS-1$
-
- // 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: > linked position proposals and hover popups.
- * Default value: <code>20</code>;
- *
- * @since 3.0
- */
- public static final int WIDGET_PRIORITY= 20;
-
- private static final int DEFAULT_AUTO_ACTIVATION_DELAY= 500;
-
- private IInformationControlCreator fInformationControlCreator;
- private int fAutoActivationDelay= DEFAULT_AUTO_ACTIVATION_DELAY;
- private boolean fIsAutoActivated= false;
- private boolean fIsAutoInserting= false;
- private int fProposalPopupOrientation= PROPOSAL_OVERLAY;
- private int fContextInfoPopupOrientation= CONTEXT_INFO_ABOVE;
- private Map fProcessors;
- private String fPartitioning;
-
- private Color fContextInfoPopupBackground;
- private Color fContextInfoPopupForeground;
- private Color fContextSelectorBackground;
- private Color fContextSelectorForeground;
- private Color fProposalSelectorBackground;
- private Color fProposalSelectorForeground;
-
- private ITextViewer fViewer;
- private String fLastErrorMessage;
-
- private Closer fCloser;
- private LayoutManager fLayoutManager;
- private AutoAssistListener fAutoAssistListener;
- private InternalListener fInternalListener;
- private CompletionProposalPopup fProposalPopup;
- private ContextInformationPopup fContextInfoPopup;
-
- private boolean fVerifyKeyListenerHooked= false;
- private IContentAssistListener[] fListeners= new IContentAssistListener[4];
- /**
- * The content assist subject.
- *
- * @since 3.0
- */
- private IContentAssistSubject fContentAssistSubject;
- /**
- * The content assist subject adapter.
- *
- * @since 3.0
- */
- private ContentAssistSubjectAdapter fContentAssistSubjectAdapter;
- /**
- * The dialog settings for the control's bounds.
- *
- * @since 3.0
- */
- private IDialogSettings fDialogSettings;
-
- /**
- * Creates a new content assistant. The content assistant is not automatically activated,
- * overlays the completion proposals with context information list if necessary, and
- * shows the context information above the location at which it was activated. If auto
- * activation will be enabled, without further configuration steps, this content assistant
- * is activated after a 500 ms delay. It uses the default partitioning.
- */
- public ContentAssistant() {
- fPartitioning= IDocumentExtension3.DEFAULT_PARTITIONING;
- }
-
- /**
- * Sets the document partitioning this content assistant is using.
- *
- * @param partitioning the document partitioning for this content assistant
- */
- public void setDocumentPartitioning(String partitioning) {
- Assert.isNotNull(partitioning);
- fPartitioning= partitioning;
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistantExtension#getDocumentPartitioning()
- * @since 3.0
- */
- public String getDocumentPartitioning() {
- return fPartitioning;
- }
-
- /**
- * Registers a given content assist processor for a particular content type.
- * If there is already a processor registered for this type, the new processor
- * is registered instead of the old one.
- *
- * @param processor the content assist processor to register, or <code>null</code> to remove an existing one
- * @param contentType the content type under which to register
- */
- public void setContentAssistProcessor(IContentAssistProcessor processor, String contentType) {
-
- Assert.isNotNull(contentType);
-
- if (fProcessors == null)
- fProcessors= new HashMap();
-
- if (processor == null)
- fProcessors.remove(contentType);
- else
- fProcessors.put(contentType, processor);
- }
-
- /*
- * @see IContentAssistant#getContentAssistProcessor
- */
- public IContentAssistProcessor getContentAssistProcessor(String contentType) {
- if (fProcessors == null)
- return null;
-
- return (IContentAssistProcessor) fProcessors.get(contentType);
- }
-
- /**
- * Enables the content assistant's auto activation mode.
- *
- * @param enabled indicates whether auto activation is enabled or not
- */
- public void enableAutoActivation(boolean enabled) {
- fIsAutoActivated= enabled;
- manageAutoActivation(fIsAutoActivated);
- }
-
- /**
- * Enables the content assistant's auto insertion mode. If enabled,
- * the content assistant inserts a proposal automatically if it is
- * the only proposal. In the case of ambiguities, the user must
- * make the choice.
- *
- * @param enabled indicates whether auto insertion is enabled or not
- * @since 2.0
- */
- public void enableAutoInsert(boolean enabled) {
- fIsAutoInserting= enabled;
- }
-
- /**
- * Returns whether this content assistant is in the auto insertion
- * mode or not.
- *
- * @return <code>true</code> if in auto insertion mode
- * @since 2.0
- */
- boolean isAutoInserting() {
- return fIsAutoInserting;
- }
-
- /**
- * Installs and uninstall the listeners needed for autoactivation.
- * @param start <code>true</code> if listeners must be installed,
- * <code>false</code> if they must be removed
- * @since 2.0
- */
- private void manageAutoActivation(boolean start) {
- if (start) {
-
- if ((fContentAssistSubjectAdapter != null) && fAutoAssistListener == null) {
- fAutoAssistListener= new AutoAssistListener();
- // TODO see bug 49212
- if (fContentAssistSubjectAdapter.supportsVerifyKeyListener())
- fContentAssistSubjectAdapter.appendVerifyKeyListener(fAutoAssistListener);
- else
- fContentAssistSubjectAdapter.addKeyListener(fAutoAssistListener);
- }
-
- } else if (fAutoAssistListener != null) {
- // TODO see bug 49212
- if (fContentAssistSubjectAdapter.supportsVerifyKeyListener())
- fContentAssistSubjectAdapter.removeVerifyKeyListener(fAutoAssistListener);
- else
- fContentAssistSubjectAdapter.removeKeyListener(fAutoAssistListener);
- fAutoAssistListener= null;
- }
- }
-
- /**
- * Sets the delay after which the content assistant is automatically invoked
- * if the cursor is behind an auto activation character.
- *
- * @param delay the auto activation delay
- */
- public void setAutoActivationDelay(int delay) {
- fAutoActivationDelay= delay;
- }
-
- /**
- * Sets the proposal popups' orientation.
- * The following values may be used:
- * <ul>
- * <li>PROPOSAL_OVERLAY<p>
- * proposal popup windows should overlay each other
- * </li>
- * <li>PROPOSAL_REMOVE<p>
- * any currently shown proposal popup should be closed
- * </li>
- * <li>PROPOSAL_STACKED<p>
- * proposal popup windows should be vertical stacked, with no overlap,
- * beneath the line containing the current cursor location
- * </li>
- * </ul>
- *
- * @param orientation the popup's orientation
- */
- public void setProposalPopupOrientation(int orientation) {
- fProposalPopupOrientation= orientation;
- }
-
- /**
- * Sets the context information popup's orientation.
- * The following values may be used:
- * <ul>
- * <li>CONTEXT_ABOVE<p>
- * context information popup should always appear above the line containing
- * the current cursor location
- * </li>
- * <li>CONTEXT_BELOW<p>
- * context information popup should always appear below the line containing
- * the current cursor location
- * </li>
- * </ul>
- *
- * @param orientation the popup's orientation
- */
- public void setContextInformationPopupOrientation(int orientation) {
- fContextInfoPopupOrientation= orientation;
- }
-
- /**
- * Sets the context information popup's background color.
- *
- * @param background the background color
- */
- public void setContextInformationPopupBackground(Color background) {
- fContextInfoPopupBackground= background;
- }
-
- /**
- * Returns the background of the context information popup.
- *
- * @return the background of the context information popup
- * @since 2.0
- */
- Color getContextInformationPopupBackground() {
- return fContextInfoPopupBackground;
- }
-
- /**
- * Sets the context information popup's foreground color.
- *
- * @param foreground the foreground color
- * @since 2.0
- */
- public void setContextInformationPopupForeground(Color foreground) {
- fContextInfoPopupForeground= foreground;
- }
-
- /**
- * Returns the foreground of the context information popup.
- *
- * @return the foreground of the context information popup
- * @since 2.0
- */
- Color getContextInformationPopupForeground() {
- return fContextInfoPopupForeground;
- }
-
- /**
- * Sets the proposal selector's background color.
- *
- * @param background the background color
- * @since 2.0
- */
- public void setProposalSelectorBackground(Color background) {
- fProposalSelectorBackground= background;
- }
-
- /**
- * Returns the background of the proposal selector.
- *
- * @return the background of the proposal selector
- * @since 2.0
- */
- Color getProposalSelectorBackground() {
- return fProposalSelectorBackground;
- }
-
- /**
- * Sets the proposal's foreground color.
- *
- * @param foreground the foreground color
- * @since 2.0
- */
- public void setProposalSelectorForeground(Color foreground) {
- fProposalSelectorForeground= foreground;
- }
-
- /**
- * Returns the foreground of the proposal selector.
- *
- * @return the foreground of the proposal selector
- * @since 2.0
- */
- Color getProposalSelectorForeground() {
- return fProposalSelectorForeground;
- }
-
- /**
- * Sets the context selector's background color.
- *
- * @param background the background color
- * @since 2.0
- */
- public void setContextSelectorBackground(Color background) {
- fContextSelectorBackground= background;
- }
-
- /**
- * Returns the background of the context selector.
- *
- * @return the background of the context selector
- * @since 2.0
- */
- Color getContextSelectorBackground() {
- return fContextSelectorBackground;
- }
-
- /**
- * Sets the context selector's foreground color.
- *
- * @param foreground the foreground color
- * @since 2.0
- */
- public void setContextSelectorForeground(Color foreground) {
- fContextSelectorForeground= foreground;
- }
-
- /**
- * Returns the foreground of the context selector.
- *
- * @return the foreground of the context selector
- * @since 2.0
- */
- Color getContextSelectorForeground() {
- return fContextSelectorForeground;
- }
-
- /**
- * Sets the information control creator for the additional information control.
- *
- * @param creator the information control creator for the additional information control
- * @since 2.0
- */
- public void setInformationControlCreator(IInformationControlCreator creator) {
- fInformationControlCreator= creator;
- }
-
- /*
- * @see IContentAssistantExtension#install(IContentAssistSubject)
- */
- public void install(IContentAssistSubject contentAssistSubject) {
- fContentAssistSubject= contentAssistSubject;
- fContentAssistSubjectAdapter= new ContentAssistSubjectAdapter(fContentAssistSubject);
- install();
- }
-
- /*
- * @see IContentAssist#install
- */
- public void install(ITextViewer textViewer) {
- fViewer= textViewer;
- fContentAssistSubjectAdapter= new ContentAssistSubjectAdapter(fViewer);
- install();
- }
-
- protected void install() {
-
- fLayoutManager= new LayoutManager();
- fInternalListener= new InternalListener();
-
- AdditionalInfoController controller= null;
- if (fInformationControlCreator != null) {
- int delay= fAutoActivationDelay;
- if (delay == 0)
- delay= DEFAULT_AUTO_ACTIVATION_DELAY;
- delay= Math.round(delay * 1.5f);
- controller= new AdditionalInfoController(fInformationControlCreator, delay);
- }
-
- fContextInfoPopup= fContentAssistSubjectAdapter.createContextInfoPopup(this);
- fProposalPopup= fContentAssistSubjectAdapter.createCompletionProposalPopup(this, controller);
-
- manageAutoActivation(fIsAutoActivated);
- }
-
- /*
- * @see IContentAssist#uninstall
- */
- public void uninstall() {
- hide();
- manageAutoActivation(false);
-
- if (fCloser != null) {
- fCloser.uninstall();
- fCloser= null;
- }
-
- fViewer= null;
- fContentAssistSubject= null;
- fContentAssistSubjectAdapter= null;
- }
-
- /**
- * Adds the given shell of the specified type to the layout.
- * Valid types are defined by <code>LayoutManager</code>.
- *
- * @param popup a content assist popup
- * @param shell the shell of the content-assist popup
- * @param type the type of popup
- * @param visibleOffset the offset at which to layout the popup relative to the offset of the viewer's visible region
- * @since 2.0
- */
- void addToLayout(Object popup, Shell shell, int type, int visibleOffset) {
- fLayoutManager.add(popup, shell, type, visibleOffset);
- }
-
- /**
- * Layouts the registered popup of the given type relative to the
- * given offset. The offset is relative to the offset of the viewer's visible region.
- * Valid types are defined by <code>LayoutManager</code>.
- *
- * @param type the type of popup to layout
- * @param visibleOffset the offset at which to layout relative to the offset of the viewer's visible region
- * @since 2.0
- */
- void layout(int type, int visibleOffset) {
- fLayoutManager.layout(type, visibleOffset);
- }
-
- /**
- * Notifies the controller that a popup has lost focus.
- *
- * @param e the focus event
- */
- void popupFocusLost(FocusEvent e) {
- fCloser.focusLost(e);
- }
-
- /**
- * Returns the offset of the selection relative to the offset of the visible region.
- *
- * @return the offset of the selection relative to the offset of the visible region
- * @since 2.0
- */
- int getSelectionOffset() {
- return fContentAssistSubjectAdapter.getWidgetSelectionRange().x;
- }
-
- /**
- * Returns whether the widget token could be acquired.
- * The following are valid listener types:
- * <ul>
- * <li>AUTO_ASSIST
- * <li>CONTEXT_SELECTOR
- * <li>PROPOSAL_SELECTOR
- * <li>CONTEXT_INFO_POPUP
- * <ul>
- * @param type the listener type for which to acquire
- * @return <code>true</code> if the widget token could be acquired
- * @since 2.0
- */
- private boolean acquireWidgetToken(int type) {
- switch (type) {
- case CONTEXT_SELECTOR:
- case PROPOSAL_SELECTOR:
- if (fContentAssistSubject instanceof IWidgetTokenOwnerExtension) {
- IWidgetTokenOwnerExtension extension= (IWidgetTokenOwnerExtension)fContentAssistSubject;
- return extension.requestWidgetToken(this, WIDGET_PRIORITY);
- } else if (fContentAssistSubject instanceof IWidgetTokenOwner) {
- IWidgetTokenOwner owner= (IWidgetTokenOwner)fContentAssistSubject;
- return owner.requestWidgetToken(this);
- } else if (fViewer instanceof IWidgetTokenOwnerExtension) {
- IWidgetTokenOwnerExtension extension= (IWidgetTokenOwnerExtension) fViewer;
- return extension.requestWidgetToken(this, WIDGET_PRIORITY);
- } else if (fViewer instanceof IWidgetTokenOwner) {
- IWidgetTokenOwner owner= (IWidgetTokenOwner) fViewer;
- return owner.requestWidgetToken(this);
- }
- }
- return true;
- }
-
- /**
- * Registers a content assist listener.
- * The following are valid listener types:
- * <ul>
- * <li>AUTO_ASSIST
- * <li>CONTEXT_SELECTOR
- * <li>PROPOSAL_SELECTOR
- * <li>CONTEXT_INFO_POPUP
- * <ul>
- * Returns whether the listener could be added successfully. A listener
- * can not be added if the widget token could not be acquired.
- *
- * @param listener the listener to register
- * @param type the type of listener
- * @return <code>true</code> if the listener could be added
- */
- boolean addContentAssistListener(IContentAssistListener listener, int type) {
-
- if (acquireWidgetToken(type)) {
-
- fListeners[type]= listener;
-
- if (fCloser == null && getNumberOfListeners() == 1) {
- fCloser= new Closer();
- fCloser.install();
- fContentAssistSubjectAdapter.setEventConsumer(fInternalListener);
- installKeyListener();
- } else
- promoteKeyListener();
- return true;
- }
-
- return false;
- }
-
- /**
- * Repromotes the keylistener to the first position, using
- * prependVerifyKeyListener. This ensures no other instance is
- * filtering away the keystrokes underneath, if we've been up for a
- * while (e.g. when the context info is showing.
- *
- * @since 3.0
- */
- private void promoteKeyListener() {
- uninstallVerifyKeyListener();
- installKeyListener();
- }
-
- /**
- * Installs a key listener on the text viewer's widget.
- */
- private void installKeyListener() {
- if (!fVerifyKeyListenerHooked) {
- if (Helper.okToUse(fContentAssistSubjectAdapter.getControl())) {
- fVerifyKeyListenerHooked= fContentAssistSubjectAdapter.prependVerifyKeyListener(fInternalListener);
- }
- }
- }
-
- /**
- * Releases the previously acquired widget token if the token
- * is no longer necessary.
- * The following are valid listener types:
- * <ul>
- * <li>AUTO_ASSIST
- * <li>CONTEXT_SELECTOR
- * <li>PROPOSAL_SELECTOR
- * <li>CONTEXT_INFO_POPUP
- * <ul>
- *
- * @param type the listener type
- * @since 2.0
- */
- private void releaseWidgetToken(int type) {
- if (fListeners[CONTEXT_SELECTOR] == null && fListeners[PROPOSAL_SELECTOR] == null) {
- IWidgetTokenOwner owner= null;
- if (fContentAssistSubject instanceof IWidgetTokenOwner)
- owner= (IWidgetTokenOwner)fContentAssistSubject;
- else if (fViewer instanceof IWidgetTokenOwner)
- owner= (IWidgetTokenOwner)fViewer;
- if (owner != null)
- owner.releaseWidgetToken(this);
- }
- }
-
- /**
- * Unregisters a content assist listener.
- *
- * @param listener the listener to unregister
- * @param type the type of listener
- *
- * @see #addContentAssistListener
- */
- void removeContentAssistListener(IContentAssistListener listener, int type) {
- fListeners[type]= null;
-
- if (getNumberOfListeners() == 0) {
-
- if (fCloser != null) {
- fCloser.uninstall();
- fCloser= null;
- }
-
- uninstallVerifyKeyListener();
- fContentAssistSubjectAdapter.setEventConsumer(null);
- }
-
- releaseWidgetToken(type);
- }
-
- /**
- * Uninstall the key listener from the text viewer's widget.
- */
- private void uninstallVerifyKeyListener() {
- if (fVerifyKeyListenerHooked) {
- if (Helper.okToUse(fContentAssistSubjectAdapter.getControl()))
- fContentAssistSubjectAdapter.removeVerifyKeyListener(fInternalListener);
- fVerifyKeyListenerHooked= false;
- }
- }
-
- /**
- * Returns the number of listeners.
- *
- * @return the number of listeners
- * @since 2.0
- */
- private int getNumberOfListeners() {
- int count= 0;
- for (int i= 0; i <= CONTEXT_INFO_POPUP; i++) {
- if (fListeners[i] != null)
- ++ count;
- }
- return count;
- }
-
- /*
- * @see IContentAssist#showPossibleCompletions
- */
- public String showPossibleCompletions() {
- promoteKeyListener();
- return fProposalPopup.showProposals(false);
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistantExtension#completePrefix()
- */
- public String completePrefix() {
- promoteKeyListener();
- return fProposalPopup.incrementalComplete();
- }
-
- /**
- * Callback to signal this content assistant that the presentation of the possible completions has been stopped.
- * @since 2.1
- */
- protected void possibleCompletionsClosed() {
- storeCompletionProposalPopupSize();
- }
-
- /*
- * @see IContentAssist#showContextInformation
- */
- public String showContextInformation() {
- promoteKeyListener();
- if (fContextInfoPopup != null)
- return fContextInfoPopup.showContextProposals(false);
- else
- return null;
- }
-
- /**
- * Callback to signal this content assistant that the presentation of the context information has been stopped.
- * @since 2.1
- */
- protected void contextInformationClosed() {
- }
-
- /**
- * Requests that the specified context information to be shown.
- *
- * @param contextInformation the context information to be shown
- * @param position the position to which the context information refers to
- * @since 2.0
- */
- void showContextInformation(IContextInformation contextInformation, int position) {
- if (fContextInfoPopup != null)
- fContextInfoPopup.showContextInformation(contextInformation, position);
- }
-
- /**
- * Returns the current content assist error message.
- *
- * @return an error message or <code>null</code> if no error has occurred
- */
- String getErrorMessage() {
- return fLastErrorMessage;
- }
-
- /**
- * Returns the content assist processor for the content
- * type of the specified document position.
- *
- * @param viewer the text viewer
- * @param offset a offset within the document
- * @return a content-assist processor or <code>null</code> if none exists
- */
- private IContentAssistProcessor getProcessor(ITextViewer viewer, int offset) {
- try {
-
- IDocument document= viewer.getDocument();
- String type= TextUtilities.getContentType(document, getDocumentPartitioning(), offset);
-
- return getContentAssistProcessor(type);
-
- } catch (BadLocationException x) {
- }
-
- return null;
- }
-
- /**
- * Returns the content assist processor for the content
- * type of the specified document position.
- *
- * @param contentAssistSubject the content assist subject
- * @param offset a offset within the document
- * @return a content-assist processor or <code>null</code> if none exists
- */
- private IContentAssistProcessor getProcessor(IContentAssistSubject contentAssistSubject, int offset) {
- try {
-
- IDocument document= contentAssistSubject.getDocument();
- String type;
- if (document != null)
- type= TextUtilities.getContentType(document, getDocumentPartitioning(), offset);
- else
- type= IDocument.DEFAULT_CONTENT_TYPE;
-
- return getContentAssistProcessor(type);
-
- } catch (BadLocationException x) {
- }
-
- return null;
- }
-
- /**
- * Returns an array of completion proposals computed based on
- * the specified document position. The position is used to
- * determine the appropriate content assist processor to invoke.
- *
- * @param contentAssistSubject the content assit subject
- * @param position a document position
- * @return an array of completion proposals
- *
- * @see IContentAssistProcessor#computeCompletionProposals
- */
- ICompletionProposal[] computeCompletionProposals(IContentAssistSubject contentAssistSubject, int position) {
- fLastErrorMessage= null;
-
- ICompletionProposal[] result= null;
-
- IContentAssistProcessor p= getProcessor(contentAssistSubject, position);
- if (p instanceof IContentAssistProcessorExtension) {
- result= ((IContentAssistProcessorExtension)p).computeCompletionProposals(contentAssistSubject, position);
- fLastErrorMessage= p.getErrorMessage();
- }
-
- return result;
- }
-
- /**
- * Returns an array of completion proposals computed based on
- * the specified document position. The position is used to
- * determine the appropriate content assist processor to invoke.
- *
- * @param viewer the viewer for which to compute the prosposals
- * @param position a document position
- * @return an array of completion proposals
- *
- * @see IContentAssistProcessor#computeCompletionProposals
- */
- ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int position) {
- fLastErrorMessage= null;
-
- ICompletionProposal[] result= null;
-
- IContentAssistProcessor p= getProcessor(viewer, position);
- if (p != null) {
- result= p.computeCompletionProposals(viewer, position);
- fLastErrorMessage= p.getErrorMessage();
- }
-
- return result;
- }
-
- /**
- * Returns an array of context information objects computed based
- * on the specified document position. The position is used to determine
- * the appropriate content assist processor to invoke.
- *
- * @param viewer the viewer for which to compute the context information
- * @param position a document position
- * @return an array of context information objects
- *
- * @see IContentAssistProcessor#computeContextInformation
- */
- IContextInformation[] computeContextInformation(ITextViewer viewer, int position) {
- fLastErrorMessage= null;
-
- IContextInformation[] result= null;
-
- IContentAssistProcessor p= getProcessor(viewer, position);
- if (p != null) {
- result= p.computeContextInformation(viewer, position);
- fLastErrorMessage= p.getErrorMessage();
- }
-
- return result;
- }
-
- /**
- * Returns an array of context information objects computed based
- * on the specified document position. The position is used to determine
- * the appropriate content assist processor to invoke.
- *
- * @param contentAssistSubject the content assit subject
- * @param position a document position
- * @return an array of context information objects
- *
- * @see IContentAssistProcessor#computeContextInformation
- */
- IContextInformation[] computeContextInformation(IContentAssistSubject contentAssistSubject, int position) {
- fLastErrorMessage= null;
-
- IContextInformation[] result= null;
-
- IContentAssistProcessor p= getProcessor(contentAssistSubject, position);
- if (p instanceof IContentAssistProcessorExtension) {
- result= ((IContentAssistProcessorExtension)p).computeContextInformation(contentAssistSubject, position);
- fLastErrorMessage= p.getErrorMessage();
- }
-
- return result;
- }
-
- /**
- * Returns the context information validator that should be used to
- * determine when the currently displayed context information should
- * be dismissed. The position is used to determine the appropriate
- * content assist processor to invoke.
- *
- * @param viewer the text viewer
- * @param offset a document offset
- * @return an validator
- *
- * @see IContentAssistProcessor#getContextInformationValidator
- */
- IContextInformationValidator getContextInformationValidator(ITextViewer viewer, int offset) {
- IContentAssistProcessor p= getProcessor(viewer, offset);
- return p != null ? p.getContextInformationValidator() : null;
- }
-
- /**
- * Returns the context information validator that should be used to
- * determine when the currently displayed context information should
- * be dismissed. The position is used to determine the appropriate
- * content assist processor to invoke.
- *
- * @param contentAssistSubject the content assist subject
- * @param offset a document offset
- * @return an validator
- * @see IContentAssistProcessor#getContextInformationValidator
- * @since 3.0
- */
- IContextInformationValidator getContextInformationValidator(IContentAssistSubject contentAssistSubject, int offset) {
- IContentAssistProcessor p= getProcessor(contentAssistSubject, offset);
- return p != null ? p.getContextInformationValidator() : null;
- }
-
- /**
- * Returns the context information presenter that should be used to
- * display context information. The position is used to determine the appropriate
- * content assist processor to invoke.
- *
- * @param viewer the text viewer
- * @param offset a document offset
- * @return a presenter
- * @since 2.0
- */
- IContextInformationPresenter getContextInformationPresenter(ITextViewer viewer, int offset) {
- IContextInformationValidator validator= getContextInformationValidator(viewer, offset);
- if (validator instanceof IContextInformationPresenter)
- return (IContextInformationPresenter) validator;
- return null;
- }
-
- /**
- * Returns the context information presenter that should be used to
- * display context information. The position is used to determine the appropriate
- * content assist processor to invoke.
- *
- * @param contentAssistSubject the content assist subject
- * @param offset a document offset
- * @return a presenter
- * @since 3.0
- */
- IContextInformationPresenter getContextInformationPresenter(IContentAssistSubject contentAssistSubject, int offset) {
- IContextInformationValidator validator= getContextInformationValidator(contentAssistSubject, offset);
- if (validator instanceof IContextInformationPresenter)
- return (IContextInformationPresenter) validator;
- return null;
- }
-
- /**
- * Returns the characters which when typed by the user should automatically
- * initiate proposing completions. The position is used to determine the
- * appropriate content assist processor to invoke.
- *
- * @param contentAssistSubject the content assist subject
- * @param offset a document offset
- * @return the auto activation characters
- * @see IContentAssistProcessor#getCompletionProposalAutoActivationCharacters
- * @since 3.0
- */
- char[] getCompletionProposalAutoActivationCharacters(IContentAssistSubject contentAssistSubject, int offset) {
- IContentAssistProcessor p= getProcessor(contentAssistSubject, offset);
- return p != null ? p.getCompletionProposalAutoActivationCharacters() : null;
- }
-
- /**
- * Returns the characters which when typed by the user should automatically
- * initiate proposing completions. The position is used to determine the
- * appropriate content assist processor to invoke.
- *
- * @param viewer the text viewer
- * @param offset a document offset
- * @return the auto activation characters
- *
- * @see IContentAssistProcessor#getCompletionProposalAutoActivationCharacters
- */
- char[] getCompletionProposalAutoActivationCharacters(ITextViewer viewer, int offset) {
- IContentAssistProcessor p= getProcessor(viewer, offset);
- return p != null ? p.getCompletionProposalAutoActivationCharacters() : null;
- }
-
- /**
- * Returns the characters which when typed by the user should automatically
- * initiate the presentation of context information. The position is used
- * to determine the appropriate content assist processor to invoke.
- *
- * @param viewer the text viewer
- * @param offset a document offset
- * @return the auto activation characters
- *
- * @see IContentAssistProcessor#getContextInformationAutoActivationCharacters
- */
- char[] getContextInformationAutoActivationCharacters(ITextViewer viewer, int offset) {
- IContentAssistProcessor p= getProcessor(viewer, offset);
- return p != null ? p.getContextInformationAutoActivationCharacters() : null;
- }
-
- /**
- * Returns the characters which when typed by the user should automatically
- * initiate the presentation of context information. The position is used
- * to determine the appropriate content assist processor to invoke.
- *
- * @param contentAssistSubject the content assist subject
- * @param offset a document offset
- * @return the auto activation characters
- *
- * @see IContentAssistProcessor#getContextInformationAutoActivationCharacters
- */
- char[] getContextInformationAutoActivationCharacters(IContentAssistSubject contentAssistSubject, int offset) {
- IContentAssistProcessor p= getProcessor(contentAssistSubject, offset);
- return p != null ? p.getContextInformationAutoActivationCharacters() : null;
- }
-
- /*
- * @see org.eclipse.jface.text.IWidgetTokenKeeper#requestWidgetToken(IWidgetTokenOwner)
- * @since 2.0
- */
- public boolean requestWidgetToken(IWidgetTokenOwner owner) {
- return false;
- }
-
- /*
- * @see org.eclipse.jface.text.IWidgetTokenKeeperExtension#requestWidgetToken(org.eclipse.jface.text.IWidgetTokenOwner, int)
- * @since 3.0
- */
- public boolean requestWidgetToken(IWidgetTokenOwner owner, int priority) {
- if (priority > WIDGET_PRIORITY) {
- hide();
- return true;
- } else {
- return false;
- }
- }
-
- /*
- * @see org.eclipse.jface.text.IWidgetTokenKeeperExtension#setFocus(org.eclipse.jface.text.IWidgetTokenOwner)
- * @since 3.0
- */
- public boolean setFocus(IWidgetTokenOwner owner) {
- if (fProposalPopup != null) {
- fProposalPopup.setFocus();
- return fProposalPopup.hasFocus();
- }
- return false;
- }
-
- /**
- * Hides any open popups.
- */
- protected void hide() {
- if (fProposalPopup != null)
- fProposalPopup.hide();
-
- if (fContextInfoPopup != null)
- fContextInfoPopup.hide();
- }
- // ------ control's size handling dialog settings ------
-
- /**
- * 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 ContentAssistant#STORE_SIZE_X}</li>
- * <li>{@link ContentAssistant#STORE_SIZE_Y}</li>
- * </ul>
- * </p>
- *
- * @param dialogSettings
- * @since 3.0
- */
- public void setRestoreCompletionProposalSize(IDialogSettings dialogSettings) {
- Assert.isTrue(dialogSettings != null);
- fDialogSettings= dialogSettings;
- }
-
- /**
- * Stores the content assist pop-up's size.
- */
- protected void storeCompletionProposalPopupSize() {
- if (fDialogSettings == null || fProposalPopup == null)
- return;
-
- Point size= fProposalPopup.getSize();
- if (size == null)
- return;
-
- fDialogSettings.put(STORE_SIZE_X, size.x);
- fDialogSettings.put(STORE_SIZE_Y, size.y);
- }
-
- /**
- * Restores the content assist pop-up's size.
- *
- * @return the stored size
- * @since 3.0
- */
- protected Point restoreCompletionProposalPopupSize() {
- if (fDialogSettings == null)
- return null;
-
- Point size= new Point(-1, -1);
-
- try {
- size.x= fDialogSettings.getInt(STORE_SIZE_X);
- size.y= fDialogSettings.getInt(STORE_SIZE_Y);
- } catch (NumberFormatException ex) {
- size.x= -1;
- size.y= -1;
- }
-
- // sanity check
- if (size.x == -1 && size.y == -1)
- return null;
-
- Rectangle maxBounds= null;
- if (fContentAssistSubject != null && !fContentAssistSubject.getControl().isDisposed())
- maxBounds= fContentAssistSubject.getControl().getDisplay().getBounds();
- else {
- // fallback
- Display display= Display.getCurrent();
- if (display == null)
- display= Display.getDefault();
- if (display != null && !display.isDisposed())
- maxBounds= display.getBounds();
- }
-
-
- if (size.x > -1 && size.y > -1) {
- if (maxBounds != null) {
- size.x= Math.min(size.x, maxBounds.width);
- size.y= Math.min(size.y, maxBounds.height);
- }
-
- // Enforce an absolute minimal size
- size.x= Math.max(size.x, 30);
- size.y= Math.max(size.y, 30);
- }
-
- return size;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformation.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformation.java
deleted file mode 100644
index 9931964..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformation.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.contentassist;
-
-
-import org.eclipse.swt.graphics.Image;
-
-import org.eclipse.jface.text.Assert;
-
-
-
-/**
- * A default implementation of the <code>IContextInformation</code> interface.
- */
-public final class ContextInformation implements IContextInformation {
-
- /** The name of the context */
- private String fContextDisplayString;
- /** The information to be displayed */
- private String fInformationDisplayString;
- /** The image to be displayed */
- private Image fImage;
-
- /**
- * Creates a new context information without an image.
- *
- * @param contextDisplayString the string to be used when presenting the context
- * @param informationDisplayString the string to be displayed when presenting the context information
- */
- public ContextInformation(String contextDisplayString, String informationDisplayString) {
- this(null, contextDisplayString, informationDisplayString);
- }
-
- /**
- * Creates a new context information with an image.
- *
- * @param image the image to display when presenting the context information
- * @param contextDisplayString the string to be used when presenting the context
- * @param informationDisplayString the string to be displayed when presenting the context information,
- * may not be <code>null</code>
- */
- public ContextInformation(Image image, String contextDisplayString, String informationDisplayString) {
-
- Assert.isNotNull(informationDisplayString);
-
- fImage= image;
- fContextDisplayString= contextDisplayString;
- fInformationDisplayString= informationDisplayString;
- }
-
- /*
- * @see IContextInformation#equals(Object)
- */
- public boolean equals(Object object) {
- if (object instanceof IContextInformation) {
- IContextInformation contextInformation= (IContextInformation) object;
- boolean equals= fInformationDisplayString.equalsIgnoreCase(contextInformation.getInformationDisplayString());
- if (fContextDisplayString != null)
- equals= equals && fContextDisplayString.equalsIgnoreCase(contextInformation.getContextDisplayString());
- return equals;
- }
- return false;
- }
-
- /*
- * @see IContextInformation#getInformationDisplayString()
- */
- public String getInformationDisplayString() {
- return fInformationDisplayString;
- }
-
- /*
- * @see IContextInformation#getImage()
- */
- public Image getImage() {
- return fImage;
- }
-
- /*
- * @see IContextInformation#getContextDisplayString()
- */
- public String getContextDisplayString() {
- if (fContextDisplayString != null)
- return fContextDisplayString;
- return fInformationDisplayString;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.java
deleted file mode 100644
index 80738bc..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.java
+++ /dev/null
@@ -1,783 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.contentassist;
-
-
-import java.util.Iterator;
-import java.util.Stack;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.events.VerifyEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.TextPresentation;
-
-
-/**
- * This class is used to present context information to the user.
- * If multiple contexts are valid at the current cursor location,
- * a list is presented from which the user may choose one context.
- * Once the user makes their choice, or if there was only a single
- * possible context, the context information is shown in a tooltip like popup. <p>
- * If the tooltip is visible and the user wants to see context information of
- * a context embedded into the one for which context information is displayed,
- * context information for the embedded context is shown. As soon as the
- * cursor leaves the embedded context area, the context information for
- * the embedding context is shown again.
- *
- * @see IContextInformation
- * @see IContextInformationValidator
- */
-class ContextInformationPopup implements IContentAssistListener {
-
-
-
- /**
- * Represents the state necessary for embedding contexts.
- * @since 2.0
- */
- static class ContextFrame {
- public int fBeginOffset;
- public int fOffset;
- public int fVisibleOffset;
- public IContextInformation fInformation;
- public IContextInformationValidator fValidator;
- public IContextInformationPresenter fPresenter;
-
- /*
- * @see java.lang.Object#equals(java.lang.Object)
- * @since 3.0
- */
- public boolean equals(Object obj) {
- if (obj instanceof ContextFrame) {
- ContextFrame frame= (ContextFrame) obj;
- return fInformation.equals(frame.fInformation) && fBeginOffset == frame.fBeginOffset;
- }
- return super.equals(obj);
- }
- }
-
- private ITextViewer fViewer;
- private ContentAssistant fContentAssistant;
-
- private PopupCloser fPopupCloser= new PopupCloser();
- private Shell fContextSelectorShell;
- private Table fContextSelectorTable;
- private IContextInformation[] fContextSelectorInput;
- private String fLineDelimiter= null;
-
- private Shell fContextInfoPopup;
- private StyledText fContextInfoText;
- private TextPresentation fTextPresentation;
-
- private Stack fContextFrameStack= new Stack();
- /**
- * The content assist subjects.
- *
- * @since 3.0
- */
- private IContentAssistSubject fContentAssistSubject;
- /**
- * The content assist subject adapter.
- *
- * @since 3.0
- */
- private ContentAssistSubjectAdapter fContentAssistSubjectAdapter;
-
- /**
- * Selection listener on the text widget which is active
- * while a context information pop up is shown.
- *
- * @since 3.0
- */
- private SelectionListener fTextWidgetSelectionListener;
-
- /**
- * The last removed context frame is remembered in order to not re-query the
- * user about which context should be used.
- *
- * @since 3.0
- */
- private ContextFrame fLastContext= null;
-
- /**
- * Creates a new context information popup.
- *
- * @param contentAssistant the content assist for computing the context information
- * @param viewer the viewer on top of which the context information is shown
- */
- public ContextInformationPopup(ContentAssistant contentAssistant, ITextViewer viewer) {
- fContentAssistant= contentAssistant;
- fViewer= viewer;
- fContentAssistSubjectAdapter= new ContentAssistSubjectAdapter(fViewer);
- }
-
- /**
- * Creates a new context information popup.
- *
- * @param contentAssistant the content assist for computing the context information
- * @param contentAssistSubject the content assist subject on top of which the context information is shown
- * @since 3.0
- */
- public ContextInformationPopup(ContentAssistant contentAssistant, IContentAssistSubject contentAssistSubject) {
- fContentAssistant= contentAssistant;
- fContentAssistSubject= contentAssistSubject;
- fContentAssistSubjectAdapter= new ContentAssistSubjectAdapter(fContentAssistSubject);
- }
-
- /**
- * Shows all possible contexts for the given cursor position of the viewer.
- *
- * @param autoActivated <code>true</code> if auto activated
- * @return a potential error message or <code>null</code> in case of no error
- */
- public String showContextProposals(final boolean autoActivated) {
- final Control control= fContentAssistSubjectAdapter.getControl();
- BusyIndicator.showWhile(control.getDisplay(), new Runnable() {
- public void run() {
-
- int position= fContentAssistSubjectAdapter.getSelectedRange().x;
-
- IContextInformation[] contexts= computeContextInformation(position);
- int count = (contexts == null ? 0 : contexts.length);
- if (count == 1) {
-
- ContextFrame frame= createContextFrame(contexts[0], position);
- if (isDuplicate(frame))
- validateContextInformation();
- else
- // Show context information directly
- internalShowContextInfo(frame);
-
- } else if (count > 0) {
-
- // if any of the proposed context matches the any of the contexts on the stack,
- // assume that one (so, if context info is invoked repeatedly, the current
- // info is kept)
- for (int i= 0; i < contexts.length; i++) {
- IContextInformation info= contexts[i];
- ContextFrame frame= createContextFrame(info, position);
-
- // check top of stack and stored context
- if (isDuplicate(frame)) {
- validateContextInformation();
- return;
- }
-
- if (isLastFrame(frame)) {
- internalShowContextInfo(frame);
- return;
- }
-
- // also check all other contexts
- for (Iterator it= fContextFrameStack.iterator(); it.hasNext(); ) {
- ContextFrame stackFrame= (ContextFrame) it.next();
- if (stackFrame.equals(frame)) {
- validateContextInformation();
- return;
- }
- }
- }
-
- // otherwise:
- // Precise context must be selected
-
- if (fLineDelimiter == null)
- fLineDelimiter= fContentAssistSubjectAdapter.getLineDelimiter();
-
- createContextSelector();
- setContexts(contexts);
- displayContextSelector();
- hideContextInfoPopup();
-
- } else if (!autoActivated) {
- control.getDisplay().beep();
- }
- }
- });
-
- return getErrorMessage();
- }
-
- /**
- * Displays the given context information for the given offset.
- *
- * @param info the context information
- * @param position the offset
- * @since 2.0
- */
- public void showContextInformation(final IContextInformation info, final int position) {
- Control control= fContentAssistSubjectAdapter.getControl();
- BusyIndicator.showWhile(control.getDisplay(), new Runnable() {
- public void run() {
- ContextFrame frame= createContextFrame(info, position);
- if (isDuplicate(frame))
- validateContextInformation();
- else
- internalShowContextInfo(frame);
- hideContextSelector();
- }
- });
- }
-
- /**
- * Displays the given context information for the given offset.
- *
- * @param frame the context frame tod display, or <code>null</code>
- * @since 3.0
- */
- private void internalShowContextInfo(ContextFrame frame) {
- if (frame != null) {
- fContextFrameStack.push(frame);
- if (fContextFrameStack.size() == 1)
- fLastContext= null;
- internalShowContextFrame(frame, fContextFrameStack.size() == 1);
- }
- }
-
- /**
- * Creates a context frame for the given offset.
- *
- * @param info the context information
- * @param position the offset
- * @since 3.0
- */
- private ContextFrame createContextFrame(IContextInformation information, int offset) {
- IContextInformationValidator validator= fContentAssistSubjectAdapter.getContextInformationValidator(fContentAssistant, offset);
-
- if (validator != null) {
- ContextFrame current= new ContextFrame();
- current.fInformation= information;
- current.fBeginOffset= (information instanceof IContextInformationExtension) ? ((IContextInformationExtension) information).getContextInformationPosition() : offset;
- if (current.fBeginOffset == -1) current.fBeginOffset= offset;
- current.fOffset= offset;
- current.fVisibleOffset= fContentAssistSubjectAdapter.getWidgetSelectionRange().x - (offset - current.fBeginOffset);
- current.fValidator= validator;
- current.fPresenter= fContentAssistSubjectAdapter.getContextInformationPresenter(fContentAssistant, offset);
- return current;
- }
-
- return null;
- }
-
- /**
- * Compares <code>frame</code> with the top of the stack, returns <code>true</code>
- * if the frames are the same.
- *
- * @param frame the frame to check
- * @return <code>true</code> if <code>frame</code> matches the top of the stack
- * @since 3.0
- */
- private boolean isDuplicate(ContextFrame frame) {
- if (frame == null)
- return false;
- if (fContextFrameStack.isEmpty())
- return false;
- // stack not empty
- ContextFrame top= (ContextFrame) fContextFrameStack.peek();
- return frame.equals(top);
- }
-
- /**
- * Compares <code>frame</code> with most recently removed context frame, returns <code>true</code>
- * if the frames are the same.
- *
- * @param frame the frame to check
- * @return <code>true</code> if <code>frame</code> matches the most recently removed
- * @since 3.0
- */
- private boolean isLastFrame(ContextFrame frame) {
- return frame != null && frame.equals(fLastContext);
- }
-
- /**
- * Shows the given context frame.
- *
- * @param frame the frane to display
- * @param initial <code>true</code> if this is the first frame to be displayed
- * @since 2.0
- */
- private void internalShowContextFrame(ContextFrame frame, boolean initial) {
-
- fContentAssistSubjectAdapter.installValidator(frame);
-
- if (frame.fPresenter != null) {
- if (fTextPresentation == null)
- fTextPresentation= new TextPresentation();
- fContentAssistSubjectAdapter.installContextInformationPresenter(frame);
- frame.fPresenter.updatePresentation(frame.fOffset, fTextPresentation);
- }
-
- createContextInfoPopup();
-
- fContextInfoText.setText(frame.fInformation.getInformationDisplayString());
- if (fTextPresentation != null)
- TextPresentation.applyTextPresentation(fTextPresentation, fContextInfoText);
- resize();
-
- if (initial) {
- if (fContentAssistant.addContentAssistListener(this, ContentAssistant.CONTEXT_INFO_POPUP)) {
- if (fContentAssistSubjectAdapter.getControl() != null) {
- fTextWidgetSelectionListener= new SelectionAdapter() {
- /*
- * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
- */
- public void widgetSelected(SelectionEvent e) {
- validateContextInformation();
- }};
- fContentAssistSubjectAdapter.addSelectionListener(fTextWidgetSelectionListener);
- }
- fContentAssistant.addToLayout(this, fContextInfoPopup, ContentAssistant.LayoutManager.LAYOUT_CONTEXT_INFO_POPUP, frame.fVisibleOffset);
- fContextInfoPopup.setVisible(true);
- }
- } else {
- fContentAssistant.layout(ContentAssistant.LayoutManager.LAYOUT_CONTEXT_INFO_POPUP, frame.fVisibleOffset);
- }
- }
-
- /**
- * Computes all possible context information for the given offset.
- *
- * @param position the offset
- * @return all possible context information for the given offset
- * @since 2.0
- */
- private IContextInformation[] computeContextInformation(int position) {
- return fContentAssistSubjectAdapter.computeContextInformation(fContentAssistant, position);
- }
-
- /**
- *Returns the error message generated while computing context information.
- *
- * @return the error message
- */
- private String getErrorMessage() {
- return fContentAssistant.getErrorMessage();
- }
-
- /**
- * Creates the context information popup. This is the tooltip like overlay window.
- */
- private void createContextInfoPopup() {
- if (Helper.okToUse(fContextInfoPopup))
- return;
-
- Control control= fContentAssistSubjectAdapter.getControl();
- Display display= control.getDisplay();
-
- fContextInfoPopup= new Shell(control.getShell(), SWT.NO_TRIM | SWT.ON_TOP);
- fContextInfoPopup.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
-
- fContextInfoText= new StyledText(fContextInfoPopup, SWT.MULTI | SWT.READ_ONLY);
-
- Color c= fContentAssistant.getContextInformationPopupBackground();
- if (c == null)
- c= display.getSystemColor(SWT.COLOR_INFO_BACKGROUND);
- fContextInfoText.setBackground(c);
-
- c= fContentAssistant.getContextInformationPopupForeground();
- if (c == null)
- c= display.getSystemColor(SWT.COLOR_INFO_FOREGROUND);
- fContextInfoText.setForeground(c);
- }
-
- /**
- * Resizes the context information popup.
- * @since 2.0
- */
- private void resize() {
- Point size= fContextInfoText.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
- size.x += 3;
- fContextInfoText.setSize(size);
- fContextInfoText.setLocation(1,1);
- size.x += 2;
- size.y += 2;
- fContextInfoPopup.setSize(size);
- }
-
- /**
- *Hides the context information popup.
- */
- private void hideContextInfoPopup() {
-
- if (Helper.okToUse(fContextInfoPopup)) {
-
- int size= fContextFrameStack.size();
- if (size > 0) {
- fLastContext= (ContextFrame) fContextFrameStack.pop();
- -- size;
- }
-
- if (size > 0) {
- ContextFrame current= (ContextFrame) fContextFrameStack.peek();
- internalShowContextFrame(current, false);
- } else {
-
- fContentAssistant.removeContentAssistListener(this, ContentAssistant.CONTEXT_INFO_POPUP);
-
- if (fContentAssistSubjectAdapter.getControl() != null)
- fContentAssistSubjectAdapter.removeSelectionListener(fTextWidgetSelectionListener);
- fTextWidgetSelectionListener= null;
-
- fContextInfoPopup.setVisible(false);
- fContextInfoPopup.dispose();
- fContextInfoPopup= null;
-
- if (fTextPresentation != null) {
- fTextPresentation.clear();
- fTextPresentation= null;
- }
- }
- }
-
- if (fContextInfoPopup == null)
- fContentAssistant.contextInformationClosed();
- }
-
- /**
- * Creates the context selector in case the user has the choice between multiple valid contexts
- * at a given offset.
- */
- private void createContextSelector() {
- if (Helper.okToUse(fContextSelectorShell))
- return;
-
- Control control= fContentAssistSubjectAdapter.getControl();
- fContextSelectorShell= new Shell(control.getShell(), SWT.ON_TOP | SWT.RESIZE);
- fContextSelectorTable= new Table(fContextSelectorShell, SWT.H_SCROLL | SWT.V_SCROLL);
-
- int height= fContextSelectorTable.getItemHeight() * 10;
- fContextSelectorShell.setSize(302, height + 2);
- fContextSelectorTable.setSize(300, height);
- fContextSelectorTable.setLocation(1, 1);
-
- fContextSelectorShell.setBackground(control.getDisplay().getSystemColor(SWT.COLOR_BLACK));
-
- Color c= fContentAssistant.getContextSelectorBackground();
- if (c == null)
- c= control.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND);
- fContextSelectorTable.setBackground(c);
-
- c= fContentAssistant.getContextSelectorForeground();
- if (c == null)
- c= control.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND);
- fContextSelectorTable.setForeground(c);
-
- fContextSelectorTable.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- insertSelectedContext();
- hideContextSelector();
- }
- });
-
- fPopupCloser.install(fContentAssistant, fContextSelectorTable);
-
- fContextSelectorTable.setHeaderVisible(false);
- fContentAssistant.addToLayout(this, fContextSelectorShell, ContentAssistant.LayoutManager.LAYOUT_CONTEXT_SELECTOR, fContentAssistant.getSelectionOffset());
- }
-
- /**
- * Causes the context information of the context selected in the context selector
- * to be displayed in the context information popup.
- */
- private void insertSelectedContext() {
- int i= fContextSelectorTable.getSelectionIndex();
-
- if (i < 0 || i >= fContextSelectorInput.length)
- return;
-
- int position= fContentAssistSubjectAdapter.getSelectedRange().x;
- internalShowContextInfo(createContextFrame(fContextSelectorInput[i], position));
- }
-
- /**
- * Sets the contexts in the context selector to the given set.
- *
- * @param contexts the possible contexts
- */
- private void setContexts(IContextInformation[] contexts) {
- if (Helper.okToUse(fContextSelectorTable)) {
-
- fContextSelectorInput= contexts;
-
- fContextSelectorTable.setRedraw(false);
- fContextSelectorTable.removeAll();
-
- TableItem item;
- IContextInformation t;
- for (int i= 0; i < contexts.length; i++) {
- t= contexts[i];
- item= new TableItem(fContextSelectorTable, SWT.NULL);
- if (t.getImage() != null)
- item.setImage(t.getImage());
- item.setText(t.getContextDisplayString());
- }
-
- fContextSelectorTable.select(0);
- fContextSelectorTable.setRedraw(true);
- }
- }
-
- /**
- * Displays the context selector.
- */
- private void displayContextSelector() {
- if (fContentAssistant.addContentAssistListener(this, ContentAssistant.CONTEXT_SELECTOR))
- fContextSelectorShell.setVisible(true);
- }
-
- /**
- * Hodes the context selector.
- */
- private void hideContextSelector() {
- if (Helper.okToUse(fContextSelectorShell)) {
- fContentAssistant.removeContentAssistListener(this, ContentAssistant.CONTEXT_SELECTOR);
-
- fPopupCloser.uninstall();
- fContextSelectorShell.setVisible(false);
- fContextSelectorShell.dispose();
- fContextSelectorShell= null;
- }
-
- if (!Helper.okToUse(fContextInfoPopup))
- fContentAssistant.contextInformationClosed();
- }
-
- /**
- *Returns whether the context selector has the focus.
- *
- * @return <code>true</code> if teh context selector has the focus
- */
- public boolean hasFocus() {
- if (Helper.okToUse(fContextSelectorShell))
- return (fContextSelectorShell.isFocusControl() || fContextSelectorTable.isFocusControl());
-
- return false;
- }
-
- /**
- * Hides context selector and context information popup.
- */
- public void hide() {
- hideContextSelector();
- hideContextInfoPopup();
- }
-
- /**
- * Returns whether this context information popup is active. I.e., either
- * a context selector or context information is displayed.
- *
- * @return <code>true</code> if the context selector is active
- */
- public boolean isActive() {
- return (Helper.okToUse(fContextInfoPopup) || Helper.okToUse(fContextSelectorShell));
- }
-
- /*
- * @see IContentAssistListener#verifyKey(VerifyEvent)
- */
- public boolean verifyKey(VerifyEvent e) {
- if (Helper.okToUse(fContextSelectorShell))
- return contextSelectorKeyPressed(e);
- if (Helper.okToUse(fContextInfoPopup))
- return contextInfoPopupKeyPressed(e);
- return true;
- }
-
- /**
- * Processes a key stroke in the context selector.
- *
- * @param e the verify event describing the key stroke
- * @return <code>true</code> if processing can be stopped
- */
- private boolean contextSelectorKeyPressed(VerifyEvent e) {
-
- char key= e.character;
- if (key == 0) {
-
- int change;
- int visibleRows= (fContextSelectorTable.getSize().y / fContextSelectorTable.getItemHeight()) - 1;
- int selection= fContextSelectorTable.getSelectionIndex();
-
- switch (e.keyCode) {
-
- case SWT.ARROW_UP:
- change= (fContextSelectorTable.getSelectionIndex() > 0 ? -1 : 0);
- break;
-
- case SWT.ARROW_DOWN:
- change= (fContextSelectorTable.getSelectionIndex() < fContextSelectorTable.getItemCount() - 1 ? 1 : 0);
- break;
-
- case SWT.PAGE_DOWN :
- change= visibleRows;
- if (selection + change >= fContextSelectorTable.getItemCount())
- change= fContextSelectorTable.getItemCount() - selection;
- break;
-
- case SWT.PAGE_UP :
- change= -visibleRows;
- if (selection + change < 0)
- change= -selection;
- break;
-
- case SWT.HOME :
- change= -selection;
- break;
-
- case SWT.END :
- change= fContextSelectorTable.getItemCount() - selection;
- break;
-
- default:
- if (e.keyCode != SWT.MOD1 && e.keyCode != SWT.MOD2 && e.keyCode != SWT.MOD3 && e.keyCode != SWT.MOD4)
- hideContextSelector();
- return true;
- }
-
- fContextSelectorTable.setSelection(selection + change);
- fContextSelectorTable.showSelection();
- e.doit= false;
- return false;
-
- } else if ('\t' == key) {
- // switch focus to selector shell
- e.doit= false;
- fContextSelectorShell.setFocus();
- return false;
- } else if (key == 0x1B) {
- // terminate on Esc
- hideContextSelector();
- }
-
- return true;
- }
-
- /**
- * Processes a key stroke while the info popup is up.
- *
- * @param e the verify event describing the key stroke
- * @return <code>true</code> if processing can be stopped
- */
- private boolean contextInfoPopupKeyPressed(KeyEvent e) {
-
- char key= e.character;
- if (key == 0) {
-
- switch (e.keyCode) {
-
- case SWT.ARROW_LEFT:
- case SWT.ARROW_RIGHT:
- validateContextInformation();
- break;
- default:
- if (e.keyCode != SWT.MOD1 && e.keyCode != SWT.MOD2 && e.keyCode != SWT.MOD3 && e.keyCode != SWT.MOD4)
- hideContextInfoPopup();
- break;
- }
-
- } else if (key == 0x1B) {
- // terminate on Esc
- hideContextInfoPopup();
- } else {
- validateContextInformation();
- }
- return true;
- }
-
- /*
- * @see IEventConsumer#processEvent(VerifyEvent)
- */
- public void processEvent(VerifyEvent event) {
- if (Helper.okToUse(fContextSelectorShell))
- contextSelectorProcessEvent(event);
- if (Helper.okToUse(fContextInfoPopup))
- contextInfoPopupProcessEvent(event);
- }
-
- /**
- * Processes a key stroke in the context selector.
- *
- * @param e the verify event describing the key stroke
- */
- private void contextSelectorProcessEvent(VerifyEvent e) {
-
- if (e.start == e.end && e.text != null && e.text.equals(fLineDelimiter)) {
- e.doit= false;
- insertSelectedContext();
- }
-
- hideContextSelector();
- }
-
- /**
- * Processes a key stroke while the info popup is up.
- *
- * @param e the verify event describing the key stroke
- */
- private void contextInfoPopupProcessEvent(VerifyEvent e) {
- if (e.start != e.end && (e.text == null || e.text.length() == 0))
- validateContextInformation();
- }
-
- /**
- * Validates the context information for the viewer's actual cursor position.
- */
- private void validateContextInformation() {
- /*
- * Post the code in the event queue in order to ensure that the
- * action described by this verify key event has already beed executed.
- * Otherwise, we'd validate the context information based on the
- * pre-key-stroke state.
- */
- fContextInfoPopup.getDisplay().asyncExec(new Runnable() {
-
- private ContextFrame fFrame= (ContextFrame) fContextFrameStack.peek();
-
- public void run() {
- // only do this if no other frames have been added in between
- if (!fContextFrameStack.isEmpty() && fFrame == fContextFrameStack.peek()) {
- int offset= fContentAssistSubjectAdapter.getSelectedRange().x;
-
- // iterate all contexts on the stack
- while (Helper.okToUse(fContextInfoPopup) && !fContextFrameStack.isEmpty()) {
- ContextFrame top= (ContextFrame) fContextFrameStack.peek();
- if (top.fValidator == null || !top.fValidator.isContextInformationValid(offset)) {
- hideContextInfoPopup(); // loop variant: reduces the number of contexts on the stack
- } else if (top.fPresenter != null && top.fPresenter.updatePresentation(offset, fTextPresentation)) {
- TextPresentation.applyTextPresentation(fTextPresentation, fContextInfoText);
- resize();
- break;
- } else
- break;
- }
- }
- }
- });
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationValidator.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationValidator.java
deleted file mode 100644
index 79d1117..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationValidator.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.contentassist;
-
-
-
-import org.eclipse.jface.text.ITextViewer;
-
-
-/**
- * A default implementation of the <code>IContextInfomationValidator</code> interface.
- * This implementation determines whether the information is valid by asking the content
- * assist processor for all context information objects for the current position. If the
- * currently displayed information is in the result set, the context information is
- * considered valid.
- */
-public final class ContextInformationValidator implements IContextInformationValidator, IContextInformationValidatorExtension {
-
- /** The content assist processor */
- private IContentAssistProcessor fProcessor;
- /** The context information to be validated */
- private IContextInformation fContextInformation;
- /** The associated text viewer */
- private ITextViewer fViewer;
- /**
- * The content assist subject.
- *
- * @since 3.0
- */
- private IContentAssistSubject fContentAssistSubject;
-
- /**
- * Creates a new context information validator which is ready to be installed on
- * a particular context information.
- *
- * @param processor the processor to be used for validation
- */
- public ContextInformationValidator(IContentAssistProcessor processor) {
- fProcessor= processor;
- }
-
- /*
- * @see IContextInformationValidator#install(IContextInformation, ITextViewer, int)
- */
- public void install(IContextInformation contextInformation, ITextViewer viewer, int position) {
- fContextInformation= contextInformation;
- fViewer= viewer;
- }
-
- public void install(IContextInformation contextInformation, IContentAssistSubject contentAssistSubject, int position) {
- fContextInformation= contextInformation;
- fContentAssistSubject= contentAssistSubject;
- }
-
- /*
- * @see IContentAssistTipCloser#isContextInformationValid(int)
- */
- public boolean isContextInformationValid(int position) {
- IContextInformation[] infos= null;
- if (fContentAssistSubject != null) {
- if (fProcessor instanceof IContentAssistProcessorExtension)
- infos= ((IContentAssistProcessorExtension)fProcessor).computeContextInformation(fContentAssistSubject, position);
- } else
- infos= fProcessor.computeContextInformation(fViewer, position);
- if (infos != null && infos.length > 0) {
- for (int i= 0; i < infos.length; i++)
- if (fContextInformation.equals(infos[i]))
- return true;
- }
- return false;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/Helper.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/Helper.java
deleted file mode 100644
index 79fd6b2..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/Helper.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.contentassist;
-
-
-
-import org.eclipse.swt.widgets.Widget;
-
-
-/**
- * Helper class for testing widget state.
- */
-class Helper {
-
- /**
- * Returns whether the widget is <code>null</code> or disposed.
- *
- * @param widget the widget to check
- * @return <code>true</code> if the widget is neither <code>null</code> nor disposed
- */
- public static boolean okToUse(Widget widget) {
- return (widget != null && !widget.isDisposed());
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposal.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposal.java
deleted file mode 100644
index cbf8ecb..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposal.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.contentassist;
-
-
-
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-
-import org.eclipse.jface.text.IDocument;
-
-
-/**
- * The interface of completion proposals generated by content assist processors.
- * A completion proposal contains information used to present the proposed completion
- * to the user, to insert the completion should the user select it, and to present
- * context information for the choosen completion once it has been inserted.<p>
- * The interface can be implemented by clients. By default, clients use
- * <code>CompletionProposal</code> as the standard implementer of this interface.
- *
- * @see IContentAssistProcessor
- */
-public interface ICompletionProposal {
-
- /**
- * Inserts the proposed completion into the given document.
- *
- * @param document the document into which to insert the proposed completion
- */
- void apply(IDocument document);
-
- /**
- * Returns the new selection after the proposal has been applied to
- * the given document in absolute document coordinates. If it returns
- * <code>null</code>, no new selection is set.
- *
- * A document change can trigger other document changes, which have
- * to be taken into account when calculating the new selection. Typically,
- * this would be done by installing a document listener or by using a
- * document position during apply().
- *
- * @param document the document into which the proposed completion has been inserted
- * @return the new selection in absolute document coordinates
- */
- Point getSelection(IDocument document);
-
- /**
- * Returns optional additional information about the proposal.
- * The additional information will be presented to assist the user
- * in deciding if the selected proposal is the desired choice.
- *
- * @return the additional information or <code>null</code>
- */
- String getAdditionalProposalInfo();
-
- /**
- * Returns the string to be displayed in the list of completion proposals.
- *
- * @return the string to be displayed
- */
- String getDisplayString();
-
- /**
- * Returns the image to be displayed in the list of completion proposals.
- * The image would typically be shown to the left of the display string.
- *
- * @return the image to be shown or <code>null</code> if no image is desired
- */
- Image getImage();
-
- /**
- * Returns optional context information associated with this proposal.
- * The context information will automatically be shown if the proposal
- * has been applied.
- *
- * @return the context information for this proposal or <code>null</code>
- */
- IContextInformation getContextInformation();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposalExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposalExtension.java
deleted file mode 100644
index d34eea4..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposalExtension.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.contentassist;
-
-
-import org.eclipse.jface.text.IDocument;
-
-
-/**
- * Extension interface to <code>ICompletionProposal</code>.
- * Add the following functions:
- * <ul>
- * <li> handling of trigger characters other then ENTER
- * <li> completion proposal validation for a given offset
- * <li> freely positionable context information
- * </ul>
- *
- * @since 2.0
- */
-public interface ICompletionProposalExtension {
-
- /**
- * Applies the proposed completion to the given document. The insertion
- * has been triggered by entering the given character at the given offset.
- * This method assumes that <code>isValidFor</code> returns
- * <code>true</code> if called for <code>offset</code>.
- *
- * @param document the document into which to insert the proposed completion
- * @param trigger the trigger to apply the completion
- * @param offset the offset at which the trigger has been activated
- */
- void apply(IDocument document, char trigger, int offset);
-
- /**
- * Returns whether this completion proposal is valid for the given
- * position in the given document.
- *
- * @param document the document for which the proposal is tested
- * @param offset the offset for which the proposal is tested
- * @return <code>true</code> iff valid
- */
- boolean isValidFor(IDocument document, int offset);
-
- /**
- * Returns the characters which trigger the application of this completion proposal.
- *
- * @return the completion characters for this completion proposal or <code>null</code>
- * if no completion other than the new line character is possible
- */
- char[] getTriggerCharacters();
-
- /**
- * Returns the position to which the computed context information refers to or
- * <code>-1</code> if no context information can be provided by this completion proposal.
- *
- * @return the position to which the context information refers to or <code>-1</code> for no information
- */
- int getContextInformationPosition();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposalExtension2.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposalExtension2.java
deleted file mode 100644
index eba9b8f..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposalExtension2.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.contentassist;
-
-
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextViewer;
-
-
-/**
- * Extension interface to <code>ICompletionProposal</code>.
- * Add the following functions:
- * <ul>
- * <li> handling of trigger characters with modifiers
- * <li> visual indication for selection of a proposal
- * </ul>
- *
- * @since 2.1
- */
-public interface ICompletionProposalExtension2 {
-
- /**
- * Applies the proposed completion to the given document. The insertion
- * has been triggered by entering the given character with a modifier at the given offset.
- * This method assumes that <code>isValidFor</code> returns
- * <code>true</code> if called for <code>offset</code>.
- *
- * @param viewer the text viewer into which to insert the proposed completion
- * @param trigger the trigger to apply the completion
- * @param stateMask the state mask of the modifiers
- * @param offset the offset at which the trigger has been activated
- */
- void apply(ITextViewer viewer, char trigger, int stateMask, int offset);
-
- /**
- * Called when the proposal is selected.
- *
- * @param viewer the text viewer.
- * @param smartToggle the smart toggle key was pressed
- */
- void selected(ITextViewer viewer, boolean smartToggle);
-
- /**
- * Called when the proposal is unselected.
- *
- * @param viewer the text viewer.
- */
- void unselected(ITextViewer viewer);
-
- /**
- * Requests the proposal to be validated with respect to the document event.
- * If the proposal cannot be validated, the methods returns <code>false</code>.
- * If the document event was <code>null</code>, only the caret offset was changed, but not the document.
- *
- * This method deprecates ICompletionProposalExtension.isValidFor(IDocument, int)
- *
- * @param document the document
- * @param offset the caret offset
- * @param event the document event, may be <code>null</code>
- * @return boolean
- */
- boolean validate(IDocument document, int offset, DocumentEvent event);
-
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposalExtension3.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposalExtension3.java
deleted file mode 100644
index 4a41e3a..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposalExtension3.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.contentassist;
-
-
-import org.eclipse.jface.text.IInformationControlCreator;
-
-
-/**
- * Extension interface to <code>ICompletionProposal</code>.
- * Add the following functions:
- * <ul>
- * <li> provision of a custom information control creator
- * </ul>
- *
- * @since 3.0
- */
-public interface ICompletionProposalExtension3 {
- /**
- * Returns the information control creator of this completion proposal.
- *
- * @return the information control creator, or <code>null</code> if no custom control creater is available
- */
- IInformationControlCreator getInformationControlCreator();
-
- /**
- * Returns the string that would be inserted at the position returned from
- * {@see #getCompletionOffset()} if this proposal was applied. If the
- * replacement string cannot be determined, <code>null</code> may be returned.
- *
- * @return the replacement string or <code>null</code> if it cannot be determined
- */
- CharSequence getCompletionText();
-
- /**
- * Returns the document offset at which the receiver would insert its proposal.
- *
- * @return the offset at which the proposal would insert its proposal
- */
- int getCompletionOffset();
-
- /**
- * Updates the replacement offset of a completion proposal. Implementations
- * may use the offset to detect whether a partial
- *
- * @param offset the new replacement offset, nee
- */
- void updateReplacementOffset(int offset);
-
- /**
- * Returns the replacement string that would be inserted at the replacement offset if
- * the proposal were applied.
- *
- * @return the replacement string that would be inserted at the replacement offset
- */
- String getReplacementString();
-
- /**
- * Updates the replacement length of a completion proposal. Implementations
- * may use the length to ajust the amount of code they would 'eat' when inserted.
- *
- * @param length the new replacement length hint
- */
- void updateReplacementLength(int length);
-
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistListener.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistListener.java
deleted file mode 100644
index 34cf082..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistListener.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.contentassist;
-
-
-
-import org.eclipse.swt.events.VerifyEvent;
-
-import org.eclipse.jface.text.IEventConsumer;
-
-
-
-/**
- * An interface whereby listeners can not only receive key events,
- * but can also consume them to prevent subsequent listeners from
- * processing the event.
- */
-interface IContentAssistListener extends IEventConsumer {
-
- /**
- * Verifies the key event.
- *
- * @param event the verify event
- * @return <code>true</code> if processing should be continued by additional listeners
- * @see org.eclipse.swt.custom.VerifyKeyListener#verifyKey(VerifyEvent)
- */
- public boolean verifyKey(VerifyEvent event);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistProcessor.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistProcessor.java
deleted file mode 100644
index 55bbbab..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistProcessor.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.contentassist;
-
-
-
-import org.eclipse.jface.text.ITextViewer;
-
-
-
-/**
- * A content assist processor proposes completions and
- * computes context information for a particular content type.
- * A content assist processor is an <code>IContentAssistant</code>-plug-ins.
- * This interface must be implemented by clients. Implementers should be
- * registered with a content assistant in order to get involved in the
- * assisting process.
-*/
-public interface IContentAssistProcessor {
-
- /**
- * Returns a list of completion proposals based on the
- * specified location within the document that corresponds
- * to the current cursor position within the text viewer.
- *
- * @param viewer the viewer whose document is used to compute the proposals
- * @param 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(ITextViewer viewer, int documentOffset);
-
- /**
- * Returns information about possible contexts based on the
- * specified location within the document that corresponds
- * to the current cursor position within the text viewer.
- *
- * @param viewer the viewer whose document is used to compute the possible contexts
- * @param 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(ITextViewer viewer, int documentOffset);
-
- /**
- * Returns the characters which when entered by the user should
- * automatically trigger the presentation of possible completions.
- *
- * @return the auto activation characters for completion proposal or <code>null</code>
- * if no auto activation is desired
- */
- char[] getCompletionProposalAutoActivationCharacters();
-
- /**
- * Returns the characters which when entered by the user should
- * automatically trigger the presentation of context information.
- *
- * @return the auto activation characters for presenting context information
- * or <code>null</code> if no auto activation is desired
- */
- char[] getContextInformationAutoActivationCharacters();
-
- /**
- * Returns the reason why this content assist processor
- * was unable to produce any completion proposals or context information.
- *
- * @return an error message or <code>null</code> if no error occurred
- */
- String getErrorMessage();
-
- /**
- * Returns a validator used to determine when displayed context information
- * should be dismissed. May only return <code>null</code> if the processor is
- * incapable of computing context information. <p>
- *
- * @return a context information validator, or <code>null</code> if the processor
- * is incapable of computing context information
- */
- IContextInformationValidator getContextInformationValidator();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistProcessorExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistProcessorExtension.java
deleted file mode 100644
index 53ca73d..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistProcessorExtension.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.contentassist;
-
-/**
- * Extends <code>IContentAssit</code> with the concept of a
- * content assist subject which provides the context for
- * the content assistant.
- *
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubject
- * @since 3.0
- */
-public interface IContentAssistProcessorExtension {
- /**
- * Returns a list of completion proposals based on the specified location
- * within the document that corresponds to the current cursor position
- * within the text viewer.
- *
- * @param contentAssistSubject the content assist subject whose
- * document is used to compute the proposals
- * @param 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(IContentAssistSubject contentAssistSubject, int documentOffset);
-
- /**
- * Returns information about possible contexts based on the specified
- * location within the document that corresponds to the current cursor
- * position within the content assist subject.
- *
- * @param contentAssistSubject the content assist subject whose
- * document is used to compute the possible contexts
- * @param 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(IContentAssistSubject contentAssistSubject, int documentOffset);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistSubject.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistSubject.java
deleted file mode 100644
index 9adc27e..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistSubject.java
+++ /dev/null
@@ -1,296 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.contentassist;
-
-import org.eclipse.swt.custom.VerifyKeyListener;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Control;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IEventConsumer;
-
-/**
- * A content assist subject can request assistance provided by a
- * {@link org.eclipse.jface.text.contentassist.IContentAssistant content assistant}.
- *
- * @since 3.0
- */
-public interface IContentAssistSubject {
-
- /**
- * Returns the control of this content assist subject.
- *
- * @return the control of this content assist subject
- */
- Control getControl();
-
- /**
- * Returns the line height.
- *
- * @return line height in pixel
- * @exception 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's document.
- *
- * @return the viewer's input document
- */
- IDocument getDocument();
-
- /**
- * If supported, appends a verify key listener to the viewer's list of verify key
- * listeners. If the listener is already registered with the viewer this
- * call moves the listener to the end of the list.
- * <p>
- * Note: This content assist subject may not support appending a verify
- * listener, in which case <code>false</code> will be returned. If this
- * content assist subject only supports <code>addVerifyKeyListener</code>
- * then this method can be used but <code>prependVerifyKeyListener</code>
- * must return <code>false</code>.
- * </p>
- *
- * @param verifyKeyListener the listener to be added
- * @return <code>true</code> if the listener was added
- */
- boolean appendVerifyKeyListener(VerifyKeyListener verifyKeyListener);
-
- /**
- * If supported, inserts the verify key listener at the beginning of this content assist
- * subject's list of verify key listeners. If the listener is already
- * registered with the viewer this call moves the listener to the beginnng
- * of the list.
- * <p>
- * Note: This content assist subject may not support prepending a verify
- * listener, in which case <code>false</code> will be returned. However,
- * <code>appendVerifyKeyListener</code> might work.
- * </p>
- *
- * @param verifyKeyListener the listener to be inserted
- * @return <code>true</code> if the listener was added
- */
- boolean prependVerifyKeyListener(VerifyKeyListener verifyKeyListener);
-
- /**
- * Removes the verify key listener from this content assist subject's
- * list of verify key listeners. If the listener is not registered, this
- * call has no effect.
- *
- * @param verifyKeyListener the listener to be removed
- */
- void removeVerifyKeyListener(VerifyKeyListener verifyKeyListener);
-
- /**
- * Tests whether a verify key listener can be added either using <code>prependVerifyKeyListener</code>
- * or <code>appendVerifyKeyListener</code>.
- *
- * @return <code>true</code> if adding verify key listeners is supported
- */
- boolean supportsVerifyKeyListener();
-
- /**
- * Adds the listener to the collection of listeners who will be notified
- * when keys are pressed and released on the system keyboard, by sending it
- * one of the messages defined in the <code>KeyListener</code> interface.
- *
- * @param keyListener the listener which should be notified
- *
- * @exception IllegalArgumentException
- * <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception 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'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/text/contentassist/IContentAssistant.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistant.java
deleted file mode 100644
index edb152a..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistant.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.contentassist;
-
-
-import org.eclipse.jface.text.ITextViewer;
-
-
-/**
- * An <code>IContentAssistant</code> provides support on interactive content completion.
- * The content assistant is a <code>ITextViewer</code> add-on. Its
- * purpose is to propose, display, and insert completions of the content
- * of the text viewer's document at the viewer's cursor position. In addition
- * to handle completions, a content assistant can also be requested to provide
- * context information. Context information is shown in a tooltip like popup.
- * As it is not always possible to determine the exact context at a given
- * document offset, a content assistant displays the possible contexts and requests
- * the user to choose the one whose information should be displayed.<p>
- * A content assistant has a list of <code>IContentAssistProcessor</code>
- * objects each of which is registered for a particular document content
- * type. The content assistant uses the processors to react on the request
- * of completing documents or presenting context information.<p>
- * The interface can be implemented by clients. By default, clients use
- * <code>ContentAssistant</code> as the standard implementer of this interface.
- *
- * @see ITextViewer
- * @see IContentAssistProcessor
- */
-
- public interface IContentAssistant {
-
- //------ proposal popup orientation styles ------------
- /** The context info list will overlay the list of completion proposals. */
- public final static int PROPOSAL_OVERLAY= 10;
- /** The completion proposal list will be removed before the context info list will be shown. */
- public final static int PROPOSAL_REMOVE= 11;
- /** The context info list will be presented without hiding or overlapping the completion proposal list. */
- public final static int PROPOSAL_STACKED= 12;
-
- //------ context info box orientation styles ----------
- /** Context info will be shown above the location it has been requested for without hiding the location. */
- public final static int CONTEXT_INFO_ABOVE= 20;
- /** Context info will be shown below the location it has been requested for without hiding the location. */
- public final static int CONTEXT_INFO_BELOW= 21;
-
-
- /**
- * Installs content assist support on the given text viewer.
- *
- * @param textViewer the text viewer on which content assist will work
- */
- void install(ITextViewer textViewer);
-
- /**
- * Uninstalls content assist support from the text viewer it has
- * previously be installed on.
- */
- void uninstall();
-
- /**
- * Shows all possible completions of the content at the viewer's cursor position.
- *
- * @return an optional error message if no proposals can be computed
- */
- String showPossibleCompletions();
-
- /**
- * Shows context information for the content at the viewer's cursor position.
- *
- * @return an optional error message if no context information can be computed
- */
- String showContextInformation();
-
- /**
- * Returns the content assist processor to be used for the given content type.
- *
- * @param contentType the type of the content for which this
- * content assistant is to be requested
- * @return an instance content assist processor or
- * <code>null</code> if none exists for the specified content type
- */
- IContentAssistProcessor getContentAssistProcessor(String contentType);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistantExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistantExtension.java
deleted file mode 100644
index cd09722..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContentAssistantExtension.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**********************************************************************
-Copyright (c) 2000, 2003 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-
-Contributors:
- IBM Corporation - Initial implementation
-**********************************************************************/
-package org.eclipse.jface.text.contentassist;
-
-/**
- * Extension interface for <code>IContentAssistant</code>.
- * Updates the content assistant to be aware of documents with multiple partitions.
- *
- * @since 3.0
- */
-public interface IContentAssistantExtension {
-
- /**
- * Returns the document partitioning this content assistant is using.
- *
- * @return the document partitioning this content assistant is using
- */
- String getDocumentPartitioning();
-
- /**
- * Installs content assist support on the given subject.
- *
- * @param contentAssistSubject the one who requests content assist
- * @throws UnsupportedOperationException if the content assist does not support this method
- */
- void install(IContentAssistSubject contentAssistSubject);
-
- /**
- * Complete the common prefix of the available choices.
- *
- * @return an optional error message if no proposals can be computed
- */
- String completePrefix();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformation.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformation.java
deleted file mode 100644
index a87158f..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformation.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.contentassist;
-
-
-
-import org.eclipse.swt.graphics.Image;
-
-
-/**
- * The inferface of context information presented to the user and
- * generated by content assist processors.
- * The interface can be implemented by clients. By default, clients use
- * <code>ContextInformation</code> as the standard implementer of this interface.
- *
- * @see IContentAssistProcessor
- */
-public interface IContextInformation {
-
- /**
- * Returns the string to be displayed in the list of contexts.
- * This method is used to supply a unique presentation for
- * situations where the context is ambiguous. These strings are
- * used to allow the user to select the specific context.
- *
- * @return the string to be displayed for the context
- */
- String getContextDisplayString();
-
- /**
- * Returns the image for this context information.
- * The image will be shown to the left of the display string.
- *
- * @return the image to be shown or <code>null</code> if no image is desired
- */
- Image getImage();
-
- /**
- * Returns the string to be displayed in the tooltip like information popup.
- *
- * @return the string to be displayed
- */
- String getInformationDisplayString();
-
- /**
- * Compares the given object with this receiver. Two context informations are
- * equal if there information display strings and their context display strings
- * are equal.
- *
- * @see Object#equals(Object)
- */
- boolean equals(Object object);
-}
-
-
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformationExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformationExtension.java
deleted file mode 100644
index 7da3180..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformationExtension.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.contentassist;
-
-
-/**
- * Extension interface for <code>IContextInformation</code>.
- * Adds the functionality of freely positionable context information.
- *
- * @since 2.0
- */
-public interface IContextInformationExtension {
-
- /**
- * Returns the start offset of the range for which this context information is valid.
- *
- * @return the start offset of the range for which this context information is valid
- */
- int getContextInformationPosition();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformationPresenter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformationPresenter.java
deleted file mode 100644
index f7d60fd..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformationPresenter.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.contentassist;
-
-
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.TextPresentation;
-
-
-/**
- * A context information presenter determines the presentation
- * of context information depending on a given document position.
- * The interface can be implemented by clients.
- *
- * @since 2.0
- */
-public interface IContextInformationPresenter {
-
- /**
- * Installs this presenter for the given context information.
- *
- * @param info the context information which this presenter should style
- * @param viewer the text viewer on which the information is presented
- * @param documentPosition the document position for which the information has been computed
- */
- void install(IContextInformation info, ITextViewer viewer, int documentPosition);
-
- /**
- * Updates the given presentation of the given context information
- * at the given document position. Returns whether update changed the
- * presentation.
- *
- * @param documentPosition the current position within the document
- * @param presentation the presentation to be updated
- * @return <code>true</code> if the given presentation has been changed
- */
- boolean updatePresentation(int documentPosition, TextPresentation presentation);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformationPresenterExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformationPresenterExtension.java
deleted file mode 100644
index 9625342..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformationPresenterExtension.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.contentassist;
-
-/**
- * Extends <code>IContentAssit</code> with the concept of a
- * content assist subject which provides the context for
- * the content assistant.
- *
- * @since 3.0
- */
-public interface IContextInformationPresenterExtension {
-
- /**
- * Installs this presenter for the given context information.
- *
- * @param info the context information which this presenter should style
- * @param contentAssistSubject the content assit subject
- * @param documentPosition the document position for which the information has been computed
- */
- void install(IContextInformation info, IContentAssistSubject contentAssistSubject, int documentPosition);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformationValidator.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformationValidator.java
deleted file mode 100644
index 35cec4c..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformationValidator.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.contentassist;
-
-
-
-import org.eclipse.jface.text.ITextViewer;
-
-
-/**
- * A context information validator is used to determine if
- * a displayed context information is still valid or should
- * be dismissed. The interface can be implemented by clients. <p>
- *
- * @see IContextInformationPresenter
- */
-public interface IContextInformationValidator {
-
- /**
- * Installs this validator for the given context information.
- *
- * @param info the context information which this validator should check
- * @param viewer the text viewer on which the information is presented
- * @param documentPosition the document position for which the information has been computed
- */
- void install(IContextInformation info, ITextViewer viewer, int documentPosition);
-
- /**
- * Returns whether the information this validator is installed on is still valid
- * at the given document position.
- *
- * @param documentPosition the current position within the document
- * @return <code>true</code> if the information also valid at the given document position
- */
- boolean isContextInformationValid(int documentPosition);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformationValidatorExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformationValidatorExtension.java
deleted file mode 100644
index 5da21bb..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/IContextInformationValidatorExtension.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.contentassist;
-/**
- * Extends <code>IContentAssit</code> with the concept of a content assist
- * subject which provides the context for the content assistant.
- *
- * @since 3.0
- */
-public interface IContextInformationValidatorExtension {
-
- /**
- * Installs this validator for the given context information.
- *
- * @param info the context information which this validator should check
- * @param contentAssistSubject the content assist subject
- * @param documentPosition the document position for which the information
- * has been computed
- */
- void install(IContextInformation info, IContentAssistSubject contentAssistSubject, int documentPosition);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/JFaceTextMessages.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/JFaceTextMessages.java
deleted file mode 100644
index cdc432e..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/JFaceTextMessages.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.contentassist;
-
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-class JFaceTextMessages {
-
- private static final String RESOURCE_BUNDLE= "org.eclipse.jface.text.JFaceTextMessages";//$NON-NLS-1$
-
- private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
-
- private JFaceTextMessages() {
- }
-
- public static String getString(String key) {
- try {
- return fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/PopupCloser.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/PopupCloser.java
deleted file mode 100644
index c83e35b..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/PopupCloser.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.contentassist;
-
-
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.ScrollBar;
-import org.eclipse.swt.widgets.Table;
-
-
-/**
- * A generic closer class used to monitor various
- * interface events in order to determine whether
- * a content assistant should be terminated and all
- * associated windows be closed.
- */
-class PopupCloser implements FocusListener, SelectionListener {
-
- /** The content assistant to be monitored */
- private ContentAssistant fContentAssistant;
- /** The table of a selector popup opened by the content assistant */
- private Table fTable;
- /** The scrollbar of the table for the selector popup */
- private ScrollBar fScrollbar;
- /** Indicates whether the scrollbar thumb has been grabed */
- private boolean fScrollbarClicked= false;
-
- /**
- * Installs this closer on the given table opened by the given content assistant.
- *
- * @param contentAssistant the content assistant
- * @param table the table to be tracked
- */
- public void install(ContentAssistant contentAssistant, Table table) {
- fContentAssistant= contentAssistant;
- fTable= table;
- if (Helper.okToUse(fTable)) {
- fTable.addFocusListener(this);
- fScrollbar= fTable.getVerticalBar();
- if (fScrollbar != null)
- fScrollbar.addSelectionListener(this);
- }
- }
-
- /**
- * Uninstalls this closer if previously installed.
- */
- public void uninstall() {
- if (Helper.okToUse(fScrollbar))
- fScrollbar.removeSelectionListener(this);
- if (Helper.okToUse(fTable))
- fTable.removeFocusListener(this);
- }
-
- /*
- * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
- */
- public void widgetSelected(SelectionEvent e) {
- fScrollbarClicked= true;
- }
-
- /*
- * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
- */
- public void widgetDefaultSelected(SelectionEvent e) {
- fScrollbarClicked= true;
- }
-
- /*
- * @see org.eclipse.swt.events.FocusListener#focusGained(org.eclipse.swt.events.FocusEvent)
- */
- public void focusGained(FocusEvent e) {
- }
-
- /*
- * @see org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt.events.FocusEvent)
- */
- public void focusLost(final FocusEvent e) {
- fScrollbarClicked= false;
- Display d= fTable.getDisplay();
- d.asyncExec(new Runnable() {
- public void run() {
- if (Helper.okToUse(fTable) && !fTable.isFocusControl() && !fScrollbarClicked)
- fContentAssistant.popupFocusLost(e);
- }
- });
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/TextContentAssistSubjectAdapter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/TextContentAssistSubjectAdapter.java
deleted file mode 100644
index ab4c72d..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/TextContentAssistSubjectAdapter.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.contentassist;
-
-import java.util.HashMap;
-
-import 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>IContentAssistSubject</code>.
- *
- * @see org.eclipse.swt.widgets.Text
- * @see org.eclipse.jface.text.contentassist.IContentAssistSubject
- * @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 adapter for the given text.
- *
- * @param text the text to adapt
- */
- public TextContentAssistSubjectAdapter(Text text) {
- this(text, true);
- }
-
- /**
- * Creates a content assist subject adapter for the given text.
- *
- * @param text the text to adapt
- * @param showCue show cue on the left side of control
- */
- public TextContentAssistSubjectAdapter(Text text, boolean showCue) {
- super(text, showCue);
- 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/text/contentassist/images/content_assist_cue.gif b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/images/content_assist_cue.gif
deleted file mode 100644
index 6efb807..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/images/content_assist_cue.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/images/error_small.gif b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/images/error_small.gif
deleted file mode 100644
index 9a48edc..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/images/error_small.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/package.html b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/package.html
deleted file mode 100644
index 2d94dfb..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/package.html
+++ /dev/null
@@ -1,25 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="Author" content="IBM">
- <meta name="GENERATOR" content="Mozilla/4.51 [en] (WinNT; I) [Netscape]">
- <title>Package-level Javadoc</title>
-</head>
-<body>
-Provides a content assist add-on for an <tt>ITextViewer</tt>.
-Content assist supports the user in writing by proposing context
-sensitive completions at a given document position. A completion can also
-be a incomplete in itself and content assist provides means to deal with
-nested completions.
-<h2>
-Package Specification</h2>
-<tt>IContentAssistant</tt> defines the concept of the content assist add-on.
-It collaborates with content type specific completion processors (<tt>IContentAssistProcessor</tt>)
-in order to generate completion proposals (<tt>ICompletionProposal</tt>)
-valid at the current document position. The package provides a default
-implementation <tt>ContentAssistant</tt> which completely defines and implements
-the UI and the control flow for content assist.
-<br>
-</body>
-</html>
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContentFormatter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContentFormatter.java
deleted file mode 100644
index d04bea9..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContentFormatter.java
+++ /dev/null
@@ -1,793 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.formatter;
-
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.DefaultPositionUpdater;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentExtension3;
-import org.eclipse.jface.text.IPositionUpdater;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.TextUtilities;
-import org.eclipse.jface.text.TypedPosition;
-
-
-/**
- * Standard implementation of <code>IContentFormatter</code>.
- * The formatter supports two operation modes: partition aware and
- * partition unaware. <p>
- * In the partition aware mode, the formatter determines the
- * partitioning of the document region to be formatted. For each
- * partition it determines all document positions which are affected
- * when text changes are applied to the partition. Those which overlap
- * with the partition are remembered as character positions. These
- * character positions are passed over to the formatting strategy
- * registered for the partition's content type. The formatting strategy
- * returns a string containing the formatted document partition as well
- * as the adapted character positions. The formatted partition replaces
- * the old content of the partition. The remembered document positions
- * are updated with the adapted character positions. In addition, all
- * other document positions are accordingly adapted to the formatting
- * changes.<p>
- * In the partition unaware mode, the document's partitioning is ignored
- * and the document is considered consisting of only one partition of
- * the content type <code>IDocument.DEFAULT_CONTENT_TYPE</code>. The
- * formatting process is similar to the partition aware mode, with the
- * exception of having only one partition.<p>
- * Usually, clients instantiate this class and configure it before using it.
- *
- * @see IContentFormatter
- * @see IDocument
- * @see ITypedRegion
- * @see Position
- */
-public class ContentFormatter implements IContentFormatter, IContentFormatterExtension {
-
- /**
- * Defines a reference to either the offset or the end offset of
- * a particular position.
- */
- static class PositionReference implements Comparable {
-
- /** The referenced position */
- protected Position fPosition;
- /** The reference to either the offset or the end offset */
- protected boolean fRefersToOffset;
- /** The original category of the referenced position */
- protected String fCategory;
-
- /**
- * Creates a new position reference.
- *
- * @param position the position to be referenced
- * @param refersToOffset <code>true</code> if position offset should be referenced
- * @param category the category the given position belongs to
- */
- protected PositionReference(Position position, boolean refersToOffset, String category) {
- fPosition= position;
- fRefersToOffset= refersToOffset;
- fCategory= category;
- }
-
- /**
- * Returns the offset of the referenced position.
- *
- * @return the offset of the referenced position
- */
- protected int getOffset() {
- return fPosition.getOffset();
- }
-
- /**
- * Manipulates the offset of the referenced position.
- *
- * @param offset the new offset of the referenced position
- */
- protected void setOffset(int offset) {
- fPosition.setOffset(offset);
- }
-
- /**
- * Returns the length of the referenced position.
- *
- * @return the length of the referenced position
- */
- protected int getLength() {
- return fPosition.getLength();
- }
-
- /**
- * Manipulates the length of the referenced position.
- *
- * @param the new length of the referenced position
- */
- protected void setLength(int length) {
- fPosition.setLength(length);
- }
-
- /**
- * Returns whether this reference points to the offset or end offset
- * of the references position.
- *
- * @return <code>true</code> if the offset of the position is referenced, <code>false</code> otherwise
- */
- protected boolean refersToOffset() {
- return fRefersToOffset;
- }
-
- /**
- * Returns the category of the referenced position.
- *
- * @return the category of the referenced position
- */
- protected String getCategory() {
- return fCategory;
- }
-
- /**
- * Returns the referenced position.
- *
- * @return the referenced position
- */
- protected Position getPosition() {
- return fPosition;
- }
-
- /**
- * Returns the referenced character position
- *
- * @return the referenced character position
- */
- protected int getCharacterPosition() {
- if (fRefersToOffset)
- return getOffset();
- return getOffset() + getLength();
- }
-
- /*
- * @see Comparable#compareTo(Object)
- */
- public int compareTo(Object obj) {
-
- if (obj instanceof PositionReference) {
- PositionReference r= (PositionReference) obj;
- return getCharacterPosition() - r.getCharacterPosition();
- }
-
- throw new ClassCastException();
- }
- }
-
- /**
- * The position updater used to update the remembered partitions.
- *
- * @see IPositionUpdater
- * @see DefaultPositionUpdater
- */
- class NonDeletingPositionUpdater extends DefaultPositionUpdater {
-
- /**
- * Creates a new updater for the given category.
- *
- * @param category the category
- */
- protected NonDeletingPositionUpdater(String category) {
- super(category);
- }
-
- /*
- * @see DefaultPositionUpdater#notDeleted()
- */
- protected boolean notDeleted() {
- return true;
- }
- }
-
- /**
- * The position updater which runs as first updater on the document's positions.
- * Used to remove all affected positions from their categories to avoid them
- * from being regularly updated.
- *
- * @see IPositionUpdater
- */
- class RemoveAffectedPositions implements IPositionUpdater {
- /**
- * @see IPositionUpdater#update(DocumentEvent)
- */
- public void update(DocumentEvent event) {
- removeAffectedPositions(event.getDocument());
- }
- }
-
- /**
- * The position updater which runs as last updater on the document's positions.
- * Used to update all affected positions and adding them back to their
- * original categories.
- *
- * @see IPositionUpdater
- */
- class UpdateAffectedPositions implements IPositionUpdater {
-
- /** The affected positions */
- private int[] fPositions;
- /** The offset */
- private int fOffset;
-
- /**
- * Creates a new updater.
- *
- * @param positions the affected positions
- * @param offset the offset
- */
- public UpdateAffectedPositions(int[] positions, int offset) {
- fPositions= positions;
- fOffset= offset;
- }
-
- /*
- * @see IPositionUpdater#update(DocumentEvent)
- */
- public void update(DocumentEvent event) {
- updateAffectedPositions(event.getDocument(), fPositions, fOffset);
- }
- }
-
-
- /** Internal position category used for the formatter partitioning */
- private final static String PARTITIONING= "__formatter_partitioning"; //$NON-NLS-1$
-
- /** The map of <code>IFormattingStrategy</code> objects */
- private Map fStrategies;
- /** The indicator of whether the formatter operates in partition aware mode or not */
- private boolean fIsPartitionAware= true;
-
- /** The partition information managing document position categories */
- private String[] fPartitionManagingCategories;
- /** The list of references to offset and end offset of all overlapping positions */
- private List fOverlappingPositionReferences;
- /** Position updater used for partitioning positions */
- private IPositionUpdater fPartitioningUpdater;
- /**
- * The document partitioning used by this formatter.
- * @since 3.0
- */
- private String fPartitioning;
- /**
- * The document this formatter works on.
- * @since 3.0
- */
- private IDocument fDocument;
- /**
- * The external partition managing categories.
- * @since 3.0
- */
- private String[] fExternalPartitonManagingCategories;
- /**
- * Indicates whether <code>fPartitionManagingCategories</code> must be computed.
- * @since 3.0
- */
- private boolean fNeedsComputation= true;
-
-
- /**
- * Creates a new content formatter. The content formatter operates by default
- * in the partition-aware mode. There are no preconfigured formatting strategies.
- * Will use the default document partitioning if not further configured.
- */
- public ContentFormatter() {
- fPartitioning= IDocumentExtension3.DEFAULT_PARTITIONING;
- }
-
- /**
- * Registers a strategy for a particular content type. If there is already a strategy
- * registered for this type, the new strategy is registered instead of the old one.
- * If the given content type is <code>null</code> the given strategy is registered for
- * all content types as is called only once per formatting session.
- *
- * @param strategy the formatting strategy to register, or <code>null</code> to remove an existing one
- * @param contentType the content type under which to register, or <code>null</code> for all content types
- */
- public void setFormattingStrategy(IFormattingStrategy strategy, String contentType) {
-
- Assert.isNotNull(contentType);
-
- if (fStrategies == null)
- fStrategies= new HashMap();
-
- if (strategy == null)
- fStrategies.remove(contentType);
- else
- fStrategies.put(contentType, strategy);
- }
-
- /**
- * Informs this content formatter about the names of those position categories
- * which are used to manage the document's partitioning information and thus should
- * be ignored when this formatter updates positions.
- *
- * @param categories the categories to be ignored
- * @deprecated incompatible with an open set of document partitionings. The provided information is only used
- * if this formatter can not compute the partition managing position categories.
- */
- public void setPartitionManagingPositionCategories(String[] categories) {
- fExternalPartitonManagingCategories= categories;
- }
-
- /**
- * Sets the document partitioning to be used by this formatter.
- *
- * @param partitioning the document partitioning
- * @since 3.0
- */
- public void setDocumentPartitioning(String partitioning) {
- fPartitioning= partitioning;
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.IContentFormatterExtension#getDocumentPartitioning()
- * @since 3.0
- */
- public String getDocumentPartitioning() {
- return fPartitioning;
- }
-
- /**
- * Sets the formatter's operation mode.
- *
- * @param enable indicates whether the formatting process should be partition ware
- */
- public void enablePartitionAwareFormatting(boolean enable) {
- fIsPartitionAware= enable;
- }
-
- /*
- * @see IContentFormatter#getFormattingStrategy(String)
- */
- public IFormattingStrategy getFormattingStrategy(String contentType) {
-
- Assert.isNotNull(contentType);
-
- if (fStrategies == null)
- return null;
-
- return (IFormattingStrategy) fStrategies.get(contentType);
- }
-
- /*
- * @see IContentFormatter#format(IDocument, IRegion)
- */
- public void format(IDocument document, IRegion region) {
- fNeedsComputation= true;
- fDocument= document;
- try {
-
- if (fIsPartitionAware)
- formatPartitions(region);
- else
- formatRegion(region);
-
- } finally {
- fNeedsComputation= true;
- fDocument= null;
- }
- }
-
- /**
- * Determines the partitioning of the given region of the document.
- * Informs the formatting strategies of each partition about the start,
- * the process, and the termination of the formatting session.
- *
- * @param region the document region to be formatted
- */
- private void formatPartitions(IRegion region) {
-
- addPartitioningUpdater();
-
- try {
-
- TypedPosition[] ranges= getPartitioning(region);
- if (ranges != null) {
- start(ranges, getIndentation(region.getOffset()));
- format(ranges);
- stop(ranges);
- }
-
- } catch (BadLocationException x) {
- }
-
- removePartitioningUpdater();
- }
-
- /**
- * Formats the given region with the strategy registered for the default
- * content type. The strategy is informed about the start, the process, and
- * the termination of the formatting session.
- *
- * @param region the region to be formatted
- */
- private void formatRegion(IRegion region) {
-
- IFormattingStrategy strategy= getFormattingStrategy(IDocument.DEFAULT_CONTENT_TYPE);
- if (strategy != null) {
- strategy.formatterStarts(getIndentation(region.getOffset()));
- format(strategy, new TypedPosition(region.getOffset(), region.getLength(), IDocument.DEFAULT_CONTENT_TYPE));
- strategy.formatterStops();
- }
- }
-
- /**
- * Returns the partitioning of the given region of the specified document.
- * As one partition after the other will be formatted and formatting will
- * probably change the length of the formatted partition, it must be kept
- * track of the modifications in order to submit the correct partition to all
- * formatting strategies. For this, all partitions are remembered as positions
- * in a dedicated position category. (As formatting strategies might rely on each
- * other, calling them in reversed order is not an option.)
- *
- * @param region the region for which the partitioning must be determined
- * @return the partitioning of the specified region
- * @exception BadLocationException of region is invalid in the document
- */
- private TypedPosition[] getPartitioning(IRegion region) throws BadLocationException {
-
- ITypedRegion[] regions= TextUtilities.computePartitioning(fDocument, fPartitioning, region.getOffset(), region.getLength());
- TypedPosition[] positions= new TypedPosition[regions.length];
-
- for (int i= 0; i < regions.length; i++) {
- positions[i]= new TypedPosition(regions[i]);
- try {
- fDocument.addPosition(PARTITIONING, positions[i]);
- } catch (BadPositionCategoryException x) {
- // should not happen
- }
- }
-
- return positions;
- }
-
- /**
- * Fires <code>formatterStarts</code> to all formatter strategies
- * which will be involved in the forthcoming formatting process.
- *
- * @param regions the partitioning of the document to be formatted
- * @param indentation the initial indentation
- */
- private void start(TypedPosition[] regions, String indentation) {
- for (int i= 0; i < regions.length; i++) {
- IFormattingStrategy s= getFormattingStrategy(regions[i].getType());
- if (s != null)
- s.formatterStarts(indentation);
- }
- }
-
- /**
- * Formats one partition after the other using the formatter strategy registered for
- * the partition's content type.
- *
- * @param ranges the partitioning of the document region to be formatted
- */
- private void format(TypedPosition[] ranges) {
- for (int i= 0; i < ranges.length; i++) {
- IFormattingStrategy s= getFormattingStrategy(ranges[i].getType());
- if (s != null) {
- format(s, ranges[i]);
- }
- }
- }
-
- /**
- * Formats the given region of the document using the specified formatting
- * strategy. In order to maintain positions correctly, first all affected
- * positions determined, after all document listeners have been informed about
- * the coming change, the affected positions are removed to avoid that they
- * are regularly updated. After all position updaters have run, the affected
- * positions are updated with the formatter's information and added back to
- * their categories, right before the first document listener is informed about
- * that a change happened.
- *
- * @param strategy the strategy to be used
- * @param region the region to be formatted
- */
- private void format(IFormattingStrategy strategy, TypedPosition region) {
- try {
-
- final int offset= region.getOffset();
- int length= region.getLength();
-
- String content= fDocument.get(offset, length);
- final int[] positions= getAffectedPositions(offset, length);
- String formatted= strategy.format(content, isLineStart(offset), getIndentation(offset), positions);
-
- if (formatted != null && !formatted.equals(content)) {
-
- IPositionUpdater first= new RemoveAffectedPositions();
- fDocument.insertPositionUpdater(first, 0);
- IPositionUpdater last= new UpdateAffectedPositions(positions, offset);
- fDocument.addPositionUpdater(last);
-
- fDocument.replace(offset, length, formatted);
-
- fDocument.removePositionUpdater(first);
- fDocument.removePositionUpdater(last);
- }
-
- } catch (BadLocationException x) {
- // should not happen
- }
- }
-
- /**
- * Fires <code>formatterStops</code> to all formatter strategies which were
- * involved in the formatting process which is about to terminate.
- *
- * @param regions the partitioning of the document which has been formatted
- */
- private void stop(TypedPosition[] regions) {
- for (int i= 0; i < regions.length; i++) {
- IFormattingStrategy s= getFormattingStrategy(regions[i].getType());
- if (s != null)
- s.formatterStops();
- }
- }
-
- /**
- * Installs those updaters which the formatter needs to keep track of the partitions.
- */
- private void addPartitioningUpdater() {
- fPartitioningUpdater= new NonDeletingPositionUpdater(PARTITIONING);
- fDocument.addPositionCategory(PARTITIONING);
- fDocument.addPositionUpdater(fPartitioningUpdater);
- }
-
- /**
- * Removes the formatter's internal position updater and category.
- */
- private void removePartitioningUpdater() {
-
- try {
-
- fDocument.removePositionUpdater(fPartitioningUpdater);
- fDocument.removePositionCategory(PARTITIONING);
- fPartitioningUpdater= null;
-
- } catch (BadPositionCategoryException x) {
- // should not happen
- }
- }
-
- /**
- * Returns the partition managing position categories for the formatted document.
- *
- * @return the position managing position categories
- * @since 3.0
- */
- private String[] getPartitionManagingCategories() {
- if (fNeedsComputation) {
- fNeedsComputation= false;
- fPartitionManagingCategories= TextUtilities.computePartitionManagingCategories(fDocument);
- if (fPartitionManagingCategories == null)
- fPartitionManagingCategories= fExternalPartitonManagingCategories;
- }
- return fPartitionManagingCategories;
- }
-
- /**
- * Determines whether the given document position category should be ignored
- * by this formatter's position updating.
- *
- * @param category the category to check
- * @return <code>true</code> if the category should be ignored, <code>false</code> otherwise
- */
- private boolean ignoreCategory(String category) {
-
- if (PARTITIONING.equals(category))
- return true;
-
- String[] categories= getPartitionManagingCategories();
- if (categories != null) {
- for (int i= 0; i < categories.length; i++) {
- if (categories[i].equals(category))
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Determines all embracing, overlapping, and follow up positions
- * for the given region of the document.
- *
- * @param offset the offset of the document region to be formatted
- * @param length the length of the document to be formatted
- */
- private void determinePositionsToUpdate(int offset, int length) {
-
- String[] categories= fDocument.getPositionCategories();
- if (categories != null) {
- for (int i= 0; i < categories.length; i++) {
-
- if (ignoreCategory(categories[i]))
- continue;
-
- try {
-
- Position[] positions= fDocument.getPositions(categories[i]);
-
- for (int j= 0; j < positions.length; j++) {
-
- Position p= positions[j];
- if (p.overlapsWith(offset, length)) {
-
- if (offset < p.getOffset())
- fOverlappingPositionReferences.add(new PositionReference(p, true, categories[i]));
-
- if (p.getOffset() + p.getLength() < offset + length)
- fOverlappingPositionReferences.add(new PositionReference(p, false, categories[i]));
- }
- }
-
- } catch (BadPositionCategoryException x) {
- // can not happen
- }
- }
- }
- }
-
- /**
- * Returns all offset and the end offset of all positions overlapping with the
- * specified document range.
- *
- * @param offset the offset of the document region to be formatted
- * @param length the length of the document to be formatted
- * @return all character positions of the interleaving positions
- */
- private int[] getAffectedPositions(int offset, int length) {
-
- fOverlappingPositionReferences= new ArrayList();
-
- determinePositionsToUpdate(offset, length);
-
- Collections.sort(fOverlappingPositionReferences);
-
- int[] positions= new int[fOverlappingPositionReferences.size()];
- for (int i= 0; i < positions.length; i++) {
- PositionReference r= (PositionReference) fOverlappingPositionReferences.get(i);
- positions[i]= r.getCharacterPosition() - offset;
- }
-
- return positions;
- }
-
- /**
- * Removes the affected positions from their categories to avoid
- * that they are invalidly updated.
- *
- * @param document the document
- */
- private void removeAffectedPositions(IDocument document) {
- int size= fOverlappingPositionReferences.size();
- for (int i= 0; i < size; i++) {
- PositionReference r= (PositionReference) fOverlappingPositionReferences.get(i);
- try {
- document.removePosition(r.getCategory(), r.getPosition());
- } catch (BadPositionCategoryException x) {
- // can not happen
- }
- }
- }
-
- /**
- * Updates all the overlapping positions. Note, all other positions are
- * automatically updated by their document position updaters.
- *
- * @param document the document to has been formatted
- * @param positions the adapted character positions to be used to update the document positions
- * @param offset the offset of the document region that has been formatted
- */
- protected void updateAffectedPositions(IDocument document, int[] positions, int offset) {
-
- if (document != fDocument)
- return;
-
- if (positions.length == 0)
- return;
-
- for (int i= 0; i < positions.length; i++) {
-
- PositionReference r= (PositionReference) fOverlappingPositionReferences.get(i);
-
- if (r.refersToOffset())
- r.setOffset(offset + positions[i]);
- else
- r.setLength((offset + positions[i]) - r.getOffset());
-
- Position p= r.getPosition();
- String category= r.getCategory();
- if (!document.containsPosition(category, p.offset, p.length)) {
- try {
- if (positionAboutToBeAdded(document, category, p))
- document.addPosition(r.getCategory(), p);
- } catch (BadPositionCategoryException x) {
- // can not happen
- } catch (BadLocationException x) {
- // should not happen
- }
- }
-
- }
-
- fOverlappingPositionReferences= null;
- }
-
- /**
- * The given position is about to be added to the given position category of the given document. <p>
- * This default implementation return <code>true</code>.
- *
- * @param document the document
- * @param category the position category
- * @param position the position that will be added
- * @return <code>true</code> if the position can be added, <code>false</code> if it should be ignored
- */
- protected boolean positionAboutToBeAdded(IDocument document, String category, Position position) {
- return true;
- }
-
- /**
- * Returns the indentation of the line of the given offset.
- *
- * @param offset the offset
- * @return the indentation of the line of the offset
- */
- private String getIndentation(int offset) {
-
- try {
- int start= fDocument.getLineOfOffset(offset);
- start= fDocument.getLineOffset(start);
-
- int end= start;
- char c= fDocument.getChar(end);
- while ('\t' == c || ' ' == c)
- c= fDocument.getChar(++end);
-
- return fDocument.get(start, end - start);
- } catch (BadLocationException x) {
- }
-
- return ""; //$NON-NLS-1$
- }
-
- /**
- * Determines whether the offset is the beginning of a line in the given document.
- *
- * @param offset the offset
- * @return <code>true</code> if offset is the beginning of a line
- * @exception BadLocationException if offset is invalid in document
- */
- private boolean isLineStart(int offset) throws BadLocationException {
- int start= fDocument.getLineOfOffset(offset);
- start= fDocument.getLineOffset(start);
- return (start == offset);
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContextBasedFormattingStrategy.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContextBasedFormattingStrategy.java
deleted file mode 100644
index ec60fb3..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContextBasedFormattingStrategy.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *****************************************************************************/
-
-package org.eclipse.jface.text.formatter;
-
-import java.util.LinkedList;
-import java.util.Map;
-
-import org.eclipse.jface.text.source.ISourceViewer;
-
-/**
- * Formatting strategy for context based content formatting.
- * <p>
- *
- * @see IContentFormatterExtension2
- * @see IFormattingStrategyExtension
- * @since 3.0
- */
-public abstract class ContextBasedFormattingStrategy implements IFormattingStrategy, IFormattingStrategyExtension {
-
- /** The current preferences for formatting */
- private Map fCurrentPreferences= null;
-
- /** The list of preferences for initiated the formatting steps */
- private final LinkedList fPreferences= new LinkedList();
-
- /** The source viewer to operate on */
- private ISourceViewer fViewer;
-
- /**
- * Creates a new context based formatting strategy.
- */
- public ContextBasedFormattingStrategy() {
- }
-
- /**
- * Creates a new context based formatting strategy.
- *
- * TODO: remove
- *
- * @param viewer
- * The source viewer to operate on
- *
- * @deprecated Use {@link ContextBasedFormattingStrategy#ContextBasedFormattingStrategy()}
- * instead. Also set and use the property value of {@link FormattingContextProperties#CONTEXT_MEDIUM})
- * in order to access the document. Consider migration to {@link MultiPassContentFormatter}. To be removed.
- */
- public ContextBasedFormattingStrategy(final ISourceViewer viewer) {
- fViewer= viewer;
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.IFormattingStrategyExtension#format()
- */
- public void format() {
- fCurrentPreferences= (Map)fPreferences.removeFirst();
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.IFormattingStrategy#format(java.lang.String, boolean, java.lang.String, int[])
- */
- public String format(String content, boolean start, String indentation, int[] positions) {
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.IFormattingStrategyExtension#formatterStarts(org.eclipse.jface.text.formatter.IFormattingContext)
- */
- public void formatterStarts(final IFormattingContext context) {
- fPreferences.addLast(context.getProperty(FormattingContextProperties.CONTEXT_PREFERENCES));
- }
-
- /*
- * @see IFormattingStrategy#formatterStarts(String)
- */
- public void formatterStarts(final String indentation) {
- // Do nothing
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.IFormattingStrategyExtension#formatterStops()
- */
- public void formatterStops() {
- fPreferences.clear();
-
- fCurrentPreferences= null;
- }
-
- /**
- * Returns the preferences used for the current formatting step.
- *
- * @return The preferences for the current formatting step
- */
- public final Map getPreferences() {
- return fCurrentPreferences;
- }
-
- /**
- * Returns the source viewer where the formatting happens.
- *
- * TODO: remove
- *
- * @return The source viewer where the formatting happens.
- *
- * @deprecated Set and use property value of
- * {@link FormattingContextProperties#CONTEXT_MEDIUM}) in
- * order to access the document. Consider migration to
- * {@link MultiPassContentFormatter}. To be removed.
- */
- public final ISourceViewer getViewer() {
- return fViewer;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/FormattingContext.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/FormattingContext.java
deleted file mode 100644
index b49426d..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/FormattingContext.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *****************************************************************************/
-
-package org.eclipse.jface.text.formatter;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-
-/**
- * Default implementation of <code>IFormattingContext</code>.
- *
- * @since 3.0
- */
-public class FormattingContext implements IFormattingContext {
-
- /** Map to store the properties */
- private final Map fMap= new HashMap();
-
- /*
- * @see org.eclipse.jface.text.formatter.IFormattingContext#dispose()
- */
- public void dispose() {
- fMap.clear();
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.IFormattingContext#getPreferenceKeys()
- */
- public String[] getPreferenceKeys() {
- return new String[] {
- };
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.IFormattingContext#getProperty(java.lang.Object)
- */
- public Object getProperty(Object key) {
- return fMap.get(key);
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.IFormattingContext#isBooleanPreference(java.lang.String)
- */
- public boolean isBooleanPreference(String key) {
- return false;
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.IFormattingContext#isDoublePreference(java.lang.String)
- */
- public boolean isDoublePreference(String key) {
- return false;
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.IFormattingContext#isFloatPreference(java.lang.String)
- */
- public boolean isFloatPreference(String key) {
- return false;
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.IFormattingContext#isIntegerPreference(java.lang.String)
- */
- public boolean isIntegerPreference(String key) {
- return false;
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.IFormattingContext#isLongPreference(java.lang.String)
- */
- public boolean isLongPreference(String key) {
- return false;
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.IFormattingContext#isStringPreference(java.lang.String)
- */
- public boolean isStringPreference(String key) {
- return false;
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.IFormattingContext#mapToStore(java.util.Map, org.eclipse.jface.preference.IPreferenceStore)
- */
- public void mapToStore(Map map, IPreferenceStore store) {
-
- final String[] preferences= getPreferenceKeys();
-
- String result= null;
- String preference= null;
-
- for (int index= 0; index < preferences.length; index++) {
-
- preference= preferences[index];
- result= (String)map.get(preference);
-
- if (result != null) {
-
- try {
- if (isBooleanPreference(preference)) {
- store.setValue(preference, result.equals(IPreferenceStore.TRUE));
- } else if (isIntegerPreference(preference)) {
- store.setValue(preference, Integer.parseInt(result));
- } else if (isStringPreference(preference)) {
- store.setValue(preference, result);
- } else if (isDoublePreference(preference)) {
- store.setValue(preference, Double.parseDouble(result));
- } else if (isFloatPreference(preference)) {
- store.setValue(preference, Float.parseFloat(result));
- } else if (isLongPreference(preference)) {
- store.setValue(preference, Long.parseLong(result));
- }
- } catch (NumberFormatException exception) {
- // Do nothing
- }
- }
- }
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.IFormattingContext#setProperty(java.lang.Object, java.lang.Object)
- */
- public void setProperty(Object key, Object property) {
- fMap.put(key, property);
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.IFormattingContext#storeToMap(org.eclipse.jface.preference.IPreferenceStore, java.util.Map, boolean)
- */
- public void storeToMap(IPreferenceStore store, Map map, boolean useDefault) {
-
- final String[] preferences= getPreferenceKeys();
-
- String preference= null;
- for (int index= 0; index < preferences.length; index++) {
-
- preference= preferences[index];
-
- if (isBooleanPreference(preference)) {
- map.put(preference, (useDefault ? store.getDefaultBoolean(preference) : store.getBoolean(preference)) ? IPreferenceStore.TRUE : IPreferenceStore.FALSE);
- } else if (isIntegerPreference(preference)) {
- map.put(preference, String.valueOf(useDefault ? store.getDefaultInt(preference) : store.getInt(preference)));
- } else if (isStringPreference(preference)) {
- map.put(preference, useDefault ? store.getDefaultString(preference) : store.getString(preference));
- } else if (isDoublePreference(preference)) {
- map.put(preference, String.valueOf(useDefault ? store.getDefaultDouble(preference) : store.getDouble(preference)));
- } else if (isFloatPreference(preference)) {
- map.put(preference, String.valueOf(useDefault ? store.getDefaultFloat(preference) : store.getFloat(preference)));
- } else if (isLongPreference(preference)) {
- map.put(preference, String.valueOf(useDefault ? store.getDefaultLong(preference) : store.getLong(preference)));
- }
- }
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/FormattingContextProperties.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/FormattingContextProperties.java
deleted file mode 100644
index fb91186..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/FormattingContextProperties.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *****************************************************************************/
-
-package org.eclipse.jface.text.formatter;
-
-/**
- * Keys used by <code>IFormattingContext</code> objects to register specific
- * properties needed during the formatting process of a content formatter
- * implementing <code>IContentFormatterExtension2</code>.
- *
- * @see IFormattingContext
- * @see IFormattingStrategyExtension
- * @see IContentFormatterExtension2
- * @since 3.0
- */
-public class FormattingContextProperties {
-
- /**
- * Property key of the document property. The property must implement
- * <code>java.lang#Boolean</code>.
- * <p>
- * Value: <code>"formatting.context.document"</code>
- */
- public static final String CONTEXT_DOCUMENT= "formatting.context.document"; //$NON-NLS-1$
-
- /**
- * Property key of the indentation property. The property must implement
- * <code>java.lang#String</code>.
- * <p>
- * Value: <code>"formatting.context.indentation"</code>
- *
- * TODO: remove
- *
- * @deprecated Use the document (set and use property value of
- * {@link FormattingContextProperties#CONTEXT_MEDIUM}) to compute
- * the indentation in the formatting strategy. Consider migration to
- * {@link MultiPassContentFormatter}. To be removed.
- */
- public static final String CONTEXT_INDENTATION= "formatting.context.indentation"; //$NON-NLS-1$
-
- /**
- * Property key of the partition property. The property must implement
- * <code>org.eclipse.jface.text#TypedPosition</code>.
- * <p>
- * Value: <code>"formatting.context.partition"</code>
- */
- public static final String CONTEXT_PARTITION= "formatting.context.partition"; //$NON-NLS-1$
-
- /**
- * Property key of the positions property. The property must implement
- * <code>int[]</code>.
- * <p>
- * Value: <code>"formatting.context.positions"</code>
- *
- * TODO: remove
- *
- * @deprecated Apply changes directly on the document (set and use
- * the property value of {@link FormattingContextProperties#CONTEXT_MEDIUM}).
- * Consider migration to {@link MultiPassContentFormatter}.
- */
- public static final String CONTEXT_POSITIONS= "formatting.context.positions"; //$NON-NLS-1$
-
- /**
- * Property key of the preferences property. The property must implement
- * <code>java.util#Map</code>.
- * <p>
- * Value: <code>"formatting.context.preferences"</code>
- */
- public static final String CONTEXT_PREFERENCES= "formatting.context.preferences"; //$NON-NLS-1$
-
- /**
- * Property key of the region property. The property must implement <code>org.eclipse.jface.text#IRegion</code>.
- * <p>
- * Value: <code>"formatting.context.region"</code>
- */
- public static final String CONTEXT_REGION= "formatting.context.region"; //$NON-NLS-1$
-
- /**
- * Property key of the medium property. The property must implement <code>org.eclipse.jface.text#IDocument</code>.
- * <p>
- * Value: <code>"formatting.context.medium"</code>
- */
- public static final String CONTEXT_MEDIUM= "formatting.context.medium"; //$NON-NLS-1$
-
- /**
- * Ensure that this class cannot be instantiated.
- */
- private FormattingContextProperties() {
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IContentFormatter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IContentFormatter.java
deleted file mode 100644
index 4b60fdd..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IContentFormatter.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.formatter;
-
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-
-
-/**
- * The interface of a document content formatter. The formatter formats ranges
- * within documents. The documents are modified by the formatter.<p>
- * The content formatter is assumed to determine the partitioning of the document
- * range to be formatted. For each partition, the formatter determines based
- * on the partition's content type the formatting strategy to be used. Before
- * the first strategy is activated all strategies are informed about the
- * start of the formatting process. After that, the formatting strategies are
- * activated in the sequence defined by the partitioning of the document range to be
- * formatted. It is assumed that a strategy must be finished before the next strategy
- * can be activated. After the last strategy has been finished, all strategies are
- * informed about the termination of the formatting process.<p>
- * The interface can be implemented by clients. By default, clients use <code>ContentFormatter</code>
- * as the standard implementer of this interface.
- *
- * @see IDocument
- * @see IFormattingStrategy
- */
-public interface IContentFormatter {
-
- /**
- * Formats the given region of the specified document.The formatter may safely
- * assume that it is the only subject that modifies the document at this point in time.
- *
- * @param document the document to be formatted
- * @param region the region within the document to be formatted
- */
- void format(IDocument document, IRegion region);
-
- /**
- * Returns the formatting strategy registered for the given content type.
- *
- * @param contentType the content type for which to look up the formatting strategy
- * @return the formatting strategy for the given content type, or
- * <code>null</code> if there is no such strategy
- */
- IFormattingStrategy getFormattingStrategy(String contentType);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IContentFormatterExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IContentFormatterExtension.java
deleted file mode 100644
index 0ab4f5e..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IContentFormatterExtension.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**********************************************************************
-Copyright (c) 2000, 2003 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-
-Contributors:
- IBM Corporation - Initial implementation
-**********************************************************************/
-package org.eclipse.jface.text.formatter;
-
-/**
- * Extension interface for <code>IContentFormatter</code>.
- * Updates the content formatter to be aware of documents with multiple partitions.
- *
- * @since 3.0
- */
-public interface IContentFormatterExtension {
-
- /**
- * Returns the partitioning this content formatter is using.
- *
- * @return the partitioning this content formatter is using
- */
- String getDocumentPartitioning();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IContentFormatterExtension2.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IContentFormatterExtension2.java
deleted file mode 100644
index 5ea47ab..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IContentFormatterExtension2.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *****************************************************************************/
-
-package org.eclipse.jface.text.formatter;
-
-import org.eclipse.jface.text.IDocument;
-
-/**
- * Extension interface for <code>IContentFormatter</code>.
- * <p>
- * Updates the content formatter to be able to pass <code>IFormattingContext</code>
- * context objects to <code>IFormattingStrategyExtension<code> objects
- * operating in context based mode.
- * <p>
- * Clients using context based formatting call the method
- * <code>format(IDocument, IFormattingContext)</code> with a properly
- * initialized formatting context.<br>
- * The formatting context must be set up according to the desired formatting mode:
- * <ul>
- * <li>For whole document formatting set the property <code>CONTEXT_DOCUMENT</code>. This is
- * equivalent to setting <code>CONTEXT_REGION</code> with a region spanning the whole document.</li>
- * <li>For multiple region formatting set the property <code>CONTEXT_REGION</code>. Note that
- * the content formatter automatically aligns the region to a block selected region, and if the region spans
- * multiple partitions, it also completes eventual partitions covered only partially by the region.</li>
- * </ul>
- * Depending on the registered formatting strategies, more context information must
- * be passed in the formatting context, like e.g. <code>CONTEXT_PREFERENCES</code>.
- * <p>
- * Note that in context based mode the content formatter is fully reentrant, but not
- * thread-safe.
- * <p>
- *
- * @see IFormattingContext
- * @see FormattingContextProperties
- * @since 3.0
- */
-public interface IContentFormatterExtension2 {
-
- /**
- * Formats the given region of the specified document.
- * <p>
- * The formatter may safely assume that it is the only subject that
- * modifies the document at this point in time. This method is fully
- * reentrant, but not thread-safe.
- * <p>
- * The formatting process performed by <code>format(IDocument, IFormattingContext)</code>
- * happens as follows:
- * <ul>
- * <li>In a first pass the content formatter formats the range of the
- * document to be formatted by using the master formatting strategy. This
- * happens regardless of the content type of the underlying partition.
- * </li>
- * <li>In the second pass, the range is formatted again, this time using
- * the registered slave formatting strategies. For each partition contained
- * in the range to be formatted, the content formatter determines its
- * content type and formats the partition with the correct formatting
- * strategy.
- * </li>
- *
- * @param document
- * The document to be formatted
- * @param context
- * The formatting context to pass to the formatting strategies.
- * This argument must not be <code>null</code>.
- */
- void format(IDocument document, IFormattingContext context);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IFormattingContext.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IFormattingContext.java
deleted file mode 100644
index ca45c51..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IFormattingContext.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *****************************************************************************/
-
-package org.eclipse.jface.text.formatter;
-
-import java.util.Map;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-
-/**
- * Formatting context used in formatting strategies implementing interface
- * <code>IFormattingStrategyExtension</code>.
- *
- * @see IFormattingStrategyExtension
- * @see IFormattingContextProperties
- * @since 3.0
- */
-public interface IFormattingContext {
-
- /**
- * Dispose of the formatting context.
- * <p>
- * Must be called after the formatting context has been used in a
- * formatting process.
- */
- void dispose();
-
- /**
- * Returns the preference keys used for the retrieval of formatting
- * preferences.
- *
- * @return The preference keys for formatting
- */
- String[] getPreferenceKeys();
-
- /**
- * Retrieves the property <code>key</code> from the formatting context
- *
- * @param key
- * Key of the property to store in the context
- * @return The property <code>key</code> if available, <code>null</code>
- * otherwise
- */
- Object getProperty(Object key);
-
- /**
- * Is this preference key for a boolean preference?
- *
- * @param key
- * The preference key to query its type
- * @return <code>true</code> iff this key is for a boolean preference,
- * <code>false</code> otherwise.
- */
- boolean isBooleanPreference(String key);
-
- /**
- * Is this preference key for a double preference?
- *
- * @param key
- * The preference key to query its type
- * @return <code>true</code> iff this key is for a double preference,
- * <code>false</code> otherwise.
- */
- boolean isDoublePreference(String key);
-
- /**
- * Is this preference key for a float preference?
- *
- * @param key
- * The preference key to query its type
- * @return <code>true</code> iff this key is for a float preference,
- * <code>false</code> otherwise.
- */
- boolean isFloatPreference(String key);
-
- /**
- * Is this preference key for an integer preference?
- *
- * @param key
- * The preference key to query its type
- * @return <code>true</code> iff this key is for an integer preference,
- * <code>false</code> otherwise.
- */
- boolean isIntegerPreference(String key);
-
- /**
- * Is this preference key for a long preference?
- *
- * @param key
- * The preference key to query its type
- * @return <code>true</code> iff this key is for a long preference,
- * <code>false</code> otherwise.
- */
- boolean isLongPreference(String key);
-
- /**
- * Is this preference key for a string preference?
- *
- * @param key
- * The preference key to query its type
- * @return <code>true</code> iff this key is for a string preference,
- * <code>false</code> otherwise.
- */
- boolean isStringPreference(String key);
-
- /**
- * Stores the preferences from a map to a preference store.
- * <p>
- * Note that the preference keys returned by
- * {@link getPreferenceKeys()} must not be used in the preference store.
- * Otherwise the preferences are overwritten.
- * </p>
- *
- * @param map
- * Map to retrieve the preferences from
- * @param store
- * Preference store to store the preferences in
- */
- void mapToStore(Map map, IPreferenceStore store);
-
- /**
- * Stores the property <code>key</code> in the formatting context.
- *
- * @param key
- * Key of the property to store in the context
- * @param property
- * Property to store in the context. If already present, the new
- * property overwrites the present one.
- */
- void setProperty(Object key, Object property);
-
- /**
- * Retrieves the preferences from a preference store in a map.
- * <p>
- * Note that the preference keys returned by
- * {@link getPreferenceKeys()} must not be used in the map. Otherwise the
- * preferences are overwritten.
- * </p>
- *
- * @param store
- * Preference store to retrieve the preferences from
- * @param map
- * Map to store the preferences in
- * @param useDefault
- * <code>true</code> if the default preferences should be
- * used, <code>false</code> otherwise
- */
- void storeToMap(IPreferenceStore store, Map map, boolean useDefault);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IFormattingStrategy.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IFormattingStrategy.java
deleted file mode 100644
index 1a65470..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IFormattingStrategy.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.formatter;
-
-
-/**
- * A formatting strategy is assumed to be specialized on formatting text
- * of a particular content type. Each formatting process calls the strategy's
- * methods in the following sequence:
- * <ul>
- * <li><code>formatterStarts</code>
- * <li><code>format</code>
- * <li><code>formatterStops</code>
- * </ul>
- * This interface must be implemented by clients. Implementers should be registered with
- * a content formatter in order get involved in the formatting process.
- */
-public interface IFormattingStrategy {
-
- /**
- * Informs the strategy about the start of a formatting process in which it will
- * participate.
- *
- * @param initialIndentation the indent string of the first line at which the
- * overall formatting process starts.
- */
- void formatterStarts(String initialIndentation);
-
- /**
- * Formats the given string. During the formatting process this strategy must update
- * the given character positions according to the changes applied to the given string.
- *
- * @param content the initial string to be formatted
- * @param isLineStart indicates whether the beginning of content is a line start in its document
- * @param indentation the indentation string to be used
- * @param positions the character positions to be updated
- * @return the formatted string
- */
- String format(String content, boolean isLineStart, String indentation, int[] positions);
-
- /**
- * Informs the strategy that the formatting process in which it has participated
- * has been finished.
- */
- void formatterStops();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IFormattingStrategyExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IFormattingStrategyExtension.java
deleted file mode 100644
index a817c2d..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IFormattingStrategyExtension.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *****************************************************************************/
-
-package org.eclipse.jface.text.formatter;
-
-/**
- * Extension interface for <code>IFormattingStrategy</code>.
- * <p>
- * Updates formatting strategies to be able to receive a more general <code>IFormattingContext</code>
- * object from its associated content formatters.
- * <p>
- * Each formatting process calls the strategy's methods in the following
- * sequence:
- * <ul>
- * <li><code>formatterStarts</code>
- * <li><code>format</code>
- * <li><code>formatterStops</code>
- * </ul>
- * <p>
- * Note that multiple calls to <code>formatterStarts</code> can be issued to
- * a strategy before launching the formatting process with <code>format</code>.
- * <p>
- * This interface must be implemented by clients. Implementers should be
- * registered with a content formatter in order get involved in the formatting
- * process.
- *
- * @see IFormattingContext
- * @since 3.0
- */
-public interface IFormattingStrategyExtension {
-
- /**
- * Formats the region with the properties indicated in the formatting
- * context previously supplied by <code>formatterStarts(IFormattingContext)</code>.
- */
- void format();
-
- /**
- * Informs the strategy about the start of a formatting process in which it
- * will participate.
- *
- * @param context
- * Formatting context used in the corresponding formatting
- * process.
- */
- void formatterStarts(IFormattingContext context);
-
- /**
- * Informs the strategy that the formatting process in which it has
- * participated has been finished.
- */
- void formatterStops();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/MultiPassContentFormatter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/MultiPassContentFormatter.java
deleted file mode 100644
index 4eec06a..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/MultiPassContentFormatter.java
+++ /dev/null
@@ -1,319 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.formatter;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DefaultPositionUpdater;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.TextUtilities;
-import org.eclipse.jface.text.TypedPosition;
-
-/**
- * Content formatter for edit-based formatting strategies.
- * <p>
- * Two kinds of formatting strategies can be registered with this formatter:
- * <ul>
- * <li>Master formatting strategies</li>
- * <li>Slave formatting strategies</li>
- * </ul>
- * The master formatting strategy always formats the whole region to be
- * formatted in the first pass. In a second pass, all partitions of the region
- * to be formatted that are not of master content type are formatted using the
- * slave formatting strategy registered for the underlying content type.
- * <p>
- * Regions to be formatted with the master formatting strategy are always
- * aligned to block selections. Regions to be formatted with slave formatting
- * strategies are aligned on partition boundaries.
- *
- * @since 3.0
- */
-public class MultiPassContentFormatter implements IContentFormatter, IContentFormatterExtension, IContentFormatterExtension2 {
-
- /**
- * Position updater that shifts otherwise deleted positions to the next
- * non-whitespace character. The length of the positions are truncated to
- * one if the position was shifted.
- */
- protected class NonDeletingPositionUpdater extends DefaultPositionUpdater {
-
- /**
- * Creates a new non-deleting position updater.
- *
- * @param category The position category to update its positions
- */
- public NonDeletingPositionUpdater(final String category) {
- super(category);
- }
-
- /*
- * @see org.eclipse.jface.text.DefaultPositionUpdater#notDeleted()
- */
- protected final boolean notDeleted() {
-
- if (fOffset < fPosition.offset && (fPosition.offset + fPosition.length < fOffset + fLength)) {
-
- int offset= fOffset + fLength;
- if (offset < fDocument.getLength()) {
-
- try {
-
- boolean moved= false;
- char character= fDocument.getChar(offset);
-
- while (offset < fDocument.getLength() && Character.isWhitespace(character)) {
-
- moved= true;
- character= fDocument.getChar(offset++);
- }
-
- if (moved)
- offset--;
-
- } catch (BadLocationException exception) {
- // Can not happen
- }
-
- fPosition.offset= offset;
- fPosition.length= 0;
- }
- }
- return true;
- }
- }
-
- /** The master formatting strategy */
- private IFormattingStrategyExtension fMaster= null;
- /** The partitioning of this content formatter */
- private final String fPartitioning;
- /** The slave formatting strategies */
- private final Map fSlaves= new HashMap();
- /** The default content type */
- private final String fType;
-
- /**
- * Creates a new content formatter.
- *
- * @param partitioning The document partitioning for this formatter
- * @param default The default content type
- */
- public MultiPassContentFormatter(final String partitioning, final String type) {
- fPartitioning= partitioning;
- fType= type;
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.IContentFormatterExtension2#format(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.formatter.IFormattingContext)
- */
- public final void format(final IDocument medium, final IFormattingContext context) {
-
- context.setProperty(FormattingContextProperties.CONTEXT_MEDIUM, medium);
-
- final Boolean document= (Boolean)context.getProperty(FormattingContextProperties.CONTEXT_DOCUMENT);
- if (document == null || !document.booleanValue()) {
-
- final IRegion region= (IRegion)context.getProperty(FormattingContextProperties.CONTEXT_REGION);
- if (region != null) {
- try {
- formatMaster(context, medium, region.getOffset(), region.getLength());
- } finally {
- formatSlaves(context, medium, region.getOffset(), region.getLength());
- }
- }
- } else {
- try {
- formatMaster(context, medium, 0, medium.getLength());
- } finally {
- formatSlaves(context, medium, 0, medium.getLength());
- }
- }
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.IContentFormatter#format(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IRegion)
- */
- public final void format(final IDocument medium, final IRegion region) {
-
- final FormattingContext context= new FormattingContext();
-
- context.setProperty(FormattingContextProperties.CONTEXT_DOCUMENT, Boolean.FALSE);
- context.setProperty(FormattingContextProperties.CONTEXT_REGION, region);
-
- format(medium, context);
- }
-
- /**
- * Formats the document specified in the formatting context with the master
- * formatting strategy.
- * <p>
- * The master formatting strategy covers all regions of the document. The
- * offset of the region to be formatted is aligned on line start boundaries,
- * whereas the end index of the region remains the same. For this formatting
- * type the document partitioning is not taken into account.
- *
- * @param context The formatting context to use
- * @param document The document to operate on
- * @param offset The offset of the region to format
- * @param length The length of the region to format
- */
- protected void formatMaster(final IFormattingContext context, final IDocument document, int offset, int length) {
-
- try {
-
- final int delta= offset - document.getLineInformationOfOffset(offset).getOffset();
- offset -= delta;
- length += delta;
-
- } catch (BadLocationException exception) {
- // Do nothing
- }
-
- if (fMaster != null) {
-
- context.setProperty(FormattingContextProperties.CONTEXT_PARTITION, new TypedPosition(offset, length, fType));
-
- fMaster.formatterStarts(context);
- fMaster.format();
- fMaster.formatterStops();
- }
- }
-
- /**
- * Formats the document specified in the formatting context with the
- * formatting strategy registered for the content type.
- * <p>
- * For this formatting type only slave strategies are used. The region to be
- * formatted is aligned on partition boundaries of the underlying content
- * type. The exact formatting strategy is determined by the underlying
- * content type of the document partitioning.
- *
- * @param context The formatting context to use
- * @param document The document to operate on
- * @param offset The offset of the region to format
- * @param length The length of the region to format
- * @param type The content type of the region to format
- */
- protected void formatSlave(final IFormattingContext context, final IDocument document, final int offset, final int length, final String type) {
-
- final IFormattingStrategyExtension strategy= (IFormattingStrategyExtension)fSlaves.get(type);
- if (strategy != null) {
-
- context.setProperty(FormattingContextProperties.CONTEXT_PARTITION, new TypedPosition(offset, length, type));
-
- strategy.formatterStarts(context);
- strategy.format();
- strategy.formatterStops();
- }
- }
-
- /**
- * Formats the document specified in the formatting context with the slave
- * formatting strategies.
- * <p>
- * For each content type of the region to be formatted in the document
- * partitioning, the registered slave formatting strategy is used to format
- * that particular region. The region to be formatted is aligned on
- * partition boundaries of the underlying content type. If the content type
- * is the document's default content type, nothing happens.
- *
- * @param context The formatting context to use
- * @param document The document to operate on
- * @param offset The offset of the region to format
- * @param length The length of the region to format
- */
- protected void formatSlaves(final IFormattingContext context, final IDocument document, final int offset, final int length) {
-
- Map partitioners= new HashMap(0);
- try {
-
- final ITypedRegion[] partitions= TextUtilities.computePartitioning(document, fPartitioning, offset, length);
-
- if (!fType.equals(partitions[0].getType()))
- partitions[0]= TextUtilities.getPartition(document, fPartitioning, partitions[0].getOffset());
-
- if (partitions.length > 1) {
-
- if (!fType.equals(partitions[partitions.length - 1].getType()))
- partitions[partitions.length - 1]= TextUtilities.getPartition(document, fPartitioning, partitions[partitions.length - 1].getOffset());
- }
-
- String type= null;
- ITypedRegion partition= null;
-
- partitioners= TextUtilities.removeDocumentPartitioners(document);
-
- for (int index= partitions.length - 1; index >= 0; index--) {
-
- partition= partitions[index];
- type= partition.getType();
-
- if (!fType.equals(type))
- formatSlave(context, document, partition.getOffset(), partition.getLength(), type);
- }
-
- } catch (BadLocationException exception) {
- // Should not happen
- } finally {
- TextUtilities.addDocumentPartitioners(document, partitioners);
- }
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.IContentFormatterExtension#getDocumentPartitioning()
- */
- public final String getDocumentPartitioning() {
- return fPartitioning;
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.IContentFormatter#getFormattingStrategy(java.lang.String)
- */
- public final IFormattingStrategy getFormattingStrategy(final String type) {
- return null;
- }
-
- /**
- * Registers a master formatting strategy.
- * <p>
- * The strategy may already be registered with a certain content type as
- * slave strategy. The master strategy is registered for the default content
- * type of documents. If a master strategy has already been registered, it
- * is overridden by the new one.
- *
- * @param strategy The master formatting strategy
- */
- public final void setMasterStrategy(final IFormattingStrategyExtension strategy) {
- fMaster= strategy;
- }
-
- /**
- * Registers a slave formatting strategy for a certain content type.
- * <p>
- * The strategy may already be registered as master strategy. If it is
- * already registered as slave strategy for the specified content type,
- * nothing happens. However, the same strategy may be registered with
- * several content types. Slave strategies cannot be registered for the
- * default content type of documents.
- *
- * @param strategy The slave formatting strategy
- * @param type The content type to register this strategy with
- */
- public final void setSlaveStrategy(final IFormattingStrategyExtension strategy, final String type) {
-
- if (!fType.equals(type))
- fSlaves.put(type, strategy);
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/package.html b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/package.html
deleted file mode 100644
index 938929c..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/package.html
+++ /dev/null
@@ -1,57 +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 formatter add-on for an <tt>ITextViewer</tt>.
-A content formatter changes the formatting of a document region while
-preserving and correctly updating the positions of the document.
-<h2>
-Package Specification</h2>
-<tt>IContentFormatter</tt> defines the concept of a text formatter. It
-collaborates with content type specific formatting stratgies (<tt>IFormattingStrategy</tt>)
-which for a given document region format the subregion with the matching
-content type. The package contains a default implementation of <tt>IContentFormatter</tt>
-(<tt>ContentFormatter</tt>).<br>Additionally, an implementation of <tt>IContentFormatter</tt> is provided
-for text edit based formatting strategies. This implementation only accepts formatting strategies
-implementing the extension interface <tt>IFormattingStrategyExtension</tt>. These formatting strategies are required to
-handle the position updating of the document. To facilitate the work with these text edit based formatting strategies, a default implementation called <tt>ContextBasedFormattingStrategy</tt>
-is provided. Formatting strategies inheriting from this class are text edit based and behave context dependent. Depending on the formatting context that is passed
-to the content formatter, different preferences and modes can be used to format different parts of a document.
-<p>
-To set up a proper working text edit based content formatter, the following steps are needed:
-<ul>
-<li>Create an instance of <tt>IFormattingContext</tt>. The default implementation <tt>FormattingContext</tt> already
-provides support for the conversion of preferences from a preference store to a map and vice versa. The method <tt>getPreferenceKeys</tt>
-usually has to be overridden to return the appropriate keys of the preferences used during the formatting process. Then register a map of preferences
-with the formatting context by calling <tt>setProperty(String, Object)</tt> with the property identifier <tt>FormattingContextProperties.CONTEXT_PREFERENCES</tt>.</li>
-<li>Create an instance of the text edit based content formatter class <tt>MultiPassContentFormatter</tt>. The document partitioning and its associated
-default content type have to be passed to the constructor. This information is needed since the content formatter is able to format documents
-according to arbitrary partitionings and default content types.</li>
-<li>Register the formatting strategies for the content types that have to be formatted. If a formatting strategy is
-registered as master strategy, it is automatically associated with the default content type of the specified partitioning.
-If the formatting strategy is registered as slave strategy, it is associated with the indicated content type during the registration.
-Note that the master strategy can also be registered as a slave strategy for a content type other than the default content type.</li>
-<li>Specify the proper formatting mode:
-<ul>
-<li>For whole document formatting set the property <tt>CONTEXT_DOCUMENT</tt> of the created formatting context to <tt>true</tt>. This is
-equivalent to setting <code>CONTEXT_REGION</code> with a region spanning the whole document.</li>
-<li>For multiple region formatting set the property <code>CONTEXT_REGION</code> of the formatting context. Note that
-the content formatter automatically aligns the region to a block selected region, and if the region spans
-multiple partitions, it also completes eventual partitions covered only partially by the region.</li>
-<li>For explicit formatting of a partition with the formatting strategy registered for a certain content type use the
-property <tt>CONTEXT_PARTITION</tt>. Note that the region denoted by this property must correspond to a partition relative
-to the specified partitioning in the document to be formatted. The content type of this property overrides the content type of the partition
-in the document.</li>
-</ul>
-</li>
-<li>Call the method <tt>MultiPassContentFormatter#format(IDocument, IFormattingContext)</tt> with the created formatting context
-and the document to be formatted.</li>
-</ul>
-</p>
-</body>
-</html>
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/information/IInformationPresenter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/information/IInformationPresenter.java
deleted file mode 100644
index 489f4e8..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/information/IInformationPresenter.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.information;
-
-
-import org.eclipse.jface.text.ITextViewer;
-
-
-/**
- * An information presenter shows information available at the text viewer's
- * current document position. An <code>IInformationPresenter</code> is a
- * <code>ITextViewer</code> add-on.<p>
- * An information presenters has a list of <code>IInformationProvider</code> objects
- * each of which is registered for a particular document content type.
- * The presenter uses the strategy objects to retrieve the information to present.<p>
- * The interface can be implemented by clients. By default, clients use
- * <code>InformationPresenter</code> as the standard implementer of this interface.
- *
- * @see ITextViewer
- * @see IInformationProvider
- * @since 2.0
- */
-public interface IInformationPresenter {
-
- /**
- * Installs the information presenter on the given text viewer. After this method has been
- * finished, the presenter is operational. I.e., the method <code>showInformation</code>
- * can be called until <code>uninstall</code> is called.
- *
- * @param textViewer the viewer on which the presenter is installed
- */
- void install(ITextViewer textViewer);
-
- /**
- * Removes the information presenter from the text viewer it has previously been
- * installed on.
- */
- void uninstall();
-
- /**
- * Shows information related to the cursor position of the text viewer
- * this information presenter is installed on.
- *
- * @return an optional error message if
- */
- void showInformation();
-
- /**
- * Returns the information provider to be used for the given content type.
- *
- * @param contentType the type of the content for which information will be requested
- * @return an information provider or
- * <code>null</code> if none exists for the specified content type
- */
- IInformationProvider getInformationProvider(String contentType);
-}
-
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/information/IInformationPresenterExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/information/IInformationPresenterExtension.java
deleted file mode 100644
index ebff080..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/information/IInformationPresenterExtension.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**********************************************************************
-Copyright (c) 2000, 2003 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-
-Contributors:
- IBM Corporation - Initial implementation
-**********************************************************************/
-package org.eclipse.jface.text.information;
-
-/**
- * Extension interface for <code>IInformationPresenter</code>.
- * Updates the information presenter to be aware of documents with multiple partitions.
- *
- * @since 3.0
- */
-public interface IInformationPresenterExtension {
-
- /**
- * Returns the document partitioning this information presenter is using.
- *
- * @return the document partitioning this information presenter is using
- */
- String getDocumentPartitioning();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/information/IInformationProvider.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/information/IInformationProvider.java
deleted file mode 100644
index 527aec4..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/information/IInformationProvider.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.information;
-
-
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextViewer;
-
-
-/**
- * Provides information related to the content of a text viewer.<p>
- * Clients may implement this interface.
- *
- * @see ITextViewer
- * @since 2.0
- */
-public interface IInformationProvider {
-
- /**
- * Returns the region of the text viewer's document close to the given
- * offset that contains a subject about which information can be provided.<p>
- * For example, if information can be provided on a per code block basis,
- * the offset should be used to find the enclosing code block and the source
- * range of the block should be returned.
- *
- * @param textViewer the text viewer in which informationhas been requested
- * @param offset the offset at which information has been requested
- * @return the region of the text viewer's document containing the information subject
- */
- IRegion getSubject(ITextViewer textViewer, int offset);
-
- /**
- * Returns the information about the given subject or <code>null</code> if
- * no information is available. It depends on the concrete configuration in which
- * format the information is to be provided. For example, information presented
- * in an information control displaying HTML, should be provided in HTML.
- *
- * @param textViewer the viewer in whose document the subject is contained
- * @param subject the text region constituting the information subject
- * @return the information about the subject
- * @see IInformationPresenter
- * @deprecated As of 2.1, replaced by {@link IInformationProviderExtension#getInformation2(ITextViewer, IRegion)}
- */
- String getInformation(ITextViewer textViewer, IRegion subject);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/information/IInformationProviderExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/information/IInformationProviderExtension.java
deleted file mode 100644
index 077c9f1..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/information/IInformationProviderExtension.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.information;
-
-
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextViewer;
-
-
-/**
- * Extension interface for <code>IInformationProvider</code> to provide
- * the element for a given subject.
- *
- * @see org.eclipse.jface.text.information.IInformationProvider
- * @since 2.1
- */
-public interface IInformationProviderExtension {
-
- /**
- * Returns the element for the given subject or <code>null</code> if
- * no element is available.
- * <p>
- * Implementers should ignore the text returned by <code>IInformationProvider.getInformation()</code>.
- * </p>
- *
- * @param textViewer the viewer in whose document the subject is contained
- * @param subject the text region constituting the information subject
- * @return the element for the subject
- *
- * @see IInformationProvider#getInformation(ITextViewer, IRegion)
- * @see org.eclipse.jface.text.ITextViewer
- */
- Object getInformation2(ITextViewer textViewer, IRegion subject);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/information/IInformationProviderExtension2.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/information/IInformationProviderExtension2.java
deleted file mode 100644
index eaa6623..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/information/IInformationProviderExtension2.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.information;
-
-import org.eclipse.jface.text.IInformationControlCreator;
-
- /**
- * Extension interface for <code>IInformationProvider</code> to provide
- * its own information control creator.
- *
- * @see org.eclipse.jface.text.IInformationControlCreator
- * @see org.eclipse.jface.text.information.IInformationProvider
- * @since 3.0
- */
- public interface IInformationProviderExtension2 {
-
- /**
- * Returns the information control creator of this information provider.
- *
- * @return the information control creator
- */
- IInformationControlCreator getInformationPresenterControlCreator();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/information/InformationPresenter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/information/InformationPresenter.java
deleted file mode 100644
index 37d0576..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/information/InformationPresenter.java
+++ /dev/null
@@ -1,492 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.information;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.ControlListener;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-
-import org.eclipse.jface.text.AbstractInformationControlManager;
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocumentExtension3;
-import org.eclipse.jface.text.IInformationControl;
-import org.eclipse.jface.text.IInformationControlCreator;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.ITextViewerExtension5;
-import org.eclipse.jface.text.IViewportListener;
-import org.eclipse.jface.text.IWidgetTokenKeeper;
-import org.eclipse.jface.text.IWidgetTokenKeeperExtension;
-import org.eclipse.jface.text.IWidgetTokenOwner;
-import org.eclipse.jface.text.IWidgetTokenOwnerExtension;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextUtilities;
-
-
-/**
- * Standard implementation of <code>IInformationPresenter</code>.
- * This implementation extends <code>AbstractInformationControlManager</code>.
- * The information control is made visible on request by calling
- * <code>showInformation</code>.<p>
- * Usually, clients instantiate this class and configure it before using it. The configuration
- * must be consistent: This means the used <code>IInformationControlCreator</code>
- * must create an information control expecting information in the same format the configured
- * <code>IInformationProvider</code>s use to encode the information they provide.
- *
- * @since 2.0
- */
-public class InformationPresenter extends AbstractInformationControlManager implements IInformationPresenter, IInformationPresenterExtension, IWidgetTokenKeeper, IWidgetTokenKeeperExtension {
-
-
- /**
- * Priority of the info controls managed by this information presenter.
- * Default value: <code>5</code> in order to beat the hovers of <code>TextViewerHoverManager</code>
- * @since 3.0
- */
- public static final int WIDGET_PRIORITY= 5;
-
-
- /**
- * Internal information control closer. Listens to several events issued by its subject control
- * and closes the information control when necessary.
- */
- class Closer implements IInformationControlCloser, ControlListener, MouseListener, FocusListener, IViewportListener, KeyListener {
-
- /** The subject control */
- private Control fSubjectControl;
- /** The information control */
- private IInformationControl fInformationControl;
- /** Indicates whether this closer is active */
- private boolean fIsActive= false;
-
- /*
- * @see IInformationControlCloser#setSubjectControl(Control)
- */
- public void setSubjectControl(Control control) {
- fSubjectControl= control;
- }
-
- /*
- * @see IInformationControlCloser#setInformationControl(IInformationControl)
- */
- public void setInformationControl(IInformationControl control) {
- fInformationControl= control;
- }
-
- /*
- * @see IInformationControlCloser#start(Rectangle)
- */
- public void start(Rectangle informationArea) {
-
- if (fIsActive)
- return;
- fIsActive= true;
-
- if (fSubjectControl != null && ! fSubjectControl.isDisposed()) {
- fSubjectControl.addControlListener(this);
- fSubjectControl.addMouseListener(this);
- fSubjectControl.addFocusListener(this);
- fSubjectControl.addKeyListener(this);
- }
-
- if (fInformationControl != null)
- fInformationControl.addFocusListener(this);
-
- fTextViewer.addViewportListener(this);
- }
-
- /*
- * @see IInformationControlCloser#stop()
- */
- public void stop() {
-
- if (!fIsActive)
- return;
- fIsActive= false;
-
- fTextViewer.removeViewportListener(this);
-
- if (fInformationControl != null)
- fInformationControl.removeFocusListener(this);
-
- hideInformationControl();
-
- if (fSubjectControl != null && !fSubjectControl.isDisposed()) {
- fSubjectControl.removeControlListener(this);
- fSubjectControl.removeMouseListener(this);
- fSubjectControl.removeFocusListener(this);
- fSubjectControl.removeKeyListener(this);
- }
- }
-
- /*
- * @see ControlListener#controlResized(ControlEvent)
- */
- public void controlResized(ControlEvent e) {
- stop();
- }
-
- /*
- * @see ControlListener#controlMoved(ControlEvent)
- */
- public void controlMoved(ControlEvent e) {
- stop();
- }
-
- /*
- * @see MouseListener#mouseDown(MouseEvent)
- */
- public void mouseDown(MouseEvent e) {
- stop();
- }
-
- /*
- * @see MouseListener#mouseUp(MouseEvent)
- */
- public void mouseUp(MouseEvent e) {
- }
-
- /*
- * @see MouseListener#mouseDoubleClick(MouseEvent)
- */
- public void mouseDoubleClick(MouseEvent e) {
- stop();
- }
-
- /*
- * @see FocusListener#focusGained(FocusEvent)
- */
- public void focusGained(FocusEvent e) {
- }
-
- /*
- * @see FocusListener#focusLost(FocusEvent)
- */
- public void focusLost(FocusEvent e) {
- Display d= fSubjectControl.getDisplay();
- d.asyncExec(new Runnable() {
- public void run() {
- if (fInformationControl == null || !fInformationControl.isFocusControl())
- stop();
- }
- });
- }
-
- /*
- * @see IViewportListenerListener#viewportChanged(int)
- */
- public void viewportChanged(int topIndex) {
- stop();
- }
-
- /*
- * @see KeyListener#keyPressed(KeyEvent)
- */
- public void keyPressed(KeyEvent e) {
- stop();
- }
-
- /*
- * @see KeyListener#keyReleased(KeyEvent)
- */
- public void keyReleased(KeyEvent e) {
- }
- }
-
-
- /** The text viewer this information presenter works on */
- private ITextViewer fTextViewer;
- /** The map of <code>IInformationProvider</code> objects */
- private Map fProviders;
- /** The offset to override selection. */
- private int fOffset= -1;
- /**
- * The document partitioning for this information presenter.
- * @since 3.0
- */
- private String fPartitioning;
-
- /**
- * Creates a new information presenter that uses the given information control creator.
- * The presenter is not installed on any text viewer yet. By default, an information
- * control closer is set that closes the information control in the event of key strokes,
- * resizing, moves, focus changes, mouse clicks, and disposal - all of those applied to
- * the information control's parent control. Also, the setup ensures that the information
- * control when made visible will request thel focus. By default, the default document
- * partitioning <code>IDocumentExtension3.DEFAULT_PARTITIONING</code> is used.
- *
- * @param creator the information control creator to be used
- */
- public InformationPresenter(IInformationControlCreator creator) {
- super(creator);
- setCloser(new Closer());
- takesFocusWhenVisible(true);
- fPartitioning= IDocumentExtension3.DEFAULT_PARTITIONING;
- }
-
- /**
- * Sets the document partitioning to be used by this information presenter.
- *
- * @param partitioning the document partitioning to be used by this information presenter
- * @since 3.0
- */
- public void setDocumentPartitioning(String partitioning) {
- Assert.isNotNull(partitioning);
- fPartitioning= partitioning;
- }
-
- /*
- * @see org.eclipse.jface.text.information.IInformationPresenterExtension#getDocumentPartitioning()
- * @since 3.0
- */
- public String getDocumentPartitioning() {
- return fPartitioning;
- }
-
- /**
- * Registers a given information provider for a particular content type.
- * If there is already a provider registered for this type, the new provider
- * is registered instead of the old one.
- *
- * @param provider the information provider to register, or <code>null</code> to remove an existing one
- * @param contentType the content type under which to register
- */
- public void setInformationProvider(IInformationProvider provider, String contentType) {
-
- Assert.isNotNull(contentType);
-
- if (fProviders == null)
- fProviders= new HashMap();
-
- if (provider == null)
- fProviders.remove(contentType);
- else
- fProviders.put(contentType, provider);
- }
-
- /*
- * @see IInformationPresenter#getInformationProvider(String)
- */
- public IInformationProvider getInformationProvider(String contentType) {
- if (fProviders == null)
- return null;
-
- return (IInformationProvider) fProviders.get(contentType);
- }
-
- /**
- * Sets a offset to override the selection. Setting the value to <code>-1</code> will disable
- * overriding.
- *
- * @param offset the offset to override selection or <code>-1</code>
- */
- public void setOffset(int offset) {
- fOffset= offset;
- }
-
- /*
- * @see AbstractInformationControlManager#computeInformation()
- */
- protected void computeInformation() {
-
- int offset= fOffset < 0 ? fTextViewer.getSelectedRange().x : fOffset;
- if (offset == -1)
- return;
-
- fOffset= -1;
-
- IInformationProvider provider= null;
- try {
- String contentType= TextUtilities.getContentType(fTextViewer.getDocument(), getDocumentPartitioning(), offset);
- provider= getInformationProvider(contentType);
- } catch (BadLocationException x) {
- }
- if (provider == null)
- return;
-
- IRegion subject= provider.getSubject(fTextViewer, offset);
- if (subject == null)
- return;
-
- if (provider instanceof IInformationProviderExtension2)
- setCustomInformationControlCreator(((IInformationProviderExtension2) provider).getInformationPresenterControlCreator());
- else
- setCustomInformationControlCreator(null);
-
- if (provider instanceof IInformationProviderExtension) {
- IInformationProviderExtension extension= (IInformationProviderExtension) provider;
- setInformation(extension.getInformation2(fTextViewer, subject), computeArea(subject));
- } else
- setInformation(provider.getInformation(fTextViewer, subject), computeArea(subject));
- }
-
- /**
- * Determines the graphical area covered by the given text region.
- *
- * @param region the region whose graphical extend must be computed
- * @return the graphical extend of the given region
- */
- private Rectangle computeArea(IRegion region) {
-
- IRegion widgetRegion= modelRange2WidgetRange(region);
- int start= widgetRegion.getOffset();
- int end= widgetRegion.getOffset() + widgetRegion.getLength();
-
- StyledText styledText= fTextViewer.getTextWidget();
- Point upperLeft= styledText.getLocationAtOffset(start);
- Point lowerRight= new Point(upperLeft.x, upperLeft.y);
-
- for (int i= start +1; i < end; i++) {
-
- Point p= styledText.getLocationAtOffset(i);
-
- if (upperLeft.x > p.x)
- upperLeft.x= p.x;
-
- if (upperLeft.y > p.y)
- upperLeft.y= p.y;
-
- if (lowerRight.x < p.x)
- lowerRight.x= p.x;
-
- if (lowerRight.y < p.y)
- lowerRight.y= p.y;
- }
-
- GC gc= new GC(styledText);
- lowerRight.x += gc.getFontMetrics().getAverageCharWidth();
- lowerRight.y += styledText.getLineHeight();
- gc.dispose();
-
- int width= lowerRight.x - upperLeft.x;
- int height= lowerRight.y - upperLeft.y;
- return new Rectangle(upperLeft.x, upperLeft.y, width, height);
- }
-
- /**
- * Translated the given range in the viewer's document into the corresponding
- * range of the viewer's widget.
- *
- * @param region the range in the viewer's document
- * @return the corresponding widget range
- * @since 2.1
- */
- private IRegion modelRange2WidgetRange(IRegion region) {
- if (fTextViewer instanceof ITextViewerExtension5) {
- ITextViewerExtension5 extension= (ITextViewerExtension5) fTextViewer;
- return extension.modelRange2WidgetRange(region);
- }
-
- IRegion visibleRegion= fTextViewer.getVisibleRegion();
- int start= region.getOffset() - visibleRegion.getOffset();
- int end= start + region.getLength();
- if (end > visibleRegion.getLength())
- end= visibleRegion.getLength();
-
- return new Region(start, end - start);
- }
-
- /*
- * @see IInformationPresenter#install(ITextViewer)
- */
- public void install(ITextViewer textViewer) {
- fTextViewer= textViewer;
- install(fTextViewer.getTextWidget());
- }
-
- /*
- * @see IInformationPresenter#uninstall()
- */
- public void uninstall() {
- dispose();
- }
-
- /*
- * @see AbstractInformationControlManager#showInformationControl(Rectangle)
- */
- protected void showInformationControl(Rectangle subjectArea) {
- if (fTextViewer instanceof IWidgetTokenOwnerExtension) {
- IWidgetTokenOwnerExtension extension= (IWidgetTokenOwnerExtension) fTextViewer;
- if (extension.requestWidgetToken(this, WIDGET_PRIORITY))
- super.showInformationControl(subjectArea);
- } else if (fTextViewer instanceof IWidgetTokenOwner) {
- IWidgetTokenOwner owner= (IWidgetTokenOwner) fTextViewer;
- if (owner.requestWidgetToken(this))
- super.showInformationControl(subjectArea);
-
- }
- }
-
- /*
- * @see AbstractInformationControlManager#hideInformationControl()
- */
- protected void hideInformationControl() {
- try {
- super.hideInformationControl();
- } finally {
- if (fTextViewer instanceof IWidgetTokenOwner) {
- IWidgetTokenOwner owner= (IWidgetTokenOwner) fTextViewer;
- owner.releaseWidgetToken(this);
- }
- }
- }
-
- /*
- * @see AbstractInformationControlManager#handleInformationControlDisposed()
- */
- protected void handleInformationControlDisposed() {
- try {
- super.handleInformationControlDisposed();
- } finally {
- if (fTextViewer instanceof IWidgetTokenOwner) {
- IWidgetTokenOwner owner= (IWidgetTokenOwner) fTextViewer;
- owner.releaseWidgetToken(this);
- }
- }
- }
-
- /*
- * @see org.eclipse.jface.text.IWidgetTokenKeeper#requestWidgetToken(IWidgetTokenOwner)
- */
- public boolean requestWidgetToken(IWidgetTokenOwner owner) {
- return false;
- }
-
- /*
- * @see org.eclipse.jface.text.IWidgetTokenKeeperExtension#requestWidgetToken(org.eclipse.jface.text.IWidgetTokenOwner, int)
- */
- public boolean requestWidgetToken(IWidgetTokenOwner owner, int priority) {
- return false;
- }
-
- /*
- * @see org.eclipse.jface.text.IWidgetTokenKeeperExtension#setFocus(org.eclipse.jface.text.IWidgetTokenOwner)
- */
- public boolean setFocus(IWidgetTokenOwner owner) {
- return false;
- }
-}
-
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/information/package.html b/org.eclipse.jface.text/src/org/eclipse/jface/text/information/package.html
deleted file mode 100644
index 2c20da0..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/information/package.html
+++ /dev/null
@@ -1,22 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="Author" content="IBM">
- <meta name="GENERATOR" content="Mozilla/4.76 [en] (Windows NT 5.0; U) [Netscape]">
- <title>Package-level Javadoc</title>
-</head>
-<body>
-Provides an information provider add-on for an <tt>ITextViewer</tt>.
-An information provider presents information for a certain subject in a
-specific information control. An information control usually is a floating
-window.
-<h2>
-Package Specification</h2>
-<tt>IInformationPresenter</tt> defines the concept of an information provider.
-It collaborates with content type specific information providers (<tt>IInformationProvider</tt>)
-which determine for a certain offset in a text viewer an information subject
-and the information available about this subject.. The package contains
-a default implementation of <tt>IInformationPresenter</tt> (<tt>InformationPresenter</tt>).
-</body>
-</html>
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedPositionAnnotations.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedPositionAnnotations.java
deleted file mode 100644
index 7503192..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedPositionAnnotations.java
+++ /dev/null
@@ -1,308 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.link;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.link.LinkedEnvironment;
-import org.eclipse.jface.text.link.LinkedPosition;
-import org.eclipse.jface.text.link.LinkedPositionGroup;
-import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.jface.text.source.AnnotationModel;
-
-/**
- * @since 3.0
- */
-final class LinkedPositionAnnotations extends AnnotationModel {
-
- /* annotation types */
- private static final String TARGET_ANNOTATION_TYPE= "org.eclipse.jdt.ui.link.target"; //$NON-NLS-1$
- private static final String SLAVE_ANNOTATION_TYPE= "org.eclipse.jdt.ui.link.slave"; //$NON-NLS-1$
- private static final String FOCUS_ANNOTATION_TYPE= "org.eclipse.jdt.ui.link.master"; //$NON-NLS-1$
- private static final String EXIT_ANNOTATION_TYPE= "org.eclipse.jdt.ui.link.exit"; //$NON-NLS-1$
-
- /* configuration */
- private boolean fMarkTargets= true;
- private boolean fMarkSlaves= true;
- private boolean fMarkFocus= true;
- private boolean fMarkExitTarget= true;
-
- private Annotation fFocusAnnotation= null;
- private Annotation fExitAnnotation= null;
- private final Map fGroupAnnotations= new HashMap();
- private final Map fTargetAnnotations= new HashMap();
- private Position[] fTargets= new Position[0];
- private LinkedPosition fExitPosition= null;
-
- /**
- * Sets the position that should be highlighted as the focus position, i.e.
- * as the position whose changes are propagated to all its linked positions
- * by the linked environment.
- *
- * @param position the new focus position, or <code>null</code> if no focus is set.
- */
- private void setFocusPosition(Position position) throws BadLocationException {
- if (fMarkFocus && getPosition(fFocusAnnotation) != position) {
- removeAnnotation(fFocusAnnotation, false);
- if (position != null) {
- fFocusAnnotation= new Annotation(FOCUS_ANNOTATION_TYPE, false, ""); //$NON-NLS-1$
- addAnnotation(fFocusAnnotation, position, false);
- } else
- fFocusAnnotation= null;
- }
- }
-
- /**
- * Sets the position that should be highlighted as the exit position, i.e.
- * as the position whose changes are propagated to all its linked positions
- * by the linked environment.
- *
- * @param position the new exit position, or <code>null</code> if no focus is set.
- */
- private void setExitPosition(Position position) throws BadLocationException {
- if (fMarkExitTarget && getPosition(fExitAnnotation) != position) {
- removeAnnotation(fExitAnnotation, false);
- if (position != null) {
- fExitAnnotation= new Annotation(EXIT_ANNOTATION_TYPE, false, ""); //$NON-NLS-1$
- addAnnotation(fExitAnnotation, position, false);
- } else
- fExitAnnotation= null;
- }
- }
-
- /**
- * Sets the positions that should be highlighted as the slave positions, i.e.
- * as the positions that are linked to the focus position.
- *
- * @param positions the new slave positions, or <code>null</code> if no slave positions are to be set
- */
- private void setGroupPositions(List positions) throws BadLocationException {
- if (!fMarkSlaves)
- return;
-
- // remove all positions which are already there
- // algo: toRemove contains all mappings at first, but all that are in
- // positions get removed -> toRemove contains the difference set of previsous - new
- // toAdd are the new positions, which don't exist in previous = new - previous
- List toRemove= new ArrayList(fGroupAnnotations.values());
- Map toAdd= new HashMap();
- if (positions != null) {
- for (Iterator iter= positions.iterator(); iter.hasNext();) {
- Position p= (Position) iter.next();
- if (fGroupAnnotations.containsKey(p)) {
- toRemove.remove(fGroupAnnotations.get(p));
- } else {
- Annotation a= new Annotation(SLAVE_ANNOTATION_TYPE, false, ""); //$NON-NLS-1$
- toAdd.put(a, p);
- fGroupAnnotations.put(p, a);
- }
- }
- }
- fGroupAnnotations.values().removeAll(toRemove);
-
- replaceAnnotations((Annotation[]) toRemove.toArray(new Annotation[0]), toAdd, false);
- }
-
- /**
- * Sets the positions that should be highlighted as the target positions, i.e.
- * as the positions that can be jumped to in a linked set up.
- *
- * @param positions the new target positions, or <code>null</code> if no target positions are to be set
- */
- private void setTargetPositions(List positions) throws BadLocationException {
- if (!fMarkTargets)
- return;
-
- // remove all positions which are already there
- // algo: toRemove contains all mappings at first, but all that are in
- // positions get removed -> toRemove contains the difference set of previsous - new
- // toAdd are the new positions, which don't exist in previous = new - previous
- List toRemove= new ArrayList(fTargetAnnotations.values());
- Map toAdd= new HashMap();
- if (positions != null) {
- for (Iterator iter= positions.iterator(); iter.hasNext();) {
- Position p= (Position) iter.next();
- if (fTargetAnnotations.containsKey(p)) {
- toRemove.remove(fTargetAnnotations.get(p));
- } else {
- Annotation a= new Annotation(TARGET_ANNOTATION_TYPE, false, ""); //$NON-NLS-1$
- toAdd.put(a, p);
- fTargetAnnotations.put(p, a);
- }
- }
- }
- fTargetAnnotations.values().removeAll(toRemove);
-
- replaceAnnotations((Annotation[]) toRemove.toArray(new Annotation[0]), toAdd, false);
- }
-
- /**
- * Switches the focus position to <code>position</code> given the
- * <code>LinkedEnvironment env</code>. The slave positions for <code>position</code>
- * is extracted from the environment and set accordingly, the target positions
- * are updated as well.
- *
- * @param env
- * @param position
- */
- public void switchToPosition(LinkedEnvironment env, LinkedPosition position) {
- if (fDocument == null ||
- (position != null && getPosition(fFocusAnnotation) == position) ||
- (position == null && fFocusAnnotation == null))
- return;
-
- LinkedPositionGroup linkedGroup= null;
- if (position != null)
- linkedGroup= env.getGroupForPosition(position);
-
- List targets= new ArrayList();
- targets.addAll(Arrays.asList(fTargets));
-
- List group;
- if (linkedGroup != null)
- group= new ArrayList(Arrays.asList(linkedGroup.getPositions()));
- else
- group= new ArrayList();
-
- if (position == null || !fDocument.equals(position.getDocument()))
- // position is not valid if not in this document
- position= null;
-
- LinkedPosition exit= fExitPosition;
- if (exit == null || !fDocument.equals(exit.getDocument()))
- // position is not valid if not in this document
- exit= null;
-
-
- if (exit != null) {
- group.remove(exit);
- targets.remove(exit);
- }
-
- group.removeAll(targets);
- targets.remove(position);
- group.remove(position);
- prune(targets);
- prune(group);
-
- try {
- setFocusPosition(position);
- setExitPosition(exit);
- setGroupPositions(group);
- setTargetPositions(targets);
- } catch (BadLocationException e) {
- // will never happen as we don't actually add/remove positions from the document
- // see the addPosition / removePosition methods
- Assert.isTrue(false);
- }
- fireModelChanged();
-
- }
-
- /**
- * Prune <code>list</code> of all <code>LinkedPosition</code>s that
- * do not belong to this model's <code>IDocument</code>.
- *
- * @param list the list of positions to prune
- */
- private void prune(List list) {
- for (Iterator iter= list.iterator(); iter.hasNext();) {
- LinkedPosition pos= (LinkedPosition) iter.next();
- if (!pos.getDocument().equals(fDocument))
- iter.remove();
- }
- }
-
- /**
- * Sets the target positions
- * @param positions
- */
- public void setTargets(Position[] positions) {
- fTargets= positions;
- }
-
- /**
- * Sets the exit position.
- *
- * @param position the new exit position, or <code>null</code> if no exit position should be set
- */
- public void setExitTarget(LinkedPosition position) {
- fExitPosition = position;
- }
-
- /*
- * @see org.eclipse.jface.text.source.AnnotationModel#addPosition(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.Position)
- */
- protected void addPosition(IDocument document, Position position) {
- // don't to anything as our positions are managed by custom
- // position updaters
- }
-
- /*
- * @see org.eclipse.jface.text.source.AnnotationModel#removePosition(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.Position)
- */
- protected void removePosition(IDocument document, Position pos) {
- // don't to anything as our positions are managed by custom
- // position updaters
- }
-
- /*
- * @see org.eclipse.jface.text.source.AnnotationModel#fireModelChanged()
- */
- public void fireModelChanged() {
- super.fireModelChanged();
- }
-
- /**
- * Sets the drawing state for the exit target. Default is <code>true</code>.
- *
- * @param markExitTargets the new drawing state for exit targets
- */
- public void markExitTarget(boolean markExitTargets) {
- fMarkExitTarget= markExitTargets;
- }
-
- /**
- * Sets the drawing state for the focus position. Default is <code>true</code>.
- *
- * @param markFocus the new drawing state for exit targets
- */
- public void markFocus(boolean markFocus) {
- fMarkFocus= markFocus;
- }
-
- /**
- * Sets the drawing state for slave positions. Default is <code>true</code>.
- *
- * @param markSlaves the new drawing state for slaves
- */
- public void markSlaves(boolean markSlaves) {
- fMarkSlaves= markSlaves;
- }
-
- /**
- * Sets the drawing state for targets. Default is <code>true</code>.
- *
- * @param markTargets the new drawing state for targets
- */
- public void markTargets(boolean markTargets) {
- fMarkTargets= markTargets;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedUIControl.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedUIControl.java
deleted file mode 100644
index 2d4268a..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedUIControl.java
+++ /dev/null
@@ -1,1140 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.link;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.custom.VerifyKeyListener;
-import org.eclipse.swt.events.ShellEvent;
-import org.eclipse.swt.events.ShellListener;
-import org.eclipse.swt.events.VerifyEvent;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.jface.internal.text.link.contentassist.ContentAssistant2;
-import org.eclipse.jface.internal.text.link.contentassist.IProposalListener;
-import org.eclipse.jface.viewers.IPostSelectionProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPartitioningException;
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.DefaultPositionUpdater;
-import org.eclipse.jface.text.DocumentCommand;
-import org.eclipse.jface.text.IAutoEditStrategy;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentExtension3;
-import org.eclipse.jface.text.IPositionUpdater;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.IRewriteTarget;
-import org.eclipse.jface.text.ITextOperationTarget;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.ITextViewerExtension;
-import org.eclipse.jface.text.ITextViewerExtension2;
-import org.eclipse.jface.text.ITextViewerExtension5;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.source.IAnnotationModel;
-import org.eclipse.jface.text.source.IAnnotationModelExtension;
-import org.eclipse.jface.text.source.ISourceViewer;
-
-/**
- * The UI for linked mode. Detects events that influence behaviour of the linked
- * position UI and acts upon them.
- * <p>
- * <code>LinkedUIControl</code> relies on all added
- * <code>LinkedUITarget</code> s to provide implementations of
- * <code>ITextViewer</code> that implement <code>ITextViewerExtension</code>,
- * and the documents being edited to implement <code>IDocumentExtension3</code>.
- * </p>
- *
- * @since 3.0
- */
-public class LinkedUIControl {
-
- /* cycle constants */
- /**
- * Constant indicating that this UI should never cycle from the last
- * position to the first and vice versa.
- */
- public static final Object CYCLE_NEVER= new Object();
- /**
- * Constant indicating that this UI should always cycle from the last
- * position to the first and vice versa.
- */
- public static final Object CYCLE_ALWAYS= new Object();
- /**
- * Constant indicating that this UI should cycle from the last position to
- * the first and vice versa if its environment is not nested.
- */
- public static final Object CYCLE_WHEN_NO_PARENT= new Object();
-
- /**
- * Listener that gets notified when the linked ui switches its focus position.
- */
- public static interface ILinkedFocusListener {
- /**
- * Called when the UI for the linked mode leaves a linked position.
- *
- * @param position the position being left
- * @param target the target where <code>position</code> resides in
- */
- void linkedFocusLost(LinkedPosition position, LinkedUITarget target);
- /**
- * Called when the UI for the linked mode gives focus to a linked position.
- *
- * @param position the position being entered
- * @param target the target where <code>position</code> resides in
- */
- void linkedFocusGained(LinkedPosition position, LinkedUITarget target);
- }
-
- /**
- * Null object implementation of focus listener.
- */
- private static final class EmtpyFocusListener implements ILinkedFocusListener {
-
- public void linkedFocusGained(LinkedPosition position, LinkedUITarget target) {
- // ignore
- }
-
- public void linkedFocusLost(LinkedPosition position, LinkedUITarget target) {
- // ignore
- }
- }
-
- /**
- * A link target consists of a viewer and gets notified if the linked UI on
- * it is being shown.
- *
- * @since 3.0
- */
- public static abstract class LinkedUITarget implements ILinkedFocusListener {
- /**
- * Returns the viewer represented by this target, never <code>null</code>.
- *
- * @return the viewer associated with this target.
- */
- public abstract ITextViewer getViewer();
-
- /**
- * The viewer's text widget is initialized when the UI first connects
- * to the viewer and never changed thereafter. This is to keep the
- * reference of the widget that we have registered our listeners with,
- * as the viewer, when it gets disposed, does not remember it, resulting
- * in a situation where we cannot uninstall the listeners and a memory leak.
- */
- StyledText fWidget;
-
- /** The cached shell - same reason as fWidget. */
- Shell fShell;
-
- /** The registered listener, or <code>null</code>. */
- LinkedUIKeyListener fKeyListener;
-
- /** The cached custom annotation model. */
- LinkedPositionAnnotations fAnnotationModel;
- }
-
- private static final class EmptyTarget extends LinkedUITarget {
-
- private ITextViewer fTextViewer;
-
- /**
- * @param viewer the viewer
- */
- public EmptyTarget(ITextViewer viewer) {
- Assert.isNotNull(viewer);
- fTextViewer= viewer;
- }
-
- /*
- * @see org.eclipse.jdt.internal.ui.text.link2.LinkedUIControl.ILinkedUITarget#getViewer()
- */
- public ITextViewer getViewer() {
- return fTextViewer;
- }
-
- /**
- * {@inheritDoc}
- */
- public void linkedFocusLost(LinkedPosition position, LinkedUITarget target) {
- }
-
- /**
- * {@inheritDoc}
- */
- public void linkedFocusGained(LinkedPosition position, LinkedUITarget target) {
- }
-
- }
-
- /**
- * Listens for state changes in the model.
- */
- private final class ExitListener implements ILinkedListener {
- /*
- * @see org.eclipse.jdt.internal.ui.text.link2.LinkedEnvironment.ILinkedListener#left(org.eclipse.jdt.internal.ui.text.link2.LinkedEnvironment, int)
- */
- public void left(LinkedEnvironment environment, int flags) {
- leave(ILinkedListener.EXIT_ALL | flags);
- }
-
- /*
- * @see org.eclipse.jdt.internal.ui.text.link2.LinkedEnvironment.ILinkedListener#suspend(org.eclipse.jdt.internal.ui.text.link2.LinkedEnvironment)
- */
- public void suspend(LinkedEnvironment environment) {
- disconnect();
- redraw();
- }
-
- /*
- * @see org.eclipse.jdt.internal.ui.text.link2.LinkedEnvironment.ILinkedListener#resume(org.eclipse.jdt.internal.ui.text.link2.LinkedEnvironment)
- */
- public void resume(LinkedEnvironment environment, int flags) {
- if ((flags & ILinkedListener.EXIT_ALL) != 0) {
- leave(flags);
- } else {
- connect();
- if ((flags & ILinkedListener.SELECT) != 0)
- select();
- ensureAnnotationModelInstalled();
- redraw();
- }
- }
- }
-
- /**
- * Exit flags returned if a custom exit policy wants to exit linked mode.
- */
- public static class ExitFlags {
- /** The flags to return in the <code>leave</code> method. */
- public int flags;
- /** The doit flag of the checked <code>VerifyKeyEvent</code>. */
- public boolean doit;
- /**
- * Creates a new instance.
- *
- * @param flags the exit flags
- * @param doit the doit flag for the verify event
- */
- public ExitFlags(int flags, boolean doit) {
- this.flags= flags;
- this.doit= doit;
- }
- }
-
- /**
- * An exit policy can be registered by a caller to get custom exit
- * behaviour.
- */
- public interface IExitPolicy {
- /**
- * Checks whether the linked mode should be left after receiving the
- * given <code>VerifyEvent</code> and selection. Note that the event
- * carries widget coordinates as opposed to <code>offset</code> and
- * <code>length</code> which are document coordinates.
- *
- * @param environment the linked environment
- * @param event the verify event
- * @param offset the offset of the current selection
- * @param length the length of the current selection
- * @return valid exit flags or <code>null</code> if no special action
- * should be taken
- */
- ExitFlags doExit(LinkedEnvironment environment, VerifyEvent event, int offset, int length);
- }
-
- /**
- * A NullObject implementation of <code>IExitPolicy</code>.
- */
- private static class NullExitPolicy implements IExitPolicy {
- /*
- * @see org.eclipse.jdt.internal.ui.text.link2.LinkedUIControl.IExitPolicy#doExit(org.eclipse.swt.events.VerifyEvent, int, int)
- */
- public ExitFlags doExit(LinkedEnvironment environment, VerifyEvent event, int offset, int length) {
- return null;
- }
- }
-
- /**
- * Listens for shell events and acts upon them.
- */
- private class LinkedUICloser implements ShellListener {
-
- public void shellActivated(ShellEvent e) {
- }
-
- public void shellClosed(ShellEvent e) {
- leave(ILinkedListener.EXIT_ALL);
- }
-
- public void shellDeactivated(ShellEvent e) {
-// T ODO reenable after debugging
-// if (true) return;
-
- // from LinkedPositionUI:
-
- // don't deactivate on focus lost, since the proposal popups may take focus
- // plus: it doesn't hurt if you can check with another window without losing linked mode
- // since there is no intrusive popup sticking out.
-
- // need to check first what happens on reentering based on an open action
- // Seems to be no problem
-
- // Better:
- // Check with content assistant and only leave if its not the proposal shell that took the
- // focus away.
-
- StyledText text;
- Display display;
-
- if (fAssistant == null || fCurrentTarget == null || (text= fCurrentTarget.fWidget) == null
- || text.isDisposed() || (display= text.getDisplay()) == null || display.isDisposed()) {
- leave(ILinkedListener.EXIT_ALL);
- } else {
- // Post in UI thread since the assistant popup will only get the focus after we lose it.
- display.asyncExec(new Runnable() {
- public void run() {
- if (fIsActive && (fAssistant == null || !fAssistant.hasFocus())) {
- leave(ILinkedListener.EXIT_ALL);
- }
- }
- });
- }
- }
-
- public void shellDeiconified(ShellEvent e) {
- }
-
- public void shellIconified(ShellEvent e) {
- leave(ILinkedListener.EXIT_ALL);
- }
-
- }
-
- /**
- * Listens for key events, checks the exit policy for custom exit
- * strategies but defaults to handling Tab, Enter, and Escape.
- */
- private class LinkedUIKeyListener implements VerifyKeyListener {
-
- private boolean fIsEnabled= true;
-
- public void verifyKey(VerifyEvent event) {
-
- if (!event.doit || !fIsEnabled)
- return;
-
- Point selection= fCurrentTarget.getViewer().getSelectedRange();
- int offset= selection.x;
- int length= selection.y;
-
- // if the custom exit policy returns anything, use that
- ExitFlags exitFlags= fExitPolicy.doExit(fEnvironment, event, offset, length);
- if (exitFlags != null) {
- leave(exitFlags.flags);
- event.doit= exitFlags.doit;
- return;
- }
-
- // standard behaviour:
- // (Shift+)Tab: jumps from position to position, depending on cycle mode
- // Enter: accepts all entries and leaves all (possibly stacked) environments, the last sets the caret
- // Esc: accepts all entries and leaves all (possibly stacked) environments, the caret stays
- // ? what do we do to leave one level of a cycling environment that is stacked?
- // -> This is only the case if the level was set up with forced cycling (CYCLE_ALWAYS), in which case
- // the caller is sure that one does not need by-level exiting.
- switch (event.character) {
- // [SHIFT-]TAB = hop between edit boxes
- case 0x09:
- if (!(fExitPosition != null && fExitPosition.includes(offset)) && !fEnvironment.anyPositionContains(offset)) {
- // outside any edit box -> leave (all? TODO should only leave the affected, level and forward to the next upper)
- leave(ILinkedListener.EXIT_ALL);
- break;
- } else {
- if (event.stateMask == SWT.SHIFT)
- previous();
- else
- next();
- }
-
- event.doit= false;
- break;
-
- // ENTER
- case 0x0A:
- // Ctrl+Enter on WinXP
- case 0x0D:
-// if ((fExitPosition != null && fExitPosition.includes(offset)) || !fEnvironment.anyPositionContains(offset)) {
- if (!fEnvironment.anyPositionContains(offset)) {
-// if ((fExitPosition == null || !fExitPosition.includes(offset)) && !fEnvironment.anyPositionContains(offset)) {
- // outside any edit box or on exit position -> leave (all? TODO should only leave the affected, level and forward to the next upper)
- leave(ILinkedListener.EXIT_ALL);
- break;
- } else {
- // normal case: exit entire stack and put caret to final position
- leave(ILinkedListener.EXIT_ALL | ILinkedListener.UPDATE_CARET);
- event.doit= false;
- break;
- }
-
- // ESC
- case 0x1B:
- // exit entire stack and leave caret
- leave(ILinkedListener.EXIT_ALL);
- event.doit= false;
- break;
-
- default:
- if (event.character != 0) {
- if (!controlUndoBehavior(offset, length)) {
- leave(ILinkedListener.EXIT_ALL);
- break;
- }
- }
- }
- }
-
- private boolean controlUndoBehavior(int offset, int length) {
- LinkedPosition position= fEnvironment.findPosition(new LinkedPosition(fCurrentTarget.getViewer().getDocument(), offset, length, LinkedPositionGroup.NO_STOP));
- if (position != null) {
-
- // if the last position is not the same and there is an open change: close it.
- if (!position.equals(fPreviousPosition))
- endCompoundChange();
-
- beginCompoundChange();
- }
-
- fPreviousPosition= position;
- return fPreviousPosition != null;
- }
-
- /**
- * @param enabled the new enabled state
- */
- public void setEnabled(boolean enabled) {
- fIsEnabled= enabled;
- }
-
- }
-
- /**
- * Installed as post selection listener on the watched viewer. Updates the
- * linked position after cursor movement, even to positions not in the
- * iteration list.
- */
- private class MySelectionListener implements ISelectionChangedListener {
-
- /*
- * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
- */
- public void selectionChanged(SelectionChangedEvent event) {
- ISelection selection= event.getSelection();
- if (selection instanceof ITextSelection) {
- ITextSelection textsel= (ITextSelection) selection;
- if (event.getSelectionProvider() instanceof ITextViewer) {
- IDocument doc= ((ITextViewer) event.getSelectionProvider()).getDocument();
- if (doc != null) {
- int offset= textsel.getOffset();
- int length= textsel.getLength();
- if (offset >= 0 && length >= 0) {
- LinkedPosition find= new LinkedPosition(doc, offset, length, LinkedPositionGroup.NO_STOP);
- LinkedPosition pos= fEnvironment.findPosition(find);
- if (pos == null && fExitPosition != null && fExitPosition.includes(find))
- pos= fExitPosition;
-
- if (pos != null)
- switchPosition(pos, false, false);
- }
- }
- }
- }
- }
-
- }
-
- private class ProposalListener implements IProposalListener {
-
- /*
- * @see org.eclipse.jface.internal.text.link.contentassist.IProposalListener#proposalChosen(org.eclipse.jface.text.contentassist.ICompletionProposal)
- */
- public void proposalChosen(ICompletionProposal proposal) {
- next();
- }
- }
-
- /** The current viewer. */
- private LinkedUITarget fCurrentTarget;
- /** The manager of the linked positions we provide a UI for. */
- private LinkedEnvironment fEnvironment;
- /** The set of viewers we manage. */
- private LinkedUITarget[] fTargets;
- /** The iterator over the tab stop positions. */
- private TabStopIterator fIterator;
-
- /* Our team of event listeners */
- /** The shell listener. */
- private LinkedUICloser fCloser= new LinkedUICloser();
- /** The linked listener. */
- private ILinkedListener fLinkedListener= new ExitListener();
- /** The selection listener. */
- private MySelectionListener fSelectionListener= new MySelectionListener();
- /** The content assist listener. */
- private ProposalListener fProposalListener= new ProposalListener();
-
- /** The last caret position, used by fCaretListener. */
- private final Position fCaretPosition= new Position(0, 0);
- /** The exit policy to control custom exit behaviour */
- private IExitPolicy fExitPolicy= new NullExitPolicy();
- /** The current frame position shown in the UI, or <code>null</code>. */
- private LinkedPosition fFramePosition;
- /** The last visisted position, used for undo / redo. */
- private LinkedPosition fPreviousPosition;
- /** The content assistant used to show proposals. */
- private ContentAssistant2 fAssistant;
- /** The exit position. */
- private LinkedPosition fExitPosition;
- /** State indicator to prevent multiple invocation of leave. */
- private boolean fIsActive= false;
- /** The position updater for the exit position. */
- private IPositionUpdater fPositionUpdater= new DefaultPositionUpdater(getCategory());
- /** Whether to show context info. */
- private boolean fDoContextInfo= false;
- /** Whether we have begun a compound change, but not yet closed. */
- private boolean fHasOpenCompoundChange= false;
- /** The position listener. */
- private ILinkedFocusListener fPositionListener= new EmtpyFocusListener();
- private IAutoEditStrategy fAutoEditVetoer= new IAutoEditStrategy() {
-
- /*
- * @see org.eclipse.jface.text.IAutoEditStrategy#customizeDocumentCommand(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.DocumentCommand)
- */
- public void customizeDocumentCommand(IDocument document, DocumentCommand command) {
- // invalidate the change to ensure that the change is performed on the document only.
- if (fEnvironment.anyPositionContains(command.offset)) {
- command.doit= false;
- command.caretOffset= command.offset + command.length;
- }
-
- }
- };
- /** Whether this ui is in simple highlighting mode or not. */
- private boolean fSimple;
-
- /**
- * Creates a new UI on the given model (environment) and the set of
- * viewers. The environment must provide a tab stop sequence with a
- * non-empty list of tab stops.
- *
- * @param environment the linked position model
- * @param targets the non-empty list of targets upon which the linked ui
- * should act
- */
- public LinkedUIControl(LinkedEnvironment environment, LinkedUITarget[] targets) {
- constructor(environment, targets);
- }
-
- /**
- * Conveniance ctor for just one viewer.
- *
- * @param environment the linked position model
- * @param viewer the viewer upon which the linked ui
- * should act
- */
- public LinkedUIControl(LinkedEnvironment environment, ITextViewer viewer) {
- constructor(environment, new LinkedUITarget[]{new EmptyTarget(viewer)});
- }
-
- /**
- * Conveniance ctor for multiple viewers.
- *
- * @param environment the linked position model
- * @param viewers the non-empty list of viewers upon which the linked ui
- * should act
- */
- public LinkedUIControl(LinkedEnvironment environment, ITextViewer[] viewers) {
- LinkedUITarget[] array= new LinkedUITarget[viewers.length];
- for (int i= 0; i < array.length; i++) {
- array[i]= new EmptyTarget(viewers[i]);
- }
- constructor(environment, array);
- }
-
- /**
- * Conveniance ctor for one target.
- *
- * @param environment the linked position model
- * @param target the target upon which the linked ui
- * should act
- */
- public LinkedUIControl(LinkedEnvironment environment, LinkedUITarget target) {
- constructor(environment, new LinkedUITarget[]{target});
- }
-
- /**
- * This does the actual constructor work.
- *
- * @param environment the linked position model
- * @param targets the non-empty array of targets upon which the linked ui
- * should act
- */
- private void constructor(LinkedEnvironment environment, LinkedUITarget[] targets) {
- Assert.isNotNull(environment);
- Assert.isNotNull(targets);
- Assert.isTrue(targets.length > 0);
- Assert.isTrue(environment.getTabStopSequence().size() > 0);
-
- fEnvironment= environment;
- fTargets= targets;
- fCurrentTarget= targets[0];
- fIterator= new TabStopIterator(fEnvironment.getTabStopSequence());
- fIterator.setCycling(!fEnvironment.isNested());
- fEnvironment.addLinkedListener(fLinkedListener);
-
- fAssistant= new ContentAssistant2();
- fAssistant.addProposalListener(fProposalListener);
- // TODO find a way to set up content assistant.
-// fAssistant.setDocumentPartitioning(IJavaPartitions.JAVA_PARTITIONING);
-
- fCaretPosition.delete();
- }
-
- /**
- * Starts this UI on the first position.
- */
- public void enter() {
- fIsActive= true;
- connect();
- next();
- }
-
- /**
- * Sets an <code>IExitPolicy</code> to customize the exit behaviour of
- * this linked UI.
- *
- * @param policy the exit policy to use.
- */
- public void setExitPolicy(IExitPolicy policy) {
- fExitPolicy= policy;
- }
-
- /**
- * Sets the exit position to move the caret to when linked mode is exited.
- *
- * @param target the target where the exit position is located
- * @param offset the offset of the exit position
- * @param length the length of the exit position (in case there should be a
- * selection)
- * @param sequence set to the tab stop position of the exit position, or
- * <code>LinkedPositionGroup.NO_STOP</code> if there should be no tab stop.
- * @throws BadLocationException if the position is not valid in the
- * viewer's document
- */
- public void setExitPosition(LinkedUITarget target, int offset, int length, int sequence) throws BadLocationException {
- // remove any existing exit position
- if (fExitPosition != null) {
- fExitPosition.getDocument().removePosition(fExitPosition);
- fIterator.removePosition(fExitPosition);
- fExitPosition= null;
- }
-
- IDocument doc= target.getViewer().getDocument();
- if (doc == null)
- return;
-
- fExitPosition= new LinkedPosition(doc, offset, length, sequence);
- doc.addPosition(fExitPosition); // gets removed in leave()
- if (sequence != LinkedPositionGroup.NO_STOP)
- fIterator.addPosition(fExitPosition);
-
- }
-
- /**
- * Sets the exit position to move the caret to when linked mode is exited.
- *
- * @param viewer the viewer where the exit position is located
- * @param offset the offset of the exit position
- * @param length the length of the exit position (in case there should be a
- * selection)
- * @param sequence set to the tab stop position of the exit position, or
- * <code>LinkedPositionGroup.NO_STOP</code> if there should be no tab stop.
- * @throws BadLocationException if the position is not valid in the
- * viewer's document
- */
- public void setExitPosition(ITextViewer viewer, int offset, int length, int sequence) throws BadLocationException {
- setExitPosition(new EmptyTarget(viewer), offset, length, sequence);
- }
-
- /**
- * Sets the cycling mode to either of <code>CYCLING_ALWAYS</code>,
- * <code>CYCLING_NEVER</code>, or <code>CYCLING_WHEN_NO_PARENT</code>,
- * which is the default.
- *
- * @param mode the new cycling mode.
- */
- public void setCyclingMode(Object mode) {
- if (mode != CYCLE_ALWAYS && mode != CYCLE_NEVER && mode != CYCLE_WHEN_NO_PARENT)
- throw new IllegalArgumentException();
-
- if (mode == CYCLE_ALWAYS || mode == CYCLE_WHEN_NO_PARENT && !fEnvironment.isNested())
- fIterator.setCycling(true);
- else
- fIterator.setCycling(false);
- }
-
- void next() {
- if (fIterator.hasNext(fFramePosition)) {
- switchPosition(fIterator.next(fFramePosition), true, true);
- return;
- } else
- leave(ILinkedListener.UPDATE_CARET);
- }
-
- void previous() {
- if (fIterator.hasPrevious(fFramePosition)) {
- switchPosition(fIterator.previous(fFramePosition), true, true);
- } else
- // dont't update caret, but rather select the current frame
- leave(ILinkedListener.SELECT);
- }
-
- private void triggerContextInfo() {
- ITextOperationTarget target= fCurrentTarget.getViewer().getTextOperationTarget();
- if (target != null) {
- if (target.canDoOperation(ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION))
- target.doOperation(ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION);
- }
- }
-
- /** Trigger content assist on choice positions */
- private void triggerContentAssist() {
- if (fFramePosition instanceof ProposalPosition) {
- ProposalPosition pp= (ProposalPosition) fFramePosition;
- ICompletionProposal[] choices= pp.getChoices();
- if (choices != null && choices.length > 0) {
- fAssistant.setCompletions(choices);
- fAssistant.showPossibleCompletions();
- return;
- }
- }
-
- fAssistant.setCompletions(new ICompletionProposal[0]);
- fAssistant.hidePossibleCompletions();
- }
-
- private void switchPosition(LinkedPosition pos, boolean select, boolean showProposals) {
- Assert.isNotNull(pos);
- if (pos.equals(fFramePosition))
- return;
-
- if (fFramePosition != null && fCurrentTarget != null)
- fPositionListener.linkedFocusLost(fFramePosition, fCurrentTarget);
-
- // undo
- endCompoundChange();
-
- redraw(); // redraw current position being left - usually not needed
- IDocument oldDoc= fFramePosition == null ? null : fFramePosition.getDocument();
- IDocument newDoc= pos.getDocument();
-
- switchViewer(oldDoc, newDoc, pos);
- fFramePosition= pos;
-
- if (select)
- select();
- if (fFramePosition == fExitPosition && !fIterator.isCycling())
- leave(ILinkedListener.NONE);
- else {
- redraw(); // redraw new position
- ensureAnnotationModelInstalled();
- }
- if (showProposals)
- triggerContentAssist();
- if (fFramePosition != fExitPosition && fDoContextInfo)
- triggerContextInfo();
-
- if (fFramePosition != null && fCurrentTarget != null)
- fPositionListener.linkedFocusGained(fFramePosition, fCurrentTarget);
-
- }
-
- private void ensureAnnotationModelInstalled() {
- LinkedPositionAnnotations lpa= fCurrentTarget.fAnnotationModel;
- if (lpa != null) {
- ITextViewer viewer= fCurrentTarget.getViewer();
- if (viewer instanceof ISourceViewer) {
- ISourceViewer sv= (ISourceViewer) viewer;
- IAnnotationModel model= sv.getAnnotationModel();
- if (model instanceof IAnnotationModelExtension) {
- IAnnotationModelExtension ext= (IAnnotationModelExtension) model;
- IAnnotationModel ourModel= ext.getAnnotationModel(getUniqueKey());
- if (ourModel == null) {
- ext.addAnnotationModel(getUniqueKey(), lpa);
- }
- }
- }
- }
- }
-
- private void uninstallAnnotationModel(LinkedUITarget target) {
- ITextViewer viewer= target.getViewer();
- if (viewer instanceof ISourceViewer) {
- ISourceViewer sv= (ISourceViewer) viewer;
- IAnnotationModel model= sv.getAnnotationModel();
- if (model instanceof IAnnotationModelExtension) {
- IAnnotationModelExtension ext= (IAnnotationModelExtension) model;
- ext.removeAnnotationModel(getUniqueKey());
- }
- }
- }
-
- private void switchViewer(IDocument oldDoc, IDocument newDoc, LinkedPosition pos) {
- if (oldDoc != newDoc) {
-
- // redraw current document with new position before switching viewer
- if (fCurrentTarget.fAnnotationModel != null)
- fCurrentTarget.fAnnotationModel.switchToPosition(fEnvironment, pos);
-
- LinkedUITarget target= null;
- for (int i= 0; i < fTargets.length; i++) {
- if (fTargets[i].getViewer().getDocument() == newDoc) {
- target= fTargets[i];
- break;
- }
- }
- if (target != fCurrentTarget) {
- disconnect();
- fCurrentTarget= target;
- target.linkedFocusLost(fFramePosition, target);
- connect();
- ensureAnnotationModelInstalled();
- if (fCurrentTarget != null)
- fCurrentTarget.linkedFocusGained(pos, fCurrentTarget);
- }
- }
- }
-
- private void select() {
- ITextViewer viewer= fCurrentTarget.getViewer();
- if (viewer instanceof ITextViewerExtension5) {
- ITextViewerExtension5 extension5= (ITextViewerExtension5) viewer;
- extension5.exposeModelRange(new Region(fFramePosition.offset, fFramePosition.length));
- } else if (!viewer.overlapsWithVisibleRegion(fFramePosition.offset, fFramePosition.length)) {
- viewer.resetVisibleRegion();
- }
- viewer.revealRange(fFramePosition.offset, fFramePosition.length);
- viewer.setSelectedRange(fFramePosition.offset, fFramePosition.length);
- }
-
- private void redraw() {
- if (fCurrentTarget.fAnnotationModel != null)
- fCurrentTarget.fAnnotationModel.switchToPosition(fEnvironment, fFramePosition);
- }
-
- private void connect() {
- Assert.isNotNull(fCurrentTarget);
- ITextViewer viewer= fCurrentTarget.getViewer();
- Assert.isNotNull(viewer);
- fCurrentTarget.fWidget= viewer.getTextWidget();
- if (fCurrentTarget.fWidget == null)
- leave(ILinkedListener.EXIT_ALL);
-
- if (fCurrentTarget.fKeyListener == null) {
- fCurrentTarget.fKeyListener= new LinkedUIKeyListener();
- ((ITextViewerExtension) viewer).prependVerifyKeyListener(fCurrentTarget.fKeyListener);
- } else
- fCurrentTarget.fKeyListener.setEnabled(true);
-
- registerAutoEditVetoer(viewer);
-
- ((IPostSelectionProvider) viewer).addPostSelectionChangedListener(fSelectionListener);
-
- createAnnotationModel();
-
- fCurrentTarget.fWidget.showSelection();
-
- fCurrentTarget.fShell= fCurrentTarget.fWidget.getShell();
- if (fCurrentTarget.fShell == null)
- leave(ILinkedListener.EXIT_ALL);
- fCurrentTarget.fShell.addShellListener(fCloser);
-
- fAssistant.install(viewer);
- }
-
- /**
- * Registers our auto edit vetoer with the viewer.
- *
- * @param viewer the viewer we want to veto ui-triggered changes within
- * linked positions
- */
- private void registerAutoEditVetoer(ITextViewer viewer) {
- try {
- if (viewer.getDocument() instanceof IDocumentExtension3) {
- IDocumentExtension3 ext= (IDocumentExtension3) viewer.getDocument();
- String[] contentTypes= ext.getLegalContentTypes(IDocumentExtension3.DEFAULT_PARTITIONING);
- if (viewer instanceof ITextViewerExtension2) {
- ITextViewerExtension2 vExtension= ((ITextViewerExtension2) viewer);
- for (int i= 0; i < contentTypes.length; i++) {
- vExtension.prependAutoEditStrategy(fAutoEditVetoer, contentTypes[i]);
- }
- } else {
- Assert.isTrue(false);
- }
- }
-
- } catch (BadPartitioningException e) {
- leave(ILinkedListener.EXIT_ALL);
- }
- }
-
- private void unregisterAutoEditVetoer(ITextViewer viewer) {
- try {
- if (viewer.getDocument() instanceof IDocumentExtension3) {
- IDocumentExtension3 ext= (IDocumentExtension3) viewer.getDocument();
- String[] contentTypes= ext.getLegalContentTypes(IDocumentExtension3.DEFAULT_PARTITIONING);
- if (viewer instanceof ITextViewerExtension2) {
- ITextViewerExtension2 vExtension= ((ITextViewerExtension2) viewer);
- for (int i= 0; i < contentTypes.length; i++) {
- vExtension.removeAutoEditStrategy(fAutoEditVetoer, contentTypes[i]);
- }
- }
- }
-
- } catch (BadPartitioningException e) {
- leave(ILinkedListener.EXIT_ALL);
- }
- }
-
- private void createAnnotationModel() {
- if (fCurrentTarget.fAnnotationModel == null) {
- LinkedPositionAnnotations lpa= new LinkedPositionAnnotations();
- if (fSimple) {
- lpa.markExitTarget(true);
- lpa.markFocus(false);
- lpa.markSlaves(false);
- lpa.markTargets(false);
- }
- lpa.setTargets(fIterator.getPositions());
- lpa.setExitTarget(fExitPosition);
- lpa.connect(fCurrentTarget.getViewer().getDocument());
- fCurrentTarget.fAnnotationModel= lpa;
- }
- }
-
- private String getUniqueKey() {
- return "linked.annotationmodelkey."+toString(); //$NON-NLS-1$
- }
-
- private void disconnect() {
- Assert.isNotNull(fCurrentTarget);
- ITextViewer viewer= fCurrentTarget.getViewer();
- Assert.isNotNull(viewer);
-
- fAssistant.uninstall();
- fAssistant.removeProposalListener(fProposalListener);
-
- fCurrentTarget.fWidget= null;
-
- Shell shell= fCurrentTarget.fShell;
- fCurrentTarget.fShell= null;
-
- if (shell != null && !shell.isDisposed())
- shell.removeShellListener(fCloser);
-
- // this one is asymmetric: we don't install the model in
- // connect, but leave it to its callers to ensure they
- // have the model installed if they need it
- uninstallAnnotationModel(fCurrentTarget);
-
- unregisterAutoEditVetoer(viewer);
-
- // don't remove the verify key listener to let it keep its position
- // in the listener queue
- fCurrentTarget.fKeyListener.setEnabled(false);
-
- ((IPostSelectionProvider) viewer).removePostSelectionChangedListener(fSelectionListener);
-
- redraw();
- }
-
- void leave(final int flags) {
- if (!fIsActive)
- return;
- fIsActive= false;
-
- endCompoundChange();
-
- Display display= null;
- if (fCurrentTarget.fWidget != null && !fCurrentTarget.fWidget.isDisposed())
- display= fCurrentTarget.fWidget.getDisplay();
-
-// // debug trace
-// JavaPlugin.log(new Status(IStatus.INFO, JavaPlugin.getPluginId(), IStatus.OK, "leaving linked mode", null));
- if (fCurrentTarget.fAnnotationModel != null)
- fCurrentTarget.fAnnotationModel.removeAllAnnotations();
- disconnect();
-
- for (int i= 0; i < fTargets.length; i++) {
- if (fCurrentTarget.fKeyListener != null) {
- ((ITextViewerExtension) fTargets[i].getViewer()).removeVerifyKeyListener(fCurrentTarget.fKeyListener);
- fCurrentTarget.fKeyListener= null;
- }
- }
-
- for (int i= 0; i < fTargets.length; i++) {
-
- if (fTargets[i].fAnnotationModel != null) {
- fTargets[i].fAnnotationModel.removeAllAnnotations();
- fTargets[i].fAnnotationModel.disconnect(fCurrentTarget.getViewer().getDocument());
- fTargets[i].fAnnotationModel= null;
- }
-
- uninstallAnnotationModel(fTargets[i]);
- }
-
-
- if (fExitPosition != null)
- fExitPosition.getDocument().removePosition(fExitPosition);
-
- if ((flags & ILinkedListener.UPDATE_CARET) != 0 && fExitPosition != null && fFramePosition != fExitPosition && !fExitPosition.isDeleted())
- switchPosition(fExitPosition, true, false);
-
- final List docs= new ArrayList();
- for (int i= 0; i < fTargets.length; i++) {
- IDocument doc= fTargets[i].getViewer().getDocument();
- if (doc != null)
- docs.add(doc);
- }
-
- Runnable runnable= new Runnable() {
- public void run() {
- for (Iterator iter = docs.iterator(); iter.hasNext(); ) {
- IDocument doc= (IDocument) iter.next();
- doc.removePositionUpdater(fPositionUpdater);
- boolean uninstallCat= false;
- String[] cats= doc.getPositionCategories();
- for (int j= 0; j < cats.length; j++) {
- if (getCategory().equals(cats[j])) {
- uninstallCat= true;
- break;
- }
- }
- if (uninstallCat)
- try {
- doc.removePositionCategory(getCategory());
- } catch (BadPositionCategoryException e) {
- // ignore
- }
- }
- fEnvironment.exit(flags);
- }
- };
-
- // remove positions (both exit positions AND linked positions in the
- // environment) async to make sure that the annotation painter
- // gets correct document offsets.
- if (display != null)
- display.asyncExec(runnable);
- else
- runnable.run();
- }
-
- /**
- *
- */
- private void endCompoundChange() {
- if (fHasOpenCompoundChange) {
- ITextViewerExtension extension= (ITextViewerExtension) fCurrentTarget.getViewer();
- IRewriteTarget target= extension.getRewriteTarget();
- target.endCompoundChange();
- fHasOpenCompoundChange= false;
- }
- }
-
- private void beginCompoundChange() {
- if (!fHasOpenCompoundChange) {
- ITextViewerExtension extension= (ITextViewerExtension) fCurrentTarget.getViewer();
- IRewriteTarget target= extension.getRewriteTarget();
- target.beginCompoundChange();
- fHasOpenCompoundChange= true;
- }
- }
-
- /**
- * Returns the currently selected region or <code>null</code>.
- *
- * @return the currently selected region or <code>null</code>
- */
- public IRegion getSelectedRegion() {
- if (fFramePosition == null)
- if (fExitPosition != null)
- return new Region(fExitPosition.getOffset(), fExitPosition.getLength());
- else
- return null;
- else
- return new Region(fFramePosition.getOffset(), fFramePosition.getLength());
- }
-
-
-
- private String getCategory() {
- return toString();
- }
-
- /**
- * Sets the context info property. If set to <code>true</code>, context
- * info will be invoked on the current target's viewer whenever a position
- * is switched.
- *
- * @param doContextInfo The doContextInfo to set.
- */
- public void setDoContextInfo(boolean doContextInfo) {
- fDoContextInfo= doContextInfo;
- }
-
- /**
- * Sets the focus callback which will get informed when the focus of the
- * linked mode ui changes.
- * <p>
- * If there is a listener installed already, it will be replaced.</p>
- *
- * @param listener the new listener, never <code>null</code>.
- */
- public void setPositionListener(ILinkedFocusListener listener) {
- Assert.isNotNull(listener);
- fPositionListener= listener;
- }
-
- /**
- * Sets the "simple" mode of the receiver. A linked ui in simple mode
- * merely draws the exit position, but not the target, focus, and slave
- * positions. Default is <code>false</code>. This method must be called
- * before it is entered.
- *
- * @param simple <code>true</code> if the ui should be in simple mode.
- */
- public void setSimpleMode(boolean simple) {
- fSimple= simple;
- }
-
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/link/ProposalPosition.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/link/ProposalPosition.java
deleted file mode 100644
index 6235585..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/link/ProposalPosition.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.link;
-
-import java.util.Arrays;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.contentassist.ICompletionProposalExtension3;
-
-/**
- * LinkedPosition with added completion proposals.
- *
- * @since 3.0
- */
-public class ProposalPosition extends LinkedPosition {
-
- /**
- * Da proposals
- */
- private ICompletionProposal[] fProposals;
-
- /**
- * @param document
- * @param offset
- * @param length
- * @param sequence
- * @param proposals
- */
- public ProposalPosition(IDocument document, int offset, int length, int sequence, ICompletionProposal[] proposals) {
- super(document, offset, length, sequence);
- fProposals= proposals;
- }
-
- public ProposalPosition(IDocument document, int offset, int length, ICompletionProposal[] proposals) {
- super(document, offset, length, LinkedPositionGroup.NO_STOP);
- fProposals= proposals;
- }
-
- /*
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object o) {
- if (o instanceof ProposalPosition) {
- if (super.equals(o)) {
- return Arrays.equals(fProposals, ((ProposalPosition)o).fProposals);
- }
- }
- return false;
- }
-
- /**
- * @return an array of choices, including the initial one. Clients must not modify it.
- */
- public ICompletionProposal[] getChoices() {
- updateChoicePositions();
- return fProposals;
- }
-
- private void updateChoicePositions() {
- for (int i= 0; i < fProposals.length; i++) {
- if (fProposals[i] instanceof ICompletionProposalExtension3) {
- ((ICompletionProposalExtension3)fProposals[i]).updateReplacementOffset(offset);
- }
- }
- }
-
- /*
- * @see org.eclipse.jdt.internal.ui.text.link.LinkedPosition#hashCode()
- */
- public int hashCode() {
- return super.hashCode() | (fProposals == null ? 0 : fProposals.hashCode());
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/link/TabStopIterator.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/link/TabStopIterator.java
deleted file mode 100644
index ed2d521..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/link/TabStopIterator.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.link;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.link.LinkedPosition;
-
-
-
-/**
- * Iterator that leaps over the double occurrence of an element when switching from forward
- * to backward iteration that is shown by <code>ListIterator</code>.
- *
- * @since 3.0
- */
-class TabStopIterator {
- /**
- * Comparator for <code>LinkedPosition</code>s. If the sequence nr. of two positions is equal, the
- * offset is used.
- */
- private static class SequenceComparator implements Comparator {
-
- /**
- * {@inheritDoc}
- *
- * <p><code>o1</code> and <code>o2</code> are required to be instances
- * of <code>LinkedPosition</code>.</p>
- */
- public int compare(Object o1, Object o2) {
- LinkedPosition p1= (LinkedPosition)o1;
- LinkedPosition p2= (LinkedPosition)o2;
- int i= p1.getSequenceNumber() - p2.getSequenceNumber();
- if (i != 0)
- return i;
- else
- return p1.getOffset() - p2.getOffset();
- }
-
- }
-
- /** The comparator to sort the list of positions. */
- private static final Comparator fComparator= new SequenceComparator();
-
- /** The iteration sequence. */
- private final ArrayList fList;
- /** The size of <code>fList</code>. */
- private int fSize;
- /** Index of the current element, to the first one initially. */
- private int fIndex;
- /** Cycling property. */
- private boolean fIsCycling= false;
-
- TabStopIterator(List positionSequence) {
- Assert.isNotNull(positionSequence);
- fList= new ArrayList(positionSequence);
- Collections.sort(fList, fComparator);
- fSize= fList.size();
- fIndex= -1;
- Assert.isTrue(fSize > 0);
- }
-
- boolean hasNext(LinkedPosition current) {
- return getNextIndex(current) != fSize;
- }
-
- private int getNextIndex(LinkedPosition current) {
- if (current != null && fList.get(fIndex) != current)
- return findNext(current);
- else if (fIsCycling && fIndex == fSize - 1)
- return 0;
- else
- // default: increase
- return fIndex + 1;
- }
-
- /**
- * Finds the closest position in the iteration set that follows after
- * <code>current</code> and sets <code>fIndex</code> accordingly. If <code>current</code>
- * is in the iteration set, the next in turn is chosen.
- *
- * @param current the current position
- * @return <code>true</code> if there is a next position, <code>false</code> otherwise
- */
- private int findNext(LinkedPosition current) {
- Assert.isNotNull(current);
- // if the position is in the iteration set, jump to the next one
- int index= fList.indexOf(current);
- if (index != -1) {
- if (fIsCycling && index == fSize - 1)
- return 0;
- else
- return index + 1;
- } else {
- // find the position that follows closest to the current position
- LinkedPosition found= null;
- for (Iterator it= fList.iterator(); it.hasNext(); ) {
- LinkedPosition p= (LinkedPosition) it.next();
- if (p.offset > current.offset)
- if (found == null || found.offset > p.offset)
- found= p;
- }
- if (found != null) {
- return fList.indexOf(found);
- } else if (fIsCycling) {
- return 0;
- } else
- return fSize;
- }
- }
-
- boolean hasPrevious(LinkedPosition current) {
- return getPreviousIndex(current) != -1;
- }
-
- private int getPreviousIndex(LinkedPosition current) {
- if (current != null && fList.get(fIndex) != current)
- return findPrevious(current);
- else if (fIsCycling && fIndex == 0)
- return fSize - 1;
- else
- return fIndex - 1;
- }
-
- /**
- * Finds the closest position in the iteration set that precedes
- * <code>current</code>. If <code>current</code>
- * is in the iteration set, the previous in turn is chosen.
- *
- * @param current the current position
- * @return the index of the previous position
- */
- private int findPrevious(LinkedPosition current) {
- Assert.isNotNull(current);
- // if the position is in the iteration set, jump to the next one
- int index= fList.indexOf(current);
- if (index != -1) {
- if (fIsCycling && index == 0)
- return fSize - 1;
- else
- return index - 1;
- } else {
- // find the position that follows closest to the current position
- LinkedPosition found= null;
- for (Iterator it= fList.iterator(); it.hasNext(); ) {
- LinkedPosition p= (LinkedPosition) it.next();
- if (p.offset < current.offset)
- if (found == null || found.offset < p.offset)
- found= p;
- }
- if (found != null) {
- return fList.indexOf(found);
- } else if (fIsCycling) {
- return fSize - 1;
- } else
- return -1;
- }
- }
-
- LinkedPosition next(LinkedPosition current) {
- if (!hasNext(current))
- throw new NoSuchElementException();
- else
- return (LinkedPosition) fList.get(fIndex= getNextIndex(current));
- }
-
- LinkedPosition previous(LinkedPosition current) {
- if (!hasPrevious(current))
- throw new NoSuchElementException();
- else
- return (LinkedPosition) fList.get(fIndex= getPreviousIndex(current));
- }
-
- void setCycling(boolean mode) {
- fIsCycling= mode;
- }
-
- void addPosition(Position position) {
- fList.add(fSize++, position);
- Collections.sort(fList, fComparator);
- }
-
- void removePosition(Position position) {
- if (fList.remove(position))
- fSize--;
- }
-
- /**
- * @return Returns the isCycling.
- */
- boolean isCycling() {
- return fIsCycling;
- }
-
- LinkedPosition[] getPositions() {
- return (LinkedPosition[]) fList.toArray(new LinkedPosition[0]);
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/link/package.html b/org.eclipse.jface.text/src/org/eclipse/jface/text/link/package.html
deleted file mode 100644
index aeab0f0..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/link/package.html
+++ /dev/null
@@ -1,74 +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">
- <meta content="Mozilla/4.75 [en] (Windows NT 5.0; U) [Netscape]"
- name="GENERATOR">
- <title>Linked Position Infrastructure</title>
-</head>
-<body>
-Application programming interfaces for interaction
-with the Eclipse Java User Interface text support.
-<h2>Linked Position Infrastructure</h2>
-<h3>package <span style="font-family: monospace;">org.eclipse.jface.text.link
-</span><span style="font-family: monospace;"></span></h3>
-<h3><code></code></h3>
-The Linked Position Infrastructure lets one set up a mode in an editor
-in which regions in a document (or several documents) are <em>linked</em>,
-i.e. editions
-of one linked position will be reflected in the others.
-<h4>Classes</h4>
-<ul>
- <li><code>LinkedPositionGroup</code>: a set of linked positions. Add
-positions to a group using the <code>addPosition</code> and <code>createPosition</code>
-methods, which
-also allow to specify an iteration order. See <span
- style="font-family: monospace;">ProposalPosition</span><code><span
- style="font-family: helvetica,arial,sans-serif;"> </span></code><span
- style="font-family: helvetica,arial,sans-serif;">for a position type
-that lets one attach </span><span style="font-family: monospace;">ICompletionProposals</span><span
- style="font-family: monospace;"></span><span
- style="font-family: helvetica,arial,sans-serif;"> </span><span
- style="font-family: helvetica,arial,sans-serif;">to</span>
-be shown when the position is hit.</li>
- <li><code>LinkedEnvironment</code>: umbrellas several <code>PositionGroup</code>s,
-e.g. in a template that has several groups of linked positions. Handles
-the forwarding of updates received via an IDocumentListener. Add <code>PositionGroup</code>s
-to
-an environment using the <code>addGroup</code> method. Existence of a <span
- style="font-family: monospace;">LinkedEnvironment </span>can be
-tested by one of the static methods.<br>
- </li>
- <li><code>LinkedUIControl</code>: The UI for linked mode (for one
-environment, to be precise). Monitors key etc. activity, monitors exit
-conditions, creates a painter etc. <br>
-Properties:
- <ul>
- <li><b>cycling mode</b> (whether to jump to the first position
-after the last): either of <code>CYCLE_ALWAYS</code>, <code>CYCLE_NEVER</code>
-and <code>CYCLE_WHEN_NO_PARENT</code> (default).</li>
- <li><b>exit position</b>: where to jump upon leaving the linked
-mode (e.g. using Enter, or Tab from the last position when not
-cycling). Set <code>isTabStop</code> to <code>true</code> if tabbing
-should stop over when cycling.</li>
- <li><span style="font-weight: bold;">position listener</span>:
-you can register a position listener which will get notified whenever
-the focus position changes. An example is <span
- style="font-family: monospace;">org.eclipse.ui.texteditor.link.EditorHistoryUpdater</span>
-which will store the edit location in the editor navigation history.<br>
- </li>
- </ul>
- </li>
-.
-</ul>
-<h4>Example</h4>
-<pre> IDocument doc1, doc2;<br> ITextViewer viewer1, viewer2;<br> <br> /* create groups - this step is independent of the linked mode */<br> PositionGroup group1= new PositionGroup();<br> group1.addPosition(doc1, 3,4);<br> group1.addPosition(doc1, 7,8);<br> <br> PositionGroup group2= newPositionGroup();<br> group2.addPosition(doc1, 15, 25);<br> group2.addPosition(doc2, 0, 10);<br> <br> /* set up linked mode */<br> LinkedEnvironment env= new LinkedEnvironment();<br> env.addGroup(group1);<br> env.addGroup(group2);<br> env.forceInstall();<br> <br> /* create UI */<br> LinkedUIControl ui= new LinkedUIControl(env, new ITextViewer[] { viewer1, viewer2 });<br> ui.enter();<br></pre>
-<h4>Todo</h4>
-<ul>
- <li>handle lazy computation of per-group proposals using a <code>IContentAssistProcessor</code>
-(see PositionGroup, ProposalPosition) .</li>
-</ul>
-</body>
-</html>
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/package.html b/org.eclipse.jface.text/src/org/eclipse/jface/text/package.html
deleted file mode 100644
index 5561c37..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/package.html
+++ /dev/null
@@ -1,82 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="Author" content="IBM">
- <meta name="GENERATOR" content="Mozilla/4.51 [en] (WinNT; I) [Netscape]">
- <title>Package-level Javadoc</title>
-</head>
-<body>
-Provides a framework for creating, manipulating, displaying
-and editing text documents.
-<h2>
-Package Specification</h2>
-The packages is divided into two parts. The first part defines and implements
-the notion of text documents, whereas the second part defines and implements
-a viewer for text documents.
-<h3>
-Text Model</h3>
-<tt>IDocument</tt> is the major text model abstraction. It provides content
-management, position management using position categories, document partition
-management, searching, and change notification. In order to be notified
-about document changes, an object must implements <tt>IDocumentListener</tt>
-and must be registered with the document. Position updating in responds
-to a document change is performed by implementers of <tt>IDocumentPositionUpdater</tt>.
-Partition updating in responds to a document change is performed by implements
-of <tt>IDocumentPartitioner</tt>. In order to be notified about document
-partition changes, objects must implement <tt>IDocumentParititoningListener</tt>
-and must be registered with the document.
-<p>The package contains default implementations for document position updaters
-and for documents. <tt>AbstractDocument</tt> uses <tt>ITextStorage</tt>
-for storing and managing its content and <tt>ILineTracker</tt> to maintain
-a line structure of its content. As defaults a gap text implementation
-of <tt>ITextStore</tt> is provided, together with a line tracker understanding
-the three standard line delimiters ("\r", "\n", "\r\n") and a line
-tracker which can be freely configured to consider any given set of strings
-as valid line delimiters.
-<h3>
-Text Viewer</h3>
-<tt>ITextViewer</tt> defines the concept of a document based, editiable
-viewer. <tt>ITextViewer</tt> offers the following functionality:
-<ul>
-<li>
-present a document</li>
-
-<li>
-event consumption (<tt>IEventConsumer</tt>)</li>
-
-<li>
-viewport tracking and notification (<tt>IIViewportListener</tt>)</li>
-
-<li>
-change notification (<tt>ITextListener</tt>, <tt>ITextInputListener</tt>)</li>
-
-<li>
-listeners (combined view/model notification, input document)</li>
-
-<li>
-standard text editing functions plus text hover support</li>
-
-<li>
-visual region support</li>
-</ul>
-An ITextViewer supports the following plugins
-<ul>
-<li>
-<tt>IUndoManager</tt> for the undo/redo mechanism</li>
-
-<li>
-<tt>IDoubleClickStrategy</tt> for partition type specific behavior on mouse
-double click</li>
-
-<li>
-<tt>IAutoIndentStrategy</tt> for content type specific behavior on
-inserting a line break</li>
-
-<li>
-<tt>ITextHover</tt> for content type specific behavior when overing over
-text</li>
-</ul>
-The package provides default implementations for all these interfaces.
-</body>
-</html>
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/IPresentationDamager.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/IPresentationDamager.java
deleted file mode 100644
index fcd9560..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/IPresentationDamager.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.presentation;
-
-
-
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITypedRegion;
-
-
-/**
- * Presentation damagers are used by a presentation reconciler to determine the
- * region of the document's presentation which must be rebuilt because of the
- * occurrence of a document change. A presentation damager is assumed to be
- * specific for a particular document content type. A presentation damager is
- * expected to return a damage region which is a valid input for a presentation repairer.
- * I.e. having access to the damage region only the repairer must be able to derive
- * all the information neede to sucessfully repair this region.<p>
- * This interface must either be implemented by clients or clients use the rule-based
- * default implementation <code>RuleBasedDamagerRepairer</code>. Implementers should be
- * registered with a presentation reconciler in order get involved in the reconciling
- * process.
- *
- * @see IPresentationReconciler
- * @see IDocument
- * @see DocumentEvent
- * @see IPresentationRepairer
- */
-public interface IPresentationDamager {
-
- /**
- * Tells the presentation damager on which document it will work.
- *
- * @param document the damager's working document
- */
- void setDocument(IDocument document);
-
- /**
- * Returns the damage in the document's presentation caused by the given document change.
- * The damage is restricted to the specified partition for which the presentation damager is
- * responsible. The damage may also depend on whether the document change also caused changes
- * of the document's partitioning.
- *
- * @param partition the partition inside which the damage must be determined
- * @param event the event describing the change whose damage must be determined
- * @param documentPartitioningChange indicates whether the given change changed the document's partitioning
- * @return the computed damage
- */
- IRegion getDamageRegion(ITypedRegion partition, DocumentEvent event, boolean documentPartitioningChanged);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/IPresentationReconciler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/IPresentationReconciler.java
deleted file mode 100644
index fc92652..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/IPresentationReconciler.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.presentation;
-
-
-import org.eclipse.jface.text.ITextViewer;
-
-
-/**
- * An <code>IPresentationReconciler</code> defines and maintains the representation of a
- * text viewer's document in the presence of changes applied to the document.
- * An <code>IPresentationReconciler</code> is a <code>ITextViewer</code> add-on.<p>
- * The presentation reconciler keeps track of changes applied to the text viewer. It sends
- * each change to presentation damagers which are registered for the content types of the
- * regions in which the change occurred. The presentation reconciler passes the computed
- * damage to presentation repairers which construct text presentations. Those text presentation
- * when applied to the presentation reconciler's text viewer bring the document's presentation
- * in sync with the document's content and thus repair the damage. A presentation damager
- * is expected to return damage which is a valid input for a presentation repairer registered
- * for the same content type as the damager.<p>
- * A presentation reconciler should always be configured with damager/repairer pairs. I.e.
- * for each damager there should be a corresponding repairer.<p>
- * The interface can be implemented by clients. By default, clients use
- * <code>PresentationReconciler</code> as the standard implementer of this interface.
- *
- * @see ITextViewer
- * @see IPresentationDamager
- * @see IPresentationRepairer
- * @see org.eclipse.jface.text.TextPresentation
- */
-public interface IPresentationReconciler {
-
- /**
- * Installs this presentation reconciler on the given text viewer. After
- * this method has been finished, the reconciler is operational. I.e., it
- * works without requesting further client actions until <code>uninstall</code>
- * is called.
- *
- * @param textViewer the viewer on which this presentation reconciler is installed
- */
- void install(ITextViewer viewer);
-
- /**
- * Removes the reconciler from the text viewer it has previously been
- * installed on.
- */
- void uninstall();
-
- /**
- * Returns the presentation damager registered with this presentation reconciler
- * for the specified content type.
- *
- * @param contentType the content type for which to determine the damager
- * @return the presentation damager registered for the given content type, or
- * <code>null</code> if there is no such strategy
- */
- IPresentationDamager getDamager(String contentType);
-
- /**
- * Returns the presentation repairer registered with this presentation reconciler
- * for the specified content type.
- *
- * @param contentType the content type for which to determine the repairer
- * @return the presentation repairer registered for the given content type, or
- * <code>null</code> if there is no such strategy
- */
- IPresentationRepairer getRepairer(String contentType);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/IPresentationReconcilerExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/IPresentationReconcilerExtension.java
deleted file mode 100644
index ab979c7..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/IPresentationReconcilerExtension.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**********************************************************************
-Copyright (c) 2000, 2003 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-
-Contributors:
- IBM Corporation - Initial implementation
-**********************************************************************/
-package org.eclipse.jface.text.presentation;
-
-/**
- * Extension interface for <code>IPresentationReconciler</code>.
- * Updates the presentation reconciler to be aware of documents with multiple partitions.
- *
- * @since 3.0
- */
-public interface IPresentationReconcilerExtension {
-
- /**
- * Returns the document partitioning this presentation reconciler is using.
- *
- * @return the document partitioning this presentation reconciler is using
- */
- String getDocumentPartitioning();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/IPresentationRepairer.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/IPresentationRepairer.java
deleted file mode 100644
index 571de0a..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/IPresentationRepairer.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.presentation;
-
-
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.TextPresentation;
-
-
-/**
- * Presentation repairers are used by a presentation reconciler
- * to rebuild a damaged region in a document's presentation. A presentation repairer
- * is assumed to be specific for a particular document content type. The presentation
- * repairer gets the region which it should repair and constructs a "repair description"
- * The presentation repairer adds the individual steps of this sequence into the
- * text presentation it gets passed in.<p>
- * This interface must either be implemented by clients or clients use the rule-based
- * default implementation <code>RuleBasedDamagerRepairer</code>. Implementers should be
- * registered with a presentation reconciler in order get involved in the reconciling
- * process.
- *
- * @see IPresentationReconciler
- * @see IDocument
- * @see org.eclipse.swt.custom.StyleRange
- * @see TextPresentation
- */
-public interface IPresentationRepairer {
-
-
- /**
- * Tells the presentation repairer on which document it will work.
- *
- * @param document the damager's working document
- */
- void setDocument(IDocument document);
-
- /**
- * Fills the given presentation with the style ranges which when applied to the
- * presentation reconciler's text viewer repair the presentational damage described by
- * the given region.
- *
- * @param presentation the text presentation to be filled by this repairer
- * @param damage the damage to be repaired
- */
- void createPresentation(TextPresentation presentation, ITypedRegion damage);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/PresentationReconciler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/PresentationReconciler.java
deleted file mode 100644
index b9d9150..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/PresentationReconciler.java
+++ /dev/null
@@ -1,578 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.presentation;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.swt.custom.StyleRange;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.DefaultPositionUpdater;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.DocumentPartitioningChangedEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentExtension3;
-import org.eclipse.jface.text.IDocumentListener;
-import org.eclipse.jface.text.IDocumentPartitioningListener;
-import org.eclipse.jface.text.IDocumentPartitioningListenerExtension;
-import org.eclipse.jface.text.IDocumentPartitioningListenerExtension2;
-import org.eclipse.jface.text.IPositionUpdater;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextInputListener;
-import org.eclipse.jface.text.ITextListener;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.ITextViewerExtension5;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextEvent;
-import org.eclipse.jface.text.TextPresentation;
-import org.eclipse.jface.text.TextUtilities;
-import org.eclipse.jface.text.TypedPosition;
-
-
-
-/**
- * Standard implementation of <code>IPresentationReconciler</code>.
- * This implementation assumes that the tasks performed by its
- * presentation damagers and repairers are lightweight and of low cost.
- * This presentation reconciler runs in the UI thread and always repairs
- * the complete damage caused by a document change rather than just the
- * portion overlapping with the viewer's viewport.<p>
- * Usually, clients instantiate this class and configure it before using it.
- */
-public class PresentationReconciler implements IPresentationReconciler, IPresentationReconcilerExtension {
-
- /** Prefix of the name of the position category for tracking damage regions. */
- protected final static String TRACKED_PARTITION= "__reconciler_tracked_partition"; //$NON-NLS-1$
-
-
- /**
- * Internal listener class.
- */
- class InternalListener implements
- ITextInputListener, IDocumentListener, ITextListener,
- IDocumentPartitioningListener, IDocumentPartitioningListenerExtension, IDocumentPartitioningListenerExtension2 {
-
- /** Set to <code>true</code> if between a document about to be changed and a changed event. */
- private boolean fDocumentChanging= false;
- /** The cached redraw state of the text viewer */
- private boolean fCachedRedrawState= true;
-
- /*
- * @see ITextInputListener#inputDocumentAboutToBeChanged(IDocument, IDocument)
- */
- public void inputDocumentAboutToBeChanged(IDocument oldDocument, IDocument newDocument) {
- if (oldDocument != null) {
- try {
-
- fViewer.removeTextListener(this);
- oldDocument.removeDocumentListener(this);
- oldDocument.removeDocumentPartitioningListener(this);
-
- oldDocument.removePositionUpdater(fPositionUpdater);
- oldDocument.removePositionCategory(fPositionCategory);
-
- } catch (BadPositionCategoryException x) {
- // should not happend for former input documents;
- }
- }
- }
-
- /*
- * @see ITextInputListener#inputDocumenChanged(IDocument, IDocument)
- */
- public void inputDocumentChanged(IDocument oldDocument, IDocument newDocument) {
-
- fDocumentChanging= false;
- fCachedRedrawState= true;
-
- if (newDocument != null) {
-
- newDocument.addPositionCategory(fPositionCategory);
- newDocument.addPositionUpdater(fPositionUpdater);
-
- newDocument.addDocumentPartitioningListener(this);
- newDocument.addDocumentListener(this);
- fViewer.addTextListener(this);
-
- setDocumentToDamagers(newDocument);
- setDocumentToRepairers(newDocument);
- processDamage(new Region(0, newDocument.getLength()), newDocument);
- }
- }
-
- /*
- * @see IDocumentPartitioningListener#documentPartitioningChanged(IDocument)
- */
- public void documentPartitioningChanged(IDocument document) {
- if (!fDocumentChanging && fCachedRedrawState)
- processDamage(new Region(0, document.getLength()), document);
- else
- fDocumentPartitioningChanged= true;
- }
-
- /*
- * @see IDocumentPartitioningListenerExtension#documentPartitioningChanged(IDocument, IRegion)
- * @since 2.0
- */
- public void documentPartitioningChanged(IDocument document, IRegion changedRegion) {
- if (!fDocumentChanging && fCachedRedrawState) {
- processDamage(new Region(changedRegion.getOffset(), changedRegion.getLength()), document);
- } else {
- fDocumentPartitioningChanged= true;
- fChangedDocumentPartitions= changedRegion;
- }
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentPartitioningListenerExtension2#documentPartitioningChanged(org.eclipse.jface.text.DocumentPartitioningChangedEvent)
- */
- public void documentPartitioningChanged(DocumentPartitioningChangedEvent event) {
- IRegion changedRegion= event.getChangedRegion(getDocumentPartitioning());
- if (changedRegion != null)
- documentPartitioningChanged(event.getDocument(), changedRegion);
- }
-
- /*
- * @see IDocumentListener#documentAboutToBeChanged(DocumentEvent)
- */
- public void documentAboutToBeChanged(DocumentEvent e) {
-
- fDocumentChanging= true;
- if (fCachedRedrawState) {
- try {
- int offset= e.getOffset() + e.getLength();
- ITypedRegion region= getPartition(e.getDocument(), offset);
- fRememberedPosition= new TypedPosition(region);
- e.getDocument().addPosition(fPositionCategory, fRememberedPosition);
- } catch (BadLocationException x) {
- // can not happen
- } catch (BadPositionCategoryException x) {
- // should not happen on input elements
- }
- }
- }
-
- /*
- * @see IDocumentListener#documentChanged(DocumentEvent)
- */
- public void documentChanged(DocumentEvent e) {
- if (fCachedRedrawState) {
- try {
- e.getDocument().removePosition(fPositionCategory, fRememberedPosition);
- } catch (BadPositionCategoryException x) {
- // can not happen on input documents
- }
- }
- fDocumentChanging= false;
- }
-
- /*
- * @see ITextListener#textChanged(TextEvent)
- */
- public void textChanged(TextEvent e) {
-
- fCachedRedrawState= e.getViewerRedrawState();
- if (!fCachedRedrawState)
- return;
-
- IRegion damage= null;
- IDocument document= null;
-
- if (e.getDocumentEvent() == null) {
- document= fViewer.getDocument();
- if (document != null) {
- if (e.getOffset() == 0 && e.getLength() == 0 && e.getText() == null) {
- // redraw state change, damage the whole document
- damage= new Region(0, document.getLength());
- } else {
- IRegion region= widgetRegion2ModelRegion(e);
- try {
- String text= document.get(region.getOffset(), region.getLength());
- DocumentEvent de= new DocumentEvent(document, region.getOffset(), region.getLength(), text);
- damage= getDamage(de, false);
- } catch (BadLocationException x) {
- }
- }
- }
- } else {
- DocumentEvent de= e.getDocumentEvent();
- document= de.getDocument();
- damage= getDamage(de, true);
- }
-
- if (damage != null && document != null)
- processDamage(damage, document);
-
- fDocumentPartitioningChanged= false;
- fChangedDocumentPartitions= null;
- }
-
- /**
- * Translates the given text event into the corresponding range of the viewer's document.
- *
- * @param e the text event
- * @return the widget region corresponding the region of the given event
- * @since 2.1
- */
- protected IRegion widgetRegion2ModelRegion(TextEvent e) {
-
- String text= e.getText();
- int length= text == null ? 0 : text.length();
-
- if (fViewer instanceof ITextViewerExtension5) {
- ITextViewerExtension5 extension= (ITextViewerExtension5) fViewer;
- return extension.widgetRange2ModelRange(new Region(e.getOffset(), length));
- }
-
- IRegion visible= fViewer.getVisibleRegion();
- IRegion region= new Region(e.getOffset() + visible.getOffset(), length);
- return region;
- }
- }
-
- /** The map of presentation damagers. */
- private Map fDamagers;
- /** The map of presentation repairers. */
- private Map fRepairers;
- /** The target viewer. */
- private ITextViewer fViewer;
- /** The internal listener. */
- private InternalListener fInternalListener= new InternalListener();
- /** The name of the position category to track damage regions. */
- private String fPositionCategory;
- /** The position updated for the damage regions' position category. */
- private IPositionUpdater fPositionUpdater;
- /** The positions representing the damage regions. */
- private TypedPosition fRememberedPosition;
- /** Flag indicating the receipt of a partitioning changed notification. */
- private boolean fDocumentPartitioningChanged= false;
- /** The range covering the changed partitioning. */
- private IRegion fChangedDocumentPartitions= null;
- /**
- * The partitioning used by this presentation reconciler.
- * @since 3.0
- */
- private String fPartitioning;
-
- /**
- * Creates a new presentation reconciler. There are no damagers or repairers
- * registered with this reconciler. The default partitioning
- * <code>IDocumentExtension3.DEFAULT_PARTITIONING</code> is used.
- */
- public PresentationReconciler() {
- super();
- fPartitioning= IDocumentExtension3.DEFAULT_PARTITIONING;
- fPositionCategory= TRACKED_PARTITION + hashCode();
- fPositionUpdater= new DefaultPositionUpdater(fPositionCategory);
- }
-
- /**
- * Sets the document partitioning for this presentation reconciler.
- *
- * @param partitioning the document partitioning for this presentation reconciler.
- * @since 3.0
- */
- public void setDocumentPartitioning(String partitioning) {
- Assert.isNotNull(partitioning);
- fPartitioning= partitioning;
- }
-
- /*
- * @see org.eclipse.jface.text.presentation.IPresentationReconcilerExtension#geDocumenttPartitioning()
- * @since 3.0
- */
- public String getDocumentPartitioning() {
- return fPartitioning;
- }
-
- /**
- * Registers a given presentation damager for a particular content type.
- * If there is already a damager registered for this type, the new damager
- * is registered instead of the old one.
- *
- * @param damager the presentation damager to register, or <code>null</code> to remove an existing one
- * @param contentType the content type under which to register
- */
- public void setDamager(IPresentationDamager damager, String contentType) {
-
- Assert.isNotNull(contentType);
-
- if (fDamagers == null)
- fDamagers= new HashMap();
-
- if (damager == null)
- fDamagers.remove(contentType);
- else
- fDamagers.put(contentType, damager);
- }
-
- /**
- * Registers a given presentation repairer for a particular content type.
- * If there is already a repairer registered for this type, the new repairer
- * is registered instead of the old one.
- *
- * @param repairer the presentation repairer to register, or <code>null</code> to remove an existing one
- * @param contentType the content type under which to register
- */
- public void setRepairer(IPresentationRepairer repairer, String contentType) {
-
- Assert.isNotNull(contentType);
-
- if (fRepairers == null)
- fRepairers= new HashMap();
-
- if (repairer == null)
- fRepairers.remove(contentType);
- else
- fRepairers.put(contentType, repairer);
- }
-
- /*
- * @see IPresentationReconciler#install(ITextViewer)
- */
- public void install(ITextViewer viewer) {
- Assert.isNotNull(viewer);
-
- fViewer= viewer;
- fViewer.addTextInputListener(fInternalListener);
- }
-
- /*
- * @see IPresentationReconciler#uninstall()
- */
- public void uninstall() {
- fViewer.removeTextInputListener(fInternalListener);
-
- // Ensure we uninstall all listeners
- fInternalListener.inputDocumentAboutToBeChanged(fViewer.getDocument(), null);
- }
-
- /*
- * @see IPresentationReconciler#getDamager(String)
- */
- public IPresentationDamager getDamager(String contentType) {
-
- if (fDamagers == null)
- return null;
-
- return (IPresentationDamager) fDamagers.get(contentType);
- }
-
- /*
- * @see IPresentationReconciler#getRepairer(String)
- */
- public IPresentationRepairer getRepairer(String contentType) {
-
- if (fRepairers == null)
- return null;
-
- return (IPresentationRepairer) fRepairers.get(contentType);
- }
-
- /**
- * Informs all registed damagers about the document on which they will work.
- *
- * @param document the document on which to work
- */
- private void setDocumentToDamagers(IDocument document) {
- if (fDamagers != null) {
- Iterator e= fDamagers.values().iterator();
- while (e.hasNext()) {
- IPresentationDamager damager= (IPresentationDamager) e.next();
- damager.setDocument(document);
- }
- }
- }
-
- /**
- * Informs all registed repairers about the document on which they will work.
- *
- * @param document the document on which to work
- */
- private void setDocumentToRepairers(IDocument document) {
- if (fRepairers != null) {
- Iterator e= fRepairers.values().iterator();
- while (e.hasNext()) {
- IPresentationRepairer repairer= (IPresentationRepairer) e.next();
- repairer.setDocument(document);
- }
- }
- }
-
- /**
- * Constructs a "repair description" for the given damage and returns
- * this description as a text presentation. For this, it queries the
- * partitioning of the damage region and asks for each partition an
- * appropriate presentation repairer to construct the "repair description"
- * for this partition.
- *
- * @param damage the damage to be repaired
- * @param document the document whose presentation must be repaired
- * @return the presentation repair descritption as text presentation
- */
- private TextPresentation createPresentation(IRegion damage, IDocument document) {
- try {
- if (fRepairers == null || fRepairers.isEmpty()) {
- TextPresentation presentation= new TextPresentation(damage, 1);
- presentation.setDefaultStyleRange(new StyleRange(damage.getOffset(), damage.getLength(), null, null));
- return presentation;
- }
-
- TextPresentation presentation= new TextPresentation(damage, 1000);
-
- ITypedRegion[] partitioning= TextUtilities.computePartitioning(document, getDocumentPartitioning(), damage.getOffset(), damage.getLength());
- for (int i= 0; i < partitioning.length; i++) {
- ITypedRegion r= partitioning[i];
- IPresentationRepairer repairer= getRepairer(r.getType());
- if (repairer != null)
- repairer.createPresentation(presentation, r);
- }
-
- return presentation;
-
- } catch (BadLocationException x) {
- }
-
- return null;
- }
-
-
- /**
- * Checks for the first and the last affected partition and calls their damagers.
- * Invalidates everything from the start of the damage for the first partition
- * until the end of the damage for the last partition.
- *
- * @param e the event describing the document change
- * @param optimize <code>true</code> if partition changes should be considered for optimization
- * @return the damaged caused by the change
- */
- private IRegion getDamage(DocumentEvent e, boolean optimize) {
-
- if (fDamagers == null || fDamagers.isEmpty()) {
- int length= e.getText() == null ? 0 : e.getText().length();
- length= Math.max(e.getLength(), length);
- length= Math.min(e.getDocument().getLength() - e.getOffset(), length);
- return new Region(e.getOffset(), length);
- }
-
- IRegion damage= null;
-
- try {
-
- ITypedRegion partition= getPartition(e.getDocument(), e.getOffset());
- IPresentationDamager damager= getDamager(partition.getType());
- if (damager == null)
- return null;
-
- IRegion r= damager.getDamageRegion(partition, e, fDocumentPartitioningChanged);
-
- if (!fDocumentPartitioningChanged && optimize) {
- damage= r;
- } else {
-
- int damageEnd= getDamageEndOffset(e);
-
- int parititionDamageEnd= -1;
- if (fChangedDocumentPartitions != null)
- parititionDamageEnd= fChangedDocumentPartitions.getOffset() + fChangedDocumentPartitions.getLength();
-
- int end= Math.max(damageEnd, parititionDamageEnd);
-
- damage= end == -1 ? r : new Region(r.getOffset(), end - r.getOffset());
- }
-
- } catch (BadLocationException x) {
- }
-
- return damage;
- }
-
- /**
- * Returns the end offset of the damage. If a partition has been splitted by
- * the given document event also the second half of the original
- * partition must be considered. This is achieved by using the remembered
- * partition range.
- *
- * @param e the event describing the change
- * @return the damage end offset (excluding)
- * @exception BadLocationException if method accesses invalid offset
- */
- private int getDamageEndOffset(DocumentEvent e) throws BadLocationException {
-
- IDocument d= e.getDocument();
-
- int length= 0;
- if (e.getText() != null) {
- length= e.getText().length();
- if (length > 0)
- -- length;
- }
-
- ITypedRegion partition= getPartition(d, e.getOffset() + length);
- int endOffset= partition.getOffset() + partition.getLength();
- if (endOffset == e.getOffset())
- return -1;
-
- int end= fRememberedPosition == null ? -1 : fRememberedPosition.getOffset() + fRememberedPosition.getLength();
- if (endOffset < end)
- partition= getPartition(d, end);
-
- IPresentationDamager damager= getDamager(partition.getType());
- if (damager == null)
- return -1;
-
- IRegion r= damager.getDamageRegion(partition, e, fDocumentPartitioningChanged);
-
- return r.getOffset() + r.getLength();
- }
-
- /**
- * Processes the given damage.
- * @param damage the damage to be repaired
- * @param document the document whose presentation must be repaired
- */
- private void processDamage(IRegion damage, IDocument document) {
- if (damage != null && damage.getLength() > 0) {
- TextPresentation p= createPresentation(damage, document);
- if (p != null)
- applyTextRegionCollection(p);
- }
- }
-
- /**
- * Applies the given text presentation to the text viewer the presentation
- * reconciler is installed on.
- *
- * @param presentation the text presentation to be applied to the text viewer
- */
- private void applyTextRegionCollection(TextPresentation presentation) {
- fViewer.changeTextPresentation(presentation, false);
- }
-
- /**
- * Returns the partition for the given offset in the given document.
- *
- * @param document the document
- * @param offset the offset
- * @return the partition
- * @throws BadLocationException if offset is invalid in the given document
- * @since 3.0
- */
- private ITypedRegion getPartition(IDocument document, int offset) throws BadLocationException {
- return TextUtilities.getPartition(document, getDocumentPartitioning(), offset);
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/package.html b/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/package.html
deleted file mode 100644
index 9574694..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/package.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="Author" content="IBM">
- <meta name="GENERATOR" content="Mozilla/4.51 [en] (WinNT; I) [Netscape]">
- <title>Package-level Javadoc</title>
-</head>
-<body>
-Provides a presentation reconciler add-on for an <tt>ITextViewer</tt>.
-A presentation reconciler keep the presentation (styles and colors) in
-sync with the content of the document serving as the <tt>ITextViewer</tt>'s
-input.
-<h2>
-Package Specification</h2>
-<tt>IPresentationReconciler</tt> defines the concept of a presentation
-reconciler. It collaborates with content type specific presentation damagers
-(<tt>IPresentationDamager</tt>) which for a given document change determine
-the region of the presentation which must be rebuild, and content type
-specific presentation repairers (<tt>IPresentationRepairer</tt>) which
-construct for a given damage region the document presentation. The package
-contains a default implementation of <tt>IPresentationReconciler </tt>(<tt>PresentationReconciler</tt>).
-</body>
-</html>
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/AbstractReconcileStep.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/AbstractReconcileStep.java
deleted file mode 100644
index de3367d..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/AbstractReconcileStep.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.reconciler;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.reconciler.DirtyRegion;
-
-/**
- * Abstract implementation of a reconcile step.
- *
- * @see org.eclipse.jface.text.reconciler.IReconcileStep
- * @since 3.0
- */
-public abstract class AbstractReconcileStep implements IReconcileStep {
-
- private IReconcileStep fNextStep;
- private IReconcileStep fPreviousStep;
- private IProgressMonitor fProgressMonitor;
- protected IReconcilableModel fInputModel;
-
- /**
- * Creates an intermediate reconcile step which adds
- * the given step to the pipe.
- */
- public AbstractReconcileStep(IReconcileStep step) {
- Assert.isNotNull(step);
- fNextStep= step;
- fNextStep.setPreviousStep(this);
- }
-
- /**
- * Creates the last reconcile step of the pipe.
- */
- public AbstractReconcileStep() {
- }
-
- public boolean isLastStep() {
- return fNextStep == null;
- }
-
- public boolean isFirstStep() {
- return fPreviousStep == null;
- }
-
- /*
- * @see org.eclipse.text.reconcilerpipe.IReconcilerResultCollector#setProgressMonitor(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void setProgressMonitor(IProgressMonitor monitor) {
- fProgressMonitor= monitor;
-
- if (!isLastStep())
- fNextStep.setProgressMonitor(monitor);
- }
-
- /*
- * @see org.eclipse.jface.text.reconciler.IReconcileStep#getProgressMonitor()
- */
- public IProgressMonitor getProgressMonitor() {
- return fProgressMonitor;
- }
-
- /*
- * @see IReconcileStep#reconcile(IRegion)
- */
- public final IReconcileResult[] reconcile(IRegion partition) {
- IReconcileResult[] result= reconcileModel(null, partition);
- if (!isLastStep()) {
- fNextStep.setInputModel(getModel());
- IReconcileResult[] nextResult= fNextStep.reconcile(partition);
- return merge(result, convertToInputModel(nextResult));
- } else
- return result;
- }
-
- /*
- * @see IReconcileStep#reconcile(org.eclipse.jface.text.reconciler.DirtyRegion, org.eclipse.jface.text.IRegion)
- */
- public final IReconcileResult[] reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
- IReconcileResult[] result= reconcileModel(dirtyRegion, subRegion);
- if (!isLastStep()) {
- fNextStep.setInputModel(getModel());
- IReconcileResult[] nextResult= fNextStep.reconcile(dirtyRegion, subRegion);
- return merge(result, convertToInputModel(nextResult));
- } else
- return result;
- }
-
-
- /**
- * Reconciles the model of this reconcile step. The
- * result is based on the input model.
- *
- * @param dirtyRegion the document region which has been changed
- * @param subRegion the sub region in the dirty region which should be reconciled
- * @return an array with reconcile results
- */
- abstract protected IReconcileResult[] reconcileModel(DirtyRegion dirtyRegion, IRegion subRegion);
-
- protected IReconcileResult[] convertToInputModel(IReconcileResult[] inputResults) {
- return inputResults;
- }
-
- private IReconcileResult[] merge(IReconcileResult[] results1, IReconcileResult[] results2) {
- if (results1 == null)
- return results2;
-
- if (results2 == null)
- return results1;
-
- // XXX: not yet performance optimized
- Collection collection= new ArrayList(Arrays.asList(results1));
- collection.addAll(Arrays.asList(results2));
- return (IReconcileResult[])collection.toArray(new IReconcileResult[collection.size()]);
- }
-
- /*
- * @see IProgressMonitor#isCanceled()
- */
- protected final boolean isCanceled() {
- return fProgressMonitor != null && fProgressMonitor.isCanceled();
- }
-
- /*
- * @see IReconcileStep#setPreviousStep(IReconcileStep)
- */
- public void setPreviousStep(IReconcileStep step) {
- Assert.isNotNull(step);
- Assert.isTrue(fPreviousStep == null);
- fPreviousStep= step;
- }
-
- /*
- * @see IReconcileStep#setInputModel(Object)
- */
- public void setInputModel(IReconcilableModel inputModel) {
- fInputModel= inputModel;
-
- if (!isLastStep())
- fNextStep.setInputModel(getModel());
- }
-
- public IReconcilableModel getInputModel() {
- return fInputModel;
- }
-
- abstract public IReconcilableModel getModel();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/AbstractReconciler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/AbstractReconciler.java
deleted file mode 100644
index f79b6cf..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/AbstractReconciler.java
+++ /dev/null
@@ -1,517 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.reconciler;
-
-
-import org.eclipse.core.runtime.IProgressMonitor;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentListener;
-import org.eclipse.jface.text.ITextInputListener;
-import org.eclipse.jface.text.ITextViewer;
-
-
-
-
-/**
- * Abstract implementation of <code>IReconciler</code>. The reconciler
- * listens to input document changes as well as changes of
- * the input document of the text viewer it is installed on. Depending on
- * its configuration it manages the received change notifications in a
- * queue folding neighboring or overlapping changes together. The reconciler
- * processes the dirty regions as a background activity after having waited for further
- * changes for the configured duration of time. A reconciler is started using its
- * <code>install</code> method. As a first step <code>initialProcess</code> is
- * executed in the background. Then, the reconciling thread waits for changes that
- * need to be reconciled. A reconciler can be resumed by calling <code>forceReconciling</code>
- * independent from the existence of actual changes. This mechanism is for subclasses only.
- * It is the clients responsibility to stop a reconciler using its <code>uninstall</code>
- * method. Unstopped reconcilers do not free their resources.<p>
- * It is subclass responsibility to specify how dirty regions are processed.
- *
- * @see IReconciler
- * @see IDocumentListener
- * @see ITextInputListener
- * @see DirtyRegion
- * @since 2.0
- */
-abstract public class AbstractReconciler implements IReconciler {
-
-
- /**
- * Background thread for the reconciling activity.
- */
- class BackgroundThread extends Thread {
-
- /** Has the reconciler been canceled */
- private boolean fCanceled= false;
- /** Has the reconciler been reset */
- private boolean fReset= false;
- /** Has a change been applied */
- private boolean fIsDirty= false;
- /** Is a reconciling strategy active */
- private boolean fIsActive= false;
-
- /**
- * Creates a new background thread. The thread
- * runs with minimal priority.
- *
- * @param name the thread's name
- */
- public BackgroundThread(String name) {
- super(name);
- setPriority(Thread.MIN_PRIORITY);
- setDaemon(true);
- }
-
- /**
- * Returns whether a reconciling strategy is active right now.
- *
- * @return <code>true</code> if a activity is active
- */
- public boolean isActive() {
- return fIsActive;
- }
-
- /**
- * Cancels the background thread.
- */
- public void cancel() {
- fCanceled= true;
- synchronized (fDirtyRegionQueue) {
- fDirtyRegionQueue.notifyAll();
- }
- }
-
- /**
- * Suspends the caller of this method until this background thread has
- * emptied the dirty region queue.
- */
- public void suspendCallerWhileDirty() {
- while (fIsDirty) {
- synchronized (fDirtyRegionQueue) {
- if (fIsDirty) {
- try {
- fDirtyRegionQueue.wait();
- } catch (InterruptedException x) {
- }
- }
- }
- }
- }
-
- /**
- * Reset the background thread as the text viewer has been changed,
- */
- public void reset() {
-
- if (fDelay > 0) {
-
- synchronized (this) {
- fIsDirty= true;
- fReset= true;
- }
-
- } else {
-
- synchronized (this) {
- fIsDirty= true;
- }
-
- synchronized (fDirtyRegionQueue) {
- fDirtyRegionQueue.notifyAll();
- }
- }
-
- reconcilerReset();
- }
-
- /**
- * The background activity. Waits until there is something in the
- * queue managing the changes that have been applied to the text viewer.
- * Removes the first change from the queue and process it.<p>
- * Calls <code>initialProcess</code> on entrance.
- */
- public void run() {
-
- synchronized (fDirtyRegionQueue) {
- try {
- fDirtyRegionQueue.wait(fDelay);
- } catch (InterruptedException x) {
- }
- }
-
- initialProcess();
-
- while (!fCanceled) {
-
- synchronized (fDirtyRegionQueue) {
- try {
- fDirtyRegionQueue.wait(fDelay);
- } catch (InterruptedException x) {
- }
- }
-
- if (fCanceled)
- break;
-
- if (!fIsDirty)
- continue;
-
- if (fReset) {
- synchronized (this) {
- fReset= false;
- }
- continue;
- }
-
- DirtyRegion r= null;
- synchronized (fDirtyRegionQueue) {
- r= fDirtyRegionQueue.removeNextDirtyRegion();
- }
-
- fIsActive= true;
-
- if (fProgressMonitor != null)
- fProgressMonitor.setCanceled(false);
-
- process(r);
-
- synchronized (fDirtyRegionQueue) {
- if (0 == fDirtyRegionQueue.getSize()) {
- synchronized (this) {
- fIsDirty= fProgressMonitor != null ? fProgressMonitor.isCanceled() : false;
- }
- fDirtyRegionQueue.notifyAll();
- }
- }
-
- fIsActive= false;
- }
- }
- }
-
- /**
- * Internal document listener and text input listener.
- */
- class Listener implements IDocumentListener, ITextInputListener {
-
- /*
- * @see IDocumentListener#documentAboutToBeChanged(DocumentEvent)
- */
- public void documentAboutToBeChanged(DocumentEvent e) {
- }
-
- /*
- * @see IDocumentListener#documentChanged(DocumentEvent)
- */
- public void documentChanged(DocumentEvent e) {
-
- if (!fThread.fIsDirty)
- aboutToBeReconciled();
-
- if (fProgressMonitor != null && fThread.isActive())
- fProgressMonitor.setCanceled(true);
-
- if (fIsIncrementalReconciler)
- createDirtyRegion(e);
-
-
- fThread.reset();
-
- }
-
- /*
- * @see ITextInputListener#inputDocumentAboutToBeChanged(IDocument, IDocument)
- */
- public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {
-
- if (oldInput == fDocument) {
-
- if (fDocument != null)
- fDocument.removeDocumentListener(this);
-
- if (fIsIncrementalReconciler) {
- fDirtyRegionQueue.purgeQueue();
- if (fDocument != null && fDocument.getLength() > 0) {
- DocumentEvent e= new DocumentEvent(fDocument, 0, fDocument.getLength(), null);
- createDirtyRegion(e);
- fThread.suspendCallerWhileDirty();
- }
- }
-
- fDocument= null;
- }
- }
-
- /*
- * @see ITextInputListener#inputDocumentChanged(IDocument, IDocument)
- */
- public void inputDocumentChanged(IDocument oldInput, IDocument newInput) {
-
- fDocument= newInput;
- if (fDocument == null)
- return;
-
-
- reconcilerDocumentChanged(fDocument);
-
- fDocument.addDocumentListener(this);
-
- if (!fThread.fIsDirty)
- aboutToBeReconciled();
-
- if (fIsIncrementalReconciler) {
- DocumentEvent e= new DocumentEvent(fDocument, 0, 0, fDocument.get());
- createDirtyRegion(e);
- }
-
- startReconciling();
- }
- }
-
- /** Queue to manage the changes applied to the text viewer */
- private DirtyRegionQueue fDirtyRegionQueue;
- /** The background thread */
- private BackgroundThread fThread;
- /** Internal document and text input listener */
- private Listener fListener;
- /** The background thread delay */
- private int fDelay= 500;
- /** Are there incremental reconciling strategies? */
- private boolean fIsIncrementalReconciler= true;
- /** The progress monitor used by this reconciler */
- private IProgressMonitor fProgressMonitor;
-
- /** The text viewer's document */
- private IDocument fDocument;
- /** The text viewer */
- private ITextViewer fViewer;
-
-
- /**
- * Processes a dirty region. If the dirty region is <code>null</code> the whole
- * document is consider being dirty. The dirty region is partitioned by the
- * document and each partition is handed over to a reconciling strategy registered
- * for the partition's content type.
- *
- * @param dirtyRegion the dirty region to be processed
- */
- abstract protected void process(DirtyRegion dirtyRegion);
-
- /**
- * Hook called when the document whose contents should be reconciled
- * has been changed, i.e., the input document of the text viewer this
- * reconciler is installed on. Usually, subclasses use this hook to
- * inform all their reconciling strategies about the change.
- *
- * @param newDocument the new reconciler document
- */
- abstract protected void reconcilerDocumentChanged(IDocument newDocument);
-
-
- /**
- * Creates a new reconciler without configuring it.
- */
- protected AbstractReconciler() {
- super();
- }
-
- /**
- * Tells the reconciler how long it should wait for further text changes before
- * activating the appropriate reconciling strategies.
- *
- * @param delay the duration in milli seconds of a change collection period.
- */
- public void setDelay(int delay) {
- fDelay= delay;
- }
-
- /**
- * Tells the reconciler whether any of the available reconciling strategies
- * is interested in getting detailed dirty region information or just in the
- * fact the the document has been changed. In the second case, the reconciling
- * can not incrementally be pursued.
- *
- * @param isIncremental indicates whether this reconciler will be configured with
- * incremental reconciling strategies
- *
- * @see DirtyRegion
- * @see IReconcilingStrategy
- */
- public void setIsIncrementalReconciler(boolean isIncremental) {
- fIsIncrementalReconciler= isIncremental;
- }
-
- /**
- * Sets the progress monitor of this reconciler.
- *
- * @param monitor the monitor to be used
- */
- public void setProgressMonitor(IProgressMonitor monitor) {
- fProgressMonitor= monitor;
- }
-
- /**
- * Returns whether any of the reconciling strategies is interested in
- * detailed dirty region information.
- *
- * @return whether this reconciler is incremental
- *
- * @see IReconcilingStrategy
- */
- protected boolean isIncrementalReconciler() {
- return fIsIncrementalReconciler;
- }
-
- /**
- * Returns the input document of the text viewer this reconciler is installed on.
- *
- * @return the reconciler document
- */
- protected IDocument getDocument() {
- return fDocument;
- }
-
- /**
- * Returns the text viewer this reconciler is installed on.
- *
- * @return the text viewer this reconciler is installed on
- */
- protected ITextViewer getTextViewer() {
- return fViewer;
- }
-
- /**
- * Returns the progress monitor of this reconciler.
- *
- * @return the progress monitor of this reconciler
- */
- protected IProgressMonitor getProgressMonitor() {
- return fProgressMonitor;
- }
-
- /*
- * @see IReconciler#install(ITextViewer)
- */
- public void install(ITextViewer textViewer) {
-
- Assert.isNotNull(textViewer);
-
- fViewer= textViewer;
-
- fListener= new Listener();
- fViewer.addTextInputListener(fListener);
-
- fDirtyRegionQueue= new DirtyRegionQueue();
- fThread= new BackgroundThread(getClass().getName());
- }
-
- /*
- * @see IReconciler#uninstall()
- */
- public void uninstall() {
- if (fListener != null) {
-
- fViewer.removeTextInputListener(fListener);
- if (fDocument != null) fDocument.removeDocumentListener(fListener);
- fListener= null;
-
- synchronized (this) {
- // http://dev.eclipse.org/bugs/show_bug.cgi?id=19135
- BackgroundThread bt= fThread;
- fThread= null;
- bt.cancel();
- }
- }
- }
-
- /**
- * Creates a dirty region for a document event and adds it to the queue.
- *
- * @param e the document event for which to create a dirty region
- */
- private void createDirtyRegion(DocumentEvent e) {
-
- if (e.getLength() == 0 && e.getText() != null) {
- // Insert
- fDirtyRegionQueue.addDirtyRegion(new DirtyRegion(e.getOffset(), e.getText().length(), DirtyRegion.INSERT, e.getText()));
-
- } else if (e.getText() == null || e.getText().length() == 0) {
- // Remove
- fDirtyRegionQueue.addDirtyRegion(new DirtyRegion(e.getOffset(), e.getLength(), DirtyRegion.REMOVE, null));
-
- } else {
- // Replace (Remove + Insert)
- fDirtyRegionQueue.addDirtyRegion(new DirtyRegion(e.getOffset(), e.getLength(), DirtyRegion.REMOVE, null));
- fDirtyRegionQueue.addDirtyRegion(new DirtyRegion(e.getOffset(), e.getText().length(), DirtyRegion.INSERT, e.getText()));
- }
- }
-
- /**
- * Hook for subclasses which want to perform some
- * action as soon as reconciliation is needed.
- * <p>
- * Default implementation is to do nothing.
- * </p>
- *
- * @since 3.0
- */
- protected void aboutToBeReconciled() {
- }
-
- /**
- * This method is called on startup of the background activity. It is called only
- * once during the life time of the reconciler. Clients may reimplement this method.
- */
- protected void initialProcess() {
- }
-
- /**
- * Forces the reconciler to reconcile the structure of the whole document.
- * Clients may extend this method.
- */
- protected void forceReconciling() {
-
- if (fDocument != null) {
-
- if (fIsIncrementalReconciler) {
- DocumentEvent e= new DocumentEvent(fDocument, 0, fDocument.getLength(), fDocument.get());
- createDirtyRegion(e);
- }
-
- startReconciling();
- }
- }
-
- /**
- * Starts the reconciler to reconcile the queued dirty-regions.
- * Clients may extend this method.
- */
- protected synchronized void startReconciling() {
- if (fThread == null)
- return;
-
- if (!fThread.isAlive())
- fThread.start();
- else
- fThread.reset();
- }
-
- /**
- * Hook that is called after the reconciler thread has been reset.
- */
- protected void reconcilerReset() {
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/CompositeReconcilingStrategy.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/CompositeReconcilingStrategy.java
deleted file mode 100644
index c7fdbfc..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/CompositeReconcilingStrategy.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.reconciler;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-
-/**
- * A reconciling strategy consisting of a sequence of internal reconciling strategies.
- * By default, all requests are passed on to the contained strategies.
- *
- * @since 3.0
- */
-public class CompositeReconcilingStrategy implements IReconcilingStrategy, IReconcilingStrategyExtension {
-
- /** The list of internal reconciling strategies. */
- private IReconcilingStrategy[] fStrategies;
-
- /**
- * Creates a new, empty composite reconciling strategy.
- */
- public CompositeReconcilingStrategy() {
- }
-
- /**
- * Sets the reconciling strategies for this composite strategy.
- *
- * @param strategies the strategies to be set or <code>null</code>
- */
- public void setReconcilingStrategies(IReconcilingStrategy[] strategies) {
- fStrategies= strategies;
- }
-
- /**
- * Returns the previously set stratgies or <code>null</code>.
- *
- * @return the contained strategies or <code>null</code>
- */
- public IReconcilingStrategy[] getReconcilingStrategies() {
- return fStrategies;
- }
-
- /*
- * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#setDocument(org.eclipse.jface.text.IDocument)
- */
- public void setDocument(IDocument document) {
- if (fStrategies == null)
- return;
-
- for (int i= 0; i < fStrategies.length; i++)
- fStrategies[i].setDocument(document);
- }
-
- /*
- * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.reconciler.DirtyRegion, org.eclipse.jface.text.IRegion)
- */
- public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
- if (fStrategies == null)
- return;
-
- for (int i= 0; i < fStrategies.length; i++)
- fStrategies[i].reconcile(dirtyRegion, subRegion);
- }
-
- /*
- * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.IRegion)
- */
- public void reconcile(IRegion partition) {
- if (fStrategies == null)
- return;
-
- for (int i= 0; i < fStrategies.length; i++)
- fStrategies[i].reconcile(partition);
- }
-
- /*
- * @see org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension#setProgressMonitor(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void setProgressMonitor(IProgressMonitor monitor) {
- if (fStrategies == null)
- return;
-
- for (int i=0; i < fStrategies.length; i++) {
- if (fStrategies[i] instanceof IReconcilingStrategyExtension) {
- IReconcilingStrategyExtension extension= (IReconcilingStrategyExtension) fStrategies[i];
- extension.setProgressMonitor(monitor);
- }
- }
- }
-
- /*
- * @see org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension#initialReconcile()
- */
- public void initialReconcile() {
- if (fStrategies == null)
- return;
-
- for (int i=0; i < fStrategies.length; i++) {
- if (fStrategies[i] instanceof IReconcilingStrategyExtension) {
- IReconcilingStrategyExtension extension= (IReconcilingStrategyExtension) fStrategies[i];
- extension.initialReconcile();
- }
- }
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/DirtyRegion.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/DirtyRegion.java
deleted file mode 100644
index a35e072..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/DirtyRegion.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.reconciler;
-
-
-import org.eclipse.jface.text.ITypedRegion;
-
-/**
- * A dirty region describes a document range which has been changed.
- */
-public class DirtyRegion implements ITypedRegion {
-
- /**
- * Identifies an insert operation.
- */
- final static public String INSERT= "__insert"; //$NON-NLS-1$
- /**
- * Identifies a remove operation.
- */
- final static public String REMOVE= "__remove"; //$NON-NLS-1$
-
- /** The region's offset */
- private int fOffset;
- /** The region's length */
- private int fLength;
- /** Indicates the type of the applied change */
- private String fType;
- /** The text which has been inserted */
- private String fText;
-
- /**
- * Creates a new dirty region.
- *
- *
- * @param offset the offset within the document where the change occurred
- * @param length the length of the text within the document that changed
- * @param type the type of change that this region represents: <code>INSERT</code> or <code>REMOVE</code>
- * @param text the substitution text
- */
- public DirtyRegion(int offset, int length, String type, String text) {
- fOffset= offset;
- fLength= length;
- fType= type;
- fText= text;
- }
-
- /*
- * @see ITypedRegion#getOffset()
- */
- public int getOffset() {
- return fOffset;
- }
-
- /*
- * @see ITypedRegion#getLength()
- */
- public int getLength() {
- return fLength;
- }
-
- /*
- * @see ITypedRegion#getType
- */
- public String getType() {
- return fType;
- }
-
- /**
- * Returns the text that changed as part of the region change.
- *
- * @return the changed text
- */
- public String getText() {
- return fText;
- }
-
- /**
- * Modify the receiver so that it encompasses the region specified by the dirty region.
- *
- * @param dr the dirty region with which to merge
- */
- void mergeWith(DirtyRegion dr) {
- int start= Math.min(fOffset, dr.fOffset);
- int end= Math.max(fOffset + fLength, dr.fOffset + dr.fLength);
- fOffset= start;
- fLength= end - start;
- fText= (dr.fText == null ? fText : (fText == null) ? dr.fText : fText + dr.fText);
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/DirtyRegionQueue.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/DirtyRegionQueue.java
deleted file mode 100644
index c076bbf..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/DirtyRegionQueue.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.reconciler;
-
-
-import java.util.List;
-import java.util.ArrayList;
-
-
-/**
- * Queue used by <code>Reconciler</code> to manage dirty regions. When a dirty region
- * is inserted into the queue, the queue tries to fold it into the neighboring dirty region.
- *
- * @see Reconciler
- * @see DirtyRegion
- */
-class DirtyRegionQueue {
-
- /** The list of dirty regions */
- private List fDirtyRegions= new ArrayList();
-
- /**
- * Creates a new empty dirty region.
- */
- public DirtyRegionQueue() {
- super();
- }
-
- /**
- * Adds a dirty region to the end of the dirty-region queue.
- *
- * @param dr the dirty region to add
- */
- public void addDirtyRegion(DirtyRegion dr) {
- // If the dirty region being added is directly after the last dirty
- // region on the queue then merge the two dirty regions together.
- DirtyRegion lastDR= getLastDirtyRegion();
- boolean wasMerged= false;
- if (lastDR != null)
- if (lastDR.getType() == dr.getType())
- if (lastDR.getType() == DirtyRegion.INSERT) {
- if (lastDR.getOffset() + lastDR.getLength() == dr.getOffset()) {
- lastDR.mergeWith(dr);
- wasMerged= true;
- }
- } else if (lastDR.getType() == DirtyRegion.REMOVE) {
- if (dr.getOffset() + dr.getLength() == lastDR.getOffset()) {
- lastDR.mergeWith(dr);
- wasMerged= true;
- }
- }
-
- if (!wasMerged)
- // Don't merge- just add the new one onto the queue.
- fDirtyRegions.add(dr);
- }
-
- /**
- * Returns the last dirty region that was added to the queue.
- *
- * @return the last DirtyRegion on the queue
- */
- private DirtyRegion getLastDirtyRegion() {
- int size= fDirtyRegions.size();
- return (size == 0 ? null : (DirtyRegion) fDirtyRegions.get(size - 1));
- }
-
- /**
- * Returns the number of regions in the queue.
- *
- * @return the dirty-region queue-size
- */
- public int getSize() {
- return fDirtyRegions.size();
- }
-
- /**
- * Throws away all entries in the queue.
- */
- public void purgeQueue() {
- fDirtyRegions.clear();
- }
-
- /**
- * Removes and returns the first dirty region in the queue
- *
- * @return the next dirty region on the queue
- */
- public DirtyRegion removeNextDirtyRegion() {
- if (fDirtyRegions.size() == 0)
- return null;
- DirtyRegion dr= (DirtyRegion) fDirtyRegions.get(0);
- fDirtyRegions.remove(0);
- return dr;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/DocumentAdapter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/DocumentAdapter.java
deleted file mode 100644
index dbbd70f..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/DocumentAdapter.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.reconciler;
-
-import org.eclipse.jface.text.IDocument;
-
-/**
- * Adapts an <code>IDocument</code> to a <code>IReconcilableModel</code>.
- *
- * @since 3.0
- */
-public class DocumentAdapter implements IReconcilableModel {
-
- private IDocument fDocument;
-
- /**
- * Creates a text model adapter for the given document.
- *
- * @param document
- */
- public DocumentAdapter(IDocument document) {
- fDocument= document;
- }
-
- /**
- * Returns this model's document.
- *
- * @return the model's input document
- */
- public IDocument getDocument() {
- return fDocument;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcilableModel.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcilableModel.java
deleted file mode 100644
index 73e8b52..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcilableModel.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.reconciler;
-
-/**
- * Tagging interface for a reconcilable model.
- *
- * @since 3.0
- */
-public interface IReconcilableModel {
-
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcileResult.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcileResult.java
deleted file mode 100644
index 2abecd9..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcileResult.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.reconciler;
-
-/**
- * Tagging interface for the result reported by a reconcile step
- *
- * @see org.eclipse.jface.text.reconciler.IReconcileStep
- * @since 3.0
- */
-public interface IReconcileResult {
-
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcileStep.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcileStep.java
deleted file mode 100644
index 5aadcc5..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcileStep.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.reconciler;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.reconciler.DirtyRegion;
-
-/**
- * A reconcile step is one of n steps of a reconcile
- * strategy that consists of several steps.
- *
- * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy
- * @since 3.0
- */
-public interface IReconcileStep {
-
- /**
- * Returns whether this is the last reconcile step or not.
- *
- * @return <code>true</code> if this is the last reconcile step
- */
- boolean isLastStep();
-
- /**
- * Returns whether this is the first reconcile step or not.
- *
- * @return <code>true</code> if this is the last reconcile step
- */
- boolean isFirstStep();
-
- /**
- * Sets the step which is in front of this step in the pipe.
- * <p>
- * Note: This method must be called at most once per reconcile step.
- * </p>
- *
- * @param step the previous step
- * @exception org.eclipse.jface.text.Assert#AssertionFailedException if called more than once
- */
- void setPreviousStep(IReconcileStep step);
-
- /**
- * Activates incremental reconciling of the specified dirty region.
- * As a dirty region might span multiple content types, the segment of the
- * dirty region which should be investigated is also provided to this
- * reconciling strategy. The given regions refer to the document passed into
- * the most recent call of <code>setDocument</code>.
- *
- * @param dirtyRegion the document region which has been changed
- * @param subRegion the sub region in the dirty region which should be reconciled
- * @return an array with reconcile results
- */
- IReconcileResult[] reconcile(DirtyRegion dirtyRegion, IRegion subRegion);
-
- /**
- * Activates non-incremental reconciling. The reconciling strategy is just told
- * that there are changes and that it should reconcile the given partition of the
- * document most recently passed into <code>setDocument</code>.
- *
- * @param partition the document partition to be reconciled
- * @return an array with reconcile results
- */
- IReconcileResult[] reconcile(IRegion partition);
-
- /**
- * Sets the progress monitor to this reconcile step.
- *
- * @param monitor the progress monitor to be used
- */
- void setProgressMonitor(IProgressMonitor monitor);
-
- /**
- * Returns the progress monitor used to report progress.
- *
- * @return a progress monitor or null if no progress monitor is provided
- */
- public IProgressMonitor getProgressMonitor();
-
- /**
- * Tells this reconcile step on which model it will
- * work. This method will be called before any other method
- * and can be called multiple times. The regions passed to the
- * other methods always refer to the most recent document
- * passed into this method.
- *
- * @param inputModel the model on which this strategy will work
- */
- void setInputModel(IReconcilableModel inputModel);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconciler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconciler.java
deleted file mode 100644
index 36778f1..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconciler.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.reconciler;
-
-
-
-import org.eclipse.jface.text.ITextViewer;
-
-
-
-/**
- * An <code>IReconciler</code> defines and maintains a model of the content
- * of the text viewer's document in the presence of changes applied to this
- * document. An <code>IReconciler</code> is a <code>ITextViewer</code> add-on.<p>
- * Reconcilers are assumed to be asynchronous, i.e. they allow a certain
- * temporal window of inconsistency between the document and the model of
- * the content of this document. <p>
- * Reconcilers have a list of <code>IReconcilingStrategy</code> objects
- * each of which is registered for a particular document content type.
- * The reconciler uses the strategy objects to react on the changes applied
- * to the text viewer's document.<p>
- * The interface can be implemented by clients. By default, clients use
- * <code>Reconciler</code> as the standard implementer of this interface.
- *
- * @see ITextViewer
- * @see IReconcilingStrategy
- */
-public interface IReconciler {
-
- /**
- * Installs the reconciler on the given text viewer. After this method has been
- * finished, the reconciler is operational. I.e., it works without requesting
- * further client actions until <code>uninstall</code> is called.
- *
- * @param textViewer the viewer on which the reconciler is installed
- */
- void install(ITextViewer textViewer);
-
- /**
- * Removes the reconciler from the text viewer it has previously been
- * installed on.
- */
- void uninstall();
-
- /**
- * Returns the reconciling strategy registered with the reconciler
- * for the specified content type.
- *
- * @param contentType the content type for which to determine the reconciling strategy
- * @return the reconciling strategy registered for the given content type, or
- * <code>null</code> if there is no such strategy
- */
- IReconcilingStrategy getReconcilingStrategy(String contentType);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcilerExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcilerExtension.java
deleted file mode 100644
index 53450ce..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcilerExtension.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**********************************************************************
-Copyright (c) 2000, 2003 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-
-Contributors:
- IBM Corporation - Initial implementation
-**********************************************************************/
-package org.eclipse.jface.text.reconciler;
-
-/**
- * Extension interface for <code>IReconciler</code>.
- * Updates the reconciler to be aware of documents with multiple partitions.
- *
- * @since 3.0
- */
-public interface IReconcilerExtension {
-
- /**
- * Returns the partitioning this reconciler is using.
- *
- * @return the partitioning this reconciler is using
- */
- String getDocumentPartitioning();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcilingStrategy.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcilingStrategy.java
deleted file mode 100644
index 55be9a3..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcilingStrategy.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.reconciler;
-
-
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-
-
-/**
- * A reconciling strategy is used by an reconciler to reconcile a model
- * based on text of a particular content type. It provides methods for
- * incremental as well as non-incremental reconciling.<p>
- * This interface must be implemented by clients. Implementers should be
- * registered with a reconciler in order get involved in the reconciling
- * process.
- */
-public interface IReconcilingStrategy {
-
- /**
- * Tells this reconciling strategy on which document it will
- * work. This method will be called before any other method
- * and can be called multiple times. The regions passed to the
- * other methods always refer to the most recent document
- * passed into this method.
- *
- * @param document the document on which this strategy will work
- */
- void setDocument(IDocument document);
-
- /**
- * Activates incremental reconciling of the specified dirty region.
- * As a dirty region might span multiple content types, the segment of the
- * dirty region which should be investigated is also provided to this
- * reconciling strategy. The given regions refer to the document passed into
- * the most recent call of <code>setDocument</code>.
- *
- * @param dirtyRegion the document region which has been changed
- * @param subRegion the sub region in the dirty region which should be reconciled
- */
- void reconcile(DirtyRegion dirtyRegion, IRegion subRegion);
-
- /**
- * Activates non-incremental reconciling. The reconciling strategy is just told
- * that there are changes and that it should reconcile the given partition of the
- * document most recently passed into <code>setDocument</code>.
- *
- * @param partition the document partition to be reconciled
- */
- void reconcile(IRegion partition);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcilingStrategyExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcilingStrategyExtension.java
deleted file mode 100644
index 5dc7a3c..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/IReconcilingStrategyExtension.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.reconciler;
-
-
-import org.eclipse.core.runtime.IProgressMonitor;
-
-
-/**
- * Extension interface for <code>IReconcilingStrategy</code>.
- * The new functions are:
- * <ul>
- * <li> usage of a progress monitor
- * <li> initial reconciling step: If a reconciler runs as periodic activity in the background, this
- * methods offers the reconciler a chance for initializing its startegies and achieving a
- * reconciled state before the periodic activity starts.
- * </ul>
- *
- * @since 2.0
- */
-public interface IReconcilingStrategyExtension {
-
- /**
- * Tells this reconciling strategy with which progress monitor
- * it will work. This method will be called before any other
- * method and can be called multiple times.
- *
- * @param monitor the progress monitor with which this strategy will work
- */
- void setProgressMonitor(IProgressMonitor monitor);
-
- /**
- * Called only once in the life time of this reconciling strategy.
- */
- void initialReconcile();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/MonoReconciler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/MonoReconciler.java
deleted file mode 100644
index aafcead..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/MonoReconciler.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.reconciler;
-
-
-import org.eclipse.core.runtime.IProgressMonitor;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.Region;
-
-
-/**
- * Standard implementation of <code>IReconciler</code>. The reconciler
- * is configured with a single <code>IReconcilingStrategy</code> that is
- * used independly from where a dirty region is located in the reconciler's
- * document. <p>
- * Usually, clients instantiate this class and configure it before using it.
- *
- * @see IReconciler
- * @see org.eclipse.jface.text.IDocumentListener
- * @see org.eclipse.jface.text.ITextInputListener
- * @see DirtyRegion
- * @since 2.0
- */
-public class MonoReconciler extends AbstractReconciler {
-
-
- /** The reconciling strategy */
- private IReconcilingStrategy fStrategy;
-
-
- /**
- * Creates a new reconciler that uses the same reconciling strategy to
- * reconcile its document independent of the type of the document's contents.
- *
- * @param strategy the reconciling strategy to be used
- * @param isIncremental the indication whether strategy is incremental or not
- */
- public MonoReconciler(IReconcilingStrategy strategy, boolean isIncremental) {
- super();
-
- Assert.isNotNull(strategy);
-
- fStrategy= strategy;
- setIsIncrementalReconciler(isIncremental);
- }
-
- /*
- * @see IReconciler#getReconcilingStrategy(String)
- */
- public IReconcilingStrategy getReconcilingStrategy(String contentType) {
- Assert.isNotNull(contentType);
- return fStrategy;
- }
-
- /*
- * @see AbstractReconciler#process(DirtyRegion)
- */
- protected void process(DirtyRegion dirtyRegion) {
-
- if(dirtyRegion != null)
- fStrategy.reconcile(dirtyRegion, dirtyRegion);
- else {
- IDocument document= getDocument();
- if (document != null)
- fStrategy.reconcile(new Region(0, document.getLength()));
- }
- }
-
- /*
- * @see AbstractReconciler#reconcilerDocumentChanged(IDocument)
- */
- protected void reconcilerDocumentChanged(IDocument document) {
- fStrategy.setDocument(document);
- }
-
- /*
- * @see AbstractReconciler#setProgressMonitor(IProgressMonitor)
- */
- public void setProgressMonitor(IProgressMonitor monitor) {
- super.setProgressMonitor(monitor);
- if (fStrategy instanceof IReconcilingStrategyExtension) {
- IReconcilingStrategyExtension extension= (IReconcilingStrategyExtension) fStrategy;
- extension.setProgressMonitor(monitor);
- }
- }
-
- /*
- * @see AbstractReconciler#initialProcess()
- */
- protected void initialProcess() {
- if (fStrategy instanceof IReconcilingStrategyExtension) {
- IReconcilingStrategyExtension extension= (IReconcilingStrategyExtension) fStrategy;
- extension.initialReconcile();
- }
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/Reconciler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/Reconciler.java
deleted file mode 100644
index 1693277..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/Reconciler.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.reconciler;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentExtension3;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextUtilities;
-import org.eclipse.jface.text.TypedRegion;
-
-/**
- * Standard implementation of <code>IReconciler</code>. The reconciler
- * is configured with a set of reconciling strategies each of which is
- * responsible for a particular content type. <p>
- * Usually, clients instantiate this class and configure it before using it.
- *
- * @see IReconciler
- * @see org.eclipse.jface.text.IDocumentListener
- * @see org.eclipse.jface.text.ITextInputListener
- * @see DirtyRegion
- */
-public class Reconciler extends AbstractReconciler implements IReconcilerExtension {
-
- /** The map of reconciling strategies */
- private Map fStrategies;
-
- /**
- * The partitioning this reconciler uses.
- *@since 3.0
- */
- private String fPartitioning;
-
- /**
- * Creates a new reconciler with the following configuration: it is
- * an incremental reconciler with a standard delay of 500 ms. There
- * are no predefined reconciling strategies. The partitioning it uses
- * is the default partitioning <code>IDocumentExtension3.DEFAULT_PARTITIONING</code>.
- */
- public Reconciler() {
- super();
- fPartitioning= IDocumentExtension3.DEFAULT_PARTITIONING;
- }
-
- /**
- * Sets the document partitioning for this reconciler.
- *
- * @param partitioning the document partitioning for this reconciler
- * @since 3.0
- */
- public void setDocumentPartitioning(String partitioning) {
- Assert.isNotNull(partitioning);
- fPartitioning= partitioning;
- }
-
- /*
- * @see org.eclipse.jface.text.reconciler.IReconcilerExtension#getDocumentPartitioning()
- * @since 3.0
- */
- public String getDocumentPartitioning() {
- return fPartitioning;
- }
-
- /**
- * Registers a given reconciling strategy for a particular content type.
- * If there is already a strategy registered for this type, the new strategy
- * is registered instead of the old one.
- *
- * @param strategy the reconciling strategy to register, or <code>null</code> to remove an existing one
- * @param contentType the content type under which to register
- */
- public void setReconcilingStrategy(IReconcilingStrategy strategy, String contentType) {
-
- Assert.isNotNull(contentType);
-
- if (fStrategies == null)
- fStrategies= new HashMap();
-
- if (strategy == null)
- fStrategies.remove(contentType);
- else {
- fStrategies.put(contentType, strategy);
- if (strategy instanceof IReconcilingStrategyExtension && getProgressMonitor() == null) {
- IReconcilingStrategyExtension extension= (IReconcilingStrategyExtension) strategy;
- extension.setProgressMonitor(getProgressMonitor());
- }
- }
- }
-
- /*
- * @see IReconciler#getReconcilingStrategy(String)
- */
- public IReconcilingStrategy getReconcilingStrategy(String contentType) {
-
- Assert.isNotNull(contentType);
-
- if (fStrategies == null)
- return null;
-
- return (IReconcilingStrategy) fStrategies.get(contentType);
- }
-
- /**
- * Processes a dirty region. If the dirty region is <code>null</code> the whole
- * document is consider being dirty. The dirty region is partitioned by the
- * document and each partition is handed over to a reconciling strategy registered
- * for the partition's content type.
- *
- * @param dirtyRegion the dirty region to be processed
- * @see AbstractReconciler#process(DirtyRegion)
- */
- protected void process(DirtyRegion dirtyRegion) {
-
- IRegion region= dirtyRegion;
-
- if (region == null)
- region= new Region(0, getDocument().getLength());
-
- ITypedRegion[] regions= computePartitioning(region.getOffset(), region.getLength());
-
- for (int i= 0; i < regions.length; i++) {
- ITypedRegion r= regions[i];
- IReconcilingStrategy s= getReconcilingStrategy(r.getType());
- if (s == null)
- continue;
-
- if(dirtyRegion != null)
- s.reconcile(dirtyRegion, r);
- else
- s.reconcile(r);
- }
- }
-
- /*
- * @see AbstractReconciler#reconcilerDocumentChanged(IDocument)
- * @since 2.0
- */
- protected void reconcilerDocumentChanged(IDocument document) {
- if (fStrategies != null) {
- Iterator e= fStrategies.values().iterator();
- while (e.hasNext()) {
- IReconcilingStrategy strategy= (IReconcilingStrategy) e.next();
- strategy.setDocument(document);
- }
- }
- }
-
- /*
- * @see AbstractReconciler#setProgressMonitor(IProgressMonitor)
- * @since 2.0
- */
- public void setProgressMonitor(IProgressMonitor monitor) {
- super.setProgressMonitor(monitor);
-
- if (fStrategies != null) {
- Iterator e= fStrategies.values().iterator();
- while (e.hasNext()) {
- IReconcilingStrategy strategy= (IReconcilingStrategy) e.next();
- if (strategy instanceof IReconcilingStrategyExtension) {
- IReconcilingStrategyExtension extension= (IReconcilingStrategyExtension) strategy;
- extension.setProgressMonitor(monitor);
- }
- }
- }
- }
-
- /*
- * @see AbstractReconciler#initialProcess()
- * @since 2.0
- */
- protected void initialProcess() {
- ITypedRegion[] regions= computePartitioning(0, getDocument().getLength());
- for (int i= 0; i < regions.length; i++) {
- ITypedRegion r= regions[i];
- IReconcilingStrategy s= getReconcilingStrategy(r.getType());
- if (s instanceof IReconcilingStrategyExtension) {
- IReconcilingStrategyExtension e= (IReconcilingStrategyExtension) s;
- e.initialReconcile();
- }
- }
- }
-
- /**
- * Computes and returns the partitioning for the given region of the input document
- * of the reconciler's connected text viewer.
- *
- * @param offset the region offset
- * @param length the region length
- * @return the computed partitioning
- * @since 3.0
- */
- private ITypedRegion[] computePartitioning(int offset, int length) {
- ITypedRegion[] regions= null;
- try {
- regions= TextUtilities.computePartitioning(getDocument(), getDocumentPartitioning(), offset, length);
- } catch (BadLocationException x) {
- regions= new TypedRegion[0];
- }
- return regions;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/package.html b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/package.html
deleted file mode 100644
index 8f46d6c..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/package.html
+++ /dev/null
@@ -1,25 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="Author" content="IBM">
- <meta name="GENERATOR" content="Mozilla/4.76 [en] (Windows NT 5.0; U) [Netscape]">
- <title>Package-level Javadoc</title>
-</head>
-<body>
-Provides a reconciler add-on for an <tt>ITextViewer</tt>.
-A reconciler provides generic synchronization support with
-the content of the document serving as the <tt>ITextViewer</tt>'s input.
-There is no explicit model of what is synchronized.
-<h2>
-Package Specification</h2>
-<tt>IReconciler</tt> defines the concept of a reconciler. It collaborates
-with content type specific reconciling strategies (<tt>IReconcilingStrategy</tt>)
-which perform the synchronization for a given dirty region. The package
-contains a default implementation of <tt>IReconciler</tt> (<tt>Reconciler</tt>).
-
-<tt>Reconciler</tt> and <tt>MonoReconciler</tt> implements reconciling
-as a periodic background activity and folds co-located changes while being
-inactive.
-</body>
-</html>
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/BufferedRuleBasedScanner.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/BufferedRuleBasedScanner.java
deleted file mode 100644
index 66ba10f..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/BufferedRuleBasedScanner.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.rules;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-
-/**
- * A buffered rule based scanner. The buffer always contains a section
- * of a fixed size of the document to be scanned. Completely adheres to
- * the contract of <code>RuleBasedScanner</code>.
- */
-public class BufferedRuleBasedScanner extends RuleBasedScanner {
-
- /** The default buffer size. Value = 500 */
- private final static int DEFAULT_BUFFER_SIZE= 500;
- /** The actual size of the buffer. Initially set to <code>DEFAULT_BUFFER_SIZE</code> */
- private int fBufferSize= DEFAULT_BUFFER_SIZE;
- /** The buffer */
- private char[] fBuffer= new char[DEFAULT_BUFFER_SIZE];
- /** The offset of the document at which the buffer starts */
- private int fStart;
- /** The offset of the document at which the buffer ends */
- private int fEnd;
- /** The cached length of the document */
- private int fDocumentLength;
-
-
- /**
- * Creates a new buffered rule based scanner which does
- * not have any rule and a default buffer size of 500 characters.
- */
- protected BufferedRuleBasedScanner() {
- super();
- }
-
- /**
- * Creates a new buffered rule based scanner which does
- * not have any rule. The buffer size is set to the given
- * number of characters.
- *
- * @param size the buffer size
- */
- public BufferedRuleBasedScanner(int size) {
- super();
- setBufferSize(size);
- }
-
- /**
- * Sets the buffer to the given number of characters.
- *
- * @param size the buffer size
- */
- protected void setBufferSize(int size) {
- Assert.isTrue(size > 0);
- fBufferSize= size;
- fBuffer= new char[size];
- }
-
- /**
- * Shifts the buffer so that the buffer starts at the
- * given document offset.
- *
- * @param offset the document offset at which the buffer starts
- */
- private void shiftBuffer(int offset) {
-
- fStart= offset;
- fEnd= fStart + fBufferSize;
- if (fEnd > fDocumentLength)
- fEnd= fDocumentLength;
-
- try {
-
- String content= fDocument.get(fStart, fEnd - fStart);
- content.getChars(0, fEnd - fStart, fBuffer, 0);
-
- } catch (BadLocationException x) {
- }
- }
-
- /*
- * @see RuleBasedScanner#setRange(IDocument, int, int)
- */
- public void setRange(IDocument document, int offset, int length) {
-
- super.setRange(document, offset, length);
-
- fDocumentLength= document.getLength();
- shiftBuffer(offset);
- }
-
- /*
- * @see RuleBasedScanner#read()
- */
- public int read() {
-
- if (fOffset >= fRangeEnd) {
- ++ fOffset;
- return EOF;
- }
-
- if (fOffset == fEnd)
- shiftBuffer(fEnd);
- else if (fOffset < fStart || fEnd < fOffset)
- shiftBuffer(fOffset);
-
- return fBuffer[fOffset++ - fStart];
- }
-
- /*
- * @see RuleBasedScanner#unread()
- */
- public void unread() {
-
- if (fOffset == fStart)
- shiftBuffer(Math.max(0, fStart - (fBufferSize / 2)));
-
- -- fOffset;
- }
-}
-
-
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/DefaultDamagerRepairer.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/DefaultDamagerRepairer.java
deleted file mode 100644
index 289e977..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/DefaultDamagerRepairer.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.rules;
-
-
-import org.eclipse.swt.custom.StyleRange;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextAttribute;
-import org.eclipse.jface.text.TextPresentation;
-import org.eclipse.jface.text.presentation.IPresentationDamager;
-import org.eclipse.jface.text.presentation.IPresentationRepairer;
-
-
-/**
- * A standard implementation of a syntax driven presentation damager
- * and presentation repairer. It uses a token scanner to scan
- * the document and to determine its damage and new text presentation.
- * The tokens returned by the scanner are supposed to return text attributes
- * as their data.
- *
- * @see ITokenScanner
- * @since 2.0
- */
-public class DefaultDamagerRepairer implements IPresentationDamager, IPresentationRepairer {
-
- /** The document this object works on */
- protected IDocument fDocument;
- /** The scanner it uses */
- protected ITokenScanner fScanner;
- /** The default text attribute if non is returned as data by the current token */
- protected TextAttribute fDefaultTextAttribute;
-
- /**
- * Creates a damager/repairer that uses the given scanner and returns the given default
- * text attribute if the current token does not carry a text attribute.
- *
- * @param scanner the token scanner to be used
- * @param defaultTextAttribute the text attribute to be returned if non is specified by the current token,
- * may not be <code>null</code>
- *
- * @deprecated use DefaultDamagerRepairer(ITokenScanner) instead
- */
- public DefaultDamagerRepairer(ITokenScanner scanner, TextAttribute defaultTextAttribute) {
-
- Assert.isNotNull(defaultTextAttribute);
-
- fScanner= scanner;
- fDefaultTextAttribute= defaultTextAttribute;
- }
-
- /**
- * Creates a damager/repairer that uses the given scanner. The scanner may not be <code>null</code>
- * and is assumed to return only token that carry text attributes.
- *
- * @param scanner the token scanner to be used, may not be <code>null</code>
- */
- public DefaultDamagerRepairer(ITokenScanner scanner) {
-
- Assert.isNotNull(scanner);
-
- fScanner= scanner;
- fDefaultTextAttribute= new TextAttribute(null);
- }
-
- /*
- * @see IPresentationDamager#setDocument(IDocument)
- * @see IPresentationRepairer#setDocument(IDocument)
- */
- public void setDocument(IDocument document) {
- fDocument= document;
- }
-
-
- //---- IPresentationDamager
-
- /**
- * Returns the end offset of the line that contains the specified offset or
- * if the offset is inside a line delimiter, the end offset of the next line.
- *
- * @param offset the offset whose line end offset must be computed
- * @return the line end offset for the given offset
- * @exception BadLocationException if offset is invalid in the current document
- */
- protected int endOfLineOf(int offset) throws BadLocationException {
-
- IRegion info= fDocument.getLineInformationOfOffset(offset);
- if (offset <= info.getOffset() + info.getLength())
- return info.getOffset() + info.getLength();
-
- int line= fDocument.getLineOfOffset(offset);
- try {
- info= fDocument.getLineInformation(line + 1);
- return info.getOffset() + info.getLength();
- } catch (BadLocationException x) {
- return fDocument.getLength();
- }
- }
-
- /*
- * @see IPresentationDamager#getDamageRegion(ITypedRegion, DocumentEvent, boolean)
- */
- public IRegion getDamageRegion(ITypedRegion partition, DocumentEvent e, boolean documentPartitioningChanged) {
-
- if (!documentPartitioningChanged) {
- try {
-
- IRegion info= fDocument.getLineInformationOfOffset(e.getOffset());
- int start= Math.max(partition.getOffset(), info.getOffset());
-
- int end= e.getOffset() + (e.getText() == null ? e.getLength() : e.getText().length());
-
- if (info.getOffset() <= end && end <= info.getOffset() + info.getLength()) {
- // optimize the case of the same line
- end= info.getOffset() + info.getLength();
- } else
- end= endOfLineOf(end);
-
- end= Math.min(partition.getOffset() + partition.getLength(), end);
- return new Region(start, end - start);
-
- } catch (BadLocationException x) {
- }
- }
-
- return partition;
- }
-
- //---- IPresentationRepairer
-
- /*
- * @see IPresentationRepairer#createPresentation(TextPresentation, ITypedRegion)
- */
- public void createPresentation(TextPresentation presentation, ITypedRegion region) {
-
- if (fScanner == null) {
- // will be removed if deprecated constructor will be removed
- addRange(presentation, region.getOffset(), region.getLength(), fDefaultTextAttribute);
- return;
- }
-
- int lastStart= region.getOffset();
- int length= 0;
- boolean firstToken= true;
- IToken lastToken= Token.UNDEFINED;
- TextAttribute lastAttribute= getTokenTextAttribute(lastToken);
-
- fScanner.setRange(fDocument, lastStart, region.getLength());
-
- while (true) {
- IToken token= fScanner.nextToken();
- if (token.isEOF())
- break;
-
- TextAttribute attribute= getTokenTextAttribute(token);
- if (lastAttribute != null && lastAttribute.equals(attribute)) {
- length += fScanner.getTokenLength();
- firstToken= false;
- } else {
- if (!firstToken)
- addRange(presentation, lastStart, length, lastAttribute);
- firstToken= false;
- lastToken= token;
- lastAttribute= attribute;
- lastStart= fScanner.getTokenOffset();
- length= fScanner.getTokenLength();
- }
- }
-
- addRange(presentation, lastStart, length, lastAttribute);
- }
-
- /**
- * Returns a text attribute encoded in the given token. If the token's
- * data is not <code>null</code> and a text attribute it is assumed that
- * it is the encoded text attribute. It returns the default text attribute
- * if there is no encoded text attribute found.
- *
- * @param token the token whose text attribute is to be determined
- * @return the token's text attribute
- */
- protected TextAttribute getTokenTextAttribute(IToken token) {
- Object data= token.getData();
- if (data instanceof TextAttribute)
- return (TextAttribute) data;
- return fDefaultTextAttribute;
- }
-
- /**
- * Adds style information to the given text presentation.
- *
- * @param presentation the text presentation to be extended
- * @param offset the offset of the range to be styled
- * @param length the length of the range to be styled
- * @param attr the attribute describing the style of the range to be styled
- */
- protected void addRange(TextPresentation presentation, int offset, int length, TextAttribute attr) {
- if (attr != null)
- presentation.addStyleRange(new StyleRange(offset, length, attr.getForeground(), attr.getBackground(), attr.getStyle()));
- }
-}
-
-
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/DefaultPartitioner.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/DefaultPartitioner.java
deleted file mode 100644
index 03335e4..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/DefaultPartitioner.java
+++ /dev/null
@@ -1,543 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.rules;
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.DefaultPositionUpdater;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.jface.text.IDocumentPartitionerExtension;
-import org.eclipse.jface.text.IDocumentPartitionerExtension2;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TypedPosition;
-import org.eclipse.jface.text.TypedRegion;
-
-
-
-/**
- * A standard implementation of a document partitioner.
- * It uses a partition token scanner to scan the document and to determine
- * the document's partitioning. The tokens returned by the
- * scanner are supposed to return the partition type
- * as their data. The partitoner remembers the document's partitions
- * in the document itself rather than maintaining its own data structure.
- *
- * @see IPartitionTokenScanner
- * @since 2.0
- */
-public class DefaultPartitioner implements IDocumentPartitioner, IDocumentPartitionerExtension, IDocumentPartitionerExtension2 {
-
- /**
- * The position category this partitioner uses to store the document's partitioning information.
- * @deprecated use <code>getManagingPositionCategories()</code>.
- */
- public final static String CONTENT_TYPES_CATEGORY= "__content_types_category"; //$NON-NLS-1$
-
-
- /** The partitioner's scanner */
- protected IPartitionTokenScanner fScanner;
- /** The legal content types of this partitioner */
- protected String[] fLegalContentTypes;
- /** The partitioner's document */
- protected IDocument fDocument;
- /** The document length before a document change occured */
- protected int fPreviousDocumentLength;
- /** The position updater used to for the default updating of partitions */
- protected DefaultPositionUpdater fPositionUpdater;
- /** The offset at which the first changed partition starts */
- protected int fStartOffset;
- /** The offset at which the last changed partition ends */
- protected int fEndOffset;
- /**The offset at which a partition has been deleted */
- protected int fDeleteOffset;
- /**
- * The position category this partitioner uses to store the document's partitioning information.
- * @since 3.0
- */
- private String fPositionCategory;
-
- /**
- * Creates a new partitioner that uses the given scanner and may return
- * partitions of the given legal content types.
- *
- * @param scanner the scanner this partitioner is supposed to use
- * @param legalContentTypes the legal content types of this partitioner
- */
- public DefaultPartitioner(IPartitionTokenScanner scanner, String[] legalContentTypes) {
- fScanner= scanner;
- fLegalContentTypes= legalContentTypes;
- fPositionCategory= CONTENT_TYPES_CATEGORY + hashCode();
- fPositionUpdater= new DefaultPositionUpdater(fPositionCategory);
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentPartitionerExtension2#getManagingPositionCategories()
- * @since 3.0
- */
- public String[] getManagingPositionCategories() {
- return new String[] { fPositionCategory };
- }
-
- /*
- * @see IDocumentPartitioner#connect(IDocument)
- */
- public void connect(IDocument document) {
- Assert.isNotNull(document);
- Assert.isTrue(!document.containsPositionCategory(fPositionCategory));
-
- fDocument= document;
- fDocument.addPositionCategory(fPositionCategory);
-
- initialize();
- }
-
- /**
- * Performs the initial partitioning of the partitioner's document.
- */
- protected void initialize() {
-
- fScanner.setRange(fDocument, 0, fDocument.getLength());
-
- try {
- IToken token= fScanner.nextToken();
- while (!token.isEOF()) {
-
- String contentType= getTokenContentType(token);
-
- if (isSupportedContentType(contentType)) {
- TypedPosition p= new TypedPosition(fScanner.getTokenOffset(), fScanner.getTokenLength(), contentType);
- fDocument.addPosition(fPositionCategory, p);
- }
-
- token= fScanner.nextToken();
- }
- } catch (BadLocationException x) {
- // cannot happen as offsets come from scanner
- } catch (BadPositionCategoryException x) {
- // cannot happen if document has been connected before
- }
- }
-
- /*
- * @see IDocumentPartitioner#disconnect()
- */
- public void disconnect() {
-
- Assert.isTrue(fDocument.containsPositionCategory(fPositionCategory));
-
- try {
- fDocument.removePositionCategory(fPositionCategory);
- } catch (BadPositionCategoryException x) {
- // can not happen because of Assert
- }
- }
-
- /*
- * @see IDocumentPartitioner#documentAboutToBeChanged(DocumentEvent)
- */
- public void documentAboutToBeChanged(DocumentEvent e) {
-
- Assert.isTrue(e.getDocument() == fDocument);
-
- fPreviousDocumentLength= e.getDocument().getLength();
- fStartOffset= -1;
- fEndOffset= -1;
- fDeleteOffset= -1;
- }
-
- /*
- * @see IDocumentPartitioner#documentChanged(DocumentEvent)
- */
- public boolean documentChanged(DocumentEvent e) {
- IRegion region= documentChanged2(e);
- return (region != null);
- }
-
- /**
- * Helper method for tracking the minimal region containg all partition changes.
- * If <code>offset</code> is smaller than the remembered offset, <code>offset</code>
- * will from now on be remembered. If <code>offset + length</code> is greater than
- * the remembered end offset, it will be remembered from now on.
- *
- * @param offset the offset
- * @param length the length
- */
- private void rememberRegion(int offset, int length) {
- // remember start offset
- if (fStartOffset == -1)
- fStartOffset= offset;
- else if (offset < fStartOffset)
- fStartOffset= offset;
-
- // remember end offset
- int endOffset= offset + length;
- if (fEndOffset == -1)
- fEndOffset= endOffset;
- else if (endOffset > fEndOffset)
- fEndOffset= endOffset;
- }
-
- /**
- * Remembers the given offset as the deletion offset.
- *
- * @param offset the offset
- */
- private void rememberDeletedOffset(int offset) {
- fDeleteOffset= offset;
- }
-
- /**
- * Creates the minimal region containing all partition changes using the
- * remembered offset, end offset, and deletion offset.
- *
- * @return the minimal region containing all the partition changes
- */
- private IRegion createRegion() {
- if (fDeleteOffset == -1) {
- if (fStartOffset == -1 || fEndOffset == -1)
- return null;
- return new Region(fStartOffset, fEndOffset - fStartOffset);
- } else if (fStartOffset == -1 || fEndOffset == -1) {
- return new Region(fDeleteOffset, 0);
- } else {
- int offset= Math.min(fDeleteOffset, fStartOffset);
- int endOffset= Math.max(fDeleteOffset, fEndOffset);
- return new Region(offset, endOffset - offset);
- }
- }
-
- /*
- * @see IDocumentPartitionerExtension#documentChanged2(DocumentEvent)
- * @since 2.0
- */
- public IRegion documentChanged2(DocumentEvent e) {
-
- try {
-
- IDocument d= e.getDocument();
- Position[] category= d.getPositions(fPositionCategory);
- IRegion line= d.getLineInformationOfOffset(e.getOffset());
- int reparseStart= line.getOffset();
- int partitionStart= -1;
- String contentType= null;
-
- int first= d.computeIndexInCategory(fPositionCategory, reparseStart);
- if (first > 0) {
- TypedPosition partition= (TypedPosition) category[first - 1];
- if (partition.includes(reparseStart)) {
- partitionStart= partition.getOffset();
- contentType= partition.getType();
- if (e.getOffset() == partition.getOffset() + partition.getLength())
- reparseStart= partitionStart;
- -- first;
- } else if (reparseStart == e.getOffset() && reparseStart == partition.getOffset() + partition.getLength()) {
- partitionStart= partition.getOffset();
- contentType= partition.getType();
- reparseStart= partitionStart;
- -- first;
- } else {
- partitionStart= partition.getOffset() + partition.getLength();
- contentType= IDocument.DEFAULT_CONTENT_TYPE;
- }
- }
-
- fPositionUpdater.update(e);
- for (int i= first; i < category.length; i++) {
- Position p= category[i];
- if (p.isDeleted) {
- rememberDeletedOffset(e.getOffset());
- break;
- }
- }
- category= d.getPositions(fPositionCategory);
-
- fScanner.setPartialRange(d, reparseStart, d.getLength() - reparseStart, contentType, partitionStart);
-
- int lastScannedPosition= reparseStart;
- IToken token= fScanner.nextToken();
-
- while (!token.isEOF()) {
-
- contentType= getTokenContentType(token);
-
- if (!isSupportedContentType(contentType)) {
- token= fScanner.nextToken();
- continue;
- }
-
- int start= fScanner.getTokenOffset();
- int length= fScanner.getTokenLength();
-
- lastScannedPosition= start + length - 1;
-
- // remove all affected positions
- while (first < category.length) {
- TypedPosition p= (TypedPosition) category[first];
- if (lastScannedPosition >= p.offset + p.length ||
- (p.overlapsWith(start, length) &&
- (!d.containsPosition(fPositionCategory, start, length) ||
- !contentType.equals(p.getType())))) {
-
- rememberRegion(p.offset, p.length);
- d.removePosition(fPositionCategory, p);
- ++ first;
-
- } else
- break;
- }
-
- // if position already exists we are done
- if (d.containsPosition(fPositionCategory, start, length)) {
- if (lastScannedPosition > e.getOffset())
- return createRegion();
- ++ first;
- } else {
- // insert the new type position
- try {
- d.addPosition(fPositionCategory, new TypedPosition(start, length, contentType));
- rememberRegion(start, length);
- } catch (BadPositionCategoryException x) {
- } catch (BadLocationException x) {
- }
- }
-
- token= fScanner.nextToken();
- }
-
-
- // remove all positions behind lastScannedPosition since there aren't any further types
- if (lastScannedPosition != reparseStart) {
- // if this condition is not met, nothing has been scanned because of a deletion
- ++ lastScannedPosition;
- }
- first= d.computeIndexInCategory(fPositionCategory, lastScannedPosition);
-
- TypedPosition p;
- while (first < category.length) {
- p= (TypedPosition) category[first++];
- d.removePosition(fPositionCategory, p);
- rememberRegion(p.offset, p.length);
- }
-
- } catch (BadPositionCategoryException x) {
- // should never happen on connected documents
- } catch (BadLocationException x) {
- }
-
- return createRegion();
- }
-
-
- /**
- * Returns the position in the partitoner's position category which is
- * close to the given offset. This is, the position has either an offset which
- * is the same as the given offset or an offset which is smaller than the given
- * offset. This method profits from the knowledge that a partitioning is
- * a ordered set of disjoint position.
- *
- * @param offset the offset for which to search the closest position
- * @return the closest position in the partitioner's category
- */
- protected TypedPosition findClosestPosition(int offset) {
-
- try {
-
- int index= fDocument.computeIndexInCategory(fPositionCategory, offset);
- Position[] category= fDocument.getPositions(fPositionCategory);
-
- if (category.length == 0)
- return null;
-
- if (index < category.length) {
- if (offset == category[index].offset)
- return (TypedPosition) category[index];
- }
-
- if (index > 0)
- index--;
-
- return (TypedPosition) category[index];
-
- } catch (BadPositionCategoryException x) {
- } catch (BadLocationException x) {
- }
-
- return null;
- }
-
-
- /*
- * @see IDocumentPartitioner#getContentType(int)
- */
- public String getContentType(int offset) {
-
- TypedPosition p= findClosestPosition(offset);
- if (p != null && p.includes(offset))
- return p.getType();
-
- return IDocument.DEFAULT_CONTENT_TYPE;
- }
-
- /*
- * @see IDocumentPartitioner#getPartition(int)
- */
- public ITypedRegion getPartition(int offset) {
-
- try {
-
- Position[] category = fDocument.getPositions(fPositionCategory);
-
- if (category == null || category.length == 0)
- return new TypedRegion(0, fDocument.getLength(), IDocument.DEFAULT_CONTENT_TYPE);
-
- int index= fDocument.computeIndexInCategory(fPositionCategory, offset);
-
- if (index < category.length) {
-
- TypedPosition next= (TypedPosition) category[index];
-
- if (offset == next.offset)
- return new TypedRegion(next.getOffset(), next.getLength(), next.getType());
-
- if (index == 0)
- return new TypedRegion(0, next.offset, IDocument.DEFAULT_CONTENT_TYPE);
-
- TypedPosition previous= (TypedPosition) category[index - 1];
- if (previous.includes(offset))
- return new TypedRegion(previous.getOffset(), previous.getLength(), previous.getType());
-
- int endOffset= previous.getOffset() + previous.getLength();
- return new TypedRegion(endOffset, next.getOffset() - endOffset, IDocument.DEFAULT_CONTENT_TYPE);
- }
-
- TypedPosition previous= (TypedPosition) category[category.length - 1];
- if (previous.includes(offset))
- return new TypedRegion(previous.getOffset(), previous.getLength(), previous.getType());
-
- int endOffset= previous.getOffset() + previous.getLength();
- return new TypedRegion(endOffset, fDocument.getLength() - endOffset, IDocument.DEFAULT_CONTENT_TYPE);
-
- } catch (BadPositionCategoryException x) {
- } catch (BadLocationException x) {
- }
-
- return new TypedRegion(0, fDocument.getLength(), IDocument.DEFAULT_CONTENT_TYPE);
- }
-
- /*
- * @see IDocumentPartitioner#computePartitioning(int, int)
- */
- public ITypedRegion[] computePartitioning(int offset, int length) {
-
- List list= new ArrayList();
-
- try {
-
- int endOffset= offset + length;
-
- Position[] category= fDocument.getPositions(fPositionCategory);
-
- TypedPosition previous= null, current= null;
- int start, end, gapOffset;
- Position gap= null;
-
- for (int i= 0; i < category.length; i++) {
-
- current= (TypedPosition) category[i];
-
- gapOffset= (previous != null) ? previous.getOffset() + previous.getLength() : 0;
- gap= new Position(gapOffset, current.getOffset() - gapOffset);
- if (gap.getLength() > 0 && gap.overlapsWith(offset, length)) {
- start= Math.max(offset, gapOffset);
- end= Math.min(endOffset, gap.getOffset() + gap.getLength());
- list.add(new TypedRegion(start, end - start, IDocument.DEFAULT_CONTENT_TYPE));
- }
-
- if (current.overlapsWith(offset, length)) {
- start= Math.max(offset, current.getOffset());
- end= Math.min(endOffset, current.getOffset() + current.getLength());
- list.add(new TypedRegion(start, end - start, current.getType()));
- }
-
- previous= current;
- }
-
- if (previous != null) {
- gapOffset= previous.getOffset() + previous.getLength();
- gap= new Position(gapOffset, fDocument.getLength() - gapOffset);
- if (gap.getLength() > 0 && gap.overlapsWith(offset, length)) {
- start= Math.max(offset, gapOffset);
- end= Math.min(endOffset, fDocument.getLength());
- list.add(new TypedRegion(start, end - start, IDocument.DEFAULT_CONTENT_TYPE));
- }
- }
-
- if (list.isEmpty())
- list.add(new TypedRegion(offset, length, IDocument.DEFAULT_CONTENT_TYPE));
-
- } catch (BadPositionCategoryException x) {
- }
-
- TypedRegion[] result= new TypedRegion[list.size()];
- list.toArray(result);
- return result;
- }
-
- /*
- * @see IDocumentPartitioner#getLegalContentTypes()
- */
- public String[] getLegalContentTypes() {
- return fLegalContentTypes;
- }
-
- /**
- * Returns whether the given type is one of the legal content types.
- *
- * @param contentType the content type to check
- * @return <code>true</code> if the content type is a legal content type
- */
- protected boolean isSupportedContentType(String contentType) {
- if (contentType != null) {
- for (int i= 0; i < fLegalContentTypes.length; i++) {
- if (fLegalContentTypes[i].equals(contentType))
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Returns a content type encoded in the given token. If the token's
- * data is not <code>null</code> and a string it is assumed that
- * it is the encoded content type.
- *
- * @param token the token whose content type is to be determined
- * @return the token's content type
- */
- protected String getTokenContentType(IToken token) {
- Object data= token.getData();
- if (data instanceof String)
- return (String) data;
- return null;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/EndOfLineRule.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/EndOfLineRule.java
deleted file mode 100644
index bb4d076..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/EndOfLineRule.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Christopher Lenz (cmlenz@gmx.de) - support for line continuation
- *******************************************************************************/
-package org.eclipse.jface.text.rules;
-
-
-/**
- * A specific configuration of a single line rule
- * whereby the pattern begins with a specific sequence but
- * is only ended by a line delimiter.
- */
-public class EndOfLineRule extends SingleLineRule {
-
- /**
- * Creates a rule for the given starting sequence
- * which, if detected, will return the specified token.
- *
- * @param startSequence the pattern's start sequence
- * @param token the token to be returned on success
- */
- public EndOfLineRule(String startSequence, IToken token) {
- this(startSequence, token, (char) 0);
- }
-
- /**
- * Creates a rule for the given starting sequence
- * which, if detected, will return the specified token.
- * Any character which follows the given escape character
- * will be ignored.
- *
- * @param startSequence the pattern's start sequence
- * @param token the token to be returned on success
- * @param escapeCharacter the escape character
- */
- public EndOfLineRule(String startSequence, IToken token, char escapeCharacter) {
- super(startSequence, null, token, escapeCharacter, true);
- }
-
- /**
- * Creates a rule for the given starting sequence
- * which, if detected, will return the specified token.
- * Any character which follows the given escape character
- * will be ignored. In addition, an escape character
- * immediately before an end of line can be set to continue
- * the line.
- *
- * @param startSequence the pattern's start sequence
- * @param token the token to be returned on success
- * @param escapeCharacter the escape character
- * @param escapeContinuesLine indicates whether the specified escape
- * character is used for line continuation, so that an end of
- * line immediately after the escape character does not
- * terminate the line, even if <code>breakOnEOL</code> is true
- */
- public EndOfLineRule(String startSequence, IToken token, char escapeCharacter, boolean escapeContinuesLine) {
- super(startSequence, null, token, escapeCharacter, true, escapeContinuesLine);
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/ICharacterScanner.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/ICharacterScanner.java
deleted file mode 100644
index 2edc15e..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/ICharacterScanner.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.rules;
-
-
-/**
- * Defines the interface of a character scanner used by rules.
- * Rules may request the next character or ask the character
- * scanner to unread the last read character.
- */
-public interface ICharacterScanner {
-
- /**
- * The value returned when this scanner has read EOF.
- */
- public static final int EOF= -1;
-
- /**
- * Provides rules access to the legal line delimiters.
- *
- * @return the legal line delimiters
- */
- char[][] getLegalLineDelimiters();
-
- /**
- * Returns the column of the character scanner.
- *
- * @return the column of the character scanner
- */
- int getColumn();
-
- /**
- * Returns the next character or EOF if end of file has been reached
- *
- * @return the next character or EOF
- */
- int read();
-
- /**
- * Rewinds the scanner before the last read character.
- */
- void unread();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IPartitionTokenScanner.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IPartitionTokenScanner.java
deleted file mode 100644
index 420261f..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IPartitionTokenScanner.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.rules;
-
-
-import org.eclipse.jface.text.IDocument;
-
-
-/**
- * A partition token scanner returns tokens that represent partitions. For that reason,
- * a partition token scanner is vulnerable in respect to the document offset it starts
- * scanning. In a simple case, a partition token scanner must always start at a partition
- * boundary. A partition token scanner can also start in the middle of a partition,
- * if it knows the type of the partition.
- *
- * @since 2.0
- */
-public interface IPartitionTokenScanner extends ITokenScanner {
-
- /**
- * Configures the scanner by providing access to the document range that should be scanned.
- * The range may no only contain complete partitions but starts at the beginning of a line in the
- * middle of a partition of the given content type. This requires that a partition delimiter can not
- * contain a line delimiter.
- *
- * @param document the document to scan
- * @param offset the offset of the document range to scan
- * @param length the length of the document range to scan
- * @param contentType the content type at the given offset
- * @param partitionOffset the offset at which the partition of the given offset starts
- */
- void setPartialRange(IDocument document, int offset, int length, String contentType, int partitionOffset);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IPredicateRule.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IPredicateRule.java
deleted file mode 100644
index 8e4f99e..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IPredicateRule.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.rules;
-
-/**
- * Defines the interface for a rule used in the scanning of text for the purpose of
- * document partitioning or text styling. A predicate rule can only return one single
- * token after having successfully detected content. This token is called success token.
- * Also, it also returns a token indicating that this rule has not been successful.
- *
- * @see ICharacterScanner
- * @since 2.0
- */
-public interface IPredicateRule extends IRule {
-
- /**
- * Returns the success token of this predicate rule.
- *
- * @return the success token of this rule
- */
- IToken getSuccessToken();
-
- /**
- * Evaluates the rule by examining the characters available from
- * the provided character scanner. The token returned by this rule
- * returns <code>true</code> when calling <code>isUndefined</code>,
- * if the text the rule investigated does not match the rule's requirements. Otherwise,
- * this method returns this rule's success token. If this rules relies on a text pattern
- * comprising a opening and a closing character sequence this method can also be called
- * when the scanner is positioned already between the opening and the closing sequence.
- * In this case, <code>resume</code> must be set to <code>true</code>.
- *
- * @param scanner the character scanner to be used by this rule
- * @param resume indicates that the rule starts working between the opening and the closing character sequence
- * @return the token computed by the rule
- */
- IToken evaluate(ICharacterScanner scanner, boolean resume);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IRule.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IRule.java
deleted file mode 100644
index 4b5dce4..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IRule.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.rules;
-
-
-/**
- * Defines the interface for a rule used in the
- * scanning of text for the purpose of document
- * partitioning or text styling.
- *
- * @see ICharacterScanner
- */
-public interface IRule {
-
- /**
- * Evaluates the rule by examining the characters available from
- * the provided character scanner. The token returned by this rule
- * returns <code>true</code> when calling <code>isUndefined</code>,
- * if the text the rule investigated does not match the rule's requirements.
- *
- * @param scanner the character scanner to be used by this rule
- * @return the token computed by the rule
- */
- IToken evaluate(ICharacterScanner scanner);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IToken.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IToken.java
deleted file mode 100644
index ad02d81..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IToken.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.rules;
-
-
-/**
- * A token to be returned by a rule.
- */
-public interface IToken {
-
- /**
- * Return whether this token is undefined.
- *
- * @return <code>true</code>if this token is undefined
- */
- boolean isUndefined();
-
- /**
- * Return whether this token represents a whitespace.
- *
- * @return <code>true</code>if this token represents a whitespace
- */
- boolean isWhitespace();
-
- /**
- * Return whether this token represents End Of File.
- *
- * @return <code>true</code>if this token represents EOF
- */
- boolean isEOF();
-
- /**
- * Return whether this token is neither undefined, nor whitespace, nor EOF.
- *
- * @return <code>true</code>if this token is not undefined, not a whitespace, and not EOF
- */
- boolean isOther();
-
- /**
- * Return a data attacted to this token. The semantics of this data kept undefined by this interface.
- *
- * @return the data attached to this token.
- */
- Object getData();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/ITokenScanner.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/ITokenScanner.java
deleted file mode 100644
index 0dab8df..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/ITokenScanner.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.rules;
-
-
-import org.eclipse.jface.text.IDocument;
-
-
-/**
- * A token scanner scans a range of a document and reports about the token it finds.
- * A scanner has state. When asked, the scanner returns the offset and the length of the
- * last found token.
- *
- * @see org.eclipse.jface.text.rules.IToken
- * @since 2.0
- */
-public interface ITokenScanner {
-
- /**
- * Configures the scanner by providing access to the document range that should
- * be scanned.
- *
- * @param document the document to scan
- * @param offset the offset of the document range to scan
- * @param length the length of the document range to scan
- */
- void setRange(IDocument document, int offset, int length);
-
- /**
- * Returns the next token in the document.
- *
- * @return the next token in the document
- */
- IToken nextToken();
-
- /**
- * Returns the offset of the last token read by this scanner.
- *
- * @return the offset of the last token read by this scanner
- */
- int getTokenOffset();
-
- /**
- * Returns the length of the last token read by this scanner.
- *
- * @return the length of the last token read by this scanner
- */
- int getTokenLength();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IWhitespaceDetector.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IWhitespaceDetector.java
deleted file mode 100644
index 0719ea0..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IWhitespaceDetector.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.rules;
-
-
-/**
- * Defines the interface by which <code>WhitespaceRule</code>
- * determines whether a given character is to be considered
- * whitespace in the current context.
- */
-public interface IWhitespaceDetector {
-
- /**
- * Returns whether the specified character is whitespace.
- *
- * @param c the character to be checked
- */
- boolean isWhitespace(char c);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IWordDetector.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IWordDetector.java
deleted file mode 100644
index 5b7db6f..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/IWordDetector.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.rules;
-
-
-/**
- * Defines the interface by which <code>WordRule</code>
- * determines whether a given character is valid as part
- * of a word in the current context.
- */
-public interface IWordDetector {
-
- /**
- * Returns whether the specified character is
- * valid as the first character in a word.
- *
- * @param c the character to be checked
- * @return <code>true</code> is a valid first character in a word, <code>false</code> otherwise
- */
- boolean isWordStart(char c);
-
- /**
- * Returns whether the specified character is
- * valid as a subsequent character in a word.
- *
- * @param c the character to be checked
- * @return <code>true</code> if the character is a valid word part, <code>false</code> otherwise
- */
- boolean isWordPart(char c);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/MultiLineRule.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/MultiLineRule.java
deleted file mode 100644
index 9f35df2..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/MultiLineRule.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.rules;
-
-
-/**
- * A rule for detecting patterns which begin with a given
- * sequence and may end with a given sequence thereby spanning
- * multiple lines.
- */
-public class MultiLineRule extends PatternRule {
-
- /**
- * Creates a rule for the given starting and ending sequence
- * which, if detected, will return the specified token.
- *
- * @param startSequence the pattern's start sequence
- * @param endSequence the pattern's end sequence
- * @param token the token to be returned on success
- */
- public MultiLineRule(String startSequence, String endSequence, IToken token) {
- this(startSequence, endSequence, token, (char) 0);
- }
-
- /**
- * Creates a rule for the given starting and ending sequence
- * which, if detected, will return the specific token.
- * Any character which follows the given escape character will be ignored.
- *
- * @param startSequence the pattern's start sequence
- * @param endSequence the pattern's end sequence
- * @param token the token to be returned on success
- * @param escapeCharacter the escape character
- */
- public MultiLineRule(String startSequence, String endSequence, IToken token, char escapeCharacter) {
- this(startSequence, endSequence, token, escapeCharacter, false);
- }
-
- /**
- * Creates a rule for the given starting and ending sequence
- * which, if detected, will return the specific token. Any character that follows the
- * given escape character will be ignored. <code>breakOnEOF</code> indicates whether
- * EOF is equivalent to detecting the <code>endSequence</code>.
- *
- * @param startSequence the pattern's start sequence
- * @param endSequence the pattern's end sequence
- * @param token the token to be returned on success
- * @param escapeCharacter the escape character
- * @param breaksOnEOF indicates whether the end of the file terminates this rule successfully
- * @since 2.1
- */
- public MultiLineRule(String startSequence, String endSequence, IToken token, char escapeCharacter, boolean breaksOnEOF) {
- super(startSequence, endSequence, token, escapeCharacter, false, breaksOnEOF);
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/NumberRule.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/NumberRule.java
deleted file mode 100644
index 42fb5c9..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/NumberRule.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.rules;
-
-import org.eclipse.jface.text.Assert;
-
-
-/**
- * An implementation of <code>IRule</code> capable of detecting a numerical value.
- */
-public class NumberRule implements IRule {
-
- /** Internal setting for the uninitialized column constraint */
- protected static final int UNDEFINED= -1;
- /** The token to be returned when this rule is successful */
- protected IToken fToken;
- /** The column constraint */
- protected int fColumn= UNDEFINED;
-
- /**
- * Creates a rule which will return the specified
- * token when a numerical sequence is detected.
- *
- * @param token the token to be returned
- */
- public NumberRule(IToken token) {
- Assert.isNotNull(token);
- fToken= token;
- }
-
- /**
- * Sets a column constraint for this rule. If set, the rule's token
- * will only be returned if the pattern is detected starting at the
- * specified column. If the column is smaller then 0, the column
- * constraint is considered removed.
- *
- * @param column the column in which the pattern starts
- */
- public void setColumnConstraint(int column) {
- if (column < 0)
- column= UNDEFINED;
- fColumn= column;
- }
-
- /*
- * @see IRule#evaluate(ICharacterScanner)
- */
- public IToken evaluate(ICharacterScanner scanner) {
- int c= scanner.read();
- if (Character.isDigit((char)c)) {
- if (fColumn == UNDEFINED || (fColumn == scanner.getColumn() - 1)) {
- do {
- c= scanner.read();
- } while (Character.isDigit((char) c));
- scanner.unread();
- return fToken;
- }
- }
-
- scanner.unread();
- return Token.UNDEFINED;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/PatternRule.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/PatternRule.java
deleted file mode 100644
index 92ad706..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/PatternRule.java
+++ /dev/null
@@ -1,273 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Christopher Lenz (cmlenz@gmx.de) - support for line continuation
- *******************************************************************************/
-
-package org.eclipse.jface.text.rules;
-
-import org.eclipse.jface.text.Assert;
-
-
-
-
-/**
- * Standard implementation of <code>IPredicateRule</code>.
- * Is is capable of detecting a pattern which begins with a given start
- * sequence and ends with a given end sequence. If the end sequence is
- * not specified, it can be either end of line, end or file, or both. Additionally,
- * the pattern can be constrained to begin in a certain column. The rule can also
- * be used to check whether the text to scan covers half of the pattern, i.e. contains
- * the end sequence required by the rule.
- */
-public class PatternRule implements IPredicateRule {
-
- /** Internal setting for the uninitialized column constraint */
- protected static final int UNDEFINED= -1;
-
- /** The token to be returned on success */
- protected IToken fToken;
- /** The pattern's start sequence */
- protected char[] fStartSequence;
- /** The pattern's end sequence */
- protected char[] fEndSequence;
- /** The pattern's column constrain */
- protected int fColumn= UNDEFINED;
- /** The pattern's escape character */
- protected char fEscapeCharacter;
- /**
- * Indicates whether the escape character continues a line
- * @since 3.0
- */
- protected boolean fEscapeContinuesLine;
- /** Indicates whether end of line terminates the pattern */
- protected boolean fBreaksOnEOL;
- /** Indicates whether end of file terminates the pattern */
- protected boolean fBreaksOnEOF;
-
- /**
- * Creates a rule for the given starting and ending sequence.
- * When these sequences are detected the rule will return the specified token.
- * Alternatively, the sequence can also be ended by the end of the line.
- * Any character which follows the given escapeCharacter will be ignored.
- *
- * @param startSequence the pattern's start sequence
- * @param endSequence the pattern's end sequence, <code>null</code> is a legal value
- * @param token the token which will be returned on success
- * @param escapeCharacter any character following this one will be ignored
- * @param breaksOnEOL indicates whether the end of the line also terminates the pattern
- */
- public PatternRule(String startSequence, String endSequence, IToken token, char escapeCharacter, boolean breaksOnEOL) {
- Assert.isTrue(startSequence != null && startSequence.length() > 0);
- Assert.isTrue(endSequence != null || breaksOnEOL);
- Assert.isNotNull(token);
-
- fStartSequence= startSequence.toCharArray();
- fEndSequence= (endSequence == null ? new char[0] : endSequence.toCharArray());
- fToken= token;
- fEscapeCharacter= escapeCharacter;
- fBreaksOnEOL= breaksOnEOL;
- }
-
- /**
- * Creates a rule for the given starting and ending sequence.
- * When these sequences are detected the rule will return the specified token.
- * Alternatively, the sequence can also be ended by the end of the line or the end of the file.
- * Any character which follows the given escapeCharacter will be ignored.
- *
- * @param startSequence the pattern's start sequence
- * @param endSequence the pattern's end sequence, <code>null</code> is a legal value
- * @param token the token which will be returned on success
- * @param escapeCharacter any character following this one will be ignored
- * @param breaksOnEOL indicates whether the end of the line also terminates the pattern
- * @param breaksOnEOF indicates whether the end of the file also terminates the pattern
- * @since 2.1
- */
- public PatternRule(String startSequence, String endSequence, IToken token, char escapeCharacter, boolean breaksOnEOL, boolean breaksOnEOF) {
- this(startSequence, endSequence, token, escapeCharacter, breaksOnEOL);
- fBreaksOnEOF= breaksOnEOF;
- }
-
- /**
- * Creates a rule for the given starting and ending sequence.
- * When these sequences are detected the rule will return the specified token.
- * Alternatively, the sequence can also be ended by the end of the line or the end of the file.
- * Any character which follows the given escapeCharacter will be ignored. An end of line
- * immediately after the given <code>lineContinuationCharacter</code> will not cause the
- * pattern to terminate even if <code>breakOnEOL</code> is set to true.
- *
- * @param startSequence the pattern's start sequence
- * @param endSequence the pattern's end sequence, <code>null</code> is a legal value
- * @param token the token which will be returned on success
- * @param escapeCharacter any character following this one will be ignored
- * @param breaksOnEOL indicates whether the end of the line also terminates the pattern
- * @param breaksOnEOF indicates whether the end of the file also terminates the pattern
- * @param escapeContinuesLine indicates whether the specified escape character is used for line
- * continuation, so that an end of line immediately after the escape character does not
- * terminate the pattern, even if <code>breakOnEOL</code> is set
- * @since 3.0
- */
- public PatternRule(String startSequence, String endSequence, IToken token, char escapeCharacter, boolean breaksOnEOL, boolean breaksOnEOF, boolean escapeContinuesLine) {
- this(startSequence, endSequence, token, escapeCharacter, breaksOnEOL, breaksOnEOF);
- fEscapeContinuesLine= escapeContinuesLine;
- }
-
- /**
- * Sets a column constraint for this rule. If set, the rule's token
- * will only be returned if the pattern is detected starting at the
- * specified column. If the column is smaller then 0, the column
- * constraint is considered removed.
- *
- * @param column the column in which the pattern starts
- */
- public void setColumnConstraint(int column) {
- if (column < 0)
- column= UNDEFINED;
- fColumn= column;
- }
-
-
- /**
- * Evaluates this rules without considering any column constraints.
- *
- * @param scanner the character scanner to be used
- * @return the token resulting from this evaluation
- */
- protected IToken doEvaluate(ICharacterScanner scanner) {
- return doEvaluate(scanner, false);
- }
-
- /**
- * Evaluates this rules without considering any column constraints. Resumes
- * detection, i.e. look sonly for the end sequence required by this rule if the
- * <code>resume</code> flag is set.
- *
- * @param scanner the character scanner to be used
- * @param resume <code>true</code> if detection should be resumed, <code>false</code> otherwise
- * @return the token resulting from this evaluation
- * @since 2.0
- */
- protected IToken doEvaluate(ICharacterScanner scanner, boolean resume) {
-
- if (resume) {
-
- if (endSequenceDetected(scanner))
- return fToken;
-
- } else {
-
- int c= scanner.read();
- if (c == fStartSequence[0]) {
- if (sequenceDetected(scanner, fStartSequence, false)) {
- if (endSequenceDetected(scanner))
- return fToken;
- }
- }
- }
-
- scanner.unread();
- return Token.UNDEFINED;
- }
-
- /*
- * @see IRule#evaluate(ICharacterScanner)
- */
- public IToken evaluate(ICharacterScanner scanner) {
- return evaluate(scanner, false);
- }
-
- /**
- * Returns whether the end sequence was detected. As the pattern can be considered
- * ended by a line delimiter, the result of this method is <code>true</code> if the
- * rule breaks on the end of the line, or if the EOF character is read.
- *
- * @param scanner the character scanner to be used
- * @return <code>true</code> if the end sequence has been detected
- */
- protected boolean endSequenceDetected(ICharacterScanner scanner) {
- int c;
- char[][] delimiters= scanner.getLegalLineDelimiters();
- boolean previousWasEscapeCharacter = false;
- while ((c= scanner.read()) != ICharacterScanner.EOF) {
- if (c == fEscapeCharacter) {
- // Skip the escaped character.
- scanner.read();
- } else if (fEndSequence.length > 0 && c == fEndSequence[0]) {
- // Check if the specified end sequence has been found.
- if (sequenceDetected(scanner, fEndSequence, true))
- return true;
- } else if (fBreaksOnEOL) {
- // Check for end of line since it can be used to terminate the pattern.
- for (int i= 0; i < delimiters.length; i++) {
- if (c == delimiters[i][0] && sequenceDetected(scanner, delimiters[i], true)) {
- if (!fEscapeContinuesLine || !previousWasEscapeCharacter)
- return true;
- }
- }
- }
- previousWasEscapeCharacter = (c == fEscapeCharacter);
- }
- if (fBreaksOnEOF) return true;
- scanner.unread();
- return false;
- }
-
- /**
- * Returns whether the next characters to be read by the character scanner
- * are an exact match with the given sequence. No escape characters are allowed
- * within the sequence. If specified the sequence is considered to be found
- * when reading the EOF character.
- *
- * @param scanner the character scanner to be used
- * @param sequence the sequence to be detected
- * @param eofAllowed indicated whether EOF terminates the pattern
- * @return <code>true</code> if the given sequence has been detected
- */
- protected boolean sequenceDetected(ICharacterScanner scanner, char[] sequence, boolean eofAllowed) {
- for (int i= 1; i < sequence.length; i++) {
- int c= scanner.read();
- if (c == ICharacterScanner.EOF && eofAllowed) {
- return true;
- } else if (c != sequence[i]) {
- // Non-matching character detected, rewind the scanner back to the start.
- // Do not unread the first character.
- scanner.unread();
- for (int j= i-1; j > 0; j--)
- scanner.unread();
- return false;
- }
- }
-
- return true;
- }
-
- /*
- * @see IPredicateRule#evaluate(ICharacterScanner, boolean)
- * @since 2.0
- */
- public IToken evaluate(ICharacterScanner scanner, boolean resume) {
- if (fColumn == UNDEFINED)
- return doEvaluate(scanner, resume);
-
- int c= scanner.read();
- scanner.unread();
- if (c == fStartSequence[0])
- return (fColumn == scanner.getColumn() ? doEvaluate(scanner, resume) : Token.UNDEFINED);
- else
- return Token.UNDEFINED;
- }
-
- /*
- * @see IPredicateRule#getSuccessToken()
- * @since 2.0
- */
- public IToken getSuccessToken() {
- return fToken;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedDamagerRepairer.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedDamagerRepairer.java
deleted file mode 100644
index 84f73ba..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedDamagerRepairer.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.rules;
-
-
-import org.eclipse.jface.text.TextAttribute;
-
-
-/**
- * @deprecated use <code>DefaultDamagerRepairer</code>
- */
-public class RuleBasedDamagerRepairer extends DefaultDamagerRepairer {
-
- /**
- * Creates a damager/repairer that uses the given scanner and returns the given default
- * text attribute if the current token does not carry a text attribute.
- *
- * @param scanner the rule based scanner to be used
- * @param defaultTextAttribute the text attribute to be returned if non is specified by the current token,
- * may not be <code>null</code>
- *
- * @deprecated use RuleBasedDamagerRepairer(RuleBasedScanner) instead
- */
- public RuleBasedDamagerRepairer(RuleBasedScanner scanner, TextAttribute defaultTextAttribute) {
- super(scanner, defaultTextAttribute);
- }
-
- /**
- * Creates a damager/repairer that uses the given scanner. The scanner may not be <code>null</code>
- * and is assumed to return only token that carry text attributes.
- *
- * @param scanner the rule based scanner to be used, may not be <code>null</code>
- * @since 2.0
- */
- public RuleBasedDamagerRepairer(RuleBasedScanner scanner) {
- super(scanner);
- }
-}
-
-
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedPartitionScanner.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedPartitionScanner.java
deleted file mode 100644
index 5ce40bc..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedPartitionScanner.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.rules;
-
-
-import org.eclipse.jface.text.IDocument;
-
-
-/**
- * Scanner that exclusively uses predicate rules.
- * @since 2.0
- */
-public class RuleBasedPartitionScanner extends BufferedRuleBasedScanner implements IPartitionTokenScanner {
-
- /** The content type of the partition in which to resume scanning. */
- protected String fContentType;
- /** The offset of the partition inside which to resume. */
- protected int fPartitionOffset;
-
-
- /*
- * @see RuleBasedScanner#setRules(IRule[])
- */
- public void setRules(IRule[] rules) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * @see RuleBasedScanner#setRules(IRule[])
- */
- public void setPredicateRules(IPredicateRule[] rules) {
- super.setRules(rules);
- }
-
- /*
- * @see ITokenScanner#setRange(IDocument, int, int)
- */
- public void setRange(IDocument document, int offset, int length) {
- setPartialRange(document, offset, length, null, -1);
- }
-
- /*
- * @see IPartitionTokenScanner#setPartialRange(IDocument, int, int, String, int)
- */
- public void setPartialRange(IDocument document, int offset, int length, String contentType, int partitionOffset) {
- fContentType= contentType;
- fPartitionOffset= partitionOffset;
- if (partitionOffset > -1) {
- int delta= offset - partitionOffset;
- if (delta > 0) {
- super.setRange(document, partitionOffset, length + delta);
- fOffset= offset;
- return;
- }
- }
- super.setRange(document, offset, length);
- }
-
- /*
- * @see ITokenScanner#nextToken()
- */
- public IToken nextToken() {
-
-
- if (fContentType == null || fRules == null) {
- //don't try to resume
- return super.nextToken();
- }
-
- // inside a partition
-
- fColumn= UNDEFINED;
- boolean resume= (fPartitionOffset > -1 && fPartitionOffset < fOffset);
- fTokenOffset= resume ? fPartitionOffset : fOffset;
-
- IPredicateRule rule;
- IToken token;
-
- for (int i= 0; i < fRules.length; i++) {
- rule= (IPredicateRule) fRules[i];
- token= rule.getSuccessToken();
- if (fContentType.equals(token.getData())) {
- token= rule.evaluate(this, resume);
- if (!token.isUndefined()) {
- fContentType= null;
- return token;
- }
- }
- }
-
- // haven't found any rule for this type of partition
- fContentType= null;
- if (resume)
- fOffset= fPartitionOffset;
- return super.nextToken();
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedPartitioner.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedPartitioner.java
deleted file mode 100644
index 707a67f..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedPartitioner.java
+++ /dev/null
@@ -1,551 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.rules;
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.DefaultPositionUpdater;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.jface.text.IDocumentPartitionerExtension;
-import org.eclipse.jface.text.IDocumentPartitionerExtension2;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TypedPosition;
-import org.eclipse.jface.text.TypedRegion;
-
-
-
-/**
- * A standard implementation of a syntax driven document partitioner.
- * It uses a rule based scanner to scan the document and to determine
- * the document's partitioning. The tokens returned by the rules the
- * scanner is configured with are supposed to return the partition type
- * as their data. The partitioner remembers the document's partitions
- * in the document itself rather than maintaining its own data structure.
- *
- * @see IRule
- * @see RuleBasedScanner
- *
- * @deprecated use <code>DefaultPartitioner</code> instead
- */
-public class RuleBasedPartitioner implements IDocumentPartitioner, IDocumentPartitionerExtension, IDocumentPartitionerExtension2 {
-
- /**
- * The position category this partitioner uses to store the document's partitioning information
- * @deprecated use <code>getManagingPositionCategories()</code>.
- */
- public final static String CONTENT_TYPES_CATEGORY= "__content_types_category"; //$NON-NLS-1$
-
-
- /** The partitioner's scanner */
- protected RuleBasedScanner fScanner;
- /** The legal content types of this partitioner */
- protected String[] fLegalContentTypes;
- /** The partitioner's document */
- protected IDocument fDocument;
- /** The document length before a document change occured */
- protected int fPreviousDocumentLength;
- /** The position updater used to for the default updating of partitions */
- protected DefaultPositionUpdater fPositionUpdater;
- /** The offset at which the first changed partition starts */
- protected int fStartOffset;
- /** The offset at which the last changed partition ends */
- protected int fEndOffset;
- /**The offset at which a partition has been deleted */
- protected int fDeleteOffset;
- /**
- * The position category for managing partitoning information.
- * @since 3.0
- */
- private String fPositionCategory;
-
-
- /**
- * Creates a new partitioner that uses the given scanner and may return
- * partitions of the given legal content types.
- *
- * @param scanner the scanner this partitioner is supposed to use
- * @param legalContentTypes the legal content types of this partitioner
- */
- public RuleBasedPartitioner(RuleBasedScanner scanner, String[] legalContentTypes) {
- fScanner= scanner;
- fLegalContentTypes= legalContentTypes;
- fPositionCategory= CONTENT_TYPES_CATEGORY + hashCode();
- fPositionUpdater= new DefaultPositionUpdater(fPositionCategory);
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentPartitionerExtension2#getManagingPositionCategories()
- * @since 3.0
- */
- public String[] getManagingPositionCategories() {
- return new String[] { fPositionCategory };
- }
-
- /*
- * @see IDocumentPartitioner#connect
- */
- public void connect(IDocument document) {
- Assert.isNotNull(document);
- Assert.isTrue(!document.containsPositionCategory(fPositionCategory));
-
- fDocument= document;
- fDocument.addPositionCategory(fPositionCategory);
-
- initialize();
- }
-
- /**
- * Performs the initial partitioning of the partitioner's document.
- */
- protected void initialize() {
-
- fScanner.setRange(fDocument, 0, fDocument.getLength());
-
- try {
- IToken token= fScanner.nextToken();
- while (!token.isEOF()) {
-
- String contentType= getTokenContentType(token);
-
- if (isSupportedContentType(contentType)) {
- TypedPosition p= new TypedPosition(fScanner.getTokenOffset(), fScanner.getTokenLength(), contentType);
- fDocument.addPosition(fPositionCategory, p);
- }
-
- token= fScanner.nextToken();
- }
- } catch (BadLocationException x) {
- // cannot happen as offsets come from scanner
- } catch (BadPositionCategoryException x) {
- // cannot happen if document has been connected before
- }
- }
-
- /*
- * @see IDocumentPartitioner#disconnect
- */
- public void disconnect() {
-
- Assert.isTrue(fDocument.containsPositionCategory(fPositionCategory));
-
- try {
- fDocument.removePositionCategory(fPositionCategory);
- } catch (BadPositionCategoryException x) {
- // can not happen because of Assert
- }
- }
-
- /*
- * @see IDocumentPartitioner#documentAboutToBeChanged
- */
- public void documentAboutToBeChanged(DocumentEvent e) {
-
- Assert.isTrue(e.getDocument() == fDocument);
-
- fPreviousDocumentLength= e.getDocument().getLength();
- fStartOffset= -1;
- fEndOffset= -1;
- fDeleteOffset= -1;
- }
-
- /*
- * @see IDocumentPartitioner#documentChanged
- */
- public boolean documentChanged(DocumentEvent e) {
- IRegion region= documentChanged2(e);
- return (region != null);
- }
-
- /**
- * Helper method for tracking the minimal region containg all partition changes.
- * If <code>offset</code> is smaller than the remembered offset, <code>offset</code>
- * will from now on be remembered. If <code>offset + length</code> is greater than
- * the remembered end offset, it will be remembered from now on.
- *
- * @param offset the offset
- * @param length the length
- */
- private void rememberRegion(int offset, int length) {
- // remember start offset
- if (fStartOffset == -1)
- fStartOffset= offset;
- else if (offset < fStartOffset)
- fStartOffset= offset;
-
- // remember end offset
- int endOffset= offset + length;
- if (fEndOffset == -1)
- fEndOffset= endOffset;
- else if (endOffset > fEndOffset)
- fEndOffset= endOffset;
- }
-
- /**
- * Remembers the given offset as the deletion offset.
- *
- * @param offset the offset
- */
- private void rememberDeletedOffset(int offset) {
- fDeleteOffset= offset;
- }
-
- /**
- * Creates the minimal region containing all partition changes using the
- * remembered offset, end offset, and deletion offset.
- * @return the minimal region containing all the partition changes
- */
- private IRegion createRegion() {
- if (fDeleteOffset == -1) {
- if (fStartOffset == -1 || fEndOffset == -1)
- return null;
- return new Region(fStartOffset, fEndOffset - fStartOffset);
- } else if (fStartOffset == -1 || fEndOffset == -1) {
- return new Region(fDeleteOffset, 0);
- } else {
- int offset= Math.min(fDeleteOffset, fStartOffset);
- int endOffset= Math.max(fDeleteOffset, fEndOffset);
- return new Region(offset, endOffset - offset);
- }
- }
-
- /*
- * @see IDocumentPartitionerExtension#documentChanged2(DocumentEvent)
- * @since 2.0
- */
- public IRegion documentChanged2(DocumentEvent e) {
-
- try {
-
- IDocument d= e.getDocument();
- Position[] category= d.getPositions(fPositionCategory);
- int first= 0;
- int reparseStart= 0;
- int originalSize= category.length;
-
- if (originalSize > 0) {
-
- /*
- * determine character position at which the scanner starts:
- * first position behind the last non-default partition the actual position is not involved with
- */
-
- first= d.computeIndexInCategory(fPositionCategory, e.getOffset());
-
- Position p= null;
- do {
- --first;
- if (first < 0)
- break;
-
- p= category[first];
-
- } while (p.overlapsWith(e.getOffset(), e.getLength()) ||
- (e.getOffset() == fPreviousDocumentLength &&
- (p.getOffset() + p.getLength() == fPreviousDocumentLength)));
-
- fPositionUpdater.update(e);
- for (int i= 0; i < category.length; i++) {
- p= category[i];
- if (p.isDeleted) {
- rememberDeletedOffset(e.getOffset());
- break;
- }
- }
- category= d.getPositions(fPositionCategory);
-
- if (first >= 0) {
- p= category[first];
- reparseStart= p.getOffset() + p.getLength();
- }
-
- ++first;
- }
-
- fScanner.setRange(d, reparseStart, d.getLength() - reparseStart);
-
- int lastScannedPosition= reparseStart;
- IToken token= fScanner.nextToken();
-
- while (!token.isEOF()) {
-
-
- String contentType= getTokenContentType(token);
-
- if (!isSupportedContentType(contentType)) {
- token= fScanner.nextToken();
- continue;
- }
-
- int start= fScanner.getTokenOffset();
- int length= fScanner.getTokenLength();
-
- lastScannedPosition= start + length - 1;
-
- // remove all affected positions
- while (first < category.length) {
- TypedPosition p= (TypedPosition) category[first];
- if (lastScannedPosition >= p.offset + p.length ||
- (p.overlapsWith(start, length) &&
- (!d.containsPosition(fPositionCategory, start, length) ||
- !contentType.equals(p.getType())))) {
-
- rememberRegion(p.offset, p.length);
- d.removePosition(fPositionCategory, p);
- ++ first;
-
- } else
- break;
- }
-
- // if position already exists we are done
- if (d.containsPosition(fPositionCategory, start, length))
- return createRegion();
-
- // insert the new type position
- try {
- d.addPosition(fPositionCategory, new TypedPosition(start, length, contentType));
- rememberRegion(start, length);
- } catch (BadPositionCategoryException x) {
- } catch (BadLocationException x) {
- }
-
- token= fScanner.nextToken();
- }
-
-
- // remove all positions behind lastScannedPosition since there aren't any further types
- if (lastScannedPosition != reparseStart) {
- // if this condition is not met, nothing has been scanned because of a delete
- ++ lastScannedPosition;
- }
- first= d.computeIndexInCategory(fPositionCategory, lastScannedPosition);
-
- TypedPosition p;
- while (first < category.length) {
- p= (TypedPosition) category[first++];
- d.removePosition(fPositionCategory, p);
- rememberRegion(p.offset, p.length);
- }
-
- } catch (BadPositionCategoryException x) {
- // should never happen on connected documents
- } catch (BadLocationException x) {
- }
-
- return createRegion();
- }
-
-
- /**
- * Returns the position in the partitoner's position category which is
- * close to the given offset. This is, the position has either an offset which
- * is the same as the given offset or an offset which is smaller than the given
- * offset. This method profits from the knowledge that a partitioning is
- * a ordered set of disjoint position.
- *
- * @param offset the offset for which to search the closest position
- * @return the closest position in the partitioner's category
- */
- protected TypedPosition findClosestPosition(int offset) {
-
- try {
-
- int index= fDocument.computeIndexInCategory(fPositionCategory, offset);
- Position[] category= fDocument.getPositions(fPositionCategory);
-
- if (category.length == 0)
- return null;
-
- if (index < category.length) {
- if (offset == category[index].offset)
- return (TypedPosition) category[index];
- }
-
- if (index > 0)
- index--;
-
- return (TypedPosition) category[index];
-
- } catch (BadPositionCategoryException x) {
- } catch (BadLocationException x) {
- }
-
- return null;
- }
-
-
- /*
- * @see IDocumentPartitioner#getContentType
- */
- public String getContentType(int offset) {
-
- TypedPosition p= findClosestPosition(offset);
- if (p != null && p.includes(offset))
- return p.getType();
-
- return IDocument.DEFAULT_CONTENT_TYPE;
- }
-
- /*
- * @see IDocumentPartitioner#getPartition
- */
- public ITypedRegion getPartition(int offset) {
-
- try {
-
- Position[] category = fDocument.getPositions(fPositionCategory);
-
- if (category == null || category.length == 0)
- return new TypedRegion(0, fDocument.getLength(), IDocument.DEFAULT_CONTENT_TYPE);
-
- int index= fDocument.computeIndexInCategory(fPositionCategory, offset);
-
- if (index < category.length) {
-
- TypedPosition next= (TypedPosition) category[index];
-
- if (offset == next.offset)
- return new TypedRegion(next.getOffset(), next.getLength(), next.getType());
-
- if (index == 0)
- return new TypedRegion(0, next.offset, IDocument.DEFAULT_CONTENT_TYPE);
-
- TypedPosition previous= (TypedPosition) category[index - 1];
- if (previous.includes(offset))
- return new TypedRegion(previous.getOffset(), previous.getLength(), previous.getType());
-
- int endOffset= previous.getOffset() + previous.getLength();
- return new TypedRegion(endOffset, next.getOffset() - endOffset, IDocument.DEFAULT_CONTENT_TYPE);
- }
-
- TypedPosition previous= (TypedPosition) category[category.length - 1];
- if (previous.includes(offset))
- return new TypedRegion(previous.getOffset(), previous.getLength(), previous.getType());
-
- int endOffset= previous.getOffset() + previous.getLength();
- return new TypedRegion(endOffset, fDocument.getLength() - endOffset, IDocument.DEFAULT_CONTENT_TYPE);
-
- } catch (BadPositionCategoryException x) {
- } catch (BadLocationException x) {
- }
-
- return new TypedRegion(0, fDocument.getLength(), IDocument.DEFAULT_CONTENT_TYPE);
- }
-
- /*
- * @see IDocumentPartitioner#computePartitioning
- */
- public ITypedRegion[] computePartitioning(int offset, int length) {
-
- List list= new ArrayList();
-
- try {
-
- int endOffset= offset + length;
-
- Position[] category= fDocument.getPositions(fPositionCategory);
-
- TypedPosition previous= null, current= null;
- int start, end, gapOffset;
- Position gap= null;
-
- for (int i= 0; i < category.length; i++) {
-
- current= (TypedPosition) category[i];
-
- gapOffset= (previous != null) ? previous.getOffset() + previous.getLength() : 0;
- gap= new Position(gapOffset, current.getOffset() - gapOffset);
- if (gap.getLength() > 0 && gap.overlapsWith(offset, length)) {
- start= Math.max(offset, gapOffset);
- end= Math.min(endOffset, gap.getOffset() + gap.getLength());
- list.add(new TypedRegion(start, end - start, IDocument.DEFAULT_CONTENT_TYPE));
- }
-
- if (current.overlapsWith(offset, length)) {
- start= Math.max(offset, current.getOffset());
- end= Math.min(endOffset, current.getOffset() + current.getLength());
- list.add(new TypedRegion(start, end - start, current.getType()));
- }
-
- previous= current;
- }
-
- if (previous != null) {
- gapOffset= previous.getOffset() + previous.getLength();
- gap= new Position(gapOffset, fDocument.getLength() - gapOffset);
- if (gap.getLength() > 0 && gap.overlapsWith(offset, length)) {
- start= Math.max(offset, gapOffset);
- end= Math.min(endOffset, fDocument.getLength());
- list.add(new TypedRegion(start, end - start, IDocument.DEFAULT_CONTENT_TYPE));
- }
- }
-
- if (list.isEmpty())
- list.add(new TypedRegion(offset, length, IDocument.DEFAULT_CONTENT_TYPE));
-
- } catch (BadPositionCategoryException x) {
- }
-
- TypedRegion[] result= new TypedRegion[list.size()];
- list.toArray(result);
- return result;
- }
-
- /*
- * @see IDocumentPartitioner#getLegalContentTypes
- */
- public String[] getLegalContentTypes() {
- return fLegalContentTypes;
- }
-
- /**
- * Returns whether the given type is one of the legal content types.
- *
- * @param contentType the content type to check
- * @return <code>true</code> if the content type is a legal content type
- */
- protected boolean isSupportedContentType(String contentType) {
- if (contentType != null) {
- for (int i= 0; i < fLegalContentTypes.length; i++) {
- if (fLegalContentTypes[i].equals(contentType))
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Returns a content type encoded in the given token. If the token's
- * data is not <code>null</code> and a string it is assumed that
- * it is the encoded content type.
- *
- * @param token the token whose content type is to be determined
- * @return the token's content type
- */
- protected String getTokenContentType(IToken token) {
- Object data= token.getData();
- if (data instanceof String)
- return (String) data;
- return null;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedScanner.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedScanner.java
deleted file mode 100644
index e2517f8..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedScanner.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.rules;
-
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-
-
-/**
- * A generic scanner which can be "programmed" with a sequence of rules.
- * The scanner is used to get the next token by evaluating its rule in sequence until
- * one is successful. If a rule returns a token which is undefined, the scanner will proceed to
- * the next rule. Otherwise the token provided by the rule will be returned by
- * the scanner. If no rule returned a defined token, this scanner returns a token
- * which returns <code>true</code> when calling <code>isOther</code>, unless the end
- * of the file is reached. In this case the token returns <code>true</code> when calling
- * <code>isEOF</code>.
- *
- * @see IRule
- */
-public class RuleBasedScanner implements ICharacterScanner, ITokenScanner {
-
- /** The list of rules of this scanner */
- protected IRule[] fRules;
- /** The token to be returned by default if no rule fires */
- protected IToken fDefaultReturnToken;
- /** The document to be scanned */
- protected IDocument fDocument;
- /** The cached legal line delimiters of the document */
- protected char[][] fDelimiters;
- /** The offset of the next character to be read */
- protected int fOffset;
- /** The end offset of the range to be scanned */
- protected int fRangeEnd;
- /** The offset of the last read token */
- protected int fTokenOffset;
- /** The cached column of the current scanner position */
- protected int fColumn;
- /** Internal setting for the uninitialized column cache. */
- protected static final int UNDEFINED= -1;
-
- /**
- * Creates a new rule based scanner which does not have any rule.
- */
- public RuleBasedScanner() {
- }
-
- /**
- * Configures the scanner with the given sequence of rules.
- *
- * @param rules the sequence of rules controlling this scanner
- */
- public void setRules(IRule[] rules) {
- fRules= rules;
- }
-
- /**
- * Configures the scanner's default return token. This is the token
- * which is returned when non of the rules fired and EOF has not been
- * reached.
- *
- * @param token the default return token
- * @since 2.0
- */
- public void setDefaultReturnToken(IToken defaultReturnToken) {
- Assert.isNotNull(defaultReturnToken.getData());
- fDefaultReturnToken= defaultReturnToken;
- }
-
- /*
- * @see ITokenScanner#setRange(IDocument, int, int)
- */
- public void setRange(IDocument document, int offset, int length) {
-
- fDocument= document;
- fOffset= offset;
- fColumn= UNDEFINED;
- fRangeEnd= Math.min(fDocument.getLength(), offset + length);
-
- String[] delimiters= fDocument.getLegalLineDelimiters();
- fDelimiters= new char[delimiters.length][];
- for (int i= 0; i < delimiters.length; i++)
- fDelimiters[i]= delimiters[i].toCharArray();
-
- if (fDefaultReturnToken == null)
- fDefaultReturnToken= new Token(null);
- }
-
- /*
- * @see ITokenScanner#getTokenOffset()
- */
- public int getTokenOffset() {
- return fTokenOffset;
- }
-
- /*
- * @see ITokenScanner#getTokenLength()
- */
- public int getTokenLength() {
- if (fOffset < fRangeEnd)
- return fOffset - getTokenOffset();
- return fRangeEnd - getTokenOffset();
- }
-
-
- /*
- * @see ICharacterScanner#getColumn()
- */
- public int getColumn() {
- if (fColumn == UNDEFINED) {
- try {
- int line= fDocument.getLineOfOffset(fOffset);
- int start= fDocument.getLineOffset(line);
-
- fColumn= fOffset - start;
-
- } catch (BadLocationException ex) {
- }
- }
- return fColumn;
- }
-
- /*
- * @see ICharacterScanner#getLegalLineDelimiters()
- */
- public char[][] getLegalLineDelimiters() {
- return fDelimiters;
- }
-
- /*
- * @see ITokenScanner#nextToken()
- */
- public IToken nextToken() {
-
- IToken token;
-
- while (true) {
-
- fTokenOffset= fOffset;
- fColumn= UNDEFINED;
-
- if (fRules != null) {
- for (int i= 0; i < fRules.length; i++) {
- token= (fRules[i].evaluate(this));
- if (!token.isUndefined())
- return token;
- }
- }
-
- if (read() == EOF)
- return Token.EOF;
- else
- return fDefaultReturnToken;
- }
- }
-
- /*
- * @see ICharacterScanner#read()
- */
- public int read() {
-
- try {
-
- if (fOffset < fRangeEnd) {
- try {
- return fDocument.getChar(fOffset);
- } catch (BadLocationException e) {
- }
- }
-
- return EOF;
-
- } finally {
- ++ fOffset;
- fColumn= UNDEFINED;
- }
- }
-
- /*
- * @see ICharacterScanner#unread()
- */
- public void unread() {
- --fOffset;
- }
-}
-
-
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/SingleLineRule.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/SingleLineRule.java
deleted file mode 100644
index 85946f5..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/SingleLineRule.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Christopher Lenz (cmlenz@gmx.de) - support for line continuation
- *******************************************************************************/
-package org.eclipse.jface.text.rules;
-
-
-/**
- * A specific configuration of pattern rule whereby
- * the pattern begins with a specific sequence and may
- * end with a specific sequence, but will not span more
- * than a single line.
- */
-public class SingleLineRule extends PatternRule {
-
- /**
- * Creates a rule for the given starting and ending sequence
- * which, if detected, will return the specified token.
- *
- * @param startSequence the pattern's start sequence
- * @param token the token to be returned on success
- */
- public SingleLineRule(String startSequence, String endSequence, IToken token) {
- this(startSequence, endSequence, token, (char) 0);
- }
-
- /**
- * Creates a rule for the given starting and ending sequence
- * which, if detected, will return the specified token.
- * Any character which follows the given escape character
- * will be ignored.
- *
- * @param startSequence the pattern's start sequence
- * @param endSequence the pattern's end sequence
- * @param token the token to be returned on success
- * @param escapeCharacter the escape character
- */
- public SingleLineRule(String startSequence, String endSequence, IToken token, char escapeCharacter) {
- this(startSequence, endSequence, token, escapeCharacter, false);
- }
-
- /**
- * Creates a rule for the given starting and ending sequence
- * which, if detected, will return the specified token. Alternatively, the
- * line can also be ended with the end of the file.
- * Any character which follows the given escape character
- * will be ignored.
- *
- * @param startSequence the pattern's start sequence
- * @param endSequence the pattern's end sequence
- * @param token the token to be returned on success
- * @param escapeCharacter the escape character
- * @param breaksOnEOF indicates whether the end of the file successfully terminates this rule
- * @since 2.1
- */
- public SingleLineRule(String startSequence, String endSequence, IToken token, char escapeCharacter, boolean breaksOnEOF) {
- super(startSequence, endSequence, token, escapeCharacter, true, breaksOnEOF);
- }
-
- /**
- * Creates a rule for the given starting and ending sequence
- * which, if detected, will return the specified token. Alternatively, the
- * line can also be ended with the end of the file.
- * Any character which follows the given escape character
- * will be ignored. In addition, an escape character immediately before an
- * end of line can be set to continue the line.
- *
- * @param startSequence the pattern's start sequence
- * @param endSequence the pattern's end sequence
- * @param token the token to be returned on success
- * @param escapeCharacter the escape character
- * @param breaksOnEOF indicates whether the end of the file successfully terminates this rule
- * @param escapeContinuesLine indicates whether the specified escape character is used for line
- * continuation, so that an end of line immediately after the escape character does not
- * terminate the line, even if <code>breakOnEOL</code> is true
- * @since 3.0
- */
- public SingleLineRule(String startSequence, String endSequence, IToken token, char escapeCharacter, boolean breaksOnEOF, boolean escapeContinuesLine) {
- super(startSequence, endSequence, token, escapeCharacter, true, breaksOnEOF, escapeContinuesLine);
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/Token.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/Token.java
deleted file mode 100644
index 1fd18cf..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/Token.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.rules;
-
-import org.eclipse.jface.text.Assert;
-
-
-/**
- * Standard implementation of <code>IToken</code>.
- */
-public class Token implements IToken {
-
- /** Internal token type: Undefined */
- private static final int T_UNDEFINED= 0;
- /** Internal token type: EOF */
- private static final int T_EOF= 1;
- /** Internal token type: Whitespace */
- private static final int T_WHITESPACE= 2;
- /** Internal token type: Others */
- private static final int T_OTHER= 3;
-
-
- /**
- * Standard token: Undefined.
- */
- public static final IToken UNDEFINED= new Token(T_UNDEFINED);
- /**
- * Standard token: End Of File.
- */
- public static final IToken EOF= new Token(T_EOF);
- /**
- * Standard token: Whitespace.
- */
- public static final IToken WHITESPACE= new Token(T_WHITESPACE);
-
- /**
- * Standard token: Neither Undefine, Whitespace, nor End Of File.
- * @deprecated will be removed
- */
- public static final IToken OTHER= new Token(T_OTHER);
-
- /** The type of this token */
- private int fType;
- /** The data associated with this token */
- private Object fData;
-
- /**
- * Creates a new token according to the given specification which does not
- * have any data attached to it.
- *
- * @param type the type of the token
- * @since 2.0
- */
- private Token(int type) {
- fType= type;
- fData= null;
- }
-
- /**
- * Creates a new token which represents neither undefined, whitespace, nor EOF.
- * The newly created token has the given data attached to it.
- *
- * @param data the data attached to the newly created token
- */
- public Token(Object data) {
- fType= T_OTHER;
- fData= data;
- }
-
- /**
- * Reinitializes the data of this token. The token may not represent
- * undefined, whitepsace, or EOF.
- *
- * @param the data to be attached to the token
- * @since 2.0
- */
- public void setData(Object data) {
- Assert.isTrue(isOther());
- fData= data;
- }
-
- /*
- * @see IToken#getData()
- */
- public Object getData() {
- return fData;
- }
-
- /*
- * @see IToken#isOther()
- */
- public boolean isOther() {
- return (fType == T_OTHER);
- }
-
- /*
- * @see IToken#isEOF()
- */
- public boolean isEOF() {
- return (fType == T_EOF);
- }
-
- /*
- * @see IToken#isWhitespace()
- */
- public boolean isWhitespace() {
- return (fType == T_WHITESPACE);
- }
-
- /*
- * @see IToken#isUndefined()
- */
- public boolean isUndefined() {
- return (fType == T_UNDEFINED);
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/WhitespaceRule.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/WhitespaceRule.java
deleted file mode 100644
index 7fc02d3..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/WhitespaceRule.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.rules;
-
-
-import org.eclipse.jface.text.Assert;
-
-
-/**
- * An implementation of <code>IRule</code> capable of detecting whitespace.
- * A whitespace rule uses a whitespace detector in order to find out which
- * characters are whitespace characters.
- *
- * @see IWhitespaceDetector
- */
-public class WhitespaceRule implements IRule {
-
- /** The whitespace detector used by this rule */
- protected IWhitespaceDetector fDetector;
-
- /**
- * Creates a rule which, with the help of an
- * whitespace detector, will return a whitespace
- * token when a whitespace is detected.
- *
- * @param detector the rule's whitespace detector, may not be <code>null</code>
- */
- public WhitespaceRule(IWhitespaceDetector detector) {
- Assert.isNotNull(detector);
- fDetector= detector;
- }
-
- /*
- * @see IRule#evaluate(ICharacterScanner)
- */
- public IToken evaluate(ICharacterScanner scanner) {
- int c= scanner.read();
- if (fDetector.isWhitespace((char) c)) {
- do {
- c= scanner.read();
- } while (fDetector.isWhitespace((char) c));
- scanner.unread();
- return Token.WHITESPACE;
- } else {
- scanner.unread();
- return Token.UNDEFINED;
- }
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/WordPatternRule.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/WordPatternRule.java
deleted file mode 100644
index ee09cbe..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/WordPatternRule.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.rules;
-
-
-import org.eclipse.jface.text.Assert;
-
-
-
-/**
- * A specific single line rule which stipulates that the start
- * and end sequence occur within a single word, as defined by a word detector.
- *
- * @see IWordDetector
- */
-public class WordPatternRule extends SingleLineRule {
-
- /** The word detector used by this rule */
- protected IWordDetector fDetector;
- /** The internal buffer used for pattern detection */
- private StringBuffer fBuffer= new StringBuffer();
-
- /**
- * Creates a rule for the given starting and ending word
- * pattern which, if detected, will return the specified token.
- * A word detector is used to identify words.
- *
- * @param detected the word detector to be used
- * @param startSequence the start sequence of the word pattern
- * @param endSequence the end sequence of the word pattern
- * @param token the token to be returned on success
- */
- public WordPatternRule(IWordDetector detector, String startSequence, String endSequence, IToken token) {
- this(detector, startSequence, endSequence, token, (char)0);
- }
-
- /**
- /**
- * Creates a rule for the given starting and ending word
- * pattern which, if detected, will return the specified token.
- * A word detector is used to identify words.
- * Any character which follows the given escapeCharacter will be ignored.
- *
- * @param detected the word detector to be used
- * @param startSequence the start sequence of the word pattern
- * @param endSequence the end sequence of the word pattern
- * @param token the token to be returned on success
- * @param escapeCharacter the escape character
- */
- public WordPatternRule(IWordDetector detector, String startSequence, String endSequence, IToken token, char escapeCharacter) {
- super(startSequence, endSequence, token, escapeCharacter);
- Assert.isNotNull(detector);
- fDetector= detector;
- }
-
- /**
- * Returns whether the end sequence was detected.
- * The rule acquires the rest of the word, using the
- * provided word detector, and tests to determine if
- * it ends with the end sequence.
- *
- * @param scanner the scanner to be used
- * @return <code>true</code> if the word ends on the given end sequence
- */
- protected boolean endSequenceDetected(ICharacterScanner scanner) {
- fBuffer.setLength(0);
- int c= scanner.read();
- while (fDetector.isWordPart((char) c)) {
- fBuffer.append((char) c);
- c= scanner.read();
- }
- scanner.unread();
-
- if (fBuffer.length() >= fEndSequence.length) {
- for (int i=fEndSequence.length - 1, j= fBuffer.length() - 1; i >= 0; i--, j--) {
- if (fEndSequence[i] != fBuffer.charAt(j)) {
- unreadBuffer(scanner);
- return false;
- }
- }
- return true;
- }
-
- unreadBuffer(scanner);
- return false;
- }
-
- /**
- * Returns the characters in the buffer to the scanner.
- * Note that the rule must also return the characters
- * read in as part of the start sequence expect the first one.
- *
- * @param scanner the scanner to be used
- */
- protected void unreadBuffer(ICharacterScanner scanner) {
- fBuffer.insert(0, fStartSequence);
- for (int i= fBuffer.length() - 1; i > 0; i--)
- scanner.unread();
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/WordRule.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/WordRule.java
deleted file mode 100644
index 6d162d2..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/WordRule.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.rules;
-
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.jface.text.Assert;
-
-
-/**
- * An implementation of <code>IRule</code> capable of detecting words
- * Word rules also allow for the association of tokens with specific words.
- * That is, not only can the rule be used to provide tokens for exact matches,
- * but also for the generalized notion of a word in the context in which it is used.
- * A word rules uses a word detector to determine what a word is.
- *
- * @see IWordDetector
- */
-public class WordRule implements IRule {
-
- /** Internal setting for the uninitialized column constraint */
- protected static final int UNDEFINED= -1;
-
- /** The word detector used by this rule */
- protected IWordDetector fDetector;
- /** The default token to be returned on success and if nothing else has been specified. */
- protected IToken fDefaultToken;
- /** The column constraint */
- protected int fColumn= UNDEFINED;
- /** The table of predefined words and token for this rule */
- protected Map fWords= new HashMap();
- /** Buffer used for pattern detection */
- private StringBuffer fBuffer= new StringBuffer();
-
- /**
- * Creates a rule which, with the help of an word detector, will return the token
- * associated with the detected word. If no token has been associated, the scanner
- * will be rolled back and an undefined token will be returned in order to allow
- * any subsequent rules to analyze the characters.
- *
- * @param detector the word detector to be used by this rule, may not be <code>null</code>
- *
- * @see #addWord
- */
- public WordRule(IWordDetector detector) {
- this(detector, Token.UNDEFINED);
- }
-
- /**
- * Creates a rule which, with the help of an word detector, will return the token
- * associated with the detected word. If no token has been associated, the
- * specified default token will be returned.
- *
- * @param detector the word detector to be used by this rule, may not be <code>null</code>
- * @param defaultToken the default token to be returned on success
- * if nothing else is specified, may not be <code>null</code>
- *
- * @see #addWord
- */
- public WordRule(IWordDetector detector, IToken defaultToken) {
-
- Assert.isNotNull(detector);
- Assert.isNotNull(defaultToken);
-
- fDetector= detector;
- fDefaultToken= defaultToken;
- }
-
- /**
- * Adds a word and the token to be returned if it is detected.
- *
- * @param word the word this rule will search for, may not be <code>null</code>
- * @param token the token to be returned if the word has been found, may not be <code>null</code>
- */
- public void addWord(String word, IToken token) {
- Assert.isNotNull(word);
- Assert.isNotNull(token);
-
- fWords.put(word, token);
- }
-
- /**
- * Sets a column constraint for this rule. If set, the rule's token
- * will only be returned if the pattern is detected starting at the
- * specified column. If the column is smaller then 0, the column
- * constraint is considered removed.
- *
- * @param column the column in which the pattern starts
- */
- public void setColumnConstraint(int column) {
- if (column < 0)
- column= UNDEFINED;
- fColumn= column;
- }
-
- /*
- * @see IRule#evaluate(ICharacterScanner)
- */
- public IToken evaluate(ICharacterScanner scanner) {
- int c= scanner.read();
- if (fDetector.isWordStart((char) c)) {
- if (fColumn == UNDEFINED || (fColumn == scanner.getColumn() - 1)) {
-
- fBuffer.setLength(0);
- do {
- fBuffer.append((char) c);
- c= scanner.read();
- } while (c != ICharacterScanner.EOF && fDetector.isWordPart((char) c));
- scanner.unread();
-
- IToken token= (IToken) fWords.get(fBuffer.toString());
- if (token != null)
- return token;
-
- if (fDefaultToken.isUndefined())
- unreadBuffer(scanner);
-
- return fDefaultToken;
- }
- }
-
- scanner.unread();
- return Token.UNDEFINED;
- }
-
- /**
- * Returns the characters in the buffer to the scanner.
- *
- * @param scanner the scanner to be used
- */
- protected void unreadBuffer(ICharacterScanner scanner) {
- for (int i= fBuffer.length() - 1; i >= 0; i--)
- scanner.unread();
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/package.html b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/package.html
deleted file mode 100644
index 253c053..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/package.html
+++ /dev/null
@@ -1,21 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="Author" content="IBM">
- <meta name="GENERATOR" content="Mozilla/4.51 [en] (WinNT; I) [Netscape]">
- <title>Package-level Javadoc</title>
-</head>
-<body>
-Provides a framework for rule based text scanning
-and uses the framework to provide rule-driven default implementations of
-<tt>IPresentationDamager</tt>, <tt>IPresentationRepairer</tt> and <tt>IDocumentPartitioner</tt>.
-<h2>
-Package Specification</h2>
-<tt>RuleBasedScanner</tt> is a document-based scanner controlled by <tt>IRule</tt>
-objects. When evaluated an <tt>IRule</tt> always returns an <tt>IToken</tt>.
-The package provides a set of rules whereby <tt>PatternRule</tt> is the
-most important one. <tt>PatternRule</tt> defines a pattern-configurable
-rule.
-</body>
-</html>
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/Annotation.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/Annotation.java
deleted file mode 100644
index 28f48d4..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/Annotation.java
+++ /dev/null
@@ -1,260 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.source;
-
-
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.FontMetrics;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Canvas;
-
-/**
- * Annotation managed by an <code>IAnnotationModel</code>.
- * Annotations are considered being located at layers and are considered being painted
- * starting with layer 0 upwards. Thus an annotation of layer 5 will be drawn on top of
- * all co-located annotations at the layers 4 - 0. Subclasses must provide the annotations
- * paint method.
- *
- * @see IVerticalRuler
- */
-public class Annotation {
-
- public final static String TYPE_UNKNOWN= "org.eclipse.text.annotation.unknown"; //$NON-NLS-1$
-
- /**
- * Convenience method for drawing an image aligned inside a rectangle.
- *
- * @param image the image to be drawn
- * @param GC the drawing GC
- * @param canvas the canvas on which to draw
- * @param r the clipping rectangle
- * @param halign the horizontal alignment of the image to be drawn
- * @param valign the vertical alignment of the image to be drawn
- */
- protected static void drawImage(Image image, GC gc, Canvas canvas, Rectangle r, int halign, int valign) {
- if (image != null) {
-
- Rectangle bounds= image.getBounds();
-
- int x= 0;
- switch(halign) {
- case SWT.LEFT:
- break;
- case SWT.CENTER:
- x= (r.width - bounds.width) / 2;
- break;
- case SWT.RIGHT:
- x= r.width - bounds.width;
- break;
- }
-
- int y= 0;
- switch (valign) {
- case SWT.TOP: {
- FontMetrics fontMetrics= gc.getFontMetrics();
- y= (fontMetrics.getHeight() - bounds.height)/2;
- break;
- }
- case SWT.CENTER:
- y= (r.height - bounds.height) / 2;
- break;
- case SWT.BOTTOM: {
- FontMetrics fontMetrics= gc.getFontMetrics();
- y= r.height - (fontMetrics.getHeight() + bounds.height)/2;
- break;
- }
- }
-
- gc.drawImage(image, r.x+x, r.y+y);
- }
- }
-
- /**
- * Convenience method for drawing an image aligned inside a rectangle.
- *
- * @param image the image to be drawn
- * @param GC the drawing GC
- * @param canvas the canvas on which to draw
- * @param r the clipping rectangle
- * @param align the alignment of the image to be drawn
- */
- protected static void drawImage(Image image, GC gc, Canvas canvas, Rectangle r, int align) {
- drawImage(image, gc, canvas, r, align, SWT.CENTER);
- }
-
-
-
- /** The layer of this annotation. */
- private int fLayer;
- /**
- * The type of this annotation.
- * @since 3.0
- */
- private String fType;
- /**
- * Indicates whether this annotation is persistent or not.
- * @since 3.0
- */
- private boolean fIsPersistent= false;
- /**
- * Indicates whether this annotation is marked as deleted or not.
- * @since 3.0
- */
- private boolean fMarkedAsDeleted= false;
- /**
- * The text associated with this annotation.
- * @since 3.0
- */
- private String fText;
-
-
-
- /**
- * Creates a new annotation that is not persistent and type less.
- */
- protected Annotation() {
- this(null, false, null);
- }
-
- /**
- * Creates a new annotation with the given properties.
- *
- * @param type the type of this annotation
- * @param isPersistent <code>true</code> if this annotation is
- * persistent, <code>false</code> otherwise
- * @param text the text associated with this annotation
- * @since 3.0
- */
- public Annotation(String type, boolean isPersistent, String text) {
- fType= type;
- fIsPersistent= isPersistent;
- fText= text;
- }
-
- /**
- * Creates a new annotation.
- *
- * @param isPersistent <code>true</code> if persistent, <code>false</code> otherwise
- * @since 3.0
- */
- public Annotation(boolean isPersistent) {
- this(null, isPersistent, null);
- }
-
- /**
- * Returns whether this annotation is persistent.
- *
- * @return <code>true</code> if this annotation is persistent, <code>false</code>
- * otherwise
- * @since 3.0
- */
- public boolean isPersistent() {
- return fIsPersistent;
- }
-
- /**
- * Sets the type of this annotation.
- *
- * @param type the annotation type
- * @since 3.0
- */
- public void setType(String type) {
- fType= type;
- }
-
- /**
- * Returns the type of the annotation.
- *
- * @return the type of the annotation
- * @since 3.0
- */
- public String getType() {
- return fType == null? TYPE_UNKNOWN : fType;
- }
-
- /**
- * Marks this annotation deleted according to the value of the
- * <code>deleted</code> parameter.
- *
- * @param deleted <code>true</code> if annotation should be marked as deleted
- * @since 3.0
- */
- public void markDeleted(boolean deleted) {
- fMarkedAsDeleted= deleted;
- }
-
- /**
- * Returns whether this annotation is marked as deleted.
- *
- * @return <code>true</code> if annotation is marked as deleted, <code>false</code>
- * otherwise
- * @since 3.0
- */
- public boolean isMarkedDeleted() {
- return fMarkedAsDeleted;
- }
-
- /**
- * Sets the text associated with this annotation.
- *
- * @param text the text associated with this annotation
- * @since 3.0
- */
- public void setText(String text) {
- fText= text;
- }
-
- /**
- * Returns the text associated with this annotation.
- *
- * @return the text associated with this annotation or <code>null</code>
- * @since 3.0
- */
- public String getText() {
- return fText;
- }
-
- /**
- * Sets the layer of this annotation.
- *
- * @param layer the layer of this annotation
- * @deprecated since 3.0
- */
- protected void setLayer(int layer) {
- fLayer= layer;
- }
-
- /**
- * Returns the annotations drawing layer.
- *
- * @return the annotations drawing layer
- * @deprecated use <code>IAnnotationAccessExtension.getLayer(Annotation)</code>
- */
- public int getLayer() {
- return fLayer;
- }
-
- /**
- * Implement this method to draw a graphical representation
- * of this annotation within the given bounds. This default implementation
- * does nothing.
- *
- * @param GC the drawing GC
- * @param canvas the canvas to draw on
- * @param bounds the bounds inside the canvas to draw on
- * @deprecated use <code>IAnnotationAccessExtension.paint(Annotation, GC, Canvas, Rectangle)</code>
- */
- public void paint(GC gc, Canvas canvas, Rectangle bounds) {
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationBarHoverManager.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationBarHoverManager.java
deleted file mode 100644
index a228014..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationBarHoverManager.java
+++ /dev/null
@@ -1,476 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.source;
-
-
-import java.util.Iterator;
-
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.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.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.MouseMoveListener;
-import org.eclipse.swt.events.MouseTrackAdapter;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Control;
-
-import org.eclipse.jface.text.AbstractHoverInformationControlManager;
-import org.eclipse.jface.text.AbstractInformationControlManager;
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IInformationControl;
-import org.eclipse.jface.text.IInformationControlCreator;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.ITextViewerExtension5;
-
-
-/**
- * This manager controls the layout, content, and visibility of an information
- * control in reaction to mouse hover events issued by the vertical ruler of a
- * source viewer.
- * @since 2.0
- */
-public class AnnotationBarHoverManager extends AbstractHoverInformationControlManager {
-
- /**
- * The 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.
- */
- protected class Closer extends MouseTrackAdapter
- implements IInformationControlCloser, MouseListener, MouseMoveListener, ControlListener, KeyListener, DisposeListener {
-
- /** The closer's subject control */
- private Control fSubjectControl;
- /** The subject area */
- private Rectangle fSubjectArea;
- /** Indicates whether this closer is active */
- private boolean fIsActive= false;
- /** The information control. */
- private IInformationControl fInformationControl;
- boolean fIsInformationListener;
-
- /**
- * 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) {
- fInformationControl= control;
- }
-
- /*
- * @see IInformationControlCloser#start(Rectangle)
- */
- public void start(Rectangle subjectArea) {
-
- if (fIsActive) return;
- fIsActive= true;
-
- fSubjectArea= subjectArea;
-
- fInformationControl.addDisposeListener(this);
- if (fSubjectControl != null && !fSubjectControl.isDisposed()) {
- fSubjectControl.addMouseListener(this);
- fSubjectControl.addMouseMoveListener(this);
- fSubjectControl.addMouseTrackListener(this);
- }
-
- // install control and key listeners on subject control in any case
- if (fSubjectControl != null && !fSubjectControl.isDisposed()) {
- 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);
- }
-
- if (fSubjectControl != null && !fSubjectControl.isDisposed()) {
- 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) {
- if (!fAllowMouseExit)
- 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);
- }
-
- /*
- * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent)
- */
- public void widgetDisposed(DisposeEvent e) {
- stop();
- }
- }
-
- /** The source viewer the manager is connected to */
- private ISourceViewer fSourceViewer;
- /** The vertical ruler the manager is registered with */
- private IVerticalRulerInfo fVerticalRulerInfo;
- /** The annotation hover the manager uses to retrieve the information to display */
- private IAnnotationHover fAnnotationHover;
- protected boolean fAllowMouseExit= false;
-
- /**
- * Creates an annotation hover manager with the given parameters. In addition,
- * the hovers anchor is RIGHT and the margin is 5 points to the right.
- *
- * @param sourceViewer the source viewer this manager connects to
- * @param ruler the vertical ruler this manager connects to
- * @param annotationHover the annotation hover providing the information to be displayed
- * @param creator the information control creator
- * @deprecated As of 2.1, replaced by {@link AnnotationBarHoverManager#AnnotationBarHoverManager(IVerticalRulerInfo, ISourceViewer, IAnnotationHover, IInformationControlCreator)}
- */
- public AnnotationBarHoverManager(ISourceViewer sourceViewer, IVerticalRuler ruler, IAnnotationHover annotationHover, IInformationControlCreator creator) {
- this(ruler, sourceViewer, annotationHover, creator);
- }
-
- /**
- * Creates an annotation hover manager with the given parameters. In addition,
- * the hovers anchor is RIGHT and the margin is 5 points to the right.
- *
- * @param rulerInfo the vertical ruler this manager connects to
- * @param sourceViewer the source viewer this manager connects to
- * @param annotationHover the annotation hover providing the information to be displayed
- * @param creator the information control creator
- * @since 2.1
- */
- public AnnotationBarHoverManager(IVerticalRulerInfo rulerInfo, ISourceViewer sourceViewer, IAnnotationHover annotationHover, IInformationControlCreator creator) {
- super(creator);
-
- Assert.isNotNull(sourceViewer);
- Assert.isNotNull(annotationHover);
-
- fSourceViewer= sourceViewer;
- fVerticalRulerInfo= rulerInfo;
- fAnnotationHover= annotationHover;
-
- setAnchor(ANCHOR_RIGHT);
- setMargins(5, 0);
- setCloser(new Closer());
- }
-
- /*
- * @see AbstractHoverInformationControlManager#computeInformation()
- */
- protected void computeInformation() {
- fAllowMouseExit= false;
- MouseEvent event= getHoverEvent();
- IAnnotationHover hover= getHover(event);
-
- int line= getHoverLine(event);
-
- if (hover instanceof IAnnotationHoverExtension2) {
- IAnnotationHoverExtension2 expandHover= (IAnnotationHoverExtension2) hover;
- setCustomInformationControlCreator(expandHover.getInformationControlCreator());
- setInformation(expandHover.getHoverInfo2(fSourceViewer, line), computeArea(line));
- } else if (hover instanceof IAnnotationHoverExtension) {
- IAnnotationHoverExtension extension= (IAnnotationHoverExtension) hover;
- setCustomInformationControlCreator(extension.getInformationControlCreator());
-
- int startLine= fSourceViewer.getTopIndex();
- int endLine= fSourceViewer.getBottomIndex();
- setInformation(extension.getHoverInfo(fSourceViewer, line, startLine, endLine - startLine), computeArea(line));
- } else {
- setCustomInformationControlCreator(null);
- setInformation(hover.getHoverInfo(fSourceViewer, line), computeArea(line));
- }
-
- }
-
- /**
- * Determines the hover to be used to display information based on the source of the
- * mouse hover event. If <code>fVerticalRulerInfo</code> is not a composite ruler, the
- * standard hover is returned.
- *
- * @param source the source of the mouse hover event
- * @return the hover depending on <code>source</code>, or <code>fAnnotationHover</code> if none can be found.
- * @since 3.0
- */
- private IAnnotationHover getHover(MouseEvent event) {
- if (event == null || event.getSource() == null)
- return fAnnotationHover;
-
- if (fVerticalRulerInfo instanceof CompositeRuler) {
- CompositeRuler comp= (CompositeRuler) fVerticalRulerInfo;
- for (Iterator it= comp.getDecoratorIterator(); it.hasNext();) {
- Object o= it.next();
- if (o instanceof IVerticalRulerInfoExtension && o instanceof IVerticalRulerInfo) {
- if (((IVerticalRulerInfo) o).getControl() == event.getSource()) {
- IAnnotationHover hover= ((IVerticalRulerInfoExtension) o).getHover();
- if (hover != null)
- return hover;
- }
- }
- }
- }
- return fAnnotationHover;
- }
-
-
- /**
- * Returns the line of interest deduced from the mouse hover event.
- *
- * @param event a mouse hover event that triggered hovering
- * @return the document model line number on which the hover event occurred or <code>-1</code> if there is no event
- * @since 3.0
- */
- private int getHoverLine(MouseEvent event) {
- return event == null ? -1 : fVerticalRulerInfo.toDocumentLineNumber(event.y);
- }
-
- /**
- * Returns for the widget line number for the given document line number.
- *
- * @param line the absolute line number
- * @return the line number relative to the viewer's visible region
- * @throws BadLocationException if <code>line</code> is not valid in the viewer's document
- */
- private int getWidgetLineNumber(int line) throws BadLocationException {
- if (fSourceViewer instanceof ITextViewerExtension5) {
- ITextViewerExtension5 extension= (ITextViewerExtension5) fSourceViewer;
- return extension.modelLine2WidgetLine(line);
- }
-
- IRegion region= fSourceViewer.getVisibleRegion();
- int firstLine= fSourceViewer.getDocument().getLineOfOffset(region.getOffset());
- return line - firstLine;
- }
-
- /**
- * Determines graphical area covered by the given line.
- *
- * @param line the number of the line in the viewer whose graphical extend in the vertical ruler must be computed
- * @return the graphical extend of the given line
- */
- private Rectangle computeArea(int line) {
- try {
- StyledText text= fSourceViewer.getTextWidget();
- int lineHeight= text.getLineHeight();
- int y= getWidgetLineNumber(line) * lineHeight - text.getTopPixel();
- Point size= fVerticalRulerInfo.getControl().getSize();
- return new Rectangle(0, y, size.x, lineHeight);
- } catch (BadLocationException x) {
- }
- return null;
- }
-
- /**
- * Returns the annotation hover for this hover manager.
- *
- * @return the annotation hover for this hover manager
- * @since 2.1
- */
- protected IAnnotationHover getAnnotationHover() {
- return fAnnotationHover;
- }
-
- /**
- * Returns the source viewer for this hover manager.
- *
- * @return the source viewer for this hover manager
- * @since 2.1
- */
- protected ISourceViewer getSourceViewer() {
- return fSourceViewer;
- }
-
- /**
- * Returns the vertical ruler info for this hover manager
- *
- * @return the vertical ruler info for this hover manager
- * @since 2.1
- */
- protected IVerticalRulerInfo getVerticalRulerInfo() {
- return fVerticalRulerInfo;
- }
-
- /*
- * @see org.eclipse.jface.text.AbstractInformationControlManager#computeSizeConstraints(org.eclipse.swt.widgets.Control, org.eclipse.jface.text.IInformationControl)
- * @since 3.0
- */
- protected Point computeSizeConstraints(Control subjectControl, IInformationControl informationControl) {
- /* limit the hover to the size of the styled text's client area. */
- StyledText styledText= fSourceViewer.getTextWidget();
- if (styledText == null)
- return super.computeSizeConstraints(subjectControl, informationControl);
-
- Rectangle r= styledText.getClientArea();
- if (r == null)
- return super.computeSizeConstraints(subjectControl, informationControl);
- return new Point(r.width, r.height);
- }
-
- /*
- * @see org.eclipse.jface.text.AbstractInformationControlManager#computeInformationControlLocation(org.eclipse.swt.graphics.Rectangle, org.eclipse.swt.graphics.Point)
- * @since 3.0
- */
- protected Point computeInformationControlLocation(Rectangle subjectArea, Point controlSize) {
- MouseEvent event= getHoverEvent();
- IAnnotationHover hover= getHover(event);
-
- if (hover instanceof IAnnotationHoverExtension) {
- int startLine= fSourceViewer.getTopIndex();
- int endLine= fSourceViewer.getBottomIndex();
- ITextSelection lineRange= ((IAnnotationHoverExtension) hover).getLineRange(fSourceViewer, getHoverLine(event), startLine, endLine - startLine);
- if (lineRange != null && !lineRange.isEmpty())
- return computeViewerRange(lineRange);
- }
- return super.computeInformationControlLocation(subjectArea, controlSize);
- }
-
- /*
- * @see org.eclipse.jface.text.AbstractInformationControlManager#computeLocation(org.eclipse.swt.graphics.Rectangle, org.eclipse.swt.graphics.Point, org.eclipse.jface.text.AbstractInformationControlManager.Anchor)
- */
- protected Point computeLocation(Rectangle subjectArea, Point controlSize, Anchor anchor) {
- MouseEvent event= getHoverEvent();
- IAnnotationHover hover= getHover(event);
-
- if (hover instanceof IAnnotationHoverExtension2) {
- fAllowMouseExit= true;
-
- Control subjectControl= getSubjectControl();
- // return a location that just overlaps the annotation on the bar
- if (anchor == AbstractInformationControlManager.ANCHOR_RIGHT)
- return subjectControl.toDisplay(subjectArea.x - 4, subjectArea.y - 2);
- else if (anchor == AbstractHoverInformationControlManager.ANCHOR_LEFT)
- return subjectControl.toDisplay(subjectArea.x + subjectArea.width - controlSize.x + 4, subjectArea.y - 2);
- }
-
- fAllowMouseExit= false;
- return super.computeLocation(subjectArea, controlSize, anchor);
- }
-
- /**
- * Computes the hover location for the given line range.
- *
- * @param lineRange the first and last line covered by the hover, encoded as the <code>x</code> and <code>y</code> fields of a <code>Point</code>
- * @return a <code>Point</code>containing the display coordinates of the hover location
- * @since 3.0
- */
- private Point computeViewerRange(ITextSelection lineRange) {
- final int topLine= fSourceViewer.getTopIndex();
- // compute pixel offset taking in account partially visible lines.
- int lineDelta= lineRange.getStartLine() - topLine;
- StyledText textWidget= fSourceViewer.getTextWidget();
- int lineHeight= textWidget.getLineHeight();
- // note that this works independently of the widget2model mapping, since we just get the
- // pixels of the first partially visible line, if there is one.
- int partial= (lineHeight - (textWidget.getTopPixel() % lineHeight)) % lineHeight;
- int y= lineDelta * lineHeight + partial;
- int x= 1; // avoids line overlay of the hover and the editor border.
-
- return textWidget.toDisplay(x, y);
- }
-}
-
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationColumn.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationColumn.java
deleted file mode 100644
index 176d666..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationColumn.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.source;
-
-
-/**
- * @deprecated use <code>AnnotationRulerColumn</code> instead.
- * @since 2.0
- */
-public final class AnnotationColumn extends AnnotationRulerColumn {
-
- /**
- * Creates a new <code>AnnotationColumn</code> of the given width.
- *
- * @param width the width of this column
- * @deprecated
- */
- public AnnotationColumn(int width) {
- super(width);
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationEvent.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationEvent.java
deleted file mode 100644
index b41d062..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationEvent.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.source;
-
-
-/**
- * An event sent to {@link org.eclipse.jface.text.source.IAnnotationListener} instances when annotation
- * selection etc. occurs.
- *
- * <p>
- * TODO Note that this is work in progress and the interface is still subject to change.
- * </p>
- *
- * @since 3.0
- */
-public class AnnotationEvent {
- private Annotation fAnnotation;
-
- /**
- * Creates a new event.
- *
- * @param annotation the annotation concerned, or <code>null</code>
- */
- public AnnotationEvent(Annotation annotation) {
- fAnnotation= annotation;
- }
-
- /**
- * @return the concerned annotation or <code>null</code>
- */
- public Annotation getAnnotation() {
- return fAnnotation;
- }
-
- /**
- * @param annotation the concerned annotation, or <code>null</code>
- */
- public void setAnnotation(Annotation annotation) {
- fAnnotation= annotation;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationMap.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationMap.java
deleted file mode 100644
index 6fa57e1..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationMap.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.source;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Internal implementation of <code>IAnnotationMap</code>.
- *
- * @since 3.0
- */
-class AnnotationMap implements IAnnotationMap {
-
- /**
- * The lock object used to synchronize the operations explicitly defined by
- * IAnnotationMap
- */
- private Object fLockObject;
-
- /** The map holding the annotations */
- private Map fInternalMap;
-
- /**
- * Creates a new annotation map with the given capacity.
- *
- * @param capacity the capacity
- */
- public AnnotationMap(int capacity) {
- fInternalMap = new HashMap(capacity);
- }
-
- /*
- * @see org.eclipse.jface.text.source.ISynchronizable#setLockObject(java.lang.Object)
- */
- public void setLockObject(Object lockObject) {
- fLockObject = lockObject;
- }
-
- /*
- * @see org.eclipse.jface.text.source.ISynchronizable#getLockObject()
- */
- public Object getLockObject() {
- if (fLockObject == null) return this;
- return fLockObject;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationMap#valuesIterator()
- */
- public Iterator valuesIterator() {
- synchronized (getLockObject()) {
- return new ArrayList(fInternalMap.values()).iterator();
- }
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationMap#keySetIterator()
- */
- public Iterator keySetIterator() {
- synchronized (getLockObject()) {
- return new ArrayList(fInternalMap.keySet()).iterator();
- }
- }
-
- /*
- * @see java.util.Map#containsKey(java.lang.Object)
- */
- public boolean containsKey(Object annotation) {
- synchronized (getLockObject()) {
- return fInternalMap.containsKey(annotation);
- }
- }
-
- /*
- * @see java.util.Map#put(java.lang.Object, java.lang.Object)
- */
- public Object put(Object annotation, Object position) {
- synchronized (getLockObject()) {
- return fInternalMap.put(annotation, position);
- }
- }
-
- /*
- * @see java.util.Map#get(java.lang.Object)
- */
- public Object get(Object annotation) {
- synchronized (getLockObject()) {
- return fInternalMap.get(annotation);
- }
- }
-
- /*
- * @see java.util.Map#clear()
- */
- public void clear() {
- synchronized (getLockObject()) {
- fInternalMap.clear();
- }
- }
-
- /*
- * @see java.util.Map#remove(java.lang.Object)
- */
- public Object remove(Object annotation) {
- synchronized (getLockObject()) {
- return fInternalMap.remove(annotation);
- }
- }
-
- /*
- * @see java.util.Map#size()
- */
- public int size() {
- synchronized (getLockObject()) {
- return fInternalMap.size();
- }
- }
-
- /*
- * @see java.util.Map#isEmpty()
- */
- public boolean isEmpty() {
- synchronized (getLockObject()) {
- return fInternalMap.isEmpty();
- }
- }
-
- /*
- * @see java.util.Map#containsValue(java.lang.Object)
- */
- public boolean containsValue(Object value) {
- synchronized(getLockObject()) {
- return fInternalMap.containsValue(value);
- }
- }
-
- /*
- * @see java.util.Map#putAll(java.util.Map)
- */
- public void putAll(Map map) {
- synchronized (getLockObject()) {
- fInternalMap.putAll(map);
- }
- }
-
- /*
- * @see IAnnotationMap#entrySet()
- */
- public Set entrySet() {
- synchronized (getLockObject()) {
- return fInternalMap.entrySet();
- }
- }
-
- /*
- * @see IAnnotationMap#keySet()
- */
- public Set keySet() {
- synchronized (getLockObject()) {
- return fInternalMap.keySet();
- }
- }
-
- /*
- * @see IAnnotationMap#values()
- */
- public Collection values() {
- synchronized (getLockObject()) {
- return fInternalMap.values();
- }
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationModel.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationModel.java
deleted file mode 100644
index f193f3a..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationModel.java
+++ /dev/null
@@ -1,689 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.source;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.NoSuchElementException;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentListener;
-import org.eclipse.jface.text.ISynchronizable;
-import org.eclipse.jface.text.Position;
-
-
-/**
- * Standard implementation of <code>IAnnotationModel</code>. This class can directly
- * be used by clients. Subclasses may adapt this annotation model to other existing
- * annotation mechanisms.
- */
-public class AnnotationModel implements IAnnotationModel, IAnnotationModelExtension, ISynchronizable {
-
- /**
- * Internal annotation model listener for forwarding annotation model changes from the attached models to the
- * registered listeners of the outer most annotation model.
- *
- * @since 3.0
- */
- private class InternalModelListener implements IAnnotationModelListener, IAnnotationModelListenerExtension {
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationModelListener#modelChanged(org.eclipse.jface.text.source.IAnnotationModel)
- */
- public void modelChanged(IAnnotationModel model) {
- AnnotationModel.this.fireModelChanged(new AnnotationModelEvent(model, true));
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationModelListenerExtension#modelChanged(org.eclipse.jface.text.source.AnnotationModelEvent)
- */
- public void modelChanged(AnnotationModelEvent event) {
- AnnotationModel.this.fireModelChanged(event);
- }
- }
-
- /**
- * The list of managed annotations
- * @deprecated since 3.0 use <code>getAnnotationMap</code> instead
- */
- protected Map fAnnotations;
- /** The list of annotation model listeners */
- protected ArrayList fAnnotationModelListeners;
- /** The document connected with this model */
- protected IDocument fDocument;
- /** The number of open connections to the same document */
- private int fOpenConnections= 0;
- /** The document listener for tracking whether document positions might have been changed. */
- private IDocumentListener fDocumentListener;
- /** The flag indicating whether the document positions might have been changed. */
- private boolean fDocumentChanged= true;
- /**
- * The model's attachment.
- * @since 3.0
- */
- private Map fAttachments= new HashMap();
- /**
- * The annotation model listener on attached sub-models.
- * @since 3.0
- */
- private IAnnotationModelListener fModelListener= new InternalModelListener();
- /**
- * The current annotation model event.
- * @since 3.0
- */
- private AnnotationModelEvent fModelEvent;
-
-
-
-
- /**
- * Creates a new annotation model. The annotation is empty, i.e. does not
- * manage any annotations and is not connected to any document.
- */
- public AnnotationModel() {
- fAnnotations= new AnnotationMap(10);
- fAnnotationModelListeners= new ArrayList(2);
-
- fDocumentListener= new IDocumentListener() {
-
- public void documentAboutToBeChanged(DocumentEvent event) {
- }
-
- public void documentChanged(DocumentEvent event) {
- fDocumentChanged= true;
- }
- };
- }
-
- /**
- * Returns the annotation map internally used by this annotation model.
- *
- * @return the annotation map internally used by this annotation model
- */
- protected IAnnotationMap getAnnotationMap() {
- return (IAnnotationMap) fAnnotations;
- }
-
- /*
- * @see org.eclipse.jface.text.ISynchronizable#getLockObject()
- */
- public Object getLockObject() {
- return getAnnotationMap().getLockObject();
- }
-
- /*
- * @see org.eclipse.jface.text.ISynchronizable#setLockObject(java.lang.Object)
- */
- public void setLockObject(Object lockObject) {
- getAnnotationMap().setLockObject(lockObject);
- }
-
- private AnnotationModelEvent getAnnotationModelEvent() {
- if (fModelEvent == null) {
- fModelEvent= createAnnotationModelEvent();
- fModelEvent.markWorldChange(false);
- }
- return fModelEvent;
- }
-
- /*
- * @see IAnnotationModel#addAnnotation(Annotation, Position)
- */
- public void addAnnotation(Annotation annotation, Position position) {
- try {
- addAnnotation(annotation, position, true);
- } catch (BadLocationException e) {
- // ignore invalid position
- }
- }
-
- /*
- * @see IAnnotationModelExtension#replaceAnnotations(Annotation[], Map)
- * @since 3.0
- */
- public void replaceAnnotations(Annotation[] annotationsToRemove, Map annotationsToAdd) {
- try {
- replaceAnnotations(annotationsToRemove, annotationsToAdd, true);
- } catch (BadLocationException x) {
- }
- }
-
- /**
- * Replaces the given annotations in this model and if advised fires a
- * model change event.
- *
- * @param annotationsToRemove the annotations to be removed
- * @param annotationsToAdd the annotations to be added
- * @param fireModelChanged <code>true</code> if a model change event
- * should be fired, <code>false</code> otherwise
- * @throws BadLocationException in case an annotation should be added at an
- * invalid position
- * @since 3.0
- */
- protected void replaceAnnotations(Annotation[] annotationsToRemove, Map annotationsToAdd, boolean fireModelChanged) throws BadLocationException {
-
- if (annotationsToRemove != null) {
- for (int i= 0, length= annotationsToRemove.length; i < length; i++)
- removeAnnotation(annotationsToRemove[i], false);
- }
-
- if (annotationsToAdd != null) {
- Iterator iter= annotationsToAdd.entrySet().iterator();
- while (iter.hasNext()) {
- Map.Entry mapEntry= (Map.Entry) iter.next();
- Annotation annotation= (Annotation) mapEntry.getKey();
- Position position= (Position) mapEntry.getValue();
- addAnnotation(annotation, position, false);
- }
- }
-
- if (fireModelChanged)
- fireModelChanged();
- }
-
- /**
- * Adds the given annotation to this model. Associates the
- * annotation with the given position. If requested, all annotation
- * model listeners are informed about this model change. If the annotation
- * is already managed by this model nothing happens.
- *
- * @param annotation the annotation to add
- * @param position the associate position
- * @param fireModelChange indicates whether to notify all model listeners
- * @throws BadLocationException if the position is not a valid document position
- */
- protected void addAnnotation(Annotation annotation, Position position, boolean fireModelChanged) throws BadLocationException {
- if (!fAnnotations.containsKey(annotation)) {
-
- addPosition(fDocument, position);
- fAnnotations.put(annotation, position);
- getAnnotationModelEvent().annotationAdded(annotation);
-
- if (fireModelChanged)
- fireModelChanged();
- }
- }
-
- /*
- * @see IAnnotationModel#addAnnotationModelListener(IAnnotationModelListener)
- */
- public void addAnnotationModelListener(IAnnotationModelListener listener) {
- if (!fAnnotationModelListeners.contains(listener)) {
- fAnnotationModelListeners.add(listener);
- if (listener instanceof IAnnotationModelListenerExtension)
- ((IAnnotationModelListenerExtension)listener).modelChanged(createAnnotationModelEvent());
- else
- listener.modelChanged(this);
- }
- }
-
- /**
- * Adds the given position to the default position category of the
- * given document.
- *
- * @param document the document to which to add the position
- * @param position the position to add
- * @throws BadLocationException if the position is not a valid document position
- */
- protected void addPosition(IDocument document, Position position) throws BadLocationException {
- if (document != null) {
- synchronized (document) {
- document.addPosition(position);
- }
- }
- }
-
- /**
- * Removes the given position from the default position category of the
- * given document.
- *
- * @param document the document to which to add the position
- * @param position the position to add
- *
- * @since 3.0
- */
- protected void removePosition(IDocument document, Position pos) {
- if (document != null) {
- synchronized (document) {
- document.removePosition(pos);
- }
- }
- }
-
- /*
- * @see IAnnotationModel#connect(IDocument)
- */
- public void connect(IDocument document) {
- Assert.isTrue(fDocument == null || fDocument == document);
-
- if (fDocument == null) {
- fDocument= document;
- Iterator e= getAnnotationMap().valuesIterator();
- while (e.hasNext())
- try {
- addPosition(fDocument, (Position) e.next());
- } catch (BadLocationException x) {
- // ignore invalid position
- }
- }
-
- ++ fOpenConnections;
- if (fOpenConnections == 1) {
- fDocument.addDocumentListener(fDocumentListener);
- connected();
- }
-
- for (Iterator it= fAttachments.keySet().iterator(); it.hasNext();) {
- IAnnotationModel model= (IAnnotationModel) fAttachments.get(it.next());
- model.connect(document);
- }
- }
-
- /**
- * Hook method. Is called as soon as this model becomes connected to a document.
- * Subclasses may re-implement.
- */
- protected void connected() {
- }
-
- /**
- * Hook method. Is called as soon as this model becomes disconnected from its document.
- * Subclasses may re-implement.
- */
- protected void disconnected() {
- }
-
- /*
- * @see IAnnotationModel#disconnect(IDocument)
- */
- public void disconnect(IDocument document) {
-
- Assert.isTrue(fDocument == document);
-
- for (Iterator it= fAttachments.keySet().iterator(); it.hasNext();) {
- IAnnotationModel model= (IAnnotationModel) fAttachments.get(it.next());
- model.disconnect(document);
- }
-
- -- fOpenConnections;
- if (fOpenConnections == 0) {
-
- disconnected();
- fDocument.removeDocumentListener(fDocumentListener);
-
- if (fDocument != null) {
- Iterator e= getAnnotationMap().valuesIterator();
- while (e.hasNext()) {
- Position p= (Position) e.next();
- removePosition(fDocument, p);
- }
- fDocument= null;
- }
- }
- }
-
- /**
- * Informs all annotation model listeners that this model has been changed.
- */
- protected void fireModelChanged() {
- if (fModelEvent != null) {
- fireModelChanged(fModelEvent);
- fModelEvent= null;
- }
- }
-
- /**
- * Creates and returns a new annotation model event. Subclasses may override.
- *
- * @return a new and empty annotation model event
- * @since 3.0
- */
- protected AnnotationModelEvent createAnnotationModelEvent() {
- return new AnnotationModelEvent(this);
- }
-
- /**
- * Informs all annotation model listeners that this model has been changed
- * as described in the annotation model event. The event is sent out
- * to all listeners implementing <code>IAnnotationModelListenerExtension</code>.
- * All other listeners are notified by just calling <code>modelChanged(IAnnotationModel)</code>.
- *
- * @param event the event to be sent out to the listeners
- * @since 2.0
- */
- protected void fireModelChanged(AnnotationModelEvent event) {
-
- if (event.isEmpty())
- return;
-
- ArrayList v= new ArrayList(fAnnotationModelListeners);
- Iterator e= v.iterator();
- while (e.hasNext()) {
- IAnnotationModelListener l= (IAnnotationModelListener) e.next();
- if (l instanceof IAnnotationModelListenerExtension)
- ((IAnnotationModelListenerExtension) l).modelChanged(event);
- else
- l.modelChanged(this);
- }
- }
-
- /**
- * Removes the given annotations from this model. If requested all
- * annotation model listeners will be informed about this change.
- * <code>modelInitiated</code> indicates whether the deletion has
- * been initiated by this model or by one of its clients.
- *
- * @param annotations the annotations to be removed
- * @param fireModelChanged indicates whether to notify all model listeners
- * @param modelInitiated indicates whether this changes has been initiated by this model
- */
- protected void removeAnnotations(List annotations, boolean fireModelChanged, boolean modelInitiated) {
- if (annotations.size() > 0) {
- Iterator e= annotations.iterator();
- while (e.hasNext())
- removeAnnotation((Annotation) e.next(), false);
-
- if (fireModelChanged)
- fireModelChanged();
- }
- }
-
- /**
- * Removes all annotations from the model whose associated positions have been
- * deleted. If requested inform all model listeners about the change.
- *
- * @param fireModelChanged indicates whether to notify all model listeners
- */
- protected void cleanup(boolean fireModelChanged) {
- if (fDocumentChanged) {
- fDocumentChanged= false;
-
- ArrayList deleted= new ArrayList();
- Iterator e= getAnnotationMap().keySetIterator();
- while (e.hasNext()) {
- Annotation a= (Annotation) e.next();
- Position p= (Position) fAnnotations.get(a);
- if (p == null || p.isDeleted())
- deleted.add(a);
- }
-
- removeAnnotations(deleted, fireModelChanged, false);
- }
- }
-
- /*
- * @see IAnnotationModel#getAnnotationsIterator()
- */
- public Iterator getAnnotationIterator() {
- return getAnnotationIterator(true, true);
- }
-
- /**
- * Returns all annotations managed by this model. <code>cleanup</code>
- * indicates whether all annotations whose associated positions are
- * deleted should previously be removed from the model. <code>recurse</code> indicates
- * whether annotations of attached sub-models should also be returned.
- *
- * @param cleanup indicates whether annotations with deleted associated positions are removed
- * @param recurse whether to return annotations managed by sub-models.
- * @return all annotations managed by this model
- * @since 3.0
- */
- private Iterator getAnnotationIterator(boolean cleanup, boolean recurse) {
-
- if (!recurse)
- return getAnnotationIterator(cleanup);
-
- List iterators= new ArrayList(fAttachments.size() + 1);
- iterators.add(getAnnotationIterator(cleanup));
- for (Iterator it= fAttachments.keySet().iterator(); it.hasNext();) {
- iterators.add(((IAnnotationModel) fAttachments.get(it.next())).getAnnotationIterator());
- }
-
- final Iterator iter= iterators.iterator();
-
- // Meta iterator...
- return new Iterator() {
-
- /** The current iterator. */
- private Iterator fCurrent= (Iterator) iter.next(); // there is at least one.
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- public boolean hasNext() {
- if (fCurrent.hasNext())
- return true;
- else if (iter.hasNext()) {
- fCurrent= (Iterator) iter.next();
- return hasNext();
- } else
- return false;
- }
-
- public Object next() {
- if (!hasNext())
- throw new NoSuchElementException();
- else
- return fCurrent.next();
- }
-
- };
- }
-
- /**
- * Returns all annotations managed by this model. <code>cleanup</code>
- * indicates whether all annotations whose associated positions are
- * deleted should previously be removed from the model.
- *
- * @param cleanup indicates whether annotations with deleted associated positions are removed
- * @return all annotations managed by this model
- */
- protected Iterator getAnnotationIterator(boolean cleanup) {
- if (cleanup)
- cleanup(true);
-
- return getAnnotationMap().keySetIterator();
- }
-
- /*
- * @see IAnnotationModel#getPosition(Annotation)
- */
- public Position getPosition(Annotation annotation) {
- Position position= (Position) fAnnotations.get(annotation);
- if (position != null)
- return position;
-
- Iterator it= fAttachments.values().iterator();
- while (position == null && it.hasNext())
- position= ((IAnnotationModel) it.next()).getPosition(annotation);
- return position;
- }
-
- /**
- * Removes all annotations from the annotation model and
- * informs all model listeners about this change.
- */
- public void removeAllAnnotations() {
- removeAllAnnotations(true);
- }
-
- /**
- * Removes all annotations from the annotation model. If requested
- * inform all model change listeners about this change.
- *
- * @param fireModelChanged indicates whether to notify all model listeners
- */
- protected void removeAllAnnotations(boolean fireModelChanged) {
-
- if (fDocument != null) {
- Iterator e= getAnnotationMap().keySetIterator();
- while (e.hasNext()) {
- Annotation a= (Annotation) e.next();
- Position p= (Position) fAnnotations.get(a);
- removePosition(fDocument, p);
- getAnnotationModelEvent().annotationRemoved(a);
- }
- }
-
- fAnnotations.clear();
-
- if (fireModelChanged)
- fireModelChanged();
- }
-
- /*
- * @see IAnnotationModel#removeAnnotation(Annotation)
- */
- public void removeAnnotation(Annotation annotation) {
- removeAnnotation(annotation, true);
- }
-
- /**
- * Removes the given annotation from the annotation model.
- * If requested inform all model change listeners about this change.
- *
- * @param annotation the annotation to be removed
- * @param fireModelChanged indicates whether to notify all model listeners
- */
- protected void removeAnnotation(Annotation annotation, boolean fireModelChanged) {
- if (fAnnotations.containsKey(annotation)) {
-
- if (fDocument != null) {
- Position p= (Position) fAnnotations.get(annotation);
- removePosition(fDocument, p);
- }
-
- fAnnotations.remove(annotation);
- getAnnotationModelEvent().annotationRemoved(annotation);
-
- if (fireModelChanged)
- fireModelChanged();
- }
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationModelExtension#modifyAnnotationPosition(org.eclipse.jface.text.source.Annotation, org.eclipse.jface.text.Position)
- */
- public void modifyAnnotationPosition(Annotation annotation, Position position) {
- modifyAnnotationPosition(annotation, position, true);
- }
-
- /**
- * Modifies the associated position of the given annotation to the given
- * position. If the annotation is not yet managed by this annotation model,
- * the annotation is added. When the position is <code>null</code>, the
- * annotation is removed from the model.
- * <p>
- * If requested, all annotation model change listeners will be informed
- * about the change.
- *
- * @param annotation the annotation whose associated position should be
- * modified
- * @param position the position to whose values the associated position
- * should be changed
- * @param fireModelChanged indicates whether to notify all model listeners
- * @since 3.0
- */
- protected void modifyAnnotationPosition(Annotation annotation, Position position, boolean fireModelChanged) {
- if (position == null) {
- removeAnnotation(annotation, fireModelChanged);
- } else {
- Position p= (Position) fAnnotations.get(annotation);
- if (p != null) {
-
- if (position.getOffset() != p.getOffset() || position.getLength() != p.getLength()) {
- p.setOffset(position.getOffset());
- p.setLength(position.getLength());
- }
- getAnnotationModelEvent().annotationChanged(annotation);
- if (fireModelChanged)
- fireModelChanged();
-
- } else {
- try {
- addAnnotation(annotation, position, fireModelChanged);
- } catch (BadLocationException x) {
- // ignore invalid position
- }
- }
- }
- }
-
- /**
- * Modifies the given annotation if the annotation is managed by this
- * annotation model.
- * <p>
- * If requested, all annotation model change listeners will be informed
- * about the change.
- *
- * @param annotation the annotation to be modified
- * @param fireModelChanged indicates whether to notify all model listeners
- * @since 3.0
- */
- protected void modifyAnnotation(Annotation annotation, boolean fireModelChanged) {
- if (fAnnotations.containsKey(annotation)) {
- getAnnotationModelEvent().annotationChanged(annotation);
- if (fireModelChanged)
- fireModelChanged();
- }
- }
-
- /*
- * @see IAnnotationModel#removeAnnotationModelListener(IAnnotationModelListener)
- */
- public void removeAnnotationModelListener(IAnnotationModelListener listener) {
- fAnnotationModelListeners.remove(listener);
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationModelExtension#attach(java.lang.Object, java.lang.Object)
- * @since 3.0
- */
- public void addAnnotationModel(Object key, IAnnotationModel attachment) {
- Assert.isNotNull(attachment);
- if (!fAttachments.containsValue(attachment)) {
- fAttachments.put(key, attachment);
- for (int i= 0; i < fOpenConnections; i++)
- attachment.connect(fDocument);
- attachment.addAnnotationModelListener(fModelListener);
- }
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationModelExtension#get(java.lang.Object)
- * @since 3.0
- */
- public IAnnotationModel getAnnotationModel(Object key) {
- return (IAnnotationModel) fAttachments.get(key);
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationModelExtension#detach(java.lang.Object)
- * @since 3.0
- */
- public IAnnotationModel removeAnnotationModel(Object key) {
- IAnnotationModel ret= (IAnnotationModel) fAttachments.remove(key);
- if (ret != null) {
- for (int i= 0; i < fOpenConnections; i++)
- ret.disconnect(fDocument);
- ret.removeAnnotationModelListener(fModelListener);
- }
- return ret;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationModelEvent.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationModelEvent.java
deleted file mode 100644
index fd94d86..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationModelEvent.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.source;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * Specification of changes applied to annotation models.
- * The event carries the changed annotation model
- * as well as added, removed, and modified annotations.
- *
- * @see IAnnotationModel
- * @since 2.0
- */
-public class AnnotationModelEvent {
-
- /** The model this event refers to. For internal use only. */
- private IAnnotationModel fAnnotationModel;
- /**
- * The added annotations.
- * @since 3.0
- */
- private Set fAddedAnnotations= new HashSet();
- /**
- * The removed annotations.
- * @since 3.0
- */
- private Set fRemovedAnnotations= new HashSet();
- /**
- * The changed annotations.
- * @since 3.0
- */
- private Set fChangedAnnotations= new HashSet();
- /**
- * Indicates that this event does not contain detailed information.
- * @since 3.0
- */
- private boolean fIsWorldChange;
-
- /**
- * Creates a new annotation model event for the given model.
- *
- * @param model the model
- */
- public AnnotationModelEvent(IAnnotationModel model) {
- this(model, true);
- }
-
- /**
- * Creates a new annotation model event for the given model.
- *
- * @param model the model
- * @param isWorldChange <code>true</code> if world change
- * @since 3.0
- */
- public AnnotationModelEvent(IAnnotationModel model, boolean isWorldChange) {
- fAnnotationModel= model;
- fIsWorldChange= isWorldChange;
- }
-
- /**
- * Returns the model this event refers to.
- *
- * @return the model this events belongs to
- */
- public IAnnotationModel getAnnotationModel() {
- return fAnnotationModel;
- }
-
- /**
- * Adds the given annotation to the set of annotations that are reported as
- * being added from the model. If this event is considered a world change,
- * it is no longer so after this method has successfully finished.
- *
- * @param annotation the added annotation
- * @since 3.0
- */
- public void annotationAdded(Annotation annotation) {
- fAddedAnnotations.add(annotation);
- fIsWorldChange= false;
- }
-
- /**
- * Returns the added annotations.
- *
- * @return the added annotations
- * @since 3.0
- */
- public Annotation[] getAddedAnnotations() {
- int size= fAddedAnnotations.size();
- Annotation[] added= new Annotation[size];
- fAddedAnnotations.toArray(added);
- return added;
- }
-
- /**
- * Adds the given annotation to the set of annotations that are reported as
- * being removed from the model. If this event is considered a world
- * change, it is no longer so after this method has successfully finished.
- *
- * @param annotation the removed annotation
- * @since 3.0
- */
- public void annotationRemoved(Annotation annotation) {
- fRemovedAnnotations.add(annotation);
- fIsWorldChange= false;
- }
-
- /**
- * Returns the removed annotations.
- *
- * @return the removed annotations
- * @since 3.0
- */
- public Annotation[] getRemovedAnnotations() {
- int size= fRemovedAnnotations.size();
- Annotation[] removed= new Annotation[size];
- fRemovedAnnotations.toArray(removed);
- return removed;
- }
-
- /**
- * Adds the given annotation to the set of annotations that are reported as
- * being changed from the model. If this event is considered a world
- * change, it is no longer so after this method has successfully finished.
- *
- * @param annotation the changed annotation
- * @since 3.0
- */
- public void annotationChanged(Annotation annotation) {
- fChangedAnnotations.add(annotation);
- fIsWorldChange= false;
- }
-
- /**
- * Returns the changed annotations.
- *
- * @return the changed annotations
- * @since 3.0
- */
- public Annotation[] getChangedAnnotations() {
- int size= fChangedAnnotations.size();
- Annotation[] changed= new Annotation[size];
- fChangedAnnotations.toArray(changed);
- return changed;
- }
-
- /**
- * Returns whether this annotation model event is empty or not. If this
- * event represents a world change, this method returns <code>false</code>
- * although the event does not carry any added, removed, or changed
- * annotations.
- *
- * @return <code>true</code> if this event is empty
- * @since 3.0
- */
- public boolean isEmpty() {
- return !fIsWorldChange && fAddedAnnotations.isEmpty() && fRemovedAnnotations.isEmpty() && fChangedAnnotations.isEmpty();
- }
-
- /**
- * Returns whether this annotation model events contains detailed
- * information about the modifications applied to the event annotation
- * model or whether it represents a world change, i.e. everything in the
- * model might have changed.
- *
- * @return <code>true</code> if world change, <code>false</code> otherwise
- */
- public boolean isWorldChange() {
- return fIsWorldChange;
- }
-
- /**
- * Marks this event as world change according to the given flag.
- *
- * @param worldChange <code>true</code> if this event is a world change, <code>false</code> otherwise
- * @since 3.0
- */
- void markWorldChange(boolean isWorldChange) {
- fIsWorldChange= isWorldChange;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationPainter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationPainter.java
deleted file mode 100644
index d3c5084..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationPainter.java
+++ /dev/null
@@ -1,1185 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.source;
-
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.runtime.Platform;
-
-import org.eclipse.swt.custom.StyleRange;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Display;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IPaintPositionManager;
-import org.eclipse.jface.text.IPainter;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextInputListener;
-import org.eclipse.jface.text.ITextPresentationListener;
-import org.eclipse.jface.text.ITextViewerExtension2;
-import org.eclipse.jface.text.ITextViewerExtension5;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextPresentation;
-
-
-/**
- * Paints annotations provided by an annotation model as squiggly lines and/or
- * highlighted onto an associated source viewer.
- * Clients usually instantiate and configure objects of this class.
- *
- * @since 2.1
- */
-public class AnnotationPainter implements IPainter, PaintListener, IAnnotationModelListener, IAnnotationModelListenerExtension, ITextPresentationListener {
-
-
- /**
- * A drawing strategy responsible for drawing a certain decoration.
- *
- * @since 3.0
- */
- public interface IDrawingStrategy {
- /**
- * Draws a decoration of the given length start at the given offset in the
- * given color onto the specified gc.
- *
- * @param annotation the annotation to be drawn
- * @param gc the grahical context
- * @param textWidget the text widget to draw on
- * @param offset the offset of the line
- * @param length the length of the line
- * @param color the color of the line
- */
- void draw(Annotation annotation, GC gc, StyledText textWidget, int offset, int length, Color color);
- }
-
- /**
- * Squiggly drawing strategy.
- *
- * @since 3.0
- */
- public static class SquigglesStrategy implements IDrawingStrategy {
- /**
- * {@inheritdoc}
- */
- public void draw(Annotation annotation, GC gc, StyledText textWidget, int offset, int length, Color color) {
- if (gc != null) {
-
- Point left= textWidget.getLocationAtOffset(offset);
- Point right= textWidget.getLocationAtOffset(offset + length);
-
- gc.setForeground(color);
- int[] polyline= computePolyline(left, right, gc.getFontMetrics().getHeight());
- gc.drawPolyline(polyline);
-
- } else {
- textWidget.redrawRange(offset, length, true);
- }
- }
-
- /**
- * Computes an array of alternating x and y values which are the corners of the squiggly line of the
- * given height between the given end points.
- *
- * @param left the left end point
- * @param right the right end point
- * @param height the height of the squiggly line
- * @return the array of alternating x and y values which are the corners of the squiggly line
- */
- private int[] computePolyline(Point left, Point right, int height) {
-
- final int WIDTH= 4; // must be even
- final int HEIGHT= 2; // can be any number
-// final int MINPEEKS= 2; // minimal number of peeks
-
- int peeks= (right.x - left.x) / WIDTH;
-// if (peeks < MINPEEKS) {
-// int missing= (MINPEEKS - peeks) * WIDTH;
-// left.x= Math.max(0, left.x - missing/2);
-// peeks= MINPEEKS;
-// }
-
- int leftX= left.x;
-
- // compute (number of point) * 2
- int length= ((2 * peeks) + 1) * 2;
- if (length < 0)
- return new int[0];
-
- int[] coordinates= new int[length];
-
- // cache peeks' y-coordinates
- int bottom= left.y + height - 1;
- int top= bottom - HEIGHT;
-
- // populate array with peek coordinates
- for (int i= 0; i < peeks; i++) {
- int index= 4 * i;
- coordinates[index]= leftX + (WIDTH * i);
- coordinates[index+1]= bottom;
- coordinates[index+2]= coordinates[index] + WIDTH/2;
- coordinates[index+3]= top;
- }
-
- // the last down flank is missing
- coordinates[length-2]= left.x + (WIDTH * peeks);
- coordinates[length-1]= bottom;
-
- return coordinates;
- }
- }
-
- /**
- * Drawing strategy that does nothing.
- * @since 3.0
- */
- public static final class NullStrategy implements IDrawingStrategy {
- /**
- * {@inheritdoc}
- */
- public void draw(Annotation annotation, GC gc, StyledText textWidget, int offset, int length, Color color) {
- // do nothing
- }
- }
-
- /**
- * Tells whether this class is in debug mode.
- * @since 3.0
- */
- private static boolean DEBUG= "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.jface.text/debug/AnnotationPainter")); //$NON-NLS-1$//$NON-NLS-2$
- /**
- * The squiggly painter strategy.
- * @since 3.0
- */
- private static final IDrawingStrategy fgSquigglyDrawer= new SquigglesStrategy();
- /**
- * The squiggles painter id.
- * @since 3.0
- */
- private static final Object SQUIGGLES= new Object();
- /**
- * The default strategy that does nothing.
- * @since 3.0
- */
- private static final IDrawingStrategy fgNullDrawer= new NullStrategy();
-
- /**
- * The presentation information (decoration) for an annotation. Each such
- * object represents one decoration drawn on the text area, such as squiggly lines
- * and underlines.
- */
- private static class Decoration {
- /** The position of this decoration */
- private Position fPosition;
- /** The color of this decoration */
- private Color fColor;
- /**
- * The annotation's layer
- * @since 3.0
- */
- private int fLayer;
- /**
- * The painter strategy for this decoration.
- * @since 3.0
- */
- private IDrawingStrategy fPainter;
- }
-
- /** Indicates whether this painter is active */
- private boolean fIsActive= false;
- /** Indicates whether this painter is managing decorations */
- private boolean fIsPainting= false;
- /** Indicates whether this painter is setting its annotation model */
- private boolean fIsSettingModel= false;
- /** The associated source viewer */
- private ISourceViewer fSourceViewer;
- /** The cached widget of the source viewer */
- private StyledText fTextWidget;
- /** The annotation model providing the annotations to be drawn */
- private IAnnotationModel fModel;
- /** The annotation access */
- private IAnnotationAccess fAnnotationAccess;
- /**
- * The map with decorations
- * @since 3.0
- */
- private Map fDecorationsMap= new HashMap(); // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=50767
- /**
- * The map with of highlighted decorations.
- * @since 3.0
- */
- private Map fHighlightedDecorationsMap= new HashMap(); // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=50767
- /** The internal color table */
- private Map fColorTable= new HashMap();
- /** The list of configured annotation types for being painted by this painter */
- private Set fConfiguredAnnotationTypes= new HashSet();
- /**
- * The list of allowed annotation types for being painted by this painter.
- * @since 3.0
- */
- private Set fAllowedAnnotationTypes= new HashSet();
- /**
- * The list of configured annotation typed to be highlighted by this painter.
- * @since 3.0
- */
- private Set fConfiguredHighlightAnnotationTypes= new HashSet();
- /**
- * The list of allowed annotation types to be highlighted by this painter.
- * @since 3.0
- */
- private Set fAllowedHighlightAnnotationTypes= new HashSet();
- /**
- * The range in which the current highlight annotations can be found.
- * @since 3.0
- */
- private Position fCurrentHighlightAnnotationRange= null;
- /**
- * The range in which all add, removed and changed highlight
- * annotations can be found since the last world change.
- * @since 3.0
- */
- private Position fTotalHighlightAnnotationRange= null;
- /**
- * The text input listener.
- * @since 3.0
- */
- private ITextInputListener fTextInputListener;
- /**
- * Flag which tells that a new document input is currently being set.
- * @since 3.0
- */
- private boolean fInputDocumentAboutToBeChanged;
- /**
- * Maps annotation types to drawing strategy ids.
- * @since 3.0
- */
- private Map fAnnotationType2DrawingStrategyId= new HashMap();
- /**
- * Maps drawing strategy ids to drawing strategies.
- * @since 3.0
- */
- private Map fRegisteredDrawingStrategies= new HashMap();
-
-
- /**
- * Creates a new annotation painter for the given source viewer and with the given
- * annotation access. The painter is uninitialized, i.e. no annotation types are configured
- * to be painted.
- *
- * @param sourceViewer the source viewer for this painter
- * @param access the annotation access for this painter
- */
- public AnnotationPainter(ISourceViewer sourceViewer, IAnnotationAccess access) {
- fSourceViewer= sourceViewer;
- fAnnotationAccess= access;
- fTextWidget= sourceViewer.getTextWidget();
-
- // default drawing strategies: squiggles are the only pre-3.0 drawing style,
- fRegisteredDrawingStrategies.put(SQUIGGLES, fgSquigglyDrawer);
- }
-
- /**
- * Returns whether this painter has to draw any squiggle.
- *
- * @return <code>true</code> if there are squiggles to be drawn, <code>false</code> otherwise
- */
- private boolean hasDecorations() {
- return !fDecorationsMap.isEmpty();
- }
-
- /**
- * Enables painting. This painter registers a paint listener with the
- * source viewer's widget.
- */
- private void enablePainting() {
- if (!fIsPainting && hasDecorations()) {
- fIsPainting= true;
- fTextWidget.addPaintListener(this);
- handleDrawRequest(null);
- }
- }
-
- /**
- * Disables painting, if is has previously been enabled. Removes
- * any paint listeners registered with the source viewer's widget.
- *
- * @param redraw <code>true</code> if the widget should be redrawn after disabling
- */
- private void disablePainting(boolean redraw) {
- if (fIsPainting) {
- fIsPainting= false;
- fTextWidget.removePaintListener(this);
- if (redraw && hasDecorations())
- handleDrawRequest(null);
- }
- }
-
- /**
- * Sets the annotation model for this painter. Registers this painter
- * as listener of the give model, if the model is not <code>null</code>.
- *
- * @param model the annotation model
- */
- private void setModel(IAnnotationModel model) {
- if (fModel != model) {
- if (fModel != null)
- fModel.removeAnnotationModelListener(this);
- fModel= model;
- if (fModel != null) {
- synchronized(this) {
- try {
- fIsSettingModel= true;
- fModel.addAnnotationModelListener(this);
- } finally {
- fIsSettingModel= false;
- }
- }
- }
- }
- }
-
- /**
- * Updates the set of decorations based on the current state of
- * the painter's annotation model.
- */
- private synchronized void catchupWithModel(AnnotationModelEvent event) {
-
- if (fDecorationsMap != null) {
-
- int highlightAnnotationRangeStart= Integer.MAX_VALUE;
- int highlightAnnotationRangeEnd= -1;
-
- if (fModel != null) {
-
- boolean isWorldChange= false;
-
- Iterator e;
- if (event == null || event.isWorldChange()) {
- isWorldChange= true;
-
- if (DEBUG && event == null)
- System.out.println("AP: INTERNAL CHANGE"); //$NON-NLS-1$
-
- fDecorationsMap.clear();
- fHighlightedDecorationsMap.clear();
-
- e= fModel.getAnnotationIterator();
-
-
- } else {
-
- // Remove annotations
- Annotation[] removedAnnotations= event.getRemovedAnnotations();
- for (int i=0, length= removedAnnotations.length; i < length; i++) {
- Annotation annotation= removedAnnotations[i];
- Decoration decoration= (Decoration)fHighlightedDecorationsMap.remove(annotation);
- if (decoration != null) {
- Position position= decoration.fPosition;
- if (position != null && !position.isDeleted()) {
- highlightAnnotationRangeStart= Math.min(highlightAnnotationRangeStart, position.offset);
- highlightAnnotationRangeEnd= Math.max(highlightAnnotationRangeEnd, position.offset + position.length);
- }
- }
- fDecorationsMap.remove(annotation);
- }
-
- // Update existing annotations
- Annotation[] changedAnnotations= event.getChangedAnnotations();
- for (int i=0, length= changedAnnotations.length; i < length; i++) {
- Annotation annotation= changedAnnotations[i];
-
- Object annotationType= annotation.getType();
- boolean isHighlighting= shouldBeHighlighted(annotationType);
- boolean isDrawingSquiggles= shouldBeDrawn(annotationType);
-
- Decoration decoration= (Decoration)fHighlightedDecorationsMap.get(annotation);
-
- if (decoration != null) {
- // The call below updates the decoration - no need to create new decoration
- decoration= getDecoration(annotation, decoration, isDrawingSquiggles, isHighlighting);
- if (decoration == null)
- fHighlightedDecorationsMap.remove(annotation);
- } else {
- decoration= getDecoration(annotation, decoration, isDrawingSquiggles, isHighlighting);
- if (decoration != null && isHighlighting)
- fHighlightedDecorationsMap.put(annotation, decoration);
- }
-
- Position position= null;
- if (decoration == null)
- position= fModel.getPosition(annotation);
- else
- position= decoration.fPosition;
-
- if (position != null && !position.isDeleted()) {
- highlightAnnotationRangeStart= Math.min(highlightAnnotationRangeStart, position.offset);
- highlightAnnotationRangeEnd= Math.max(highlightAnnotationRangeEnd, position.offset + position.length);
- } else {
- fHighlightedDecorationsMap.remove(annotation);
- }
-
- Decoration oldDecoration= (Decoration)fDecorationsMap.get(annotation);
- if (decoration != null && isDrawingSquiggles)
- fDecorationsMap.put(annotation, decoration);
- else if (oldDecoration != null)
- fDecorationsMap.remove(annotation);
- }
-
- e= Arrays.asList(event.getAddedAnnotations()).iterator();
- }
-
- // Add new annotations
- while (e.hasNext()) {
- Annotation annotation= (Annotation) e.next();
-
- Object annotationType= annotation.getType();
- boolean isHighlighting= shouldBeHighlighted(annotationType);
- boolean isDrawingSquiggles= shouldBeDrawn(annotationType);
-
- Decoration pp= getDecoration(annotation, null, isDrawingSquiggles, isHighlighting);
-
- if (pp != null) {
-
- if (isDrawingSquiggles)
- fDecorationsMap.put(annotation, pp);
-
- if (isHighlighting) {
- fHighlightedDecorationsMap.put(annotation, pp);
- highlightAnnotationRangeStart= Math.min(highlightAnnotationRangeStart, pp.fPosition.offset);
- highlightAnnotationRangeEnd= Math.max(highlightAnnotationRangeEnd, pp.fPosition.offset + pp.fPosition.length);
- }
- }
- }
-
- updateHighlightRanges(highlightAnnotationRangeStart, highlightAnnotationRangeEnd, isWorldChange);
- }
- }
- }
-
- /**
- * Updates the remembered highlight ranges.
- *
- * @param highlightAnnotationRangeStart the start of the range
- * @param highlightAnnotationRangeEnd the end of the range
- * @param isWorldChange tells whether the range belongs to a annotation model event reporting a world change
- * @since 3.0
- */
- private void updateHighlightRanges(int highlightAnnotationRangeStart, int highlightAnnotationRangeEnd, boolean isWorldChange) {
- if (highlightAnnotationRangeStart != Integer.MAX_VALUE) {
-
- int maxRangeStart= highlightAnnotationRangeStart;
- int maxRangeEnd= highlightAnnotationRangeEnd;
-
- if (fTotalHighlightAnnotationRange != null) {
- maxRangeStart= Math.min(maxRangeStart, fTotalHighlightAnnotationRange.offset);
- maxRangeEnd= Math.max(maxRangeEnd, fTotalHighlightAnnotationRange.offset + fTotalHighlightAnnotationRange.length);
- }
-
- if (fTotalHighlightAnnotationRange == null)
- fTotalHighlightAnnotationRange= new Position(0);
- if (fCurrentHighlightAnnotationRange == null)
- fCurrentHighlightAnnotationRange= new Position(0);
-
- if (isWorldChange) {
- fTotalHighlightAnnotationRange.offset= highlightAnnotationRangeStart;
- fTotalHighlightAnnotationRange.length= highlightAnnotationRangeEnd - highlightAnnotationRangeStart;
- fCurrentHighlightAnnotationRange.offset= maxRangeStart;
- fCurrentHighlightAnnotationRange.length= maxRangeEnd - maxRangeStart;
- } else {
- fTotalHighlightAnnotationRange.offset= maxRangeStart;
- fTotalHighlightAnnotationRange.length= maxRangeEnd - maxRangeStart;
- fCurrentHighlightAnnotationRange.offset=highlightAnnotationRangeStart;
- fCurrentHighlightAnnotationRange.length= highlightAnnotationRangeEnd - highlightAnnotationRangeStart;
- }
- } else {
- if (isWorldChange) {
- fCurrentHighlightAnnotationRange= fTotalHighlightAnnotationRange;
- fTotalHighlightAnnotationRange= null;
- } else {
- fCurrentHighlightAnnotationRange= null;
- }
- }
-
- adaptToDocumentLength(fCurrentHighlightAnnotationRange);
- adaptToDocumentLength(fTotalHighlightAnnotationRange);
- }
-
- /**
- * Adapts the given position to the document length.
- *
- * @param position the position to adapt
- * @since 3.0
- */
- private void adaptToDocumentLength(Position position) {
- if (position == null)
- return;
-
- int length= fSourceViewer.getDocument().getLength();
- position.offset= Math.min(position.offset, length);
- position.length= Math.min(position.length, length - position.offset);
- }
-
- /**
- * Returns a decoration for the given annotation if this
- * annotation is valid and shown by this painter.
- *
- * @param annotation the annotation
- * @param decoration the decoration to be adapted and returned or <code>null</code> if a new one must be created
- * @param isDrawingSquiggles tells if squiggles should be drawn for this annotation
- * @param isHighlighting tells if this annotation should be highlighted
- * @return the decoration or <code>null</code> if there's no valid one
- * @since 3.0
- */
- private Decoration getDecoration(Annotation annotation, Decoration decoration, boolean isDrawingSquiggles, boolean isHighlighting) {
-
- if (annotation.isMarkedDeleted())
- return null;
-
- Color color= null;
-
- if (isDrawingSquiggles || isHighlighting)
- color= findColor(annotation.getType());
-
- if (color == null)
- return null;
-
- Position position= fModel.getPosition(annotation);
- if (position == null || position.isDeleted())
- return null;
-
- if (decoration == null)
- decoration= new Decoration();
-
- decoration.fPosition= position;
- decoration.fColor= color;
- if (fAnnotationAccess instanceof IAnnotationAccessExtension) {
- IAnnotationAccessExtension extension= (IAnnotationAccessExtension) fAnnotationAccess;
- decoration.fLayer= extension.getLayer(annotation);
- } else {
- decoration.fLayer= IAnnotationAccessExtension.DEFAULT_LAYER;
- }
- decoration.fPainter= getDrawingStrategy(annotation);
-
- return decoration;
- }
-
- /**
- * Returns the drawing type for the given annotation type.
- *
- * @param annotationType the annotation type
- * @return the annotation painter
- * @since 3.0
- */
- private IDrawingStrategy getDrawingStrategy(Annotation annotation) {
- String type= annotation.getType();
- IDrawingStrategy strategy = (IDrawingStrategy) fRegisteredDrawingStrategies.get(fAnnotationType2DrawingStrategyId.get(type));
- if (strategy != null)
- return strategy;
-
- if (fAnnotationAccess instanceof IAnnotationAccessExtension) {
- IAnnotationAccessExtension ext = (IAnnotationAccessExtension) fAnnotationAccess;
- Object[] sts = ext.getSupertypes(type);
- for (int i= 0; i < sts.length; i++) {
- strategy= (IDrawingStrategy) fRegisteredDrawingStrategies.get(fAnnotationType2DrawingStrategyId.get(sts[i]));
- if (strategy != null)
- return strategy;
- }
- }
-
- return fgNullDrawer;
-
- }
-
- /**
- * Returns whether the given annotation type should be drawn.
- *
- * @param annotationType the annotation type
- * @return <code>true</code> if annotation type should be drawn, <code>false</code>
- * otherwise
- * @since 3.0
- */
- private boolean shouldBeDrawn(Object annotationType) {
- return contains(annotationType, fAllowedAnnotationTypes, fConfiguredAnnotationTypes);
- }
-
- /**
- * Returns whether the given annotation type should be highlighted.
- *
- * @param annotationType the annotation type
- * @return <code>true</code> if annotation type should be highlighted, <code>false</code>
- * otherwise
- * @since 3.0
- */
- private boolean shouldBeHighlighted(Object annotationType) {
- return contains(annotationType, fAllowedHighlightAnnotationTypes, fConfiguredHighlightAnnotationTypes);
- }
-
- /**
- * Returns whether the given annotation type is contained in the given <code>allowed</code>
- * set. This is the case if the type is either in the set
- * or covered by the <code>configured</code> set.
- *
- * @param annotationType the annotation type
- * @return <code>true</code> if annotation is contained, <code>false</code>
- * otherwise
- * @since 3.0
- */
- private boolean contains(Object annotationType, Set allowed, Set configured) {
- if (allowed.contains(annotationType))
- return true;
-
- boolean covered= isCovered(annotationType, configured);
- if (covered)
- allowed.add(annotationType);
-
- return covered;
- }
-
- /**
- * Computes whether the annotations of the given type are covered by the given <code>configured</code>
- * set. This is the case if either the type of the annotation or any of its
- * super types is contained in the <code>configured</code> set.
- *
- * @param annotation the annotation
- * @param annotationType the annotation type
- * @return <code>true</code> if annotation is covered, <code>false</code>
- * otherwise
- * @since 3.0
- */
- private boolean isCovered(Object annotationType, Set configured) {
- if (fAnnotationAccess instanceof IAnnotationAccessExtension) {
- IAnnotationAccessExtension extension= (IAnnotationAccessExtension) fAnnotationAccess;
- Iterator e= configured.iterator();
- while (e.hasNext()) {
- if (extension.isSubtype(annotationType,e.next()))
- return true;
- }
- return false;
- }
- return configured.contains(annotationType);
- }
-
- /**
- * Returns the color for the given annotation type
- *
- * @param annotationType the annotation type
- * @return the color
- */
- private Color findColor(Object annotationType) {
- Color color= (Color) fColorTable.get(annotationType);
- if (color != null)
- return color;
-
- if (fAnnotationAccess instanceof IAnnotationAccessExtension) {
- IAnnotationAccessExtension extension= (IAnnotationAccessExtension) fAnnotationAccess;
- Object[] superTypes= extension.getSupertypes(annotationType);
- if (superTypes != null) {
- for (int i= 0; i < superTypes.length; i++) {
- color= (Color) fColorTable.get(superTypes[i]);
- if (color != null)
- return color;
- }
- }
- }
-
- return null;
- }
-
- /**
- * Recomputes the squiggles to be drawn and redraws them.
- */
- private void updatePainting(AnnotationModelEvent event) {
- disablePainting(true);
-
- catchupWithModel(event);
-
- if (!fInputDocumentAboutToBeChanged)
- invalidateTextPresentation();
-
- enablePainting();
- }
-
- private void invalidateTextPresentation() {
- if (fCurrentHighlightAnnotationRange== null)
- return;
-
- if (fSourceViewer instanceof ITextViewerExtension2) {
- IRegion r= new Region(fCurrentHighlightAnnotationRange.getOffset(), fCurrentHighlightAnnotationRange.getLength());
-
- if (DEBUG)
- System.out.println("AP: invalidating offset: " + r.getOffset() + ", length= " + r.getLength()); //$NON-NLS-1$ //$NON-NLS-2$
-
- ((ITextViewerExtension2)fSourceViewer).invalidateTextPresentation(r.getOffset(), r.getLength());
- } else {
- fSourceViewer.invalidateTextPresentation();
- }
- }
-
- /*
- * @see ITextPresentationListener#applyTextPresentation(TextPresentation)
- * @since 3.0
- */
- public synchronized void applyTextPresentation(TextPresentation tp) {
-
- if (fHighlightedDecorationsMap == null || fHighlightedDecorationsMap.isEmpty())
- return;
-
- IRegion region= tp.getExtent();
-
- if (DEBUG)
- System.out.println("AP: applying text presentation offset: " + region.getOffset() + ", length= " + region.getLength()); //$NON-NLS-1$ //$NON-NLS-2$
-
- for (int layer= 0, maxLayer= 1; layer < maxLayer; layer++) {
-
- for (Iterator iter= fHighlightedDecorationsMap.entrySet().iterator(); iter.hasNext();) {
- Map.Entry entry= (Map.Entry)iter.next();
-
- Annotation a= (Annotation)entry.getKey();
- if (a.isMarkedDeleted())
- continue;
-
- Decoration pp = (Decoration)entry.getValue();
-
- maxLayer= Math.max(maxLayer, pp.fLayer + 1); // dynamically update layer maximum
- if (pp.fLayer != layer) // wrong layer: skip annotation
- continue;
-
- Position p= pp.fPosition;
- if (fSourceViewer instanceof ITextViewerExtension5) {
- ITextViewerExtension5 extension3= (ITextViewerExtension5) fSourceViewer;
- if (null == extension3.modelRange2WidgetRange(new Region(p.getOffset(), p.getLength())))
- continue;
- } else if (!fSourceViewer.overlapsWithVisibleRegion(p.offset, p.length)) {
- continue;
- }
-
- if (p.getOffset() + p.getLength() >= region.getOffset() && region.getOffset() + region.getLength() > p.getOffset())
- tp.mergeStyleRange(new StyleRange(p.getOffset(), p.getLength(), null, pp.fColor));
- }
- }
- }
-
- /*
- * @see IAnnotationModelListener#modelChanged(IAnnotationModel)
- */
- public synchronized void modelChanged(final IAnnotationModel model) {
- if (DEBUG)
- System.err.println("AP: OLD API of AnnotationModelListener called"); //$NON-NLS-1$
-
- modelChanged(new AnnotationModelEvent(model));
- }
-
- /*
- * @see IAnnotationModelListenerExtension#modelChanged(AnnotationModelEvent)
- */
- public synchronized void modelChanged(final AnnotationModelEvent event) {
- if (fTextWidget != null && !fTextWidget.isDisposed()) {
- if (fIsSettingModel) {
- // inside the ui thread -> no need for posting
- updatePainting(event);
- } else {
- Display d= fTextWidget.getDisplay();
- if (DEBUG && event != null && event.isWorldChange()) {
- System.out.println("AP: WORLD CHANGED, stack trace follows:"); //$NON-NLS-1$
- try {
- throw new Throwable();
- } catch (Throwable t) {
- t.printStackTrace(System.out);
- }
- }
-
- // TODO posting here is a problem for annotations that are being
- // removed and the positions of which are not updated to document
- // changes any more. If the document gets modified between
- // now and running the posted runnable, the position information
- // is not accurate any longer.
- if (d != null) {
- d.asyncExec(new Runnable() {
- public void run() {
- if (fTextWidget != null && !fTextWidget.isDisposed())
- updatePainting(event);
- }
- });
- }
- }
- }
- }
-
- /**
- * Sets the color in which the squiggly for the given annotation type should be drawn.
- *
- * @param annotationType the annotation type
- * @param color the color
- */
- public void setAnnotationTypeColor(Object annotationType, Color color) {
- if (color != null)
- fColorTable.put(annotationType, color);
- else
- fColorTable.remove(annotationType);
- }
-
- /**
- * Adds the given annotation type to the list of annotation types whose
- * annotations should be painted by this painter using squiggly drawing. If the annotation type
- * is already in this list, this method is without effect.
- *
- * @param annotationType the annotation type
- */
- public void addAnnotationType(Object annotationType) {
- addAnnotationType(annotationType, SQUIGGLES);
- }
-
- /**
- * Adds the given annotation type to the list of annotation types whose
- * annotations should be painted by this painter using the given drawing strategy.
- * If the annotation type is already in this list, the old drawing strategy gets replaced.
- *
- * <p>TODO This is new API and subject to change. </p>
- *
- * @param annotationType the annotation type
- * @param drawingStrategyID the id of the drawing strategy that should be used for this annotation type
- * @since 3.0
- */
- public void addAnnotationType(Object annotationType, Object drawingStrategyID) {
- fConfiguredAnnotationTypes.add(annotationType);
- fAnnotationType2DrawingStrategyId.put(annotationType, drawingStrategyID);
- }
-
- /**
- * Registers a new drawing strategy under the given ID. If there is already a
- * strategy registered under <code>id</code>, the old strategy gets replaced.
- * <p>The given id can be referenced when adding annotation types, see
- * {@link #addAnnotationType(Object, Object)}.</p>
- *
- * <p>TODO This is new API and subject to change. </p>
- *
- * @param id the identifier under which the strategy can be referenced, not <code>null</code>
- * @param strategy the new strategy
- * @since 3.0
- */
- public void addDrawingStrategy(Object id, IDrawingStrategy strategy) {
- // don't permit null as null is used to signal that an annotation type is not
- // registered with a specific strategy, and that its annotation hierarchy should be searched
- if (id == null)
- throw new IllegalArgumentException();
- fRegisteredDrawingStrategies.put(id, strategy);
- }
-
- /**
- * Adds the given annotation type to the list of annotation types whose
- * annotations should be highlighted this painter. If the annotation type
- * is already in this list, this method is without effect.
- *
- * @param annotationType the annotation type
- * @since 3.0
- */
- public void addHighlightAnnotationType(Object annotationType) {
- fConfiguredHighlightAnnotationTypes.add(annotationType);
- if (fTextInputListener == null) {
- fTextInputListener= new 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) {
- fInputDocumentAboutToBeChanged= true;
- }
- /*
- * @see org.eclipse.jface.text.ITextInputListener#inputDocumentChanged(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IDocument)
- */
- public void inputDocumentChanged(IDocument oldInput, IDocument newInput) {
- fInputDocumentAboutToBeChanged= false;
- }
- };
- fSourceViewer.addTextInputListener(fTextInputListener);
- }
- }
-
- /**
- * Removes the given annotation type from the list of annotation types whose
- * annotations are painted by this painter. If the annotation type is not
- * in this list, this method is wihtout effect.
- *
- * @param annotationType the annotation type
- */
- public void removeAnnotationType(Object annotationType) {
- fConfiguredAnnotationTypes.remove(annotationType);
- fAllowedAnnotationTypes.clear();
- }
-
- /**
- * Removes the given annotation type from the list of annotation types whose
- * annotations are highlighted by this painter. If the annotation type is not
- * in this list, this method is wihtout effect.
- *
- * @param annotationType the annotation type
- * @since 3.0
- */
- public void removeHighlightAnnotationType(Object annotationType) {
- fConfiguredHighlightAnnotationTypes.remove(annotationType);
- fAllowedHighlightAnnotationTypes.clear();
- if (fConfiguredHighlightAnnotationTypes.isEmpty() && fTextInputListener != null) {
- fSourceViewer.removeTextInputListener(fTextInputListener);
- fTextInputListener= null;
- fInputDocumentAboutToBeChanged= false;
- }
- }
-
- /**
- * Clears the list of annotation types whose annotations are
- * painted by this painter.
- */
- public void removeAllAnnotationTypes() {
- fConfiguredAnnotationTypes.clear();
- fAllowedAnnotationTypes.clear();
- fConfiguredHighlightAnnotationTypes.clear();
- fAllowedHighlightAnnotationTypes.clear();
- if (fTextInputListener != null) {
- fSourceViewer.removeTextInputListener(fTextInputListener);
- fTextInputListener= null;
- }
- }
-
- /**
- * Returns whether the list of annotation types whose annotations are painted
- * by this painter contains at least on element.
- *
- * @return <code>true</code> if there is an annotation type whose annotations are painted
- */
- public boolean isPaintingAnnotations() {
- return !fConfiguredAnnotationTypes.isEmpty() || !fConfiguredHighlightAnnotationTypes.isEmpty();
- }
-
- /*
- * @see IPainter#dispose()
- */
- public void dispose() {
-
- if (fColorTable != null)
- fColorTable.clear();
- fColorTable= null;
-
- if (fConfiguredAnnotationTypes != null)
- fConfiguredAnnotationTypes.clear();
- fConfiguredAnnotationTypes= null;
-
- if (fAllowedAnnotationTypes != null)
- fAllowedAnnotationTypes.clear();
- fAllowedAnnotationTypes= null;
-
- if (fConfiguredHighlightAnnotationTypes != null)
- fConfiguredHighlightAnnotationTypes.clear();
- fConfiguredHighlightAnnotationTypes= null;
-
- if (fAllowedHighlightAnnotationTypes != null)
- fAllowedHighlightAnnotationTypes.clear();
- fAllowedHighlightAnnotationTypes= null;
-
- fTextWidget= null;
- fSourceViewer= null;
- fAnnotationAccess= null;
- fModel= null;
- fDecorationsMap= null;
- fHighlightedDecorationsMap= null;
- }
-
- /**
- * Returns the document offset of the upper left corner of the source viewer's viewport,
- * possibly including partially visible lines.
- *
- * @return the document offset if the upper left corner of the viewport
- */
- private int getInclusiveTopIndexStartOffset() {
-
- if (fTextWidget != null && !fTextWidget.isDisposed()) {
- int top= fSourceViewer.getTopIndex();
- if ((fTextWidget.getTopPixel() % fTextWidget.getLineHeight()) != 0)
- top--;
- try {
- IDocument document= fSourceViewer.getDocument();
- return document.getLineOffset(top);
- } catch (BadLocationException ex) {
- }
- }
-
- return -1;
- }
-
- /*
- * @see PaintListener#paintControl(PaintEvent)
- */
- public void paintControl(PaintEvent event) {
- if (fTextWidget != null)
- handleDrawRequest(event.gc);
- }
-
- /**
- * Handles the request to draw the annotations using the given gaphical context.
- *
- * @param gc the graphical context
- */
- private void handleDrawRequest(GC gc) {
-
- if (fTextWidget == null) {
- // is already disposed
- return;
- }
-
- int vOffset= getInclusiveTopIndexStartOffset();
- // http://bugs.eclipse.org/bugs/show_bug.cgi?id=17147
- int vLength= fSourceViewer.getBottomIndexEndOffset() + 1;
-
- for (int layer= 0, maxLayer= 1; layer < maxLayer; layer++) {
-
- for (Iterator e = fDecorationsMap.entrySet().iterator(); e.hasNext();) {
- Map.Entry entry= (Map.Entry)e.next();
-
- Annotation a= (Annotation)entry.getKey();
- if (a.isMarkedDeleted())
- continue;
-
- Decoration pp = (Decoration)entry.getValue();
-
- maxLayer= Math.max(maxLayer, pp.fLayer + 1); // dynamically update layer maximum
- if (pp.fLayer != layer) // wrong layer: skip annotation
- continue;
-
- Position p= pp.fPosition;
- if (p.overlapsWith(vOffset, vLength)) {
-
- IDocument document= fSourceViewer.getDocument();
- try {
-
- int startLine= document.getLineOfOffset(p.getOffset());
- int lastInclusive= Math.max(p.getOffset(), p.getOffset() + p.getLength() - 1);
- int endLine= document.getLineOfOffset(lastInclusive);
-
- for (int i= startLine; i <= endLine; i++) {
- IRegion line= document.getLineInformation(i);
- int paintStart= Math.max(line.getOffset(), p.getOffset());
- int paintEnd= Math.min(line.getOffset() + line.getLength(), p.getOffset() + p.getLength());
- if (paintEnd >= paintStart) {
- // otherwise inside a line delimiter
- IRegion widgetRange= getWidgetRange(new Position(paintStart, paintEnd - paintStart));
- if (widgetRange != null)
- pp.fPainter.draw(a, gc, fTextWidget, widgetRange.getOffset(), widgetRange.getLength(), pp.fColor);
- }
- }
-
- } catch (BadLocationException x) {
- }
- }
- }
- }
- }
-
- /**
- * Returns the widget region that corresponds to the given region in the
- * viewer's document.
- *
- * @param p the region in the viewer's document
- * @return the corresponding widget region
- */
- private IRegion getWidgetRange(Position p) {
- if (p == null || p.offset == Integer.MAX_VALUE)
- return null;
-
- if (fSourceViewer instanceof ITextViewerExtension5) {
-
- ITextViewerExtension5 extension= (ITextViewerExtension5) fSourceViewer;
- return extension.modelRange2WidgetRange(new Region(p.getOffset(), p.getLength()));
-
- } else {
-
- IRegion region= fSourceViewer.getVisibleRegion();
- int offset= region.getOffset();
- int length= region.getLength();
-
- if (p.overlapsWith(offset , length)) {
- int p1= Math.max(offset, p.getOffset());
- int p2= Math.min(offset + length, p.getOffset() + p.getLength());
- return new Region(p1 - offset, p2 - p1);
- }
- }
-
- return null;
- }
-
- /*
- * @see IPainter#deactivate(boolean)
- */
- public void deactivate(boolean redraw) {
- if (fIsActive) {
- fIsActive= false;
- disablePainting(redraw);
- setModel(null);
- catchupWithModel(null);
- }
- }
-
- /**
- * Returns whether the given reason causes a repaint.
- *
- * @param reason the reason
- * @return <code>true</code> if repaint reason, <code>false</code> otherwise
- * @since 3.0
- */
- protected boolean isRepaintReason(int reason) {
- return CONFIGURATION == reason || INTERNAL == reason;
- }
-
- /**
- * Retrieves the annotation model from the given source viewer.
- * @since 3.0
- */
- protected IAnnotationModel findAnnotationModel(ISourceViewer sourceViewer) {
- if(sourceViewer != null)
- return sourceViewer.getAnnotationModel();
- return null;
- }
-
- /*
- * @see IPainter#paint(int)
- */
- public void paint(int reason) {
- if (fSourceViewer.getDocument() == null) {
- deactivate(false);
- return;
- }
-
- if (!fIsActive) {
- IAnnotationModel model= findAnnotationModel(fSourceViewer);
- if (model != null) {
- fIsActive= true;
- setModel(model);
- }
- } else if (isRepaintReason(reason))
- updatePainting(null);
- }
-
- /*
- * @see org.eclipse.jface.text.IPainter#setPositionManager(org.eclipse.jface.text.IPaintPositionManager)
- */
- public void setPositionManager(IPaintPositionManager manager) {
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationRulerColumn.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationRulerColumn.java
deleted file mode 100644
index df3bd63..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationRulerColumn.java
+++ /dev/null
@@ -1,708 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.source;
-
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextListener;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.ITextViewerExtension5;
-import org.eclipse.jface.text.IViewportListener;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextEvent;
-import org.eclipse.jface.text.TextViewer;
-
-
-/**
- * A vertical ruler column showing graphical representations of annotations.
- * Will become final. Do not subclass.
- * @since 2.0
- */
-public class AnnotationRulerColumn implements IVerticalRulerColumn, IVerticalRulerInfo, IVerticalRulerInfoExtension {
-
- /**
- * Internal listener class.
- */
- class InternalListener implements IViewportListener, IAnnotationModelListener, ITextListener {
-
- /*
- * @see IViewportListener#viewportChanged(int)
- */
- public void viewportChanged(int verticalPosition) {
- if (verticalPosition != fScrollPos)
- redraw();
- }
-
- /*
- * @see IAnnotationModelListener#modelChanged(IAnnotationModel)
- */
- public void modelChanged(IAnnotationModel model) {
- postRedraw();
- }
-
- /*
- * @see ITextListener#textChanged(TextEvent)
- */
- public void textChanged(TextEvent e) {
- if (e.getViewerRedrawState())
- postRedraw();
- }
- }
-
-
- /** This column's parent ruler */
- private CompositeRuler fParentRuler;
- /** The cached text viewer */
- private ITextViewer fCachedTextViewer;
- /** The cached text widget */
- private StyledText fCachedTextWidget;
- /** The ruler's canvas */
- private Canvas fCanvas;
- /** The vertical ruler's model */
- private IAnnotationModel fModel;
- /** Cache for the actual scroll position in pixels */
- private int fScrollPos;
- /** The drawable for double buffering */
- private Image fBuffer;
- /** The internal listener */
- private InternalListener fInternalListener= new InternalListener();
- /** The width of this vertical ruler */
- private int fWidth;
- /** Switch for enabling/disabling the setModel method. */
- private boolean fAllowSetModel= true;
- /**
- * The list of annotation types to be shown in this ruler.
- * @since 3.0
- */
- private Set fConfiguredAnnotationTypes= new HashSet();
- /**
- * The list of allowed annotation types to be shown in this ruler.
- * @since 3.0
- */
- private Set fAllowedAnnotationTypes= new HashSet();
- /**
- * The annotation access.
- * @since 3.0
- */
- private IAnnotationAccess fAnnotationAccess;
- /**
- * The hover for this column.
- * @since 3.0
- */
- private IAnnotationHover fHover;
-
-
- /**
- * Constructs this column with the given arguments.
- *
- * @param model the annotation model to get the annotations from
- * @param width the width of the vertical ruler
- * @param annotationAccess the annotation access
- * @since 3.0
- */
- public AnnotationRulerColumn(IAnnotationModel model, int width, IAnnotationAccess annotationAccess) {
- fWidth= width;
- fAllowSetModel= false;
- fModel= model;
- fModel.addAnnotationModelListener(fInternalListener);
- fAnnotationAccess= annotationAccess;
- }
-
- /**
- * Constructs this column with the given arguments.
- *
- * @param width the width of the vertical ruler
- * @param annotationAccess the annotation access
- * @since 3.0
- */
- public AnnotationRulerColumn(int width, IAnnotationAccess annotationAccess) {
- fWidth= width;
- fAnnotationAccess= annotationAccess;
- }
-
- /**
- * Constructs this column with the given arguments.
- *
- * @param model the annotation model to get the annotations from
- * @param width the width of the vertical ruler
- */
- public AnnotationRulerColumn(IAnnotationModel model, int width) {
- fWidth= width;
- fAllowSetModel= false;
- fModel= model;
- fModel.addAnnotationModelListener(fInternalListener);
- }
-
- /**
- * Constructs this column with the given width.
- *
- * @param width the width of the vertical ruler
- */
- public AnnotationRulerColumn(int width) {
- fWidth= width;
- }
-
- /*
- * @see IVerticalRulerColumn#getControl()
- */
- public Control getControl() {
- return fCanvas;
- }
-
- /*
- * @see IVerticalRulerColumn#getWidth()
- */
- public int getWidth() {
- return fWidth;
- }
-
- /*
- * @see IVerticalRulerColumn#createControl(CompositeRuler, Composite)
- */
- public Control createControl(CompositeRuler parentRuler, Composite parentControl) {
-
- fParentRuler= parentRuler;
- fCachedTextViewer= parentRuler.getTextViewer();
- fCachedTextWidget= fCachedTextViewer.getTextWidget();
-
- fCanvas= new Canvas(parentControl, SWT.NO_BACKGROUND);
-
- fCanvas.addPaintListener(new PaintListener() {
- public void paintControl(PaintEvent event) {
- if (fCachedTextViewer != null)
- doubleBufferPaint(event.gc);
- }
- });
-
- fCanvas.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- handleDispose();
- fCachedTextViewer= null;
- fCachedTextWidget= null;
- }
- });
-
- fCanvas.addMouseListener(new MouseListener() {
- public void mouseUp(MouseEvent event) {
- fParentRuler.setLocationOfLastMouseButtonActivity(event.x, event.y);
- mouseClicked(fParentRuler.getLineOfLastMouseButtonActivity());
- }
-
- public void mouseDown(MouseEvent event) {
- fParentRuler.setLocationOfLastMouseButtonActivity(event.x, event.y);
- }
-
- public void mouseDoubleClick(MouseEvent event) {
- fParentRuler.setLocationOfLastMouseButtonActivity(event.x, event.y);
- mouseDoubleClicked(fParentRuler.getLineOfLastMouseButtonActivity());
- }
- });
-
- if (fCachedTextViewer != null) {
- fCachedTextViewer.addViewportListener(fInternalListener);
- fCachedTextViewer.addTextListener(fInternalListener);
- }
-
- return fCanvas;
- }
-
- /**
- * Hook method for a mouse double click event on the given ruler line.
- *
- * @param rulerLine the ruler line
- */
- protected void mouseDoubleClicked(int rulerLine) {
- }
-
- /**
- * Hook method for a mouse click event on the given ruler line.
- *
- * @param rulerLine the ruler line
- */
- protected void mouseClicked(int rulerLine) {
- }
-
- /**
- * Disposes the ruler's resources.
- */
- private void handleDispose() {
-
- if (fCachedTextViewer != null) {
- fCachedTextViewer.removeViewportListener(fInternalListener);
- fCachedTextViewer.removeTextListener(fInternalListener);
- }
-
- if (fModel != null)
- fModel.removeAnnotationModelListener(fInternalListener);
-
- if (fBuffer != null) {
- fBuffer.dispose();
- fBuffer= null;
- }
-
- fConfiguredAnnotationTypes.clear();
- fAllowedAnnotationTypes.clear();
- fAnnotationAccess= null;
- }
-
- /**
- * Double buffer drawing.
- *
- * @param dest the gc to draw into
- */
- private void doubleBufferPaint(GC dest) {
-
- Point size= fCanvas.getSize();
-
- if (size.x <= 0 || size.y <= 0)
- return;
-
- if (fBuffer != null) {
- Rectangle r= fBuffer.getBounds();
- if (r.width != size.x || r.height != size.y) {
- fBuffer.dispose();
- fBuffer= null;
- }
- }
- if (fBuffer == null)
- fBuffer= new Image(fCanvas.getDisplay(), size.x, size.y);
-
- GC gc= new GC(fBuffer);
- gc.setFont(fCachedTextWidget.getFont());
- try {
- gc.setBackground(fCanvas.getBackground());
- gc.fillRectangle(0, 0, size.x, size.y);
-
- if (fCachedTextViewer instanceof ITextViewerExtension5)
- doPaint1(gc);
- else
- doPaint(gc);
- } finally {
- gc.dispose();
- }
-
- dest.drawImage(fBuffer, 0, 0);
- }
-
- /**
- * Returns the document offset of the upper left corner of the source viewer's
- * viewport, possibly including partially visible lines.
- *
- * @return document offset of the upper left corner including partially visible lines
- */
- protected int getInclusiveTopIndexStartOffset() {
-
- if (fCachedTextWidget != null && !fCachedTextWidget.isDisposed()) {
- int top= fCachedTextViewer.getTopIndex();
- if ((fCachedTextWidget.getTopPixel() % fCachedTextWidget.getLineHeight()) != 0)
- top--;
- try {
- IDocument document= fCachedTextViewer.getDocument();
- return document.getLineOffset(top);
- } catch (BadLocationException ex) {
- }
- }
-
- return -1;
- }
-
- /**
- * Draws the vertical ruler w/o drawing the Canvas background.
- *
- * @param gc the gc to draw into
- */
- protected void doPaint(GC gc) {
-
- if (fModel == null || fCachedTextViewer == null)
- return;
-
- IAnnotationAccessExtension annotationAccessExtension= null;
- if (fAnnotationAccess instanceof IAnnotationAccessExtension)
- annotationAccessExtension= (IAnnotationAccessExtension) fAnnotationAccess;
-
- int topLeft= getInclusiveTopIndexStartOffset();
- int bottomRight;
-
- if (fCachedTextViewer instanceof ITextViewerExtension5) {
- ITextViewerExtension5 extension= (ITextViewerExtension5) fCachedTextViewer;
- IRegion coverage= extension.getModelCoverage();
- bottomRight= coverage.getOffset() + coverage.getLength();
- } else if (fCachedTextViewer instanceof TextViewer) {
- // TODO remove once TextViewer implements ITextViewerExtension5
- TextViewer extension= (TextViewer) fCachedTextViewer;
- IRegion coverage= extension.getModelCoverage();
- bottomRight= coverage.getOffset() + coverage.getLength();
- } else {
- // http://dev.eclipse.org/bugs/show_bug.cgi?id=14938
- // http://dev.eclipse.org/bugs/show_bug.cgi?id=22487
- // add 1 as getBottomIndexEndOffset returns the inclusive offset, but we want the exclusive offset (right after the last character)
- bottomRight= fCachedTextViewer.getBottomIndexEndOffset() + 1;
- }
- int viewPort= bottomRight - topLeft;
-
- fScrollPos= fCachedTextWidget.getTopPixel();
- int lineheight= fCachedTextWidget.getLineHeight();
- Point dimension= fCanvas.getSize();
- int shift= fCachedTextViewer.getTopInset();
-
- IDocument doc= fCachedTextViewer.getDocument();
-
- int topLine= -1, bottomLine= -1;
- try {
- IRegion region= fCachedTextViewer.getVisibleRegion();
- topLine= doc.getLineOfOffset(region.getOffset());
- bottomLine= doc.getLineOfOffset(region.getOffset() + region.getLength());
- } catch (BadLocationException x) {
- return;
- }
-
- // draw Annotations
- Rectangle r= new Rectangle(0, 0, 0, 0);
- int maxLayer= 1; // loop at least once thru layers.
-
- for (int layer= 0; layer < maxLayer; layer++) {
- Iterator iter= fModel.getAnnotationIterator();
- while (iter.hasNext()) {
- Annotation annotation= (Annotation) iter.next();
-
- if (skip(annotation))
- continue;
-
- int lay= IAnnotationAccessExtension.DEFAULT_LAYER;
- if (annotationAccessExtension != null)
- lay= annotationAccessExtension.getLayer(annotation);
- maxLayer= Math.max(maxLayer, lay+1); // dynamically update layer maximum
- if (lay != layer) // wrong layer: skip annotation
- continue;
-
- Position position= fModel.getPosition(annotation);
- if (position == null)
- continue;
-
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=20284
- // Position.overlapsWith returns false if the position just starts at the end
- // of the specified range. If the position has zero length, we want to include it anyhow
- int viewPortSize= position.getLength() == 0 ? viewPort + 1 : viewPort;
- if (!position.overlapsWith(topLeft, viewPortSize))
- continue;
-
- try {
-
- int offset= position.getOffset();
- int length= position.getLength();
-
- int startLine= doc.getLineOfOffset(offset);
- if (startLine < topLine)
- startLine= topLine;
-
- int endLine= startLine;
- if (length > 0)
- endLine= doc.getLineOfOffset(offset + length - 1);
- if (endLine > bottomLine)
- endLine= bottomLine;
-
- startLine -= topLine;
- endLine -= topLine;
-
- r.x= 0;
- r.y= (startLine * lineheight) - fScrollPos + shift;
- r.width= dimension.x;
- int lines= endLine - startLine;
- if (lines < 0)
- lines= -lines;
- r.height= (lines+1) * lineheight;
-
- if (r.y < dimension.y && annotationAccessExtension != null) // annotation within visible area
- annotationAccessExtension.paint(annotation, gc, fCanvas, r);
-
- } catch (BadLocationException e) {
- }
- }
- }
- }
-
- /**
- * Draws the vertical ruler w/o drawing the Canvas background. Implementation based
- * on <code>ITextViewerExtension5</code>. Will replace <code>doPaint(GC)</code>.
- *
- * @param gc the gc to draw into
- */
- protected void doPaint1(GC gc) {
-
- if (fModel == null || fCachedTextViewer == null)
- return;
-
- IAnnotationAccessExtension annotationAccessExtension= null;
- if (fAnnotationAccess instanceof IAnnotationAccessExtension)
- annotationAccessExtension= (IAnnotationAccessExtension) fAnnotationAccess;
-
- ITextViewerExtension5 extension= (ITextViewerExtension5) fCachedTextViewer;
-
- fScrollPos= fCachedTextWidget.getTopPixel();
- int lineheight= fCachedTextWidget.getLineHeight();
- Point dimension= fCanvas.getSize();
- int shift= fCachedTextViewer.getTopInset();
-
- // draw Annotations
- Rectangle r= new Rectangle(0, 0, 0, 0);
- int maxLayer= 1; // loop at least once thru layers.
-
- for (int layer= 0; layer < maxLayer; layer++) {
- Iterator iter= fModel.getAnnotationIterator();
- while (iter.hasNext()) {
- Annotation annotation= (Annotation) iter.next();
-
- if (skip(annotation))
- continue;
-
- int lay= IAnnotationAccessExtension.DEFAULT_LAYER;
- if (annotationAccessExtension != null)
- lay= annotationAccessExtension.getLayer(annotation);
- maxLayer= Math.max(maxLayer, lay+1); // dynamically update layer maximum
- if (lay != layer) // wrong layer: skip annotation
- continue;
-
- Position position= fModel.getPosition(annotation);
- if (position == null)
- continue;
-
- IRegion widgetRegion= extension.modelRange2WidgetRange(new Region(position.getOffset(), position.getLength()));
- if (widgetRegion == null)
- continue;
-
- int startLine= extension.widgetLineOfWidgetOffset(widgetRegion.getOffset());
- if (startLine == -1)
- continue;
-
- int endLine= extension.widgetLineOfWidgetOffset(widgetRegion.getOffset() + Math.max(widgetRegion.getLength() -1, 0));
- if (endLine == -1)
- continue;
-
- r.x= 0;
- r.y= (startLine * lineheight) - fScrollPos + shift;
- r.width= dimension.x;
- int lines= endLine - startLine;
- if (lines < 0)
- lines= -lines;
- r.height= (lines+1) * lineheight;
-
- if (r.y < dimension.y && annotationAccessExtension != null) // annotation within visible area
- annotationAccessExtension.paint(annotation, gc, fCanvas, r);
- }
- }
- }
-
-
- /**
- * Post a redraw request for this column into the UI thread.
- */
- private void postRedraw() {
- if (fCanvas != null && !fCanvas.isDisposed()) {
- Display d= fCanvas.getDisplay();
- if (d != null) {
- d.asyncExec(new Runnable() {
- public void run() {
- redraw();
- }
- });
- }
- }
- }
-
- /*
- * @see IVerticalRulerColumn#redraw()
- */
- public void redraw() {
- if (fCanvas != null && !fCanvas.isDisposed()) {
- GC gc= new GC(fCanvas);
- doubleBufferPaint(gc);
- gc.dispose();
- }
- }
-
- /*
- * @see IVerticalRulerColumn#setModel
- */
- public void setModel(IAnnotationModel model) {
- if (fAllowSetModel && model != fModel) {
-
- if (fModel != null)
- fModel.removeAnnotationModelListener(fInternalListener);
-
- fModel= model;
-
- if (fModel != null)
- fModel.addAnnotationModelListener(fInternalListener);
-
- postRedraw();
- }
- }
-
- /*
- * @see IVerticalRulerColumn#setFont(Font)
- */
- public void setFont(Font font) {
- }
-
- /**
- * Returns the cached text viewer.
- *
- * @return the cached text viewer
- */
- protected ITextViewer getCachedTextViewer() {
- return fCachedTextViewer;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#getModel()
- */
- public IAnnotationModel getModel() {
- return fModel;
- }
-
- /**
- * Adds the given annotation type to this annotation ruler column. Starting
- * with this call, annotations of the given type are shown in this annotation
- * ruler column.
- *
- * @param annotationType the annotation type
- * @since 3.0
- */
- public void addAnnotationType(Object annotationType) {
- fConfiguredAnnotationTypes.add(annotationType);
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerInfo#getLineOfLastMouseButtonActivity()
- */
- public int getLineOfLastMouseButtonActivity() {
- return fParentRuler.getLineOfLastMouseButtonActivity();
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerInfo#toDocumentLineNumber(int)
- */
- public int toDocumentLineNumber(int y_coordinate) {
- return fParentRuler.toDocumentLineNumber(y_coordinate);
- }
-
- /**
- * Removes the given annotation type from this annotation ruler column.
- * Annotations of the given type are no longer shown in this annotation
- * ruler column.
- *
- * @param annotationType the annotation type
- * @since 3.0
- */
- public void removeAnnotationType(Object annotationType) {
- fConfiguredAnnotationTypes.remove(annotationType);
- fAllowedAnnotationTypes.clear();
- }
-
- /**
- * Returns whether the given annotation should be skipped by the drawing
- * routine.
- *
- * @param annotationType the annotation type
- * @return <code>true</code> if annotation of the given type should be
- * skipped, <code>false</code> otherwise
- * @since 3.0
- */
- private boolean skip(Annotation annotation) {
- Object annotationType= annotation.getType();
- if (fAllowedAnnotationTypes.contains(annotationType))
- return false;
-
- boolean skip= skip(annotationType);
- if (!skip)
- fAllowedAnnotationTypes.add(annotationType);
- return skip;
- }
-
- /**
- * Computes whether the annotation of the given type should be skipped or
- * not.
- *
- * @param annotation the annotation
- * @param annotationType the annotation type
- * @return <code>true</code> if annotation should be skipped, <code>false</code>
- * otherwise
- * @since 3.0
- */
- private boolean skip(Object annotationType) {
- if (fAnnotationAccess instanceof IAnnotationAccessExtension) {
- IAnnotationAccessExtension extension= (IAnnotationAccessExtension) fAnnotationAccess;
- Iterator e= fConfiguredAnnotationTypes.iterator();
- while (e.hasNext()) {
- if (extension.isSubtype(annotationType, e.next()))
- return false;
- }
- return true;
- }
- return !fConfiguredAnnotationTypes.contains(annotationType);
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#getHover()
- */
- public IAnnotationHover getHover() {
- return fHover;
- }
-
- /**
- * @param hover The hover to set.
- */
- public void setHover(IAnnotationHover hover) {
- fHover= hover;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#addAnnotationListener(org.eclipse.jface.text.source.IAnnotationListener)
- * @since 3.0
- */
- public void addAnnotationListener(IAnnotationListener listener) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#removeAnnotationListener(org.eclipse.jface.text.source.IAnnotationListener)
- * @since 3.0
- */
- public void removeAnnotationListener(IAnnotationListener listener) {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ChangeRulerColumn.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ChangeRulerColumn.java
deleted file mode 100644
index deff995..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ChangeRulerColumn.java
+++ /dev/null
@@ -1,690 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.source;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.MouseMoveListener;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Cursor;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextListener;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.ITextViewerExtension5;
-import org.eclipse.jface.text.IViewportListener;
-import org.eclipse.jface.text.TextEvent;
-
-/**
- * A vertical ruler column displaying line numbers and serving as a UI for quick diff.
- * Clients usually instantiate and configure object of this class.
- *
- * @since 3.0
- */
-public final class ChangeRulerColumn implements IVerticalRulerColumn, IVerticalRulerInfo, IVerticalRulerInfoExtension, IChangeRulerColumn {
-
- /**
- * Handles all the mouse interaction in this line number ruler column.
- */
- class MouseHandler implements MouseListener, MouseMoveListener {
-
- /*
- * @see org.eclipse.swt.events.MouseListener#mouseUp(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseUp(MouseEvent event) {
- }
-
- /*
- * @see org.eclipse.swt.events.MouseListener#mouseDown(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseDown(MouseEvent event) {
- fParentRuler.setLocationOfLastMouseButtonActivity(event.x, event.y);
- }
-
- /*
- * @see org.eclipse.swt.events.MouseListener#mouseDoubleClick(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseDoubleClick(MouseEvent event) {
- fParentRuler.setLocationOfLastMouseButtonActivity(event.x, event.y);
- }
-
- /*
- * @see org.eclipse.swt.events.MouseMoveListener#mouseMove(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseMove(MouseEvent e) {
- if (fCachedTextViewer!= null) {
- int line= toDocumentLineNumber(e.y);
- ILineDiffInfo info= getDiffInfo(line);
- Cursor cursor;
- if (info != null && info.hasChanges())
- cursor= fHitDetectionCursor;
- else
- cursor= null;
- if (cursor != fLastCursor) {
- fCanvas.setCursor(cursor);
- fLastCursor= cursor;
- }
- }
-
- }
-
- }
-
- /**
- * Internal listener class.
- */
- class InternalListener implements IViewportListener, ITextListener {
-
- /*
- * @see IViewportListener#viewportChanged(int)
- */
- public void viewportChanged(int verticalPosition) {
- if (verticalPosition != fScrollPos)
- redraw();
- }
-
- /*
- * @see ITextListener#textChanged(TextEvent)
- */
- public void textChanged(TextEvent event) {
-
- if (!event.getViewerRedrawState())
- return;
-
- if (fSensitiveToTextChanges || event.getDocumentEvent() == null)
- postRedraw();
-
- }
- }
-
- /**
- * Internal listener class that will update the ruler when the underlying model changes.
- */
- class AnnotationListener implements IAnnotationModelListener {
- /*
- * @see org.eclipse.jface.text.source.IAnnotationModelListener#modelChanged(org.eclipse.jface.text.source.IAnnotationModel)
- */
- public void modelChanged(IAnnotationModel model) {
- postRedraw();
- }
- }
-
- /** This column's parent ruler */
- private CompositeRuler fParentRuler;
- /** Cached text viewer */
- private ITextViewer fCachedTextViewer;
- /** Cached text widget */
- private StyledText fCachedTextWidget;
- /** The columns canvas */
- private Canvas fCanvas;
- /** Cache for the actual scroll position in pixels */
- private int fScrollPos;
- /** The drawable for double buffering */
- private Image fBuffer;
- /** The internal listener */
- private InternalListener fInternalListener= new InternalListener();
- /** Indicates whether this column reacts on text change events */
- private boolean fSensitiveToTextChanges= false;
- /** The foreground color */
- private Color fForeground;
- /** The background color */
- private Color fBackground;
- /** Color for changed lines */
- private Color fAddedColor;
- /** Color for added lines */
- private Color fChangedColor;
- /** Color for the deleted line indicator */
- private Color fDeletedColor;
- /** The ruler's annotation model. */
- private IAnnotationModel fAnnotationModel;
- /** The ruler's hover */
- private IAnnotationHover fHover;
- /** The internal listener */
- private AnnotationListener fAnnotationListener= new AnnotationListener();
- /** The width of the change ruler column. */
- private int fWidth= 5;
- /** The hand cursor that will show when hovering over a change. */
- Cursor fHitDetectionCursor;
- /** The last used cursor. */
- Cursor fLastCursor;
-
-
- /**
- * Returns the System background color for list widgets.
- *
- * @param display the display the drawing occurs on
- * @return the System background color for list widgets
- */
- protected Color getBackground(Display display) {
- if (fBackground == null)
- return display.getSystemColor(SWT.COLOR_LIST_BACKGROUND);
- return fBackground;
- }
-
- /*
- * @see IVerticalRulerColumn#createControl(CompositeRuler, Composite)
- */
- public Control createControl(CompositeRuler parentRuler, Composite parentControl) {
-
- fParentRuler= parentRuler;
- fCachedTextViewer= parentRuler.getTextViewer();
- fCachedTextWidget= fCachedTextViewer.getTextWidget();
-
- fCanvas= new Canvas(parentControl, SWT.NONE);
- fCanvas.setBackground(getBackground(fCanvas.getDisplay()));
- fCanvas.setForeground(fForeground);
-
- fHitDetectionCursor= new Cursor(parentControl.getDisplay(), SWT.CURSOR_HAND);
-
- fCanvas.addPaintListener(new PaintListener() {
- public void paintControl(PaintEvent event) {
- if (fCachedTextViewer != null)
- doubleBufferPaint(event.gc);
- }
- });
-
- fCanvas.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- handleDispose();
- fCachedTextViewer= null;
- fCachedTextWidget= null;
- }
- });
-
- MouseHandler mouseHandler= new MouseHandler();
-
- fCanvas.addMouseListener(mouseHandler);
-
- fCanvas.addMouseMoveListener(mouseHandler);
-
- if (fCachedTextViewer != null) {
-
- fCachedTextViewer.addViewportListener(fInternalListener);
- fCachedTextViewer.addTextListener(fInternalListener);
- }
-
- return fCanvas;
- }
-
- /**
- * Disposes the column's resources.
- */
- protected void handleDispose() {
-
- if (fAnnotationModel != null) {
- fAnnotationModel.removeAnnotationModelListener(fAnnotationListener);
- fAnnotationModel= null;
- }
-
- if (fCachedTextViewer != null) {
- fCachedTextViewer.removeViewportListener(fInternalListener);
- fCachedTextViewer.removeTextListener(fInternalListener);
- }
-
- if (fHitDetectionCursor != null) {
- fHitDetectionCursor.dispose();
- fHitDetectionCursor= null;
- }
-
- if (fBuffer != null) {
- fBuffer.dispose();
- fBuffer= null;
- }
- }
-
- /**
- * Double buffer drawing.
- *
- * @param dest the gc to draw into
- */
- private void doubleBufferPaint(GC dest) {
-
- Point size= fCanvas.getSize();
-
- if (size.x <= 0 || size.y <= 0)
- return;
-
- if (fBuffer != null) {
- Rectangle r= fBuffer.getBounds();
- if (r.width != size.x || r.height != size.y) {
- fBuffer.dispose();
- fBuffer= null;
- }
- }
- if (fBuffer == null)
- fBuffer= new Image(fCanvas.getDisplay(), size.x, size.y);
-
- GC gc= new GC(fBuffer);
- gc.setFont(fCanvas.getFont());
- if (fForeground != null)
- gc.setForeground(fForeground);
-
- try {
- gc.setBackground(getBackground(fCanvas.getDisplay()));
- gc.fillRectangle(0, 0, size.x, size.y);
-
- if (fCachedTextViewer instanceof ITextViewerExtension5)
- doPaint1(gc);
- else
- doPaint(gc);
-
- } finally {
- gc.dispose();
- }
-
- dest.drawImage(fBuffer, 0, 0);
- }
-
- /**
- * Returns the viewport height in lines.
- *
- * @return the viewport height in lines
- */
- protected int getVisibleLinesInViewport() {
- Rectangle clArea= fCachedTextWidget.getClientArea();
- if (!clArea.isEmpty())
- return clArea.height / fCachedTextWidget.getLineHeight();
- return -1;
- }
-
- /**
- * Draws the ruler column.
- *
- * @param gc the gc to draw into
- */
- private void doPaint(GC gc) {
-
- if (fCachedTextViewer == null)
- return;
-
- if (fCachedTextWidget == null)
- return;
-
-
- int firstLine= 0;
-
- int topLine= fCachedTextViewer.getTopIndex() -1;
- int bottomLine= fCachedTextViewer.getBottomIndex() + 1;
-
- try {
-
- IRegion region= fCachedTextViewer.getVisibleRegion();
- IDocument doc= fCachedTextViewer.getDocument();
-
- if (doc == null)
- return;
-
- firstLine= doc.getLineOfOffset(region.getOffset());
- if (firstLine > topLine)
- topLine= firstLine;
-
- int lastLine= doc.getLineOfOffset(region.getOffset() + region.getLength());
- if (lastLine < bottomLine)
- bottomLine= lastLine;
-
- } catch (BadLocationException x) {
- return;
- }
-
- fSensitiveToTextChanges= bottomLine - topLine < getVisibleLinesInViewport();
-
- int lineheight= fCachedTextWidget.getLineHeight();
- fScrollPos= fCachedTextWidget.getTopPixel();
- int canvasheight= fCanvas.getSize().y;
-
- int y= ((topLine - firstLine) * lineheight) - fScrollPos + fCachedTextViewer.getTopInset();
- for (int line= topLine; line <= bottomLine; line++, y+= lineheight) {
-
- if (y >= canvasheight)
- break;
-
- paintLine(line, y, lineheight, gc, fCachedTextWidget.getDisplay());
- }
- }
-
- /**
- * Draws the ruler column. Uses <code>ITextViewerExtension5</code> for the
- * implementation. Will replace <code>doPinat(GC)</code>.
- *
- * @param gc the gc to draw into
- */
- private void doPaint1(GC gc) {
-
- if (fCachedTextViewer == null)
- return;
-
- ITextViewerExtension5 extension= (ITextViewerExtension5) fCachedTextViewer;
-
- int firstLine= 0;
-
-
- int widgetTopLine= fCachedTextWidget.getTopIndex();
- if (widgetTopLine > 0)
- -- widgetTopLine;
-
- int topLine= extension.widgetlLine2ModelLine(widgetTopLine);
- int bottomLine= fCachedTextViewer.getBottomIndex();
- if (bottomLine >= 0)
- ++ bottomLine;
-
- try {
-
- IRegion region= extension.getModelCoverage();
- IDocument doc= fCachedTextViewer.getDocument();
-
- if (doc == null)
- return;
-
- firstLine= doc.getLineOfOffset(region.getOffset());
- if (firstLine > topLine || topLine == -1)
- topLine= firstLine;
-
- int lastLine= doc.getLineOfOffset(region.getOffset() + region.getLength());
- if (lastLine < bottomLine || bottomLine == -1)
- bottomLine= lastLine;
-
- } catch (BadLocationException x) {
- return;
- }
-
- fSensitiveToTextChanges= bottomLine - topLine < getVisibleLinesInViewport();
-
- int lineheight= fCachedTextWidget.getLineHeight();
- fScrollPos= fCachedTextWidget.getTopPixel();
- int canvasheight= fCanvas.getSize().y;
-
- int y= (widgetTopLine * lineheight) - fScrollPos + fCachedTextViewer.getTopInset();
- for (int modelLine= topLine; modelLine <= bottomLine; modelLine++) {
-
- if (y >= canvasheight)
- break;
-
- int widgetLine= extension.modelLine2WidgetLine(modelLine);
- if (widgetLine == -1)
- continue;
-
- paintLine(modelLine, y, lineheight, gc, fCachedTextWidget.getDisplay());
-
- y+= lineheight;
- }
- }
-
- /*
- * @see IVerticalRulerColumn#redraw()
- */
- public void redraw() {
-
- if (fCanvas != null && !fCanvas.isDisposed()) {
- GC gc= new GC(fCanvas);
- doubleBufferPaint(gc);
- gc.dispose();
- }
- }
-
- /*
- * @see IVerticalRulerColumn#setFont(Font)
- */
- public void setFont(Font font) {
- }
-
- /**
- * Returns the parent (composite) ruler of this ruler column.
- *
- * @return the parent ruler
- * @since 3.0
- */
- protected CompositeRuler getParentRuler() {
- return fParentRuler;
- }
-
- /*
- * @see org.eclipse.jface.text.source.LineNumberRulerColumn#paintLineHook(int, int, int, org.eclipse.swt.graphics.GC)
- */
- protected void paintLine(int line, int y, int lineheight, GC gc, Display display) {
- ILineDiffInfo info= getDiffInfo(line);
-
- if (info != null) {
- // width of the column
- int width= getWidth();
-
- // draw background color if special
- if (hasSpecialColor(info)) {
- gc.setBackground(getColor(info, display));
- gc.fillRectangle(0, y, width, lineheight);
- }
-
- /* Deletion Indicator: Simply a horizontal line */
- int delBefore= info.getRemovedLinesAbove();
- int delBelow= info.getRemovedLinesBelow();
- if (delBefore > 0 || delBelow > 0) {
- Color deletionColor= getDeletionColor(display);
- gc.setForeground(deletionColor);
-
- if (delBefore > 0) {
- gc.drawLine(0, y, width, y);
- }
-
- if (delBelow > 0) {
- gc.drawLine(0, y + lineheight - 1, width, y + lineheight - 1);
- }
- }
- }
- }
-
- /**
- * Returns whether the line background differs from the default.
- *
- * @param info the info being queried
- * @return <code>true</code> if <code>info</code> describes either a changed or an added line.
- */
- private boolean hasSpecialColor(ILineDiffInfo info) {
- return info.getChangeType() == ILineDiffInfo.ADDED || info.getChangeType() == ILineDiffInfo.CHANGED;
- }
-
- /**
- * Retrieves the <code>ILineDiffInfo</code> for <code>line</code> from the model.
- * There are optimizations for direct access and sequential access patterns.
- *
- * @param line the line we want the info for.
- * @return the <code>ILineDiffInfo</code> for <code>line</code>, or <code>null</code>.
- */
- private ILineDiffInfo getDiffInfo(int line) {
- if (fAnnotationModel == null)
- return null;
-
- // assume direct access
- if (fAnnotationModel instanceof ILineDiffer) {
- ILineDiffer differ= (ILineDiffer)fAnnotationModel;
- return differ.getLineInfo(line);
- }
-
- return null;
- }
-
- /**
- * Returns the color for deleted lines.
- *
- * @return the color to be used for the deletion indicator
- */
- private Color getDeletionColor(Display display) {
- return fDeletedColor == null ? getBackground(display) : fDeletedColor;
- }
-
- /**
- * Returns the color for the given line diff info.
- *
- * @param info the <code>ILineDiffInfo</code> being queried
- * @param display the display that the drawing occurs on
- * @return the correct background color for the line type being described by <code>info</code>
- */
- private Color getColor(ILineDiffInfo info, Display display) {
- Assert.isTrue(info != null && info.getChangeType() != ILineDiffInfo.UNCHANGED);
- Color ret= null;
- switch (info.getChangeType()) {
- case ILineDiffInfo.CHANGED :
- ret= fChangedColor;
- break;
- case ILineDiffInfo.ADDED :
- ret= fAddedColor;
- break;
- }
- return ret == null ? getBackground(display) : ret;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerInfo#getLineOfLastMouseButtonActivity()
- */
- public int getLineOfLastMouseButtonActivity() {
- return getParentRuler().getLineOfLastMouseButtonActivity();
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerInfo#toDocumentLineNumber(int)
- */
- public int toDocumentLineNumber(int y_coordinate) {
- return getParentRuler().toDocumentLineNumber(y_coordinate);
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#getHover()
- */
- public IAnnotationHover getHover() {
- return fHover;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IChangeRulerColumn#setHover(org.eclipse.jface.text.source.IAnnotationHover)
- */
- public void setHover(IAnnotationHover hover) {
- fHover= hover;
- }
-
- /*
- * @see IVerticalRulerColumn#setModel(IAnnotationModel)
- */
- public void setModel(IAnnotationModel model) {
- IAnnotationModel newModel;
- if (model instanceof IAnnotationModelExtension) {
- newModel= ((IAnnotationModelExtension)model).getAnnotationModel(QUICK_DIFF_MODEL_ID);
- } else {
- newModel= model;
- }
- if (fAnnotationModel != newModel) {
- if (fAnnotationModel != null) {
- fAnnotationModel.removeAnnotationModelListener(fAnnotationListener);
- }
- fAnnotationModel= newModel;
- if (fAnnotationModel != null) {
- fAnnotationModel.addAnnotationModelListener(fAnnotationListener);
- }
- redraw();
- }
- }
-
- /*
- * @see org.eclipse.jface.text.source.IChangeRulerColumn#setBackground(org.eclipse.swt.graphics.Color)
- */
- public void setBackground(Color background) {
- fBackground= background;
- if (fCanvas != null && !fCanvas.isDisposed())
- fCanvas.setBackground(getBackground(fCanvas.getDisplay()));
- }
-
- /*
- * @see org.eclipse.jface.text.source.IChangeRulerColumn#setAddedColor(org.eclipse.swt.graphics.Color)
- */
- public void setAddedColor(Color addedColor) {
- fAddedColor= addedColor;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IChangeRulerColumn#setChangedColor(org.eclipse.swt.graphics.Color)
- */
- public void setChangedColor(Color changedColor) {
- fChangedColor= changedColor;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IChangeRulerColumn#setDeletedColor(org.eclipse.swt.graphics.Color)
- */
- public void setDeletedColor(Color deletedColor) {
- fDeletedColor= deletedColor;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#getModel()
- */
- public IAnnotationModel getModel() {
- return fAnnotationModel;
- }
-
- /*
- * @see IVerticalRulerColumn#getControl()
- */
- public Control getControl() {
- return fCanvas;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerInfo#getWidth()
- */
- public int getWidth() {
- return fWidth;
- }
-
- /**
- * Triggers a redraw in the display thread.
- */
- protected final void postRedraw() {
- if (fCanvas != null && !fCanvas.isDisposed()) {
- Display d= fCanvas.getDisplay();
- if (d != null) {
- d.asyncExec(new Runnable() {
- public void run() {
- redraw();
- }
- });
- }
- }
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#addAnnotationListener(org.eclipse.jface.text.source.IAnnotationListener)
- */
- public void addAnnotationListener(IAnnotationListener listener) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#removeAnnotationListener(org.eclipse.jface.text.source.IAnnotationListener)
- */
- public void removeAnnotationListener(IAnnotationListener listener) {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/CompositeRuler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/CompositeRuler.java
deleted file mode 100644
index 0da60c1..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/CompositeRuler.java
+++ /dev/null
@@ -1,839 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.source;
-
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.ControlListener;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.HelpListener;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.MouseMoveListener;
-import org.eclipse.swt.events.MouseTrackListener;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.events.TraverseListener;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.internal.SWTEventListener;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Layout;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Menu;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.ITextViewerExtension;
-import org.eclipse.jface.text.ITextViewerExtension5;
-
-
-/**
- * Standard implementation of <code>IVerticalRuler</code>. This ruler does not have a
- * a visual representation of its own. The presentation comes from the configurable list
- * of decorators. Decorators must implement the <code>IVerticalRulerColumn</code>
- * interface.<p>
- * Clients may instantiate and configure this class.
- *
- * @see IVerticalRulerColumn
- * @see ITextViewer
- * @since 2.0
- */
-public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension, IVerticalRulerInfoExtension, IAnnotationListener {
-
-
- /**
- * Layout of the composite vertical ruler. Arranges the list of decorators.
- */
- class RulerLayout extends Layout {
-
- /**
- * Creates the new ruler layout.
- */
- protected RulerLayout() {
- }
-
- /*
- * @see Layout#computeSize(Composite, int, int, boolean)
- */
- protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) {
- Control[] children= composite.getChildren();
- Point size= new Point(0, 0);
- for (int i= 0; i < children.length; i++) {
- Point s= children[i].computeSize(SWT.DEFAULT, SWT.DEFAULT, flushCache);
- size.x += s.x;
- size.y= Math.max(size.y, s.y);
- }
- size.x += (Math.max(0, children.length -1) * fGap);
- return size;
- }
-
- /*
- * @see Layout#layout(Composite, boolean)
- */
- protected void layout(Composite composite, boolean flushCache) {
- Rectangle clArea= composite.getClientArea();
- int rulerHeight= clArea.height;
-
- int x= 0;
- Iterator e= fDecorators.iterator();
- while (e.hasNext()) {
- IVerticalRulerColumn column= (IVerticalRulerColumn) e.next();
- int columnWidth= column.getWidth();
- column.getControl().setBounds(x, 0, columnWidth, rulerHeight);
- x += (columnWidth + fGap);
- }
- }
- }
-
- /**
- * A canvas that adds listeners to all its children. Used by the implementation of the
- * vertical ruler to propagate listener additions and removals to the ruler's columns.
- */
- static class CompositeRulerCanvas extends Canvas {
-
- /**
- * Keeps the information for which event type a listener object has been added.
- */
- static class ListenerInfo {
- Class fClass;
- SWTEventListener fListener;
- }
-
- /** The list of listeners added to this canvas. */
- private List fCachedListeners= new ArrayList();
- /** Internal listener for opening the context menu. */
- private Listener fMenuDetectListener;
-
- /**
- * Creates a new composite ruler canvas.
- *
- * @param parent the parent composite
- * @param style the SWT styles
- */
- public CompositeRulerCanvas(Composite parent, int style) {
- super(parent, style);
- fMenuDetectListener= new Listener() {
- public void handleEvent(Event event) {
- if (event.type == SWT.MenuDetect) {
- Menu menu= getMenu();
- if (menu != null) {
- menu.setLocation(event.x, event.y);
- menu.setVisible(true);
- }
- }
- }
- };
- super.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- if (fCachedListeners != null) {
- fCachedListeners.clear();
- fCachedListeners= null;
- }
- }
- });
- }
-
- /**
- * Adds the given listener object as listener of the given type (<code>clazz</code>) to
- * the given control.
- *
- * @param clazz the listener type
- * @param control the control to add the listener to
- * @param listener the listener to be added
- */
- private void addListener(Class clazz, Control control, SWTEventListener listener) {
- if (ControlListener.class.equals(clazz)) {
- control. addControlListener((ControlListener) listener);
- return;
- }
- if (FocusListener.class.equals(clazz)) {
- control. addFocusListener((FocusListener) listener);
- return;
- }
- if (HelpListener.class.equals(clazz)) {
- control. addHelpListener((HelpListener) listener);
- return;
- }
- if (KeyListener.class.equals(clazz)) {
- control. addKeyListener((KeyListener) listener);
- return;
- }
- if (MouseListener.class.equals(clazz)) {
- control. addMouseListener((MouseListener) listener);
- return;
- }
- if (MouseMoveListener.class.equals(clazz)) {
- control. addMouseMoveListener((MouseMoveListener) listener);
- return;
- }
- if (MouseTrackListener.class.equals(clazz)) {
- control. addMouseTrackListener((MouseTrackListener) listener);
- return;
- }
- if (PaintListener.class.equals(clazz)) {
- control. addPaintListener((PaintListener) listener);
- return;
- }
- if (TraverseListener.class.equals(clazz)) {
- control. addTraverseListener((TraverseListener) listener);
- return;
- }
- if (DisposeListener.class.equals(clazz)) {
- control. addDisposeListener((DisposeListener) listener);
- return;
- }
- }
-
- /**
- * Removes the given listener object as listner of the given type (<code>clazz</code>) from
- * the given control.
- *
- * @param clazz the listener type
- * @param control the control to remove the listener from
- * @param listener the listener to be removed
- */
- private void removeListener(Class clazz, Control control, SWTEventListener listener) {
- if (ControlListener.class.equals(clazz)) {
- control. removeControlListener((ControlListener) listener);
- return;
- }
- if (FocusListener.class.equals(clazz)) {
- control. removeFocusListener((FocusListener) listener);
- return;
- }
- if (HelpListener.class.equals(clazz)) {
- control. removeHelpListener((HelpListener) listener);
- return;
- }
- if (KeyListener.class.equals(clazz)) {
- control. removeKeyListener((KeyListener) listener);
- return;
- }
- if (MouseListener.class.equals(clazz)) {
- control. removeMouseListener((MouseListener) listener);
- return;
- }
- if (MouseMoveListener.class.equals(clazz)) {
- control. removeMouseMoveListener((MouseMoveListener) listener);
- return;
- }
- if (MouseTrackListener.class.equals(clazz)) {
- control. removeMouseTrackListener((MouseTrackListener) listener);
- return;
- }
- if (PaintListener.class.equals(clazz)) {
- control. removePaintListener((PaintListener) listener);
- return;
- }
- if (TraverseListener.class.equals(clazz)) {
- control. removeTraverseListener((TraverseListener) listener);
- return;
- }
- if (DisposeListener.class.equals(clazz)) {
- control. removeDisposeListener((DisposeListener) listener);
- return;
- }
- }
-
- /**
- * Adds the given listener object to the internal book keeping under
- * the given listener type (<code>clazz</code>).
- *
- * @param clazz the listener type
- * @param listener the listener object
- */
- private void addListener(Class clazz, SWTEventListener listener) {
- Control[] children= getChildren();
- for (int i= 0; i < children.length; i++) {
- if (children[i] != null && !children[i].isDisposed())
- addListener(clazz, children[i], listener);
- }
-
- ListenerInfo info= new ListenerInfo();
- info.fClass= clazz;
- info.fListener= listener;
- fCachedListeners.add(info);
- }
-
- /**
- * Removes the given listener object from the internal book keeping under
- * the given listener type (<code>clazz</code>).
- *
- * @param clazz the listener type
- * @param listener the listener object
- */
- private void removeListener(Class clazz, SWTEventListener listener) {
- int length= fCachedListeners.size();
- for (int i= 0; i < length; i++) {
- ListenerInfo info= (ListenerInfo) fCachedListeners.get(i);
- if (listener == info.fListener && clazz.equals(info.fClass)) {
- fCachedListeners.remove(i);
- break;
- }
- }
-
- Control[] children= getChildren();
- for (int i= 0; i < children.length; i++) {
- if (children[i] != null && !children[i].isDisposed())
- removeListener(clazz, children[i], listener);
- }
- }
-
- /**
- * Tells this canvas that a child has been added.
- *
- * @param child the child
- */
- public void childAdded(Control child) {
- if (child != null && !child.isDisposed()) {
- int length= fCachedListeners.size();
- for (int i= 0; i < length; i++) {
- ListenerInfo info= (ListenerInfo) fCachedListeners.get(i);
- addListener(info.fClass, child, info.fListener);
- }
- child.addListener(SWT.MenuDetect, fMenuDetectListener);
- }
- }
-
- /**
- * Tells this canvas that a child has been removed.
- *
- * @param child the child
- */
- public void childRemoved(Control child) {
- if (child != null && !child.isDisposed()) {
- int length= fCachedListeners.size();
- for (int i= 0; i < length; i++) {
- ListenerInfo info= (ListenerInfo) fCachedListeners.get(i);
- removeListener(info.fClass, child, info.fListener);
- }
- child.removeListener(SWT.MenuDetect, fMenuDetectListener);
- }
- }
-
- /*
- * @see Control#removeControlListener(ControlListener)
- */
- public void removeControlListener(ControlListener listener) {
- removeListener(ControlListener.class, listener);
- super.removeControlListener(listener);
- }
-
- /*
- * @see Control#removeFocusListener(FocusListener)
- */
- public void removeFocusListener(FocusListener listener) {
- removeListener(FocusListener.class, listener);
- super.removeFocusListener(listener);
- }
-
- /*
- * @see Control#removeHelpListener(HelpListener)
- */
- public void removeHelpListener(HelpListener listener) {
- removeListener(HelpListener.class, listener);
- super.removeHelpListener(listener);
- }
-
- /*
- * @see Control#removeKeyListener(KeyListener)
- */
- public void removeKeyListener(KeyListener listener) {
- removeListener(KeyListener.class, listener);
- super.removeKeyListener(listener);
- }
-
- /*
- * @see Control#removeMouseListener(MouseListener)
- */
- public void removeMouseListener(MouseListener listener) {
- removeListener(MouseListener.class, listener);
- super.removeMouseListener(listener);
- }
-
- /*
- * @see Control#removeMouseMoveListener(MouseMoveListener)
- */
- public void removeMouseMoveListener(MouseMoveListener listener) {
- removeListener(MouseMoveListener.class, listener);
- super.removeMouseMoveListener(listener);
- }
-
- /*
- * @see Control#removeMouseTrackListener(MouseTrackListener)
- */
- public void removeMouseTrackListener(MouseTrackListener listener) {
- removeListener(MouseTrackListener.class, listener);
- super.removeMouseTrackListener(listener);
- }
-
- /*
- * @see Control#removePaintListener(PaintListener)
- */
- public void removePaintListener(PaintListener listener) {
- removeListener(PaintListener.class, listener);
- super.removePaintListener(listener);
- }
-
- /*
- * @see Control#removeTraverseListener(TraverseListener)
- */
- public void removeTraverseListener(TraverseListener listener) {
- removeListener(TraverseListener.class, listener);
- super.removeTraverseListener(listener);
- }
-
- /*
- * @see Widget#removeDisposeListener(DisposeListener)
- */
- public void removeDisposeListener(DisposeListener listener) {
- removeListener(DisposeListener.class, listener);
- super.removeDisposeListener(listener);
- }
-
- /*
- * @seeControl#addControlListener(ControlListener)
- */
- public void addControlListener(ControlListener listener) {
- super.addControlListener(listener);
- addListener(ControlListener.class, listener);
- }
-
- /*
- * @see Control#addFocusListener(FocusListener)
- */
- public void addFocusListener(FocusListener listener) {
- super.addFocusListener(listener);
- addListener(FocusListener.class, listener);
- }
-
- /*
- * @see Control#addHelpListener(HelpListener)
- */
- public void addHelpListener(HelpListener listener) {
- super.addHelpListener(listener);
- addListener(HelpListener.class, listener);
- }
-
- /*
- * @see Control#addKeyListener(KeyListener)
- */
- public void addKeyListener(KeyListener listener) {
- super.addKeyListener(listener);
- addListener(KeyListener.class, listener);
- }
-
- /*
- * @see Control#addMouseListener(MouseListener)
- */
- public void addMouseListener(MouseListener listener) {
- super.addMouseListener(listener);
- addListener(MouseListener.class, listener);
- }
-
- /*
- * @see Control#addMouseMoveListener(MouseMoveListener)
- */
- public void addMouseMoveListener(MouseMoveListener listener) {
- super.addMouseMoveListener(listener);
- addListener(MouseMoveListener.class, listener);
- }
-
- /*
- * @see Control#addMouseTrackListener(MouseTrackListener)
- */
- public void addMouseTrackListener(MouseTrackListener listener) {
- super.addMouseTrackListener(listener);
- addListener(MouseTrackListener.class, listener);
- }
-
- /*
- * @seeControl#addPaintListener(PaintListener)
- */
- public void addPaintListener(PaintListener listener) {
- super.addPaintListener(listener);
- addListener(PaintListener.class, listener);
- }
-
- /*
- * @see Control#addTraverseListener(TraverseListener)
- */
- public void addTraverseListener(TraverseListener listener) {
- super.addTraverseListener(listener);
- addListener(TraverseListener.class, listener);
- }
-
- /*
- * @see Widget#addDisposeListener(DisposeListener)
- */
- public void addDisposeListener(DisposeListener listener) {
- super.addDisposeListener(listener);
- addListener(DisposeListener.class, listener);
- }
- }
-
- /** The ruler's viewer */
- private ITextViewer fTextViewer;
- /** The ruler's canvas to which to add the ruler columns */
- private CompositeRulerCanvas fComposite;
- /** The ruler's annotation model */
- private IAnnotationModel fModel;
- /** The list of decorators */
- private List fDecorators= new ArrayList(2);
- /** The cached location of the last mouse button activity */
- private Point fLocation= new Point(-1, -1);
- /** The cached line of the list mouse button activity */
- private int fLastMouseButtonActivityLine= -1;
- /** The gap between the individual columns of this composite ruler */
- private int fGap;
- /**
- * The set of annotation listeners.
- * @since 3.0
- */
- private Set fAnnotationListeners= new HashSet();
-
-
- /**
- * Constructs a new composite vertical ruler.
- */
- public CompositeRuler() {
- this(0);
- }
-
- /**
- * Constructs a new composite ruler with the given gap between its columns.
- *
- * @param gap
- */
- public CompositeRuler(int gap) {
- fGap= gap;
- }
-
- /**
- * Inserts the given decorator at the specfied slot to this composite ruler.
- * Decorators are counted from left to right.
- *
- * @param index the index
- * @param rulerColumn the decorator to be inserted
- */
- public void addDecorator(int index, IVerticalRulerColumn rulerColumn) {
- if (index > fDecorators.size())
- fDecorators.add(rulerColumn);
- else
- fDecorators.add(index, rulerColumn);
-
- if (fComposite != null && !fComposite.isDisposed()) {
- rulerColumn.createControl(this, fComposite);
- fComposite.childAdded(rulerColumn.getControl());
- layoutTextViewer();
- }
- }
-
- /**
- * Removes the decorator in the specified slot from this composite ruler.
- *
- * @param index the index
- */
- public void removeDecorator(int index) {
- IVerticalRulerColumn rulerColumn= (IVerticalRulerColumn) fDecorators.get(index);
- removeDecorator(rulerColumn);
- }
-
- /**
- * Removes the given decorator from the composite ruler.
- *
- * @param rulerColumn the ruler column to be removed
- * @since 3.0
- */
- public void removeDecorator(IVerticalRulerColumn rulerColumn) {
- fDecorators.remove(rulerColumn);
- if (rulerColumn != null) {
- Control cc= rulerColumn.getControl();
- if (cc != null && !cc.isDisposed()) {
- fComposite.childRemoved(cc);
- cc.dispose();
- }
- }
- layoutTextViewer();
- }
-
- /**
- * Relayouts the text viewer. This also causes this ruler to get
- * relayouted.
- */
- private void layoutTextViewer() {
-
- Control parent= fTextViewer.getTextWidget();
-
- if (fTextViewer instanceof ITextViewerExtension) {
- ITextViewerExtension extension= (ITextViewerExtension) fTextViewer;
- parent= extension.getControl();
- }
-
- if (parent instanceof Composite && !parent.isDisposed())
- ((Composite) parent).layout(true);
- }
-
- /*
- * @see IVerticalRuler#getControl()
- */
- public Control getControl() {
- return fComposite;
- }
-
- /*
- * @see IVerticalRuler#createControl(Composite, ITextViewer)
- */
- public Control createControl(Composite parent, ITextViewer textViewer) {
-
- fTextViewer= textViewer;
-
- fComposite= new CompositeRulerCanvas(parent, SWT.NONE);
- fComposite.setLayout(new RulerLayout());
-
- Iterator iter= fDecorators.iterator();
- while (iter.hasNext()) {
- IVerticalRulerColumn column= (IVerticalRulerColumn) iter.next();
- column.createControl(this, fComposite);
- fComposite.childAdded(column.getControl());
- }
-
- parent.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- fTextViewer= null;
- fComposite= null;
- fModel= null;
- fDecorators.clear();
- }
- });
-
- return fComposite;
- }
-
- /*
- * @see IVerticalRuler#setModel(IAnnotationModel)
- */
- public void setModel(IAnnotationModel model) {
-
- fModel= model;
-
- Iterator e= fDecorators.iterator();
- while (e.hasNext()) {
- IVerticalRulerColumn column= (IVerticalRulerColumn) e.next();
- column.setModel(model);
- }
- }
-
- /*
- * @see IVerticalRuler#getModel()
- */
- public IAnnotationModel getModel() {
- return fModel;
- }
-
- /*
- * @see IVerticalRuler#update()
- */
- public void update() {
- if (fComposite != null && !fComposite.isDisposed()) {
- Display d= fComposite.getDisplay();
- if (d != null) {
- d.asyncExec(new Runnable() {
- public void run() {
- Iterator e= fDecorators.iterator();
- while (e.hasNext()) {
- IVerticalRulerColumn column= (IVerticalRulerColumn) e.next();
- column.redraw();
- }
- }
- });
- }
- }
- }
-
- /*
- * @see IVerticalRulerExtension#setFont(Font)
- */
- public void setFont(Font font) {
- Iterator e= fDecorators.iterator();
- while (e.hasNext()) {
- IVerticalRulerColumn column= (IVerticalRulerColumn) e.next();
- column.setFont(font);
- }
- }
-
- /*
- * @see IVerticalRulerInfo#getWidth()
- */
- public int getWidth() {
- int width= 0;
- Iterator e= fDecorators.iterator();
- while (e.hasNext()) {
- IVerticalRulerColumn column= (IVerticalRulerColumn) e.next();
- width += (column.getWidth() + fGap);
- }
- return Math.max(0, width - fGap);
- }
-
- /*
- * @see IVerticalRulerInfo#getLineOfLastMouseButtonActivity()
- */
- public int getLineOfLastMouseButtonActivity() {
- if (fLastMouseButtonActivityLine == -1)
- fLastMouseButtonActivityLine= toDocumentLineNumber(fLocation.y);
- return fLastMouseButtonActivityLine;
- }
-
- /*
- * @see IVerticalRulerInfo#toDocumentLineNumber(int)
- */
- public int toDocumentLineNumber(int y_coordinate) {
-
- if (fTextViewer == null || y_coordinate == -1)
- return -1;
-
- StyledText text= fTextViewer.getTextWidget();
- int line= ((y_coordinate + text.getTopPixel()) / text.getLineHeight());
- return widgetLine2ModelLine(fTextViewer, line);
- }
-
- /**
- * Returns the line in the given viewer's document that correspond to the given
- * line of the viewer's widget.
- *
- * @param viewer the viewer
- * @param widgetLine the widget line
- * @return the corresponding line the viewer's document
- * @since 2.1
- */
- protected final static int widgetLine2ModelLine(ITextViewer viewer, int widgetLine) {
-
- if (viewer instanceof ITextViewerExtension5) {
- ITextViewerExtension5 extension= (ITextViewerExtension5) viewer;
- return extension.widgetlLine2ModelLine(widgetLine);
- }
-
- try {
- IRegion r= viewer.getVisibleRegion();
- IDocument d= viewer.getDocument();
- return widgetLine += d.getLineOfOffset(r.getOffset());
- } catch (BadLocationException x) {
- }
- return widgetLine;
- }
-
- /**
- * Returns this ruler's text viewer.
- *
- * @return this ruler's text viewer
- */
- public ITextViewer getTextViewer() {
- return fTextViewer;
- }
-
- /*
- * @see IVerticalRulerExtension#setLocationOfLastMouseButtonActivity(int, int)
- */
- public void setLocationOfLastMouseButtonActivity(int x, int y) {
- fLocation.x= x;
- fLocation.y= y;
- fLastMouseButtonActivityLine= -1;
- }
-
- /**
- * Returns an iterator over the <code>IVerticalRulerColumns</code> that make up this
- * composite column.
- *
- * @return an iterator over the contained columns.
- * @since 3.0
- */
- public Iterator getDecoratorIterator() {
- Assert.isNotNull(fDecorators, "fDecorators must be initialized"); //$NON-NLS-1$
- return fDecorators.iterator();
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#getHover()
- */
- public IAnnotationHover getHover() {
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#addAnnotationListener(org.eclipse.jface.text.source.IAnnotationListener)
- * @since 3.0
- */
- public void addAnnotationListener(IAnnotationListener listener) {
- fAnnotationListeners.add(listener);
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#removeAnnotationListener(org.eclipse.jface.text.source.IAnnotationListener)
- * @since 3.0
- */
- public void removeAnnotationListener(IAnnotationListener listener) {
- fAnnotationListeners.remove(listener);
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationListener#annotationSelected(org.eclipse.jface.text.source.AnnotationEvent)
- * @since 3.0
- */
- public void annotationSelected(AnnotationEvent event) {
- // forward to listeners
- for (Iterator it= fAnnotationListeners.iterator(); it.hasNext();) {
- IAnnotationListener listener= (IAnnotationListener) it.next();
- listener.annotationSelected(event);
- }
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationListener#annotationDefaultSelected(org.eclipse.jface.text.source.AnnotationEvent)
- * @since 3.0
- */
- public void annotationDefaultSelected(AnnotationEvent event) {
- // forward to listeners
- for (Iterator it= fAnnotationListeners.iterator(); it.hasNext();) {
- IAnnotationListener listener= (IAnnotationListener) it.next();
- listener.annotationDefaultSelected(event);
- }
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationListener#annotationContextMenuAboutToShow(org.eclipse.jface.text.source.AnnotationEvent, org.eclipse.swt.widgets.Menu)
- * @since 3.0
- */
- public void annotationContextMenuAboutToShow(AnnotationEvent event, Menu menu) {
- // forward to listeners
- for (Iterator it= fAnnotationListeners.iterator(); it.hasNext();) {
- IAnnotationListener listener= (IAnnotationListener) it.next();
- listener.annotationContextMenuAboutToShow(event, menu);
- }
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationAccess.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationAccess.java
deleted file mode 100644
index 9b10687..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationAccess.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.source;
-
-/**
- * An annotation access provides access to information that is not available via the
- * API of <code>Annotation</code>. Clients usually implement this interface.
- *
- * @see org.eclipse.jface.text.source.Annotation
- * @since 2.1
- */
-public interface IAnnotationAccess {
-
- /**
- * Returns the type of the given annotation.
- *
- * @param annotation the annotation
- * @return the type of the given annotation or <code>null</code> if it has none.
- * @deprecated use <code>Annotation.getType()</code>
- */
- Object getType(Annotation annotation);
-
- /**
- * Returns whether the given annotation spans multiple lines.
- *
- * @param annotation the annotation
- * @return <code>true</code> if the annotation spans multiple lines,
- * <code>false</code> otherwise
- *
- * @deprecated assumed to always return <code>true</code>
- */
- boolean isMultiLine(Annotation annotation);
-
- /**
- * Returns whether the given annotation is temporary rather than persistent.
- *
- * @param annotation the annotation
- * @return <code>true</code> if the annotation is temporary,
- * <code>false</code> otherwise
- * @deprecated use <code>Annotation.isPersistent()</code>
- */
- boolean isTemporary(Annotation annotation);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationAccessExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationAccessExtension.java
deleted file mode 100644
index 4d62cb9..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationAccessExtension.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.source;
-
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Canvas;
-
-/**
- * Extension interface for <code>IAnnotationAccess</code>.
- * Allows to get a label for the annotation's type.
- * </code>.
- *
- * @since 3.0
- */
-public interface IAnnotationAccessExtension {
-
- /**
- * The default annotation layer.
- */
- static final int DEFAULT_LAYER= 0;
-
- /**
- * Returns the label for the given annotation's type.
- *
- * @param annotation the annotation
- * @return the label the given annotation's type or <code>null</code> if no such label exists
- */
- String getTypeLabel(Annotation annotation);
-
- /**
- * Returns the layer for given annotation. Annotations are considered
- * being located at layers and are considered being painted starting with
- * layer 0 upwards. Thus an annotation at layer 5 will be drawn on top of
- * all co-located annotations at the layers 4 - 0.
- *
- * @param annotation the annotation
- * @return the layer of the given annotation
- */
- int getLayer(Annotation annotation);
-
- /**
- * Draws a graphical representation of the given annotation within the given bounds.
- *
- * @param annotation the given annotation
- * @param gc the drawing GC
- * @param canvas the canvas to draw on
- * @param bounds the bounds inside the canvas to draw on
- */
- void paint(Annotation annotation, GC gc, Canvas canvas, Rectangle bounds);
-
- /**
- * Returns <code>true</code> if painting <code>annotation</code> will produce something
- * meaningful, <code>false</code> if not, e.g. if no image is available.
- *
- * @param annotation the annotation to check for paintability
- * @return <code>true</code> if painting <code>annotation</code> will succeed
- */
- boolean isPaintable(Annotation annotation);
-
- /**
- * Returns <code>true</code> if the given annotation is of the given type
- * or <code>false</code> otherwise.
- *
- * @param annotationType the annotation type
- * @param potentialSupertype the potential super annotation type
- * @return <code>true</code> if annotation type is a subtype of the potential annotation super type
- */
- boolean isSubtype(Object annotationType, Object potentialSupertype);
-
- /**
- * Returns the list of super types for the given annotation type. This does not include the type
- * itself. The index in the array of super types indicates the length of the path in the hierarchy
- * graph to the given annotation type.
- *
- * @param annotationType the annotation type to check
- * @return the super types for the given annotation type
- */
- Object[] getSupertypes(Object annotationType);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationHover.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationHover.java
deleted file mode 100644
index c2e51af..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationHover.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.source;
-
-
-
-
-/**
- * Provides the information to be displayed in a hover popup window
- * which appears over the presentation area of annotations. Clients
- * may implement this interface.
- */
-public interface IAnnotationHover {
-
- /**
- * Returns the text which should be presented in the a
- * hover popup window. This information is requested based on
- * the specified line number.
- *
- * @param sourceViewer the source viewer this hover is registered with
- * @param lineNumber the line number for which information is requested
- * @return the requested information or <code>null</code> if no such information exists
- */
- String getHoverInfo(ISourceViewer sourceViewer, int lineNumber);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationHoverExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationHoverExtension.java
deleted file mode 100644
index e4d422f..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationHoverExtension.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.source;
-
-import org.eclipse.jface.text.IInformationControlCreator;
-import org.eclipse.jface.text.ITextSelection;
-
-/**
- * Extension to <code>IAnnotationHover</code> for
- * <ul>
- * <li>providing its own information control creator</li>
- * <li>providing the range of lines for which the hover for a given line is valid
- * </ul>
- *
- * @see org.eclipse.jface.text.IInformationControlCreator
- * @see org.eclipse.jface.text.source.IAnnotationHover
- * @since 3.0
- */
-public interface IAnnotationHoverExtension {
-
- /**
- * Returns the information control creator of this annotation hover.
- *
- * @return the information control creator
- */
- IInformationControlCreator getInformationControlCreator();
-
- /**
- * Returns the text which should be presented in the a
- * hover popup window. This information is requested based on
- * the specified line number.
- *
- * @param sourceViewer the source viewer this hover is registered with
- * @param lineNumber the line number for which information is requested
- * @param first the first line in <code>viewer</code>'s document to consider
- * @param number the number of lines in <code>viewer</code>'s document to consider
- * @return the requested information or <code>null</code> if no such information exists
- */
- String getHoverInfo(ISourceViewer sourceViewer, int lineNumber, int first, int number);
-
- /**
- * Returns the range of lines that are covered by this hover for the given
- * <code>ISourceViewer</code> at model line <code>line</code>.
- *
- * @param viewer the viewer which the hover is queried for
- * @param line the line which a hover is displayed for
- * @param first the first line in <code>viewer</code>'s document to consider
- * @param number the number of lines in <code>viewer</code>'s document to consider
- * @return the selection in the document displayed in <code>viewer</code> containing <code>line</code>
- * that is covered by the hover information returned by the receiver.
- */
- ITextSelection getLineRange(ISourceViewer viewer, int line, int first, int number);
-}
\ No newline at end of file
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationHoverExtension2.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationHoverExtension2.java
deleted file mode 100644
index 8bb1e10..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationHoverExtension2.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.source;
-
-import org.eclipse.jface.text.IInformationControlCreator;
-
-/**
- *
- *
- * @since 3.0
- */
-public interface IAnnotationHoverExtension2 {
-
- Object getHoverInfo2(ISourceViewer viewer, int line);
- /**
- * Returns the information control creator of this annotation hover.
- *
- * @return the information control creator
- */
- IInformationControlCreator getInformationControlCreator();
-
-
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationListener.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationListener.java
deleted file mode 100644
index 02d7076..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationListener.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.source;
-
-import org.eclipse.swt.widgets.Menu;
-
-
-/**
- * Interface for listening to annotation selection events.
- * <p>
- * This interface may be implemented by clients.
- * </p>
- * <p>
- * TODO Note that this is work in progress and the interface is still subject to change.
- * </p>
- *
- * @since 3.0
- */
-public interface IAnnotationListener {
- /**
- * Called when an annotation is selected (e.g. hovering or selecting via keyboard) in the UI.
- *
- * @param event the annotation event that occurred
- */
- void annotationSelected(AnnotationEvent event);
-
- /**
- * Called when default selection (e.g. double clicking or pressing enter) occurs on an
- * annotation.
- *
- * @param event the annotation event that occurred
- */
- void annotationDefaultSelected(AnnotationEvent event);
-
- /**
- * Called when the context menu is opened on an annotation.
- *
- * @param event the annotation event that occurred
- * @param menu the menu that is about to be shown
- */
- void annotationContextMenuAboutToShow(AnnotationEvent event, Menu menu);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationMap.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationMap.java
deleted file mode 100644
index b16b753..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationMap.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.source;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.jface.text.ISynchronizable;
-
-/**
- * An annotation map is a map specialized for the requirements of an annotation
- * model. The annotation map supports a customizable lock object which is used
- * to synchronize concurrent operations on the map. The map supports two
- * iterator methods, one for the values and one for the keys of the map. The
- * returned iterators are robust, i.e. they work on a copy of the values and
- * keys set that is made at the point in time the iterator methods are called.
- * <p>
- * The returned collections of the methods <code>values</code>,<code>entrySet</code>,
- * and <code>keySet</code> are not synchronized on the annotation map's lock
- * object.
- * <p>
- *
- * @since 3.0
- */
-public interface IAnnotationMap extends Map, ISynchronizable {
-
- /**
- * Returns an iterator for a copy of this annotation map's values.
- *
- * @return an iterator for a copy of this map's values
- */
- Iterator valuesIterator();
-
- /**
- * Returns an iterator for a copy of this map's key set.
- *
- * @return an iterator for a copy of this map's key set
- */
- Iterator keySetIterator();
-
- /**
- * @inheritDoc
- *
- * The returned set is not synchronized on this annotation map's lock object.
- */
- Set entrySet();
-
- /**
- * @inheritDoc
- *
- * The returned set is not synchronized on this annotation map's lock object.
- */
- Set keySet();
-
- /**
- * @inheritDoc
- *
- * The returned collection is not synchronized on this annotation map's lock object.
- */
- Collection values();
-}
\ No newline at end of file
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModel.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModel.java
deleted file mode 100644
index 509d0da..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModel.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.source;
-
-
-
-import java.util.Iterator;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.Position;
-
-
-/**
- * This interface defines the model for managing annotations attached to a document.
- * The model maintains a set of annotations for a given document and notifies registered annotation
- * model listeners about annotation model changes. It also provides methods
- * for inquerying the current offset and length of an annotation managed
- * by this model.<p>
- * Clients may implement this interface or use the default implementation provided
- * by <code>AnnotationModel</code>.
- *
- * @see Annotation
- * @see IAnnotationModelListener
- */
-public interface IAnnotationModel {
-
- /**
- * Registers the annotation model listener with this annotation model.
- * After registration listener is informed about each change of this model.
- * If the listener is already registered nothing happens.
- *
- * @param listener the listener to be registered, may not be <code>null</code>
- */
- void addAnnotationModelListener(IAnnotationModelListener listener);
-
- /**
- * Removes the listener from the model's list of annotation model listeners.
- * If the listener is not registered with the model nothing happens.
- *
- * @param listener the listener to be removed, may not be <code>null</code>
- */
- void removeAnnotationModelListener(IAnnotationModelListener listener);
-
- /**
- * Connects the annotation model to a document. The annotations managed
- * by this model must subsequently update according to the changes applied
- * to the document. Once an annotation model is connected to a document,
- * all further <code>connect</code> calls must mention the document the
- * model is already connected to. An annotation model primarily uses
- * <code>connect</code> and <code>disconnect</code> for reference counting
- * the document. Reference counting frees the clients from keeping tracker
- * whether a model has already been connected to a document.
- *
- * @param document the document the model gets connected to,
- * may not be <code>null</code>
- *
- * @see #disconnect(IDocument)
- */
- void connect(IDocument document);
-
- /**
- * Disconnects this model from a document. After that, document changes no longer matter.
- * An annotation model may only be disconnected from a document to which it has been
- * connected before. If the model reference counts the connections to a document,
- * the connection to the document may only be terminated if the reference count does
- * down to 0.
- *
- * @param document the document the model gets disconnected from,
- * may not be <code>null</code>
- *
- * @see #connect(IDocument) for further specification details
- */
- void disconnect(IDocument document);
-
- /**
- * Adds a annotation to this annotation model. The annotation is associated with
- * with the given position which describes the range covered by the annotation.
- * All registered annotation model listeners are informed about the change.
- * If the model is connected to a document, the position is automatically
- * updated on document changes. If the annotation is already managed by
- * this annotation model or is not a valid position in the connected nothing happens.
- *
- * @param annotation the annotation to add, may not be <code>null</code>
- * @param position the position describing the range covered by this annotation,
- * may not be <code>null</code>
- */
- void addAnnotation(Annotation annotation, Position position);
-
- /**
- * Removes the given annotation from the model. I.e. the annotation is no
- * longer managed by this model. The position associated with the annotation
- * is no longer updated on document changes. If the annotation is not
- * managed by this model, nothing happens.
- *
- * @param annotation the annotation to be removed from this model,
- * may not be <code>null</code>
- */
- void removeAnnotation(Annotation annotation);
-
- /**
- * Returns all annotations managed by this model.
- *
- * @return all annotations managed by this model
- */
- Iterator getAnnotationIterator();
-
- /**
- * Returns the position associated with the given annotation.
- *
- * @param annotation the annotation whose position should be returned
- * @return the position of the given annotation or <code>null</code> if no
- * associated annotation exists
- */
- Position getPosition(Annotation annotation);
-}
-
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModelExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModelExtension.java
deleted file mode 100644
index 7856aad..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModelExtension.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.source;
-
-import java.util.Map;
-
-import org.eclipse.jface.text.Position;
-
-
-/**
- * Extends <code>IAnnotationModel</code> with the ability to attach additional
- * annotation models to it.
- *
- * @since 3.0
- */
-public interface IAnnotationModelExtension {
-
- /**
- * Attaches <code>attachment</code> to the receiver. Connects
- * <code>attachment</code> to the currently connected document. If
- * <code>attachment</code> is already attached (even) under a different
- * key), it is not attached again.
- *
- * @param key the key through which the attachment is identified.
- * @param attachment the attached <code>IAnnotationModel</code>
- */
- void addAnnotationModel(Object key, IAnnotationModel attachment);
-
- /**
- * Returns the attached <code>IAnnotationModel</code> for <code>key</code>,
- * or <code>null</code> if none is attached for <code>key</code>.
- *
- * @param key the key through which the attachment is identified.
- * @return an <code>IAnnotationModel</code> attached under
- * <code>key</code>, or <code>null</code>
- */
- IAnnotationModel getAnnotationModel(Object key);
-
- /**
- * Removes and returns the attached <code>IAnnotationModel</code> for
- * <code>key</code>.
- *
- * @param key the key through which the attachment is identified.
- * @return an <code>IAnnotationModel</code> attached under
- * <code>key</code>, or <code>null</code>
- */
- IAnnotationModel removeAnnotationModel(Object key);
-
- /**
- * Replaces annotations with new annotations for this annotation model. The
- * new annotations are map entries where the annotation is the key and the
- * value is the position for the annotation. Each position describes the
- * range covered by the annotation. All registered annotation model
- * listeners are informed about the change (if any). If the model is
- * connected to a document, the positions are automatically updated on
- * document changes. For each annotation which is already managed by this
- * annotation model or is not associated with a valid position in the
- * connected document nothing happens.
- *
- * @param annotationsToRemove the annotations to be removed, may be
- * <code>null</code>
- * @param annotationsToAdd the annotations which will be added, may be
- * <code>null</code> each map entry has an
- * <code>Annotation</code> as key and a <code>Position</code>
- * as value
- * @throws ClassCastException if one of the map key or values has a wrong
- * type
- */
- void replaceAnnotations(Annotation[] annotationsToRemove, Map annotationsToAdd) throws ClassCastException;
-
- /**
- * Modifies the position associated with the given annotation to the given
- * position. If the annotation is not yet managed by this annotation model,
- * the annotation is added. If the given position is <code>null</code> the
- * annotation is removed from the model. All annotation model change
- * listeners will be informed about the change.
- *
- * @param annotation the annotation whose associated position should be
- * modified
- * @param position the position to whose values the associated position
- * should be changed
- */
- void modifyAnnotationPosition(Annotation annotation, Position position);
-
- /**
- * Removes all annotations from this annotation model.
- */
- void removeAllAnnotations();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModelListener.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModelListener.java
deleted file mode 100644
index db9708b..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModelListener.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.source;
-
-
-
-/**
- * Interface for objects interested in getting informed about
- * annotation model changes. Changes are the addition or removal
- * of annotations managed by the model. Clients may implement
- * this interface.
- *
- * @see IAnnotationModel
- */
-public interface IAnnotationModelListener {
-
- /**
- * Called if a model change occurred on the given model.
- *
- * @param model the changed annotation model
- */
- void modelChanged(IAnnotationModel model);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModelListenerExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModelListenerExtension.java
deleted file mode 100644
index 6e3042f..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModelListenerExtension.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.source;
-
-/**
- * Extension interface for <code>IAnnotationModelListener</code>. Introduces a
- * notification mechanism that notifies the user by means of <code>AnnotationModelEvent</code>s.
- * Thus, more detailed information can be sent to the listener. Will replace the original notification
- * mechanism of <code>IAnnotationModelListener</code>.
- *
- * @since 2.0
- */
-public interface IAnnotationModelListenerExtension {
-
- /**
- * Called if a model change occurred on the given model.
- *
- * @param event the event to be sent out
- */
- void modelChanged(AnnotationModelEvent event);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationPresentation.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationPresentation.java
deleted file mode 100644
index 31f100e..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationPresentation.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.source;
-
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Canvas;
-
-/**
- * Interface for annotations that know how to represent themselves.
- *
- * @since 3.0
- */
-public interface IAnnotationPresentation {
-
- /**
- * Returns the annotations drawing layer.
- *
- * @return the annotations drawing layer
- * @deprecated will be removed, configuration will only happen via XML, exists to ensure backward compatibility
- */
- int getLayer();
-
- /**
- * Implement this method to draw a graphical representation
- * of this annotation within the given bounds.
- *
- * @param gc the drawing GC
- * @param canvas the canvas to draw on
- * @param bounds the bounds inside the canvas to draw on
- */
- void paint(GC gc, Canvas canvas, Rectangle bounds);
-}
\ No newline at end of file
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IChangeRulerColumn.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IChangeRulerColumn.java
deleted file mode 100644
index c8f1601..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IChangeRulerColumn.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.source;
-
-import org.eclipse.swt.graphics.Color;
-
-/**
- * An <code>IChangeRulerColumn</code> can display quick diff information.
- *
- * @since 3.0
- */
-public interface IChangeRulerColumn extends IVerticalRulerColumn, IVerticalRulerInfoExtension {
-
- /** The ID under which the quick diff model is registered with a document's annotation model. */
- public static final String QUICK_DIFF_MODEL_ID= "diff"; //$NON-NLS-1$
-
- /**
- * Sets the hover of this ruler column.
- *
- * @param hover the hover that will produce hover information text for this ruler column
- */
- public abstract void setHover(IAnnotationHover hover);
-
- /**
- * Sets the background color for normal lines. The color has to be disposed of by the caller when
- * the receiver is no longer used.
- *
- * @param addedColor the new color to be used as standard line background
- */
- public abstract void setBackground(Color addedColor);
-
- /**
- * Sets the background color for added lines. The color has to be disposed of by the caller when
- * the receiver is no longer used.
- *
- * @param addedColor the new color to be used for the added lines background
- */
- public abstract void setAddedColor(Color addedColor);
-
- /**
- * Sets the background color for changed lines. The color has to be disposed of by the caller when
- * the receiver is no longer used.
- *
- * @param changedColor the new color to be used for the changed lines background
- */
- public abstract void setChangedColor(Color changedColor);
-
- /**
- * Sets the color for the deleted lines indicator. The color has to be disposed of by the caller when
- * the receiver is no longer used.
- *
- * @param deletedColor the new color to be used for the deleted lines indicator.
- */
- public abstract void setDeletedColor(Color deletedColor);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ICharacterPairMatcher.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ICharacterPairMatcher.java
deleted file mode 100644
index e626951..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ICharacterPairMatcher.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.source;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-
-/**
- * A character pair matcher finds to a character at a certain document offset the matching peer character.
- * It is the matchers responsibility to define the concepts of "matching" and "peer". The matching process
- * starts at a given offset. Starting of this offset, the matcher chooses a character close to this offset. The
- * anchor defines whether the chosen character is left or right of the initial offset. The matcher then searches
- * for the matching peer character of the chosen character and if it finds one, delivers the minimal region of
- * the document that contains both characters.
- *
- * @since 2.1
- */
-public interface ICharacterPairMatcher {
-
- /**
- * Indicates the anchor value "right".
- */
- int RIGHT= 0;
- /**
- * Indicates the anchor value "left".
- */
- int LEFT= 1;
-
-
- /**
- * Disposes this pair matcher.
- */
- void dispose();
-
- /**
- * Clears this pair matcher. I.e. the matcher throws away all state it might
- * remember and prepares itself for a new call of the <code>match</code>
- * method.
- */
- void clear();
-
- /**
- * Starting at the given offset, the matcher chooses a character close to this offset.
- * The matcher then searches for the matching peer character of the chosen character
- * and if it finds one, returns the minimal region of the document that contains both characters.
- * It returns <code>null</code> if there is no peer character.
- *
- * @param iDocument the document to work on
- * @param i the start offset
- * @return the minimal region containg the peer characters
- */
- IRegion match(IDocument iDocument, int i);
-
- /**
- * Returns the anchor for the region of the matching peer characters. The anchor
- * says whether the character that has been chosen to search for its peer character
- * has been left or right of the initial offset.
- *
- * @return <code>RIGHT</code> or <code>LEFT</code>
- */
- int getAnchor();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ILineDiffInfo.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ILineDiffInfo.java
deleted file mode 100644
index abec446..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ILineDiffInfo.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.source;
-
-
-/**
- * Describes the change state of one line, which consists of the state of the line itself, which
- * can be <code>UNCHANGED</code>, <code>CHANGED</code> or <code>ADDED</code>, and the number of
- * deleted lines before and after this line.
- *
- * @since 3.0
- */
-public interface ILineDiffInfo {
-
- /** Denotes an unchanged line. */
- static final int UNCHANGED= 0;
-
- /** Denotes an added line. */
- static final int ADDED= 1;
-
- /** Denotes a changed line. */
- static final int CHANGED= 2;
-
- /**
- * Returns the number of deleted lines after this line.
- *
- * @return the number of lines after this line.
- */
- int getRemovedLinesBelow();
-
- /**
- * Returns the number of deleted lines before this line.
- *
- * @return the number of lines before this line.
- */
- int getRemovedLinesAbove();
-
- /**
- * Returns the type of this line, one out of <code>UNCHANGED</code>, <code>CHANGED</code> or
- * <code>ADDED</code>.
- *
- * @return the type of this line.
- */
- int getChangeType();
-
- /**
- * Returns whether this line has any changes (to itself, or any deletions before or after it).
- *
- * @return <code>true</code>, if the line's state (as returned by <code>getType</code>) is
- * either <code>CHANGED</code> or <code>ADDED</code> or either of <code>getRemovedLinesBelow</code>
- * and <code>getRemovedLinesAbove</code> would return a number > 0
- */
- boolean hasChanges();
-
- /**
- * Returns the original text of this changed region
- *
- * @return the original text of this changed region, including any deleted lines. The returned
- * value and its elements may not be <code>null/code>, it may however be of zero length
- */
- String[] getOriginalText();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ILineDiffer.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ILineDiffer.java
deleted file mode 100644
index 55dcdc3..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ILineDiffer.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.source;
-
-import org.eclipse.jface.text.BadLocationException;
-
-
-/**
- * Protocol that allows direct access to line information. Usually, implementations will also
- * implement <code>IAnnotationModel</code>, which only allows <code>Iterator</code> based access
- * to annotations.
- *
- * @since 3.0
- */
-public interface ILineDiffer {
-
- /**
- * Determines the line state for line <code>line</code> in the targeted document.
- *
- * @param line
- * @return the line information object for <code>line</code>.
- */
- ILineDiffInfo getLineInfo(int line);
-
- /**
- * Reverts a single changed line to its original state, not touching any lines that
- * are deleted at its borders.
- *
- * @param line the line number of the line to be restored.
- * @throws BadLocationException if <code>line</code> is out of bounds.
- */
- void revertLine(int line) throws BadLocationException;
-
- /**
- * Reverts a block of modified / added lines to their original state, including any deleted
- * lines inside the block or at its borders. A block is considered to be a range of modified
- * (e.g. changed, or added) lines.
- *
- * @param line any line in the block to be reverted.
- * @throws BadLocationException if <code>line</code> is out of bounds.
- */
- void revertBlock(int line) throws BadLocationException;
-
- /**
- * Reverts a range of lines to their original state, including any deleted
- * lines inside the block or at its borders.
- *
- * @param line any line in the block to be reverted.
- * @param nLines the number of lines to be reverted, must be > 0.
- * @throws BadLocationException if <code>line</code> is out of bounds.
- */
- void revertSelection(int line, int nLines) throws BadLocationException;
-
- /**
- * Restores the deleted lines after <code>line</code>.
- *
- * @param line the deleted lines following this line number are restored.
- * @return the number of restored lines.
- * @throws BadLocationException if <code>line</code> is out of bounds.
- */
- int restoreAfterLine(int line) throws BadLocationException;
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IOverviewRuler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IOverviewRuler.java
deleted file mode 100644
index f19c752..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IOverviewRuler.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.source;
-
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.widgets.Control;
-
-/**
- * This interface defines a visual component which may serve
- * text viewers as an overview annotation presentation area. This means,
- * presentation of annotations is independent from the actual viewport of
- * the text viewer. The annotations of the viewer's whole document are
- * visible in the overview ruler.
- *
- * This interfaces comprises three contracts:
- * <ul>
- * <li> The overview ruler retrieves the annotations it presents from an annotation model.
- * <li> The ruler is a visual component which must be integrated in a hierarchy of SWT controls.
- * <li> The ruler provides interested clients with mapping and
- * interaction information. This covers the mapping between
- * coordinates of the ruler's control and line numbers based
- * on the connected text viewer's document (<code>IVerticalRulerInfo</code>).
- * </ul>
- * Clients may implement this interface or use the default implementation provided
- * by <code>OverviewlRuler</code>.
- *
- * @see org.eclipse.jface.text.ITextViewer
- * @since 2.1
- */
-public interface IOverviewRuler extends IVerticalRuler {
-
- /**
- * Returns whether there is an annotation an the given y coordinate. This
- * method takes the compression factor of the overview ruler into account.
- *
- * @param y the y-coordinate
- * @return <code>true</code> if there is an annotation, <code>false</code> otherwise
- */
- boolean hasAnnotation(int y);
-
- /**
- * Returns the height of the visual presentation of an annotation in this
- * overview ruler. Assumes that all annotations are represented using the
- * same height.
- *
- * @return int the visual height of an annotation
- */
- int getAnnotationHeight();
-
- /**
- * Sets the color for the given annotation type in this overview ruler.
- *
- * @param annotationType the annotation type
- * @param color the color
- */
- void setAnnotationTypeColor(Object annotationType, Color color);
-
- /**
- * Sets the drawing layer for the given annotation type in this overview ruler.
- *
- * @param annotationType the annotation type
- * @param layer the drawing layer
- */
- void setAnnotationTypeLayer(Object annotationType, int layer);
-
- /**
- * Adds the given annotation type to this overview ruler. Starting with this
- * call, annotations of the given type are shown in the overview ruler.
- *
- * @param annotationType the annotation type
- */
- void addAnnotationType(Object annotationType);
-
- /**
- * Removes the given annotation type from this overview ruler. Annotations
- * of the given type are no longer shown in the overview ruler.
- *
- * @param annotationType the annotation type
- */
- void removeAnnotationType(Object annotationType);
-
- /**
- * Adds the given annotation type to the header of this ruler. Starting with
- * this call, the presence of annotations is tracked and the header is drawn
- * in the configured color.
- *
- * @param annotationType the annotation type to be tracked
- */
- void addHeaderAnnotationType(Object annotationType);
-
- /**
- * Removes the given annotation type from the header of this ruler. The
- * presence of annotations of the given type is no longer tracked and the
- * header is drawn in the default color, depending on the other configured
- * configured annotation types.
- *
- * @param annotationType the annotation type to be removed
- */
- void removeHeaderAnnotationType(Object annotationType);
-
- /**
- * Returns this rulers header control. This is the little area between the
- * top of the text widget and the top of this overview ruler.
- *
- * @return the header control of this overview ruler.
- */
- Control getHeaderControl();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ISharedTextColors.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ISharedTextColors.java
deleted file mode 100644
index 4f1cf98..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ISharedTextColors.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.source;
-
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.RGB;
-
-
-/**
- * Manages SWT color objects. Until the <code>dispose</code> method is called,
- * the same color object is returned for equal <code>RGB</code> values.
- * <p> This interface may be implemented by clients. </p>
- *
- * @since 2.1
- */
-public interface ISharedTextColors {
-
- /**
- * Returns the color object for the value represented by the given
- * <code>RGB</code> object.
- *
- * @param rgb the rgb color specification
- * @return the color object for the given rgb value
- */
- Color getColor(RGB rgb);
-
- /**
- * Tells this object to dispose all its managed colors.
- */
- void dispose();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ISourceViewer.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ISourceViewer.java
deleted file mode 100644
index b71c5e1..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ISourceViewer.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.source;
-
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextOperationTarget;
-import org.eclipse.jface.text.ITextViewer;
-
-
-/**
- * In addition to the text viewer functionality a source viewer supports:
- * <ul>
- * <li> visual annotations based on an annotation model
- * <li> visual range indication
- * <li> management of text viewer add-ons
- * <li> explicit configuration
- * </ul>
- * It is assumed that range indication and visual annotations are shown
- * inside the same presentation area. There are no assumptions about
- * whether this area is different from the viewer's text widget.<p>
- * As the visibility of visual annotations can dynamically be changed,
- * it is assumed that the annotation presentation area can dynamically
- * be hidden if it is different from the text widget.<p>
- * Clients may implement this interface or use the default implementation provided
- * by <code>SourceViewer</code>.
- */
-public interface ISourceViewer extends ITextViewer {
-
- /**
- * Text operation code for requesting content assist to show completion
- * proposals for the current insert position.
- */
- static final int CONTENTASSIST_PROPOSALS= ITextOperationTarget.STRIP_PREFIX + 1;
-
- /**
- * Text operation code for requesting content assist to show
- * the content information for the current insert position.
- */
- static final int CONTENTASSIST_CONTEXT_INFORMATION= ITextOperationTarget.STRIP_PREFIX + 2;
-
- /**
- * Text operation code for formatting the selected text or complete document
- * of this viewer if the selection is empty.
- */
- static final int FORMAT= ITextOperationTarget.STRIP_PREFIX + 3;
-
- /**
- * Text operation code for requesting information at the current insertion position.
- * @since 2.0
- */
- static final int INFORMATION= ITextOperationTarget.STRIP_PREFIX + 4;
-
- /**
- * Configures the source viewer using the given configuration. Prior to 3.0 this
- * method can only be called once. Since 3.0 this method can be called again
- * after a call to {@link ISourceViewerExtension2#unconfigure()}.
- *
- * @param configuration the source viewer configuration to be used
- */
- void configure(SourceViewerConfiguration configuration);
-
- /**
- * Sets the annotation hover of this source viewer. The annotation hover
- * provides the information to be displayed in a hover popup window
- * if requested over the annotation presentation area. The annotation
- * hover is assumed to be line oriented.
- *
- * @param annotationHover the hover to be used, <code>null</code> is a valid argument
- */
- void setAnnotationHover(IAnnotationHover annotationHover);
-
- /**
- * Sets the given document as this viewer's text model and the
- * given annotation model as the model for this viewer's visual
- * annotations. The presentation is accordingly updated. An appropriate
- * <code>TextEvent</code> is issued. This text event does not carry
- * a related document event.
- *
- * @param document the viewer's new input document
- * @param annotationModel the model for the viewer's visual annotations
- *
- * @see ITextViewer#setDocument(IDocument)
- */
- void setDocument(IDocument document, IAnnotationModel annotationModel);
-
- /**
- * Sets the given document as this viewer's text model and the
- * given annotation model as the model for this viewer's visual
- * annotations. The presentation is accordingly updated whereby
- * only the specified region is exposed. 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, annotationModel);setVisibleRegion(offset, length)</code>.
- *
- * @param document the new input document
- * @param annotationModel the model of the viewer's visual annotations
- * @param modelRangeOffset the offset of the model range
- * @param modelRangeLength the length of the model range
- *
- * @see ITextViewer#setDocument(IDocument, int, int)
- */
- void setDocument(IDocument document, IAnnotationModel annotationModel, int modelRangeOffset, int modelRangeLength);
-
- /**
- * Returns this viewer's annotation model.
- *
- * @return this viewer's annotation model
- */
- IAnnotationModel getAnnotationModel();
-
- /**
- * Sets the annotation used by this viewer as range indicator. The
- * range covered by this annotation is referred to as range indication.
- *
- * @param rangeIndicator the annotation to be used as this viewer's range indicator
- */
- void setRangeIndicator(Annotation rangeIndicator);
-
- /**
- * Sets the viewers's range indication to the specified range. Its is indicated
- * whether the cursor should also be moved to the beginning of the specified range.
- *
- * @param offset the offset of the range
- * @param length the length of the range
- * @param moveCursor indicates whether the cursor should be moved to the given offset
- */
- void setRangeIndication(int offset, int length, boolean moveCursor);
-
- /**
- * Returns the viewer's range indication.
- *
- * @return the viewer's range indication.
- */
- IRegion getRangeIndication();
-
- /**
- * Removes the viewer's range indication. There is no visible range indication
- * after this method completed.
- */
- void removeRangeIndication();
-
- /**
- * Controls the visibility of annotations and in the case of separate
- * presentation areas of text and annotations, the visibility of the
- * annotation's presentation area.<p>
- * By default, annotations and their presentation area are visible.
- *
- * @param show indicates the visibility of annotations
- */
- void showAnnotations(boolean show);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ISourceViewerExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ISourceViewerExtension.java
deleted file mode 100644
index b41a049..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ISourceViewerExtension.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.source;
-
-/**
- * Extension interface for <code>ISourceViewer</code>.
- * Extends the source viewer with the concept of an annotation overview.
- * The annotation overview differs from the annotation presentation in that it is
- * independent from the viewer's view port, i.e. the annotations of the
- * whole document are visible. There are no assumptions about
- * the area in which the annotation overview is shown.<p>
- * As the visibility of annotation overview can dynamically be changed,
- * it is assumed that the presentation area can dynamically
- * be hidden if it is different from the text widget.<p>
- * Clients may implement this interface or use the default implementation provided
- * by <code>SourceViewer</code>.
- *
- * @since 2.1
- */
-public interface ISourceViewerExtension {
-
- /**
- * Shows/hides an overview representation of the annotations of the whole document of this viewer.
- *
- * @param show <code>true</code> if annotation overview should be visible, <code>false</code> otherwise
- */
- void showAnnotationsOverview(boolean show);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ISourceViewerExtension2.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ISourceViewerExtension2.java
deleted file mode 100644
index 434035b..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ISourceViewerExtension2.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.source;
-
-/**
- * Extension interface for {@link ISourceViewer}.
- * Extends the source viewer with the functionality of explicit
- * unconfiguration.
- *
- * @since 3.0
- */
-public interface ISourceViewerExtension2 {
-
- /**
- * Unconfigures this source viewer. The source viewer can be configured again
- * after a call to this method. Unlike {@link ISourceViewer#configure(SourceViewerConfiguration)}
- * this method can be called more than once without interleaving calls to
- * {@link ISourceViewer#configure(SourceViewerConfiguration)}.
- */
- void unconfigure();
-
- /**
- * Returns the visual annotation model of this viewer.
- *
- * @return the visual annotation model of this viewer
- */
- IAnnotationModel getVisualAnnotationModel();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ITagHandler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ITagHandler.java
deleted file mode 100644
index d4df4d4..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ITagHandler.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.source;
-
-import java.io.IOException;
-
-
-/**
- * A tag handler is responsible to
- * - handle the attributes for the tags it supports
- * - translate the tag sequence including attributes to another language
- * - back-translate relative line offsets.
- * <p>
- * Tag handlers are used by translators via tag handler factories.</p>
- *
- * @see org.eclipse.jface.text.source.ITranslator
- * @see org.eclipse.jface.text.source.ITagHandlerFactory
- * @since 3.0
- */
-public interface ITagHandler {
-
- /**
- * Tells whether this handler can handle the given tag.
- *
- * @param tag the tag to check
- * @return <code>true</code> if this handler handles the given tag
- */
- boolean canHandleTag(String tag);
-
- /**
- * Tells whether this handler can handle the given text. Most
- * likely the handler will check if the text contains a tag
- * that he can handle.
- *
- * @param text the text to check
- * @return <code>true</code> if this handler handles the given text
- */
- boolean canHandleText(String text);
-
- /**
- * Adds an attribute to this tag handler.
- *
- * @param name the name of the attribute
- * @param value the attribute value
- * @param sourceLineNumber the line number of the attribute in the source or <code>-1</code> if unknown
- */
- void addAttribute(String name, String value, int sourceLineNumber);
-
- /**
- * Resets this handler and sets the current tag to the given tag.
- * A handler can handle more than one tag but only one tag at a time.
- * <p>
- * Resetting the handler clears the attributes.</p>
- *
- * @param tag the tag to check
- */
- void reset(String tag);
-
- /**
- * Writes the tag and line mapping information to the
- * given translator result collector.
- *
- * @param resultCollector the translator's result collector
- * @param sourceLineNumber the line number of the attribute in the source or <code>-1</code> if unknown
- * @throws IOException
- */
- void processEndTag(ITranslatorResultCollector resultCollector, int sourceLineNumber) throws IOException;
-
- /**
- * Computes the offset in the source line that corresponds
- * to the given offset in the translated line.
- *
- * @param sourceLine the source line
- * @param translatedLine the translated line
- * @param offsetInTranslatedLine the offset in the translated line
- * @return the offset in the source line or <code>-1</code> if
- * it was not possible to compute the offset
- */
- int backTranslateOffsetInLine(String sourceLine, String translatedLine, int offsetInTranslatedLine);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ITagHandlerFactory.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ITagHandlerFactory.java
deleted file mode 100644
index e9b0f9a..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ITagHandlerFactory.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.source;
-
-/**
- * A tag handler factory provides access to tag
- * handlers.
- *
- * @since 3.0
- */
-public interface ITagHandlerFactory {
-
- /**
- * Returns a handler that can handle the
- * given tag.
- * <p>
- * Depending on the used handler the factory might
- * return a new or a shared instance.</p>
- *
- * @param tag the tag for which to return the handler
- * @return a tag handler or <code>null</code> if no handler
- * is available
- */
- public ITagHandler getHandler(String tag);
-
- /**
- * Finds and returns a handler that can handle
- * the given text snippet.
- * <p>
- * Depending on the used handler the factory might
- * return a new or a shared instance.</p>
- *
- * @param text the text for which to find a handler
- * @return a tag handler or <code>null</code> if no handler
- * is available
- */
- public ITagHandler findHandler(String text);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ITranslator.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ITranslator.java
deleted file mode 100644
index 694a0ca..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ITranslator.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.source;
-
-import java.io.IOException;
-import java.io.Reader;
-
-/**
- * A translator translates a given file into another language.
- * The translator is also responsible to provide line mapping
- * information for the translation and to compute which offset
- * in an original line corresponds to a given offset in a
- * target line.
- *
- * @since 3.0
- */
-public interface ITranslator {
-
- /**
- * Reads the source from the given reader and creates
- * translates it into another language. The translated
- * source might be given the optional name.
- *
- * @param reader the reader to access the source
- * @param name the name of the translated source or <code>null</code> if none
- * @return
- * @throws IOException
- */
- String translate(Reader reader, String name) throws IOException;
-
- /**
- * Returns the line mapping information.
- *
- * @return an int array where the index corresponds to line
- * numbers in the translation and the value is a
- * source line number
- */
- int[] getLineMapping();
-
- /**
- * Assigns an optional tag handler factory to this translator.
- * <p>
- * A translator can delegate the handling of individual tags
- * to tag handlers. The factory is responsible to provide
- * the correct tag handlers.</p>
- *
- * @param tagHandlerFactory a tag handler factory or <code>null</code>
- * if this translator does all work itself
- */
- void setTagHandlerFactory(ITagHandlerFactory tagHandlerFactory);
-
- /**
- * Computes the offset in the source line that corresponds
- * to the given offset in the translated line.
- *
- * @param sourceLine the source line
- * @param translatedLine the translated line
- * @param offsetInTranslatedLine the offset in the translated line
- * @param tag the tag to which the source line belongs or
- * <code>null</code> if the tag is not known
- * @return the offset in the source line or <code>-1</code> if
- * it was not possible to compute the offset
- */
- int backTranslateOffsetInLine(String sourceLine, String translatedLine, int offsetInTranslatedLine, String tag);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ITranslatorResultCollector.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ITranslatorResultCollector.java
deleted file mode 100644
index d2b8b81..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ITranslatorResultCollector.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.source;
-
-/**
- * Tagging interface for a translator result collector.
- *
- * @since 3.0
- */
-public interface ITranslatorResultCollector {
-
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRuler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRuler.java
deleted file mode 100644
index 5e7c9b9..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRuler.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.source;
-
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-
-import org.eclipse.jface.text.ITextViewer;
-
-
-/**
- * This interface defines a visual component which may serve text viewers as an annotation presentation
- * area. Implementers of this interface have to define the presentation modus. This can either depend
- * on the connected viewer's view port or not. If the modus is view port dependent the ruler only shows
- * those annotations that are attached to document regions that are visible in the view port. If independent,
- * the presented annotations can also be attached to invisible document regions.
- *
- * This interfaces comprises three contracts:
- * <ul>
- * <li> The vertical ruler retrieves the annotations it presents from an annotation model.
- * <li> The ruler is a visual component which must be integrated in a hierarchy of SWT controls.
- * <li> The ruler provides interested clients with mapping and
- * interaction information. This covers the mapping between
- * coordinates of the ruler's control and line numbers based
- * on the connected text viewer's document (<code>IVerticalRulerInfo</code>).
- * </ul>
- * Clients may implement this interface or use the default implementation provided
- * by <code>CompositeRuler</code> and <code>VerticalRuler</code>.
- *
- * @see ITextViewer
- * @see IVerticalRulerInfo
- */
-public interface IVerticalRuler extends IVerticalRulerInfo {
-
- /**
- * Associates an annotation model with this ruler.
- * A value <code>null</code> is acceptable and clears the ruler.
- *
- * @param model the new annotation model, may be <code>null</code>
- */
- void setModel(IAnnotationModel model);
-
- /**
- * Returns the current annotation model of this ruler or <code>null</code>
- * if the ruler has no model.
- *
- * @return this ruler's annotation model or <code>null</code> if there is no model
- */
- IAnnotationModel getModel();
-
- /**
- * Forces the vertical ruler to synchronize itself with its
- * annotation model and its viewer's viewport.
- */
- void update();
-
- /**
- * Creates the ruler's SWT control.
- *
- * @param parent the parent control of the ruler's control
- * @param textViewer the text viewer to which this ruler belongs
- * @return the ruler's SWT control
- */
- Control createControl(Composite parent, ITextViewer textViewer);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRulerColumn.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRulerColumn.java
deleted file mode 100644
index 2c442e6..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRulerColumn.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.source;
-
-
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-
-
-/**
- * A <code>IVerticalRulerColumn</code> is an element that can be added
- * to a composite vertical ruler. A composite vertical ruler is a vertical ruler
- * with a dynamically changing appearance and behavior depending on its
- * actual arrangement of ruler columns. A vertical ruler column supports a
- * subset of the contract of a vertical ruler.
- *
- * @see org.eclipse.jface.text.source.CompositeRuler
- * @since 2.0
- */
-public interface IVerticalRulerColumn {
-
- /**
- * Associates an annotation model with this ruler column.
- * A value <code>null</code> is acceptable and clears the ruler.
- *
- * @param model the new annotation model, may be <code>null</code>
- */
- void setModel(IAnnotationModel model);
-
- /**
- * Redraws this column.
- */
- void redraw();
-
- /**
- * Creates the column's SWT control.
- *
- * @param parentRuler the parent ruler of this column
- * @param parentControl the control of the parent ruler
- * @return the column's SWT control
- */
- Control createControl(CompositeRuler parentRuler, Composite parentControl);
-
- /**
- * Returns the column's SWT control.
- *
- * @return the column's SWT control
- */
- Control getControl();
-
- /**
- * Returns the width of this column's control.
- *
- * @return the width of this column's control
- */
- int getWidth();
-
- /**
- * Sets the font of this ruler column.
- *
- * @param font the new font of the ruler column
- */
- void setFont(Font font);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRulerExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRulerExtension.java
deleted file mode 100644
index 7e0f3bf..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRulerExtension.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.source;
-
-
-import org.eclipse.swt.graphics.Font;
-
-
-/**
- * Extension interface for <code>IVerticalRuler</code>. Allows to set the font of the
- * vertical ruler and to set the location of the last mouse button activity.
- *
- * @since 2.0
- */
-public interface IVerticalRulerExtension {
-
- /**
- * Sets the font of this vertical ruler.
- *
- * @param font the new font of the vertical ruler
- */
- void setFont(Font font);
-
- /**
- * Sets the location of the last mouse button activity. This method is used for
- * example by external mouse listeners.
- *
- * @param x the x-coordinate
- * @param y the y-coordinate
- */
- void setLocationOfLastMouseButtonActivity(int x, int y);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRulerInfo.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRulerInfo.java
deleted file mode 100644
index ed180c3..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRulerInfo.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.source;
-
-
-import org.eclipse.swt.widgets.Control;
-
-
-/**
- * A vertical ruler is a visual component which may serve
- * text viewers as an annotation presentation
- * area. The vertical ruler info provides interested clients with the
- * mapping and interaction aspect of the vertical ruler. This
- * covers the mapping between coordinates of the ruler's
- * control and line numbers based on the connected text viewer's
- * document.
- *
- * @since 2.0
- */
-public interface IVerticalRulerInfo {
-
- /**
- * Returns the ruler's SWT control.
- *
- * @return the ruler's SWT control
- */
- Control getControl();
-
- /**
- * Returns the line number of the last mouse button activity.
- * Based on the input document of the connected text viewer.
- * The smallest possible line number is <code>0</code>.
- *
- * @return the line number of the last mouse button activity
- */
- int getLineOfLastMouseButtonActivity();
-
- /**
- * Translates a y-coordinate of the ruler's SWT control into
- * the according line number of the document of the connected text viewer.
- *
- * @param y_coordinate a y-coordinate of the ruler's SWT control
- * @return the line number of that coordinate or <code>-1</code> if that
- * coordinate does not correspond to a valid document line
- */
- int toDocumentLineNumber(int y_coordinate);
-
- /**
- * Returns the width of this ruler's control.
- *
- * @return the width of this ruler's control
- */
- int getWidth();
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRulerInfoExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRulerInfoExtension.java
deleted file mode 100644
index 4773ce2..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRulerInfoExtension.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.source;
-
-/**
- * Extends <code>IVerticalRulerInfo</code> with the ability to define a custom hover to be used
- * when hovering over the <code>IVerticalRuler</code> described by this info instance, and to
- * specify the <code>IAnnotationModel</code> used by it.
- * @since 3.0
- */
-public interface IVerticalRulerInfoExtension {
- /**
- * Returns the hover for this vertical ruler (column).
- * @return the hover for this column
- */
- IAnnotationHover getHover();
-
- /**
- * Returns the model currently used by the receiver.
- * @return the model of the receiver, or <code>null</code> if no model is installed.
- */
- IAnnotationModel getModel();
-
- /**
- * Registers an annotation listener to be informed if an annotation gets
- * selected on the vertical ruler.
- *
- * @param listener the listener to be informed about annotation selection events
- */
- void addAnnotationListener(IAnnotationListener listener);
-
- /**
- * Removes a previously registered listener. If <code>listener</code> is not registered
- * with the receiver, calling this method has no effect.
- *
- * @param listener the listener to be removed
- */
- void removeAnnotationListener(IAnnotationListener listener);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/JFaceTextMessages.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/JFaceTextMessages.java
deleted file mode 100644
index 144851f..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/JFaceTextMessages.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.source;
-
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-/**
- * Accessor for the <code>JFaceTextMessages.properties</code> file in
- * package <code>org.eclipse.jface.text</code>.
- * @since 2.0
- */
-class JFaceTextMessages {
-
- /** The resource bundle name. */
- private static final String RESOURCE_BUNDLE= "org.eclipse.jface.text.JFaceTextMessages";//$NON-NLS-1$
-
- /** The resource bundle. */
- private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
-
- /**
- * Prohibits the creation of accessor objects.
- */
- private JFaceTextMessages() {
- }
-
- /**
- * Returns the string found in the resource bundle under the given key or a place holder string.
- *
- * @param key the look up key
- * @return the value found under the given key
- */
- public static String getString(String key) {
- try {
- return fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- }
-
- /**
- * Gets a string from the resource bundle and formats it with the argument
- *
- * @param key the string used to get the bundle value, must not be null
- * @since 3.0
- */
- public static String getFormattedString(String key, Object[] args) {
- String format= null;
- try {
- format= fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- return MessageFormat.format(format, args);
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineChangeHover.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineChangeHover.java
deleted file mode 100644
index ddac4fc..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineChangeHover.java
+++ /dev/null
@@ -1,321 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.source;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.swt.graphics.Point;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IInformationControlCreator;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.TextSelection;
-
-
-/**
- * A hover for line oriented diffs. It determines the text to show as hover for a certain line in the
- * document.
- *
- * @since 3.0
- */
-public class LineChangeHover implements IAnnotationHover, IAnnotationHoverExtension {
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationHoverExtension#getHoverInfo(org.eclipse.jface.text.source.ISourceViewer, int, int, int)
- */
- public String getHoverInfo(ISourceViewer sourceViewer, int lineNumber, int first, int number) {
- int last= first + number - 1;
- String content= computeContent(sourceViewer, lineNumber, first, last);
- return formatSource(content);
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationHover#getHoverInfo(org.eclipse.jface.text.source.ISourceViewer, int)
- */
- public String getHoverInfo(ISourceViewer sourceViewer, int lineNumber) {
- return getHoverInfo(sourceViewer, lineNumber, 0, Integer.MAX_VALUE);
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationHoverExtension#getLineRange(org.eclipse.jface.text.source.ISourceViewer, int, int, int)
- */
- public ITextSelection getLineRange(ISourceViewer viewer, int line, int first, int number) {
- int last= first + number - 1;
- Point lineRange= computeLineRange(viewer, line, first, last);
- if (viewer != null && lineRange != null && lineRange.x != -1 && lineRange.y != -1) {
- try {
- IDocument document= viewer.getDocument();
- if (document != null) {
- int offset= document.getLineOffset(lineRange.x);
- // make sure that content shifts due to deleted lines are shifted one down
- IRegion endLine= document.getLineInformation(Math.max(lineRange.x, lineRange.y));
- int endOffset= endLine.getOffset() + endLine.getLength();
- // consider add one to comprise last line
- int length= endOffset - offset + 1;
- return new TextSelection(document, offset, length);
- }
- } catch (BadLocationException e) {
- }
- }
- return new TextSelection(0, 0);
- }
-
- /**
- * Formats the source w/ syntax coloring etc. This implementation replaces tabs with spaces.
- * May be overridden by subclasses.
- *
- * @param content the hover content
- * @return <code>content</code> reformatted
- */
- protected String formatSource(String content) {
- if (content != null) {
- StringBuffer sb= new StringBuffer(content);
- final String tabReplacement= getTabReplacement();
- for (int pos= 0; pos < sb.length(); pos++) {
- if (sb.charAt(pos) == '\t')
- sb.replace(pos, pos + 1, tabReplacement);
- }
- return sb.toString();
- }
- return content;
- }
-
- /**
- * Consults the preferences for the number of spaces a tab should be displayed as.
- *
- * @return a String consisting of spaces that will replace one tab character in the
- * displayed source.
- */
- protected String getTabReplacement() {
- return " "; //$NON-NLS-1$
- }
-
- /**
- * Computes the content of the hover for the document contained in <code>viewer</code> on
- * line <code>line</code>.
- *
- * @param viewer the connected viewer
- * @param line the line for which to compute the hover info
- * @param first the first line in <code>viewer</code>'s document to consider
- * @param last the last line in <code>viewer</code>'s document to consider
- * @return The hover content corresponding to the parameters
- * @see #getHoverInfo()
- */
- private String computeContent(ISourceViewer viewer, int line, int first, int last) {
- Point contentRange= computeContentRange(viewer, line, first, last);
- if (contentRange == null)
- return null;
- ILineDiffer differ= getDiffer(viewer);
- if (differ == null)
- return null;
- // sanity test line argument
- if (line > contentRange.y + 1 || line < contentRange.x - 1)
- return null;
-
- final List lines= new LinkedList();
- for (int l= contentRange.x; l <= contentRange.y; l++) {
- ILineDiffInfo info= differ.getLineInfo(l);
- if (info != null)
- lines.add(info);
- }
- final int max= viewer.getBottomIndex();
- return decorateText(lines, max - contentRange.x + 1);
- }
-
- /**
- * Takes a list of <code>ILineDiffInfo</code>s and computes a hover of at most <code>maxLines</code>.
- * Added lines are prefixed with a <code>'+'</code>, changed lines with <code>'>'</code> and
- * deleted lines with <code>'-'</code>.
- * <p>Deleted and added lines can even each other out, so that a number of deleted lines get
- * displayed where - in the current document - the added lines are.
- *
- * @param diffInfos a <code>List</code> of <code>ILineDiffInfo</code>
- * @param maxLines the maximum number of lines. Note that adding up all annotations might give
- * more than that due to deleted lines.
- * @return a <code>String</code> suitable for hover display
- */
- protected String decorateText(List diffInfos, int maxLines) {
- /* maxLines controls the size of the hover (not more than what fits into the display are of
- * the viewer).
- * added controls how many lines are added - added lines are
- */
- String text= new String();
- int added= 0;
- for (Iterator it= diffInfos.iterator(); it.hasNext();) {
- ILineDiffInfo info= (ILineDiffInfo)it.next();
- String[] original= info.getOriginalText();
- int type= info.getChangeType();
- int i= 0;
- if (type == ILineDiffInfo.ADDED)
- added++; //$NON-NLS-1$
- else if (type == ILineDiffInfo.CHANGED) {
- text += "> " + (original.length > 0 ? original[i++] : ""); //$NON-NLS-1$ //$NON-NLS-2$
- maxLines--;
- } else if (type == ILineDiffInfo.UNCHANGED) {
- maxLines++;
- }
- if (maxLines == 0)
- return trimTrailing(text);
- for (; i < original.length; i++) {
- text += "- " + original[i]; //$NON-NLS-1$
- added--;
- if (--maxLines == 0)
- return trimTrailing(text);
- }
- }
- text= text.trim();
- if (text.length() == 0 && added-- > 0 && maxLines-- > 0)
- text += "+ "; //$NON-NLS-1$
- while (added-- > 0 && maxLines-- > 0)
- text += "\n+ "; //$NON-NLS-1$
- return text;
- }
-
- /**
- * Trims trailing spaces
- *
- * @param text a <code>String</code>
- * @return a copy of <code>text</code> with trailing spaces removed
- */
- private String trimTrailing(String text) {
- int pos= text.length() - 1;
- while (pos >= 0 && Character.isWhitespace(text.charAt(pos))) {
- pos--;
- }
- return text.substring(0, pos + 1);
- }
-
- /**
- * Extracts the line differ - if any - from the viewer's document's annotation model.
- * @param viewer the viewer
- * @return a line differ for the document displayed in viewer, or <code>null</code>.
- */
- private ILineDiffer getDiffer(ISourceViewer viewer) {
- // return the upper left corner of the first hover line
- IAnnotationModel model= viewer.getAnnotationModel();
-
- if (model == null)
- return null;
- if (model instanceof IAnnotationModelExtension) {
- IAnnotationModel diffModel= ((IAnnotationModelExtension)model).getAnnotationModel(IChangeRulerColumn.QUICK_DIFF_MODEL_ID);
- if (diffModel != null)
- model= diffModel;
- }
- if (model instanceof ILineDiffer)
- return (ILineDiffer)model;
- else
- return null;
- }
-
- /**
- * Computes the content range, which is either equal to the line range or the line range plus
- * one line at the start (due to <code>ILineDiffInfo</code> implementation).
- *
- * @param viewer the connected viewer
- * @param line the achor line
- * @param first the first line in <code>viewer</code>'s document to consider
- * @param last the last line in <code>viewer</code>'s document to consider
- * @return the computed content range
- */
- private Point computeContentRange(ISourceViewer viewer, int line, int first, int last) {
- ILineDiffer differ= getDiffer(viewer);
- if (differ == null)
- return null;
-
- Point lineRange= computeLineRange(viewer, line, first, last);
- if (lineRange == null)
- return null;
-
- // here comes the hack: since we only get deleted lines *after* a line, we decrease one further if conditions met
- int l= lineRange.x - 1;
- ILineDiffInfo info= differ.getLineInfo(l);
- if (l >= first - 1 && info != null && info.getChangeType() == ILineDiffInfo.UNCHANGED && info.getRemovedLinesBelow() > 0)
- return new Point(l, lineRange.y);
- else
- return lineRange;
- }
-
- /**
- * Computes the block of lines which form a contiguous block of changes covering <code>line</code>.
- *
- * @param viewer the source viewer showing
- * @param line the line which a hover is displayed for
- * @param min the first line in <code>viewer</code>'s document to consider
- * @param max the last line in <code>viewer</code>'s document to consider
- * @return the selection in the document displayed in <code>viewer</code> containing <code>line</code>
- * that is covered by the hover information returned by the receiver.
- */
- protected Point computeLineRange(ISourceViewer viewer, int line, int min, int max) {
- /* Algorithm:
- * All lines that have changes to themselves (added, changed) are taken that form a
- * contiguous block of lines that includes <code>line</code>.
- *
- * If <code>line</code> is itself unchanged, if there is a deleted line either above or
- * below, or both, the lines +/- 1 from <code>line</code> are included in the search as well,
- * without applying this last rule to them, though. (I.e., if <code>line</code> is unchanged,
- * but has a deleted line above, this one is taken in. If the line above has changes, the block
- * is extended from there. If the line has no changes itself, the search stops).
- *
- * The block never extends the visible line range of the viewer.
- */
-
- ILineDiffer differ= getDiffer(viewer);
- if (differ == null)
- return null;
-
- // backward search
-
- int l= line;
- ILineDiffInfo info= differ.getLineInfo(l);
- // if this is a special case, we'll start the search one above line
- if (l >= min && info != null && info.getChangeType() == ILineDiffInfo.UNCHANGED && info.getRemovedLinesAbove() > 0) {
- info= differ.getLineInfo(--l);
- }
-
- // search backwards until a line has no changes to itself
- while (l >= min && info != null && (info.getChangeType() == ILineDiffInfo.CHANGED || info.getChangeType() == ILineDiffInfo.ADDED)) {
- info= differ.getLineInfo(--l);
- }
-
- // correct overrun
-// int first= l < line ? l + 1 : l;
- int first= l + 1;
-
- // forward search
-
- l= line;
- info= differ.getLineInfo(l);
- // if this is a special case, we'll start the search one below line
- if (l <= max && info != null && info.getChangeType() == ILineDiffInfo.UNCHANGED && info.getRemovedLinesBelow() > 0) {
- info= differ.getLineInfo(++l);
- }
- // search forward until a line has no changes to itself
- while (l <= max && info != null && (info.getChangeType() == ILineDiffInfo.CHANGED || info.getChangeType() == ILineDiffInfo.ADDED)) {
- info= differ.getLineInfo(++l);
- }
-
- // correct overrun
- int last= l - 1;
-
- return new Point(first, last);
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationHoverExtension#getInformationControlCreator()
- */
- public IInformationControlCreator getInformationControlCreator() {
- return null;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberChangeRulerColumn.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberChangeRulerColumn.java
deleted file mode 100644
index 4954b5d..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberChangeRulerColumn.java
+++ /dev/null
@@ -1,432 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.source;
-
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Display;
-
-import org.eclipse.jface.text.Assert;
-
-/**
- * A vertical ruler column displaying line numbers and serving as a UI for quick diff.
- * Clients usually instantiate and configure object of this class.
- *
- * @since 3.0
- */
-public final class LineNumberChangeRulerColumn extends LineNumberRulerColumn implements IVerticalRulerInfo, IVerticalRulerInfoExtension, IChangeRulerColumn {
-
- /** Width of the triangle displayed for deleted lines. */
- private final static int fTriangleWidth= 7;
- /** The height of the triangle displayed for deleted lines. */
- private final static int fTriangleHeight= 3;
-
- /**
- * Internal listener class that will update the ruler when the underlying model changes.
- */
- class AnnotationListener implements IAnnotationModelListener {
- /*
- * @see org.eclipse.jface.text.source.IAnnotationModelListener#modelChanged(org.eclipse.jface.text.source.IAnnotationModel)
- */
- public void modelChanged(IAnnotationModel model) {
- postRedraw();
- }
- }
-
- /**
- * Returns a specification of a color that lies between the given
- * foreground and background color using the given scale factor.
- *
- * @param fg the foreground color
- * @param bg the background color
- * @param scale the scale factor
- * @return the interpolated color
- */
- private static RGB interpolate(RGB fg, RGB bg, double scale) {
- return new RGB(
- (int) ((1.0-scale) * fg.red + scale * bg.red),
- (int) ((1.0-scale) * fg.green + scale * bg.green),
- (int) ((1.0-scale) * fg.blue + scale * bg.blue)
- );
- }
-
- /**
- * Returns the grey value in which the given color would be drawn in grey-scale.
- *
- * @param rgb the color
- * @return the grey-scale value
- */
- private static double greyLevel(RGB rgb) {
- if (rgb.red == rgb.green && rgb.green == rgb.blue)
- return rgb.red;
- return (0.299 * rgb.red + 0.587 * rgb.green + 0.114 * rgb.blue + 0.5);
- }
-
- /**
- * Returns whether the given color is dark or light depending on the colors grey-scale level.
- *
- * @param rgb the color
- * @return <code>true</code> if the color is dark, <code>false</code> if it is light
- */
- private static boolean isDark(RGB rgb) {
- return greyLevel(rgb) > 128;
- }
-
- /** Color for changed lines. */
- private Color fAddedColor;
- /** Color for added lines. */
- private Color fChangedColor;
- /** Color for the deleted line indicator. */
- private Color fDeletedColor;
- /** The ruler's annotation model. */
- IAnnotationModel fAnnotationModel;
- /** The ruler's hover. */
- private IAnnotationHover fHover;
- /** The internal listener. */
- private AnnotationListener fAnnotationListener= new AnnotationListener();
- /** <code>true</code> if changes should be displayed using character indications instead of background colors. */
- private boolean fCharacterDisplay;
- /** The shared text colors. */
- private ISharedTextColors fSharedColors;
-
- /**
- * Creates a new instance.
- *
- * @param sharedColors the shared colors provider to use
- */
- public LineNumberChangeRulerColumn(ISharedTextColors sharedColors) {
- Assert.isNotNull(sharedColors);
- fSharedColors= sharedColors;
- }
-
- /*
- * @see org.eclipse.jface.text.source.LineNumberRulerColumn#handleDispose()
- */
- protected void handleDispose() {
- if (fAnnotationModel != null) {
- fAnnotationModel.removeAnnotationModelListener(fAnnotationListener);
- fAnnotationModel= null;
- }
- super.handleDispose();
- }
-
- /*
- * @see org.eclipse.jface.text.source.LineNumberRulerColumn#paintLine(int, int, int, org.eclipse.swt.graphics.GC, org.eclipse.swt.widgets.Display)
- */
- protected void paintLine(int line, int y, int lineheight, GC gc, Display display) {
- ILineDiffInfo info= getDiffInfo(line);
-
- if (info != null) {
- // width of the column
- int width= getWidth();
-
- // draw background color if special
- if (hasSpecialColor(info)) {
- gc.setBackground(getColor(info, display));
- gc.fillRectangle(0, y, width, lineheight);
- }
-
- /* Deletion Indicator
- * It consists of a line across the column and a triangle as shown for a deleted
- * line below the line 50:
- * ('x' means its colored)
- *
- * 1, 2, 3 show the points of the triangle painted.
- *
- * 0 width
- * | |
- * --------------------- - y
- * | --- -- |
- * | | | | 1_
- * | -- | | x| ^
- * | | | | xxx| | fTriangleHeight / 2
- * | --- -- xxxxx| |
- * xxxxxxxxxxxx0xxxxxxx2_ v _ y + lineheight
- * | |
- * <------>
- * fTriangleWidth
- */
- int delBefore= info.getRemovedLinesAbove();
- int delBelow= info.getRemovedLinesBelow();
- if (delBefore > 0 || delBelow > 0) {
- Color deletionColor= getDeletionColor(display);
- gc.setBackground(deletionColor);
- gc.setForeground(deletionColor);
-
- int[] triangle= new int[6];
- triangle[0]= width - fTriangleWidth;
- triangle[1]= y;
- triangle[2]= width;
- triangle[3]= y - fTriangleHeight;
- triangle[4]= width;
- triangle[5]= y + fTriangleHeight;
-
- if (delBefore > 0) {
- gc.drawLine(0, y, width, y);
- gc.fillPolygon(triangle);
- }
-
- if (delBelow > 0) {
- triangle[1] += lineheight;
- triangle[3] += lineheight;
- triangle[5] += lineheight;
-
- gc.drawLine(0, y + lineheight, width, y + lineheight);
- gc.fillPolygon(triangle);
- }
- gc.setForeground(getForeground());
- }
- }
- }
-
- /**
- * Returns whether the line background differs from the default.
- *
- * @param info the info being queried
- * @return <code>true</code> if <code>info</code> describes either a changed or an added line.
- */
- private boolean hasSpecialColor(ILineDiffInfo info) {
- return info.getChangeType() == ILineDiffInfo.ADDED || info.getChangeType() == ILineDiffInfo.CHANGED;
- }
-
- /**
- * Retrieves the <code>ILineDiffInfo</code> for <code>line</code> from the model.
- * There are optimizations for direct access and sequential access patterns.
- *
- * @param line the line we want the info for.
- * @return the <code>ILineDiffInfo</code> for <code>line</code>, or <code>null</code>.
- */
- private ILineDiffInfo getDiffInfo(int line) {
- if (fAnnotationModel == null)
- return null;
-
- // assume direct access
- if (fAnnotationModel instanceof ILineDiffer) {
- ILineDiffer differ= (ILineDiffer)fAnnotationModel;
- return differ.getLineInfo(line);
- }
-
- return null;
- }
-
- /**
- * Returns the color for deleted lines.
- *
- * @param display the display that the drawing occurs on
- * @return the color to be used for the deletion indicator
- */
- private Color getDeletionColor(Display display) {
- return fDeletedColor == null ? getBackground(display) : fDeletedColor;
- }
-
- /**
- * Returns the color for the given line diff info.
- *
- * @param info the <code>ILineDiffInfo</code> being queried
- * @param display the display that the drawing occurs on
- * @return the correct background color for the line type being described by <code>info</code>
- */
- private Color getColor(ILineDiffInfo info, Display display) {
- Assert.isTrue(info != null && info.getChangeType() != ILineDiffInfo.UNCHANGED);
- Color ret= null;
- switch (info.getChangeType()) {
- case ILineDiffInfo.CHANGED :
- ret= getShadedColor(fChangedColor, display);
- break;
- case ILineDiffInfo.ADDED :
- ret= getShadedColor(fAddedColor, display);
- break;
- }
- return ret == null ? getBackground(display) : ret;
- }
-
- /**
- * Returns the character to display in character display mode for the given <code>ILineDiffInfo</code>
- *
- * @param info the <code>ILineDiffInfo</code> being queried
- * @return the character indication for <code>info</code>
- */
- private String getDisplayCharacter(ILineDiffInfo info) {
- if (info == null)
- return ""; //$NON-NLS-1$
- switch (info.getChangeType()) {
- case ILineDiffInfo.CHANGED :
- return "~"; //$NON-NLS-1$
- case ILineDiffInfo.ADDED :
- return "+"; //$NON-NLS-1$
- }
- return " "; //$NON-NLS-1$
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerInfo#getLineOfLastMouseButtonActivity()
- */
- public int getLineOfLastMouseButtonActivity() {
- return getParentRuler().getLineOfLastMouseButtonActivity();
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerInfo#toDocumentLineNumber(int)
- */
- public int toDocumentLineNumber(int y_coordinate) {
- return getParentRuler().toDocumentLineNumber(y_coordinate);
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#getHover()
- */
- public IAnnotationHover getHover() {
- return fHover;
- }
-
- /**
- * Sets the hover of this ruler column.
- * @param hover the hover that will produce hover information text for this ruler column
- */
- public void setHover(IAnnotationHover hover) {
- fHover= hover;
- }
-
- /*
- * @see IVerticalRulerColumn#setModel(IAnnotationModel)
- */
- public void setModel(IAnnotationModel model) {
- IAnnotationModel newModel;
- if (model instanceof IAnnotationModelExtension) {
- newModel= ((IAnnotationModelExtension)model).getAnnotationModel(QUICK_DIFF_MODEL_ID);
- } else {
- newModel= model;
- }
- if (fAnnotationModel != newModel) {
- if (fAnnotationModel != null) {
- fAnnotationModel.removeAnnotationModelListener(fAnnotationListener);
- }
- fAnnotationModel= newModel;
- if (fAnnotationModel != null) {
- fAnnotationModel.addAnnotationModelListener(fAnnotationListener);
- }
- updateNumberOfDigits();
- computeIndentations();
- layout(true);
- postRedraw();
- }
- }
-
- /**
- * Sets the background color for added lines. The color has to be disposed of by the caller when
- * the receiver is no longer used.
- *
- * @param addedColor the new color to be used for the added lines background
- */
- public void setAddedColor(Color addedColor) {
- fAddedColor= addedColor;
- }
-
- /**
- * Sets the background color for changed lines. The color has to be disposed of by the caller when
- * the receiver is no longer used.
- *
- * @param changedColor the new color to be used for the changed lines background
- */
- public void setChangedColor(Color changedColor) {
- fChangedColor= changedColor;
- }
-
- /**
- * Sets the background color for changed lines. The color has to be disposed of by the caller when
- * the receiver is no longer used.
- *
- * @param changedColor the new color to be used for the changed lines background
- */
- private Color getShadedColor(Color color, Display display) {
- if (color == null)
- return null;
-
- RGB baseRGB= color.getRGB();
- RGB background= getBackground(display).getRGB();
-
- boolean darkBase= isDark(baseRGB);
- boolean darkBackground= isDark(background);
- if (darkBase && darkBackground)
- background= new RGB(255, 255, 255);
- else if (!darkBase && !darkBackground)
- background= new RGB(0, 0, 0);
-
- return fSharedColors.getColor(interpolate(baseRGB, background, 0.6));
- }
-
- /**
- * Sets the color for the deleted lines indicator. The color has to be disposed of by the caller when
- * the receiver is no longer used.
- *
- * @param deletedColor the new color to be used for the deleted lines indicator.
- */
- public void setDeletedColor(Color deletedColor) {
- fDeletedColor= deletedColor;
- }
-
- /**
- * Sets the the display mode of the ruler. If character mode is set to <code>true</code>, diff
- * information will be displayed textually on the line number ruler.
- *
- * @param characterMode <code>true</code> if diff information is to be displayed textually.
- */
- public void setDisplayMode(boolean characterMode) {
- if (characterMode != fCharacterDisplay) {
- fCharacterDisplay= characterMode;
- updateNumberOfDigits();
- computeIndentations();
- layout(true);
- }
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#getModel()
- */
- public IAnnotationModel getModel() {
- return fAnnotationModel;
- }
-
- /*
- * @see org.eclipse.jface.text.source.LineNumberRulerColumn#createDisplayString(int)
- */
- protected String createDisplayString(int line) {
- if (fCharacterDisplay && getModel() != null)
- return super.createDisplayString(line) + getDisplayCharacter(getDiffInfo(line));
- else
- return super.createDisplayString(line);
- }
-
- /*
- * @see org.eclipse.jface.text.source.LineNumberRulerColumn#computeNumberOfDigits()
- */
- protected int computeNumberOfDigits() {
- if (fCharacterDisplay && getModel() != null)
- return super.computeNumberOfDigits() + 1;
- else
- return super.computeNumberOfDigits();
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#addAnnotationListener(org.eclipse.jface.text.source.IAnnotationListener)
- */
- public void addAnnotationListener(IAnnotationListener listener) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#removeAnnotationListener(org.eclipse.jface.text.source.IAnnotationListener)
- */
- public void removeAnnotationListener(IAnnotationListener listener) {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberRulerColumn.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberRulerColumn.java
deleted file mode 100644
index d09dceb..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberRulerColumn.java
+++ /dev/null
@@ -1,832 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.source;
-
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.MouseMoveListener;
-import org.eclipse.swt.events.MouseTrackListener;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextListener;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.ITextViewerExtension;
-import org.eclipse.jface.text.ITextViewerExtension5;
-import org.eclipse.jface.text.IViewportListener;
-import org.eclipse.jface.text.TextEvent;
-
-
-/**
- * A vertical ruler column displaying line numbers.
- * Clients usually instantiate and configure object of this class.
- *
- * @since 2.0
- */
-public class LineNumberRulerColumn implements IVerticalRulerColumn {
-
- /**
- * Internal listener class.
- */
- class InternalListener implements IViewportListener, ITextListener {
-
- /*
- * @see IViewportListener#viewportChanged(int)
- */
- public void viewportChanged(int verticalPosition) {
- if (verticalPosition != fScrollPos)
- redraw();
- }
-
- /*
- * @see ITextListener#textChanged(TextEvent)
- */
- public void textChanged(TextEvent event) {
-
- if (updateNumberOfDigits()) {
- computeIndentations();
- layout(event.getViewerRedrawState());
- return;
- }
-
- if (!event.getViewerRedrawState())
- return;
-
- if (fSensitiveToTextChanges || event.getDocumentEvent() == null)
- postRedraw();
-
- }
- }
-
- /**
- * Handles all the mouse interaction in this line number ruler column.
- */
- class MouseHandler implements MouseListener, MouseMoveListener, MouseTrackListener {
-
- /** The cached view port size */
- private int fCachedViewportSize;
- /** The area of the line at which line selection started */
- private IRegion fStartLine;
- /** The number of the line at which line selection started */
- private int fStartLineNumber;
- /** The auto scroll direction */
- private int fAutoScrollDirection;
-
- /*
- * @see org.eclipse.swt.events.MouseListener#mouseUp(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseUp(MouseEvent event) {
- // see bug 45700
- if (event.button == 1) {
- stopSelecting();
- stopAutoScroll();
- }
- }
-
- /*
- * @see org.eclipse.swt.events.MouseListener#mouseDown(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseDown(MouseEvent event) {
- fParentRuler.setLocationOfLastMouseButtonActivity(event.x, event.y);
- // see bug 45700
- if (event.button == 1) {
- startSelecting();
- }
- }
-
- /*
- * @see org.eclipse.swt.events.MouseListener#mouseDoubleClick(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseDoubleClick(MouseEvent event) {
- fParentRuler.setLocationOfLastMouseButtonActivity(event.x, event.y);
- stopSelecting();
- stopAutoScroll();
- }
-
- /*
- * @see org.eclipse.swt.events.MouseMoveListener#mouseMove(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseMove(MouseEvent event) {
- if (!autoScroll(event)) {
- int newLine= fParentRuler.toDocumentLineNumber(event.y);
- expandSelection(newLine);
- }
- }
-
- /*
- * @see org.eclipse.swt.events.MouseTrackListener#mouseEnter(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseEnter(MouseEvent event) {
- }
-
- /*
- * @see org.eclipse.swt.events.MouseTrackListener#mouseExit(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseExit(MouseEvent event) {
- }
-
- /*
- * @see org.eclipse.swt.events.MouseTrackListener#mouseHover(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseHover(MouseEvent event) {
- }
-
- /**
- * Called when line drag selection started. Adds mouse move and track
- * listeners to this column's control.
- */
- private void startSelecting() {
- try {
-
- // select line
- IDocument document= fCachedTextViewer.getDocument();
- fStartLineNumber= fParentRuler.getLineOfLastMouseButtonActivity();
- fStartLine= document.getLineInformation(fStartLineNumber);
- fCachedTextViewer.setSelectedRange(fStartLine.getOffset(), fStartLine.getLength());
- fCachedViewportSize= getVisibleLinesInViewport();
-
- // prepare for drag selection
- fCanvas.addMouseMoveListener(this);
- fCanvas.addMouseTrackListener(this);
-
- } catch (BadLocationException x) {
- }
- }
-
- /**
- * Called when line drag selection stopped. Removes all previously
- * installed listeners from this column's control.
- */
- private void stopSelecting() {
- // drag selection stopped
- fCanvas.removeMouseMoveListener(this);
- fCanvas.removeMouseTrackListener(this);
- }
-
- /**
- * Expands the line selection from the remembered start line to the
- * given line.
- *
- * @param lineNumber the line to which to expand the selection
- */
- private void expandSelection(int lineNumber) {
- try {
-
- IDocument document= fCachedTextViewer.getDocument();
- IRegion lineInfo= document.getLineInformation(lineNumber);
-
- int start= Math.min(fStartLine.getOffset(), lineInfo.getOffset());
- int end= Math.max(fStartLine.getOffset() + fStartLine.getLength(), lineInfo.getOffset() + lineInfo.getLength());
-
- if (lineNumber < fStartLineNumber)
- fCachedTextViewer.setSelectedRange(end, start - end);
- else
- fCachedTextViewer.setSelectedRange(start, end - start);
-
- } catch (BadLocationException x) {
- }
- }
-
- /**
- * Called when auto scrolling stopped. Clears the auto scroll direction.
- */
- private void stopAutoScroll() {
- fAutoScrollDirection= SWT.NULL;
- }
-
- /**
- * Called on drag selection.
- *
- * @param event the mouse event caught by the mouse move listener
- * @return <code>true</code> if scrolling happend, <code>false</code> otherwise
- */
- private boolean autoScroll(MouseEvent event) {
- Rectangle area= fCanvas.getClientArea();
-
- if (event.y > area.height) {
- autoScroll(SWT.DOWN);
- return true;
- }
-
- if (event.y < 0) {
- autoScroll(SWT.UP);
- return true;
- }
-
- stopAutoScroll();
- return false;
- }
-
- /**
- * Scrolls the viewer into the given direction.
- *
- * @param direction the scroll direction
- */
- private void autoScroll(int direction) {
-
- if (fAutoScrollDirection == direction)
- return;
-
- final int TIMER_INTERVAL= 5;
- final Display display = fCanvas.getDisplay();
- Runnable timer= null;
- switch (direction) {
- case SWT.UP:
- timer= new Runnable() {
- public void run() {
- if (fAutoScrollDirection == SWT.UP) {
- int top= getInclusiveTopIndex();
- if (top > 0) {
- fCachedTextViewer.setTopIndex(top -1);
- expandSelection(top -1);
- display.timerExec(TIMER_INTERVAL, this);
- }
- }
- }
- };
- break;
- case SWT.DOWN:
- timer = new Runnable() {
- public void run() {
- if (fAutoScrollDirection == SWT.DOWN) {
- int top= getInclusiveTopIndex();
- fCachedTextViewer.setTopIndex(top +1);
- expandSelection(top +1 + fCachedViewportSize);
- display.timerExec(TIMER_INTERVAL, this);
- }
- }
- };
- break;
- }
-
- if (timer != null) {
- fAutoScrollDirection= direction;
- display.timerExec(TIMER_INTERVAL, timer);
- }
- }
-
- /**
- * Returns the viewer's first visible line, even if only partially visible.
- *
- * @return the viewer's first visible line
- */
- private int getInclusiveTopIndex() {
- if (fCachedTextWidget != null && !fCachedTextWidget.isDisposed()) {
- int top= fCachedTextViewer.getTopIndex();
- if ((fCachedTextWidget.getTopPixel() % fCachedTextWidget.getLineHeight()) != 0)
- -- top;
- return top;
- }
- return -1;
- }
- }
-
- /** This column's parent ruler */
- private CompositeRuler fParentRuler;
- /** Cached text viewer */
- private ITextViewer fCachedTextViewer;
- /** Cached text widget */
- private StyledText fCachedTextWidget;
- /** The columns canvas */
- private Canvas fCanvas;
- /** Cache for the actual scroll position in pixels */
- private int fScrollPos;
- /** The drawable for double buffering */
- private Image fBuffer;
- /** The internal listener */
- private InternalListener fInternalListener= new InternalListener();
- /** The font of this column */
- private Font fFont;
- /** The indentation cache */
- private int[] fIndentation;
- /** Indicates whether this column reacts on text change events */
- private boolean fSensitiveToTextChanges= false;
- /** The foreground color */
- private Color fForeground;
- /** The background color */
- private Color fBackground;
- /** Cached number of displayed digits */
- private int fCachedNumberOfDigits= -1;
- /** Flag indicating whether a relayout is required */
- private boolean fRelayoutRequired= false;
-
-
- /**
- * Constructs a new vertical ruler column.
- */
- public LineNumberRulerColumn() {
- }
-
- /**
- * Sets the foreground color of this column.
- *
- * @param foreground the foreground color
- */
- public void setForeground(Color foreground) {
- fForeground= foreground;
- }
-
- /**
- * Returns the foreground color being used to print the line numbers.
- *
- * @return the configured foreground color
- * @since 3.0
- */
- protected Color getForeground() {
- return fForeground;
- }
-
- /**
- * Sets the background color of this column.
- *
- * @param background the background color
- */
- public void setBackground(Color background) {
- fBackground= background;
- if (fCanvas != null && !fCanvas.isDisposed())
- fCanvas.setBackground(getBackground(fCanvas.getDisplay()));
- }
-
- /**
- * Returns the System background color for list widgets.
- *
- * @param display the display
- * @return the System background color for list widgets
- */
- protected Color getBackground(Display display) {
- if (fBackground == null)
- return display.getSystemColor(SWT.COLOR_LIST_BACKGROUND);
- return fBackground;
- }
-
- /*
- * @see IVerticalRulerColumn#getControl()
- */
- public Control getControl() {
- return fCanvas;
- }
-
- /*
- * @see IVerticalRuleColumnr#getWidth
- */
- public int getWidth() {
- return fIndentation[0];
- }
-
- /**
- * Computes the number of digits to be displayed. Returns
- * <code>true</code> if the number of digits changed compared
- * to the previous call of this method. If the method is called
- * for the first time, the return value is also <code>true</code>.
- *
- * @return whether the number of digits has been changed
- */
- protected boolean updateNumberOfDigits() {
- if (fCachedTextViewer == null)
- return false;
-
- int digits= computeNumberOfDigits();
-
- if (fCachedNumberOfDigits != digits) {
- fCachedNumberOfDigits= digits;
- return true;
- }
-
- return false;
- }
-
- /**
- * Does the real computation of the number of digits. Subclasses may override this method if
- * they need extra space on the line number ruler.
- *
- * @return the number of digits to be displayed on the line number ruler.
- */
- protected int computeNumberOfDigits() {
- IDocument document= fCachedTextViewer.getDocument();
- int lines= document == null ? 0 : document.getNumberOfLines();
-
- int digits= 2;
- while (lines > Math.pow(10, digits) -1) {
- ++digits;
- }
- return digits;
- }
-
- /**
- * Layouts the enclosing viewer to adapt the layout to changes of the
- * size of the individual components.
- *
- * @param redraw <code>true</code> if this column can be redrawn
- */
- protected void layout(boolean redraw) {
- if (!redraw) {
- fRelayoutRequired= true;
- return;
- }
-
- fRelayoutRequired= false;
- if (fCachedTextViewer instanceof ITextViewerExtension) {
- ITextViewerExtension extension= (ITextViewerExtension) fCachedTextViewer;
- Control control= extension.getControl();
- if (control instanceof Composite && !control.isDisposed()) {
- Composite composite= (Composite) control;
- composite.layout(true);
- }
- }
- }
-
- /**
- * Computes the indentations for the given font and stores them in
- * <code>fIndentation</code>.
- */
- protected void computeIndentations() {
- if (fCanvas == null)
- return;
-
- GC gc= new GC(fCanvas);
- try {
-
- gc.setFont(fCanvas.getFont());
-
- fIndentation= new int[fCachedNumberOfDigits + 1];
-
- Float number= new Float(Math.pow(10, fCachedNumberOfDigits) - 1);
- Point p= gc.stringExtent(Integer.toString(number.intValue()));
- fIndentation[0]= p.x;
-
- for (int i= 1; i <= fCachedNumberOfDigits; i++) {
- number= new Float(Math.pow(10, i) - 1);
- p= gc.stringExtent(Integer.toString(number.intValue()));
- fIndentation[i]= fIndentation[0] - p.x;
- }
-
- } finally {
- gc.dispose();
- }
- }
-
- /*
- * @see IVerticalRulerColumn#createControl(CompositeRuler, Composite)
- */
- public Control createControl(CompositeRuler parentRuler, Composite parentControl) {
-
- fParentRuler= parentRuler;
- fCachedTextViewer= parentRuler.getTextViewer();
- fCachedTextWidget= fCachedTextViewer.getTextWidget();
-
- fCanvas= new Canvas(parentControl, SWT.NONE);
- fCanvas.setBackground(getBackground(fCanvas.getDisplay()));
- fCanvas.setForeground(fForeground);
-
- fCanvas.addPaintListener(new PaintListener() {
- public void paintControl(PaintEvent event) {
- if (fCachedTextViewer != null)
- doubleBufferPaint(event.gc);
- }
- });
-
- fCanvas.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- handleDispose();
- fCachedTextViewer= null;
- fCachedTextWidget= null;
- }
- });
-
- fCanvas.addMouseListener(new MouseHandler());
-
- if (fCachedTextViewer != null) {
-
- fCachedTextViewer.addViewportListener(fInternalListener);
- fCachedTextViewer.addTextListener(fInternalListener);
-
- if (fFont == null) {
- if (fCachedTextWidget != null && !fCachedTextWidget.isDisposed())
- fFont= fCachedTextWidget.getFont();
- }
- }
-
- if (fFont != null)
- fCanvas.setFont(fFont);
-
- updateNumberOfDigits();
- computeIndentations();
- return fCanvas;
- }
-
- /**
- * Disposes the column's resources.
- */
- protected void handleDispose() {
-
- if (fCachedTextViewer != null) {
- fCachedTextViewer.removeViewportListener(fInternalListener);
- fCachedTextViewer.removeTextListener(fInternalListener);
- }
-
- if (fBuffer != null) {
- fBuffer.dispose();
- fBuffer= null;
- }
- }
-
- /**
- * Double buffer drawing.
- *
- * @param dest the gc to draw into
- */
- private void doubleBufferPaint(GC dest) {
-
- Point size= fCanvas.getSize();
-
- if (size.x <= 0 || size.y <= 0)
- return;
-
- if (fBuffer != null) {
- Rectangle r= fBuffer.getBounds();
- if (r.width != size.x || r.height != size.y) {
- fBuffer.dispose();
- fBuffer= null;
- }
- }
- if (fBuffer == null)
- fBuffer= new Image(fCanvas.getDisplay(), size.x, size.y);
-
- GC gc= new GC(fBuffer);
- gc.setFont(fCanvas.getFont());
- if (fForeground != null)
- gc.setForeground(fForeground);
-
- try {
- gc.setBackground(getBackground(fCanvas.getDisplay()));
- gc.fillRectangle(0, 0, size.x, size.y);
-
- if (fCachedTextViewer instanceof ITextViewerExtension5)
- doPaint1(gc);
- else
- doPaint(gc);
-
- } finally {
- gc.dispose();
- }
-
- dest.drawImage(fBuffer, 0, 0);
- }
-
- /**
- * Returns the viewport height in lines.
- *
- * @return the viewport height in lines
- */
- protected int getVisibleLinesInViewport() {
- Rectangle clArea= fCachedTextWidget.getClientArea();
- if (!clArea.isEmpty())
- return clArea.height / fCachedTextWidget.getLineHeight();
- return -1;
- }
-
- /**
- * Draws the ruler column.
- *
- * @param gc the gc to draw into
- */
- private void doPaint(GC gc) {
-
- if (fCachedTextViewer == null)
- return;
-
- if (fCachedTextWidget == null)
- return;
-
-
- int firstLine= 0;
-
- int topLine= fCachedTextViewer.getTopIndex() -1;
- int bottomLine= fCachedTextViewer.getBottomIndex() + 1;
-
- try {
-
- IRegion region= fCachedTextViewer.getVisibleRegion();
- IDocument doc= fCachedTextViewer.getDocument();
-
- if (doc == null)
- return;
-
- firstLine= doc.getLineOfOffset(region.getOffset());
- if (firstLine > topLine)
- topLine= firstLine;
-
- int lastLine= doc.getLineOfOffset(region.getOffset() + region.getLength());
- if (lastLine < bottomLine)
- bottomLine= lastLine;
-
- } catch (BadLocationException x) {
- return;
- }
-
- fSensitiveToTextChanges= bottomLine - topLine < getVisibleLinesInViewport();
-
- int lineheight= fCachedTextWidget.getLineHeight();
- fScrollPos= fCachedTextWidget.getTopPixel();
- int canvasheight= fCanvas.getSize().y;
-
- int y= ((topLine - firstLine) * lineheight) - fScrollPos + fCachedTextViewer.getTopInset();
- for (int line= topLine; line <= bottomLine; line++, y+= lineheight) {
-
- if (y >= canvasheight)
- break;
-
- paintLine(line, y, lineheight, gc, fCachedTextWidget.getDisplay());
-
- String s= createDisplayString(line);
- int indentation= fIndentation[s.length()];
- gc.drawString(s, indentation, y, true);
- }
- }
-
- /**
- * Computes the string to be printed for <code>line</code>. The default implementation returns
- * <code>Integer.toString(line + 1)</code>.
- *
- * @param line the line number for which the line number string is generated
- * @return the string to be printed on the line number bar for <code>line</code>
- */
- protected String createDisplayString(int line) {
- return Integer.toString(line + 1);
- }
-
- /**
- * Draws the ruler column. Uses <code>ITextViewerExtension5</code> for the
- * implementation. Will replace <code>doPinat(GC)</code>.
- *
- * @param gc the gc to draw into
- */
- private void doPaint1(GC gc) {
-
- if (fCachedTextViewer == null)
- return;
-
- ITextViewerExtension5 extension= (ITextViewerExtension5) fCachedTextViewer;
-
- int firstLine= 0;
-
-
- int widgetTopLine= fCachedTextWidget.getTopIndex();
- if (widgetTopLine > 0)
- -- widgetTopLine;
-
- int topLine= extension.widgetlLine2ModelLine(widgetTopLine);
- int bottomLine= fCachedTextViewer.getBottomIndex();
- if (bottomLine >= 0)
- ++ bottomLine;
-
- try {
-
- IRegion region= extension.getModelCoverage();
- IDocument doc= fCachedTextViewer.getDocument();
-
- if (doc == null)
- return;
-
- firstLine= doc.getLineOfOffset(region.getOffset());
- if (firstLine > topLine || topLine == -1)
- topLine= firstLine;
-
- int lastLine= doc.getLineOfOffset(region.getOffset() + region.getLength());
- if (lastLine < bottomLine || bottomLine == -1)
- bottomLine= lastLine;
-
- } catch (BadLocationException x) {
- return;
- }
-
- fSensitiveToTextChanges= bottomLine - topLine < getVisibleLinesInViewport();
-
- int lineheight= fCachedTextWidget.getLineHeight();
- fScrollPos= fCachedTextWidget.getTopPixel();
- int canvasheight= fCanvas.getSize().y;
-
- int y= (widgetTopLine * lineheight) - fScrollPos + fCachedTextViewer.getTopInset();
- for (int modelLine= topLine; modelLine <= bottomLine; modelLine++) {
-
- if (y >= canvasheight)
- break;
-
- int widgetLine= extension.modelLine2WidgetLine(modelLine);
- if (widgetLine == -1)
- continue;
-
- paintLine(modelLine, y, lineheight, gc, fCachedTextWidget.getDisplay());
-
- String s= createDisplayString(modelLine);
- int indentation= fIndentation[s.length()];
- gc.drawString(s, indentation, y, true);
- y+= lineheight;
- }
- }
-
- /**
- * Paints the line. After this method is called the line numbers are painted on top
- * of the result of this method.
- * <p>This default implementation does nothing.</p>
- *
- * @param line the line of the document which the ruler is painted for
- * @param y the y-coordinate of the box being painted for <code>line</code>, relative to <code>gc</code>
- * @param lineheight the height of one line (and therefore of the box being painted)
- * @param gc the drawing context the client may choose to draw on.
- * @param display the display the drawing occurs on
- * @since 3.0
- */
- protected void paintLine(int line, int y, int lineheight, GC gc, Display display) {
- }
-
- /**
- * Triggers a redraw in the display thread.
- *
- * @since 3.0
- */
- protected final void postRedraw() {
- if (fCanvas != null && !fCanvas.isDisposed()) {
- Display d= fCanvas.getDisplay();
- if (d != null) {
- d.asyncExec(new Runnable() {
- public void run() {
- redraw();
- }
- });
- }
- }
- }
-
- /*
- * @see IVerticalRulerColumn#redraw()
- */
- public void redraw() {
-
- if (fRelayoutRequired) {
- layout(true);
- return;
- }
-
- if (fCanvas != null && !fCanvas.isDisposed()) {
- GC gc= new GC(fCanvas);
- doubleBufferPaint(gc);
- gc.dispose();
- }
- }
-
- /*
- * @see IVerticalRulerColumn#setModel(IAnnotationModel)
- */
- public void setModel(IAnnotationModel model) {
- }
-
- /*
- * @see IVerticalRulerColumn#setFont(Font)
- */
- public void setFont(Font font) {
- fFont= font;
- if (fCanvas != null && !fCanvas.isDisposed()) {
- fCanvas.setFont(fFont);
- updateNumberOfDigits();
- computeIndentations();
- }
- }
-
- /**
- * Returns the parent (composite) ruler of this ruler column.
- *
- * @return the parent ruler
- * @since 3.0
- */
- protected CompositeRuler getParentRuler() {
- return fParentRuler;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/MatchingCharacterPainter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/MatchingCharacterPainter.java
deleted file mode 100644
index 70becf3..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/MatchingCharacterPainter.java
+++ /dev/null
@@ -1,240 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.source;
-
-
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Point;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IPaintPositionManager;
-import org.eclipse.jface.text.IPainter;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextViewerExtension5;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.Region;
-
-/**
- * Highlights the peer character matching the character near the caret position. This
- * painter can be configured with an <code>ICharacterPairMatcher</code>.
- * Clients instantiate and configure object of this class.
- *
- * @since 2.1
- */
-public final class MatchingCharacterPainter implements IPainter, PaintListener {
-
- /** Indicates whether this painter is active */
- private boolean fIsActive= false;
- /** The source viewer this painter is associated with */
- private ISourceViewer fSourceViewer;
- /** The viewer's widget */
- private StyledText fTextWidget;
- /** The color in which to highlight the peer character */
- private Color fColor;
- /** The paint position manager */
- private IPaintPositionManager fPaintPositionManager;
- /** The startegy for finding matching characters */
- private ICharacterPairMatcher fMatcher;
- /** The position tracking the matching characters */
- private Position fPairPosition= new Position(0, 0);
- /** The anchor indicating whether the character is left or right of the caret */
- private int fAnchor;
-
-
- /**
- * Creates a new MatchingCharacterPainter for the given source viewer using
- * the given character pair matcher. The character matcher is not adopted by
- * this painter. Thus, it is not disposed. However, this painter requires
- * exlucsive access to the given pair matcher.
- *
- * @param sourceViewer
- * @param matcher
- */
- public MatchingCharacterPainter(ISourceViewer sourceViewer, ICharacterPairMatcher matcher) {
- fSourceViewer= sourceViewer;
- fMatcher= matcher;
- fTextWidget= sourceViewer.getTextWidget();
- }
-
- /**
- * Sets the color in which to highlight the match character.
- *
- * @param color the color
- */
- public void setColor(Color color) {
- fColor= color;
- }
-
- /*
- * @see org.eclipse.jface.text.IPainter#dispose()
- */
- public void dispose() {
- if (fMatcher != null) {
- fMatcher.clear();
- fMatcher= null;
- }
-
- fColor= null;
- fTextWidget= null;
- }
-
- /*
- * @see org.eclipse.jface.text.IPainter#deactivate(boolean)
- */
- public void deactivate(boolean redraw) {
- if (fIsActive) {
- fIsActive= false;
- fTextWidget.removePaintListener(this);
- if (fPaintPositionManager != null)
- fPaintPositionManager.unmanagePosition(fPairPosition);
- if (redraw)
- handleDrawRequest(null);
- }
- }
-
- /*
- * @see org.eclipse.swt.events.PaintListener#paintControl(org.eclipse.swt.events.PaintEvent)
- */
- public void paintControl(PaintEvent event) {
- if (fTextWidget != null)
- handleDrawRequest(event.gc);
- }
-
- /**
- * Handles a redraw request.
- *
- * @param gc the gc to draw into.
- */
- private void handleDrawRequest(GC gc) {
-
- if (fPairPosition.isDeleted)
- return;
-
- int offset= fPairPosition.getOffset();
- int length= fPairPosition.getLength();
- if (length < 1)
- return;
-
- if (fSourceViewer instanceof ITextViewerExtension5) {
- ITextViewerExtension5 extension= (ITextViewerExtension5) fSourceViewer;
- IRegion widgetRange= extension.modelRange2WidgetRange(new Region(offset, length));
- if (widgetRange == null)
- return;
-
- offset= widgetRange.getOffset();
- length= widgetRange.getLength();
-
- } else {
- IRegion region= fSourceViewer.getVisibleRegion();
- if (region.getOffset() > offset || region.getOffset() + region.getLength() < offset + length)
- return;
- offset -= region.getOffset();
- }
-
- if (ICharacterPairMatcher.RIGHT == fAnchor)
- draw(gc, offset, 1);
- else
- draw(gc, offset + length -1, 1);
- }
-
- /**
- * Highlights the given widget region.
- *
- * @param gc the gc to draw into
- * @param offset the offset of the widget region
- * @param length the length of the widget region
- */
- private void draw(GC gc, int offset, int length) {
- if (gc != null) {
- Point left= fTextWidget.getLocationAtOffset(offset);
- Point right= fTextWidget.getLocationAtOffset(offset + length);
-
- gc.setForeground(fColor);
- gc.drawRectangle(left.x, left.y, right.x - left.x - 1, gc.getFontMetrics().getHeight() - 1);
-
- } else {
- fTextWidget.redrawRange(offset, length, true);
- }
- }
-
- /*
- * @see org.eclipse.jface.text.IPainter#paint(int)
- */
- public void paint(int reason) {
-
- IDocument document= fSourceViewer.getDocument();
- if (document == null) {
- deactivate(false);
- return;
- }
-
- Point selection= fSourceViewer.getSelectedRange();
- if (selection.y > 0) {
- deactivate(true);
- return;
- }
-
- IRegion pair= fMatcher.match(document, selection.x);
- if (pair == null) {
- deactivate(true);
- return;
- }
-
- if (fIsActive) {
-
- if (IPainter.CONFIGURATION == reason) {
-
- // redraw current highlighting
- handleDrawRequest(null);
-
- } else if (pair.getOffset() != fPairPosition.getOffset() ||
- pair.getLength() != fPairPosition.getLength() ||
- fMatcher.getAnchor() != fAnchor) {
-
- // otherwise only do something if position is different
-
- // remove old highlighting
- handleDrawRequest(null);
- // update position
- fPairPosition.isDeleted= false;
- fPairPosition.offset= pair.getOffset();
- fPairPosition.length= pair.getLength();
- fAnchor= fMatcher.getAnchor();
- // apply new highlighting
- handleDrawRequest(null);
-
- }
- } else {
-
- fIsActive= true;
-
- fPairPosition.isDeleted= false;
- fPairPosition.offset= pair.getOffset();
- fPairPosition.length= pair.getLength();
- fAnchor= fMatcher.getAnchor();
-
- fTextWidget.addPaintListener(this);
- fPaintPositionManager.managePosition(fPairPosition);
- handleDrawRequest(null);
- }
- }
-
- /*
- * @see org.eclipse.jface.text.IPainter#setPositionManager(org.eclipse.jface.text.IPaintPositionManager)
- */
- public void setPositionManager(IPaintPositionManager manager) {
- fPaintPositionManager= manager;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRuler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRuler.java
deleted file mode 100644
index 487c1d9..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRuler.java
+++ /dev/null
@@ -1,1191 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.source;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.custom.ViewForm;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseMoveListener;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Cursor;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextListener;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.ITextViewerExtension5;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextEvent;
-
-
-
-/**
- * Ruler presented next to a source viewer showing all annotations of the
- * viewer's annotation model in a compact format. The ruler has the same height
- * as the source viewer.<p>
- * Clients usually instantiate and configure objects of this class.
- *
- * @since 2.1
- */
-public class OverviewRuler implements IOverviewRuler {
-
- /**
- * Internal listener class.
- */
- class InternalListener implements ITextListener, IAnnotationModelListener {
-
- /*
- * @see ITextListener#textChanged
- */
- public void textChanged(TextEvent e) {
- if (fTextViewer != null && e.getDocumentEvent() == null && e.getViewerRedrawState()) {
- // handle only changes of visible document
- redraw();
- }
- }
-
- /*
- * @see IAnnotationModelListener#modelChanged(IAnnotationModel)
- */
- public void modelChanged(IAnnotationModel model) {
- update();
- }
- }
-
- /**
- * Enumerates the annotations of a specified type and characteristics
- * of the associated annotation model.
- */
- class FilterIterator implements Iterator {
-
- private final static int IGNORE= 0;
- private final static int TEMPORARY= 1;
- private final static int PERSISTENT= 2;
-
- private Iterator fIterator;
- private Object fType;
- private Annotation fNext;
- private int fTemporary;
-
- public FilterIterator() {
- this(null, IGNORE);
- }
-
- public FilterIterator(Object annotationType) {
- this(annotationType, IGNORE);
- }
-
- public FilterIterator(Object annotationType, boolean temporary) {
- this(annotationType, temporary ? TEMPORARY : PERSISTENT);
- }
-
- private FilterIterator(Object annotationType, int temporary) {
- fType= annotationType;
- fTemporary= temporary;
- if (fModel != null) {
- fIterator= fModel.getAnnotationIterator();
- skip();
- }
- }
-
- private void skip() {
- while (fIterator.hasNext()) {
- Annotation next= (Annotation) fIterator.next();
- if (next.isMarkedDeleted())
- continue;
-
- fNext= next;
- Object annotationType= fAnnotationAccess.getType(next);
- if (fType == null || isSubtype(annotationType)) {
- if (fTemporary == IGNORE) return;
- boolean temporary= fAnnotationAccess.isTemporary(fNext);
- if (fTemporary == TEMPORARY && temporary) return;
- if (fTemporary == PERSISTENT && !temporary) return;
- }
- }
- fNext= null;
- }
-
- private boolean isSubtype(Object annotationType) {
- if (fAnnotationAccess instanceof IAnnotationAccessExtension) {
- IAnnotationAccessExtension extension= (IAnnotationAccessExtension) fAnnotationAccess;
- return extension.isSubtype(annotationType, fType);
- }
- return fType.equals(annotationType);
- }
-
- /*
- * @see Iterator#hasNext()
- */
- public boolean hasNext() {
- return fNext != null;
- }
- /*
- * @see Iterator#next()
- */
- public Object next() {
- try {
- return fNext;
- } finally {
- if (fModel != null)
- skip();
- }
- }
- /*
- * @see Iterator#remove()
- */
- public void remove() {
- throw new UnsupportedOperationException();
- }
- }
-
- /**
- * The painter of the overview ruler's header.
- */
- class HeaderPainter implements PaintListener {
-
- private Color fIndicatorColor;
- private Color fSeparatorColor;
-
- public HeaderPainter() {
- fSeparatorColor= fSharedTextColors.getColor(ViewForm.borderInsideRGB);
- }
-
- public void setColor(Color color) {
- fIndicatorColor= color;
- }
-
- private void drawBevelRect(GC gc, int x, int y, int w, int h, Color topLeft, Color bottomRight) {
- gc.setForeground(topLeft == null ? fSeparatorColor : topLeft);
- gc.drawLine(x, y, x + w -1, y);
- gc.drawLine(x, y, x, y + h -1);
-
- gc.setForeground(bottomRight == null ? fSeparatorColor : bottomRight);
- gc.drawLine(x + w, y, x + w, y + h);
- gc.drawLine(x, y + h, x + w, y + h);
- }
-
- public void paintControl(PaintEvent e) {
-
- Point s= fHeader.getSize();
-
- if (fIndicatorColor != null) {
- e.gc.setBackground(fIndicatorColor);
- Rectangle r= new Rectangle(INSET, (s.y - (2*ANNOTATION_HEIGHT)) / 2, s.x - (2*INSET), 2*ANNOTATION_HEIGHT);
- e.gc.fillRectangle(r);
- Display d= fHeader.getDisplay();
- if (d != null)
-// drawBevelRect(e.gc, r.x, r.y, r.width -1, r.height -1, d.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW), d.getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW));
- drawBevelRect(e.gc, r.x, r.y, r.width -1, r.height -1, null, null);
- }
-
- e.gc.setForeground(fSeparatorColor);
- e.gc.setLineWidth(1);
- e.gc.drawLine(0, s.y -1, s.x -1, s.y -1);
- }
- }
-
- private static final int INSET= 2;
- private static final int ANNOTATION_HEIGHT= 4;
- private static boolean ANNOTATION_HEIGHT_SCALABLE= true;
-
-
- /** The model of the overview ruler */
- private IAnnotationModel fModel;
- /** The view to which this ruler is connected */
- private ITextViewer fTextViewer;
- /** The ruler's canvas */
- private Canvas fCanvas;
- /** The ruler's header */
- private Canvas fHeader;
- /** The drawable for double buffering */
- private Image fBuffer;
- /** The internal listener */
- private InternalListener fInternalListener= new InternalListener();
- /** The width of this vertical ruler */
- private int fWidth;
- /** The hit detection cursor */
- private Cursor fHitDetectionCursor;
- /** The last cursor */
- private Cursor fLastCursor;
- /** The line of the last mouse button activity */
- private int fLastMouseButtonActivityLine= -1;
- /** The actual annotation height */
- private int fAnnotationHeight= -1;
- /** The annotation access */
- private IAnnotationAccess fAnnotationAccess;
- /** The header painter */
- private HeaderPainter fHeaderPainter;
- /** The list of annotation types to be shown in this ruler */
- private Set fConfiguredAnnotationTypes= new HashSet();
- /** The list of annotation types to be shown in the header of this ruler */
- private Set fConfiguredHeaderAnnotationTypes= new HashSet();
- /** The mapping between annotation types and colors */
- private Map fAnnotationTypes2Colors= new HashMap();
- /** The color manager */
- private ISharedTextColors fSharedTextColors;
- /**
- * All available annotation types sorted by layer.
- *
- * @since 3.0
- */
- private List fAnnotationsSortedByLayer= new ArrayList();
- /**
- * All available layers sorted by layer.
- * This list may contain duplicates.
- *
- * @since 3.0
- */
- private List fLayersSortedByLayer= new ArrayList();
- /**
- * Set of allowed annotation types.
- * @since 3.0
- */
- private Set fAllowedAnnotationTypes= new HashSet();
- /**
- * Set of allowed header annotation types.
- * @since 3.0
- */
- private Set fAllowedHeaderAnnotationTypes= new HashSet();
-
-
- /**
- * Constructs a overview ruler of the given width using the given annotation access and the given
- * color manager.
- *
- * @param annotationAccess the annotation access
- * @param width the width of the vertical ruler
- * @param sharedColors the color manager
- */
- public OverviewRuler(IAnnotationAccess annotationAccess, int width, ISharedTextColors sharedColors) {
- fAnnotationAccess= annotationAccess;
- fWidth= width;
- fSharedTextColors= sharedColors;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerInfo#getControl()
- */
- public Control getControl() {
- return fCanvas;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerInfo#getWidth()
- */
- public int getWidth() {
- return fWidth;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRuler#setModel(org.eclipse.jface.text.source.IAnnotationModel)
- */
- public void setModel(IAnnotationModel model) {
- if (model != fModel || model != null) {
-
- if (fModel != null)
- fModel.removeAnnotationModelListener(fInternalListener);
-
- fModel= model;
-
- if (fModel != null)
- fModel.addAnnotationModelListener(fInternalListener);
-
- update();
- }
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRuler#createControl(org.eclipse.swt.widgets.Composite, org.eclipse.jface.text.ITextViewer)
- */
- public Control createControl(Composite parent, ITextViewer textViewer) {
-
- fTextViewer= textViewer;
-
- fHitDetectionCursor= new Cursor(parent.getDisplay(), SWT.CURSOR_HAND);
-
- fHeader= new Canvas(parent, SWT.NONE);
-
- fCanvas= new Canvas(parent, SWT.NO_BACKGROUND);
-
- fCanvas.addPaintListener(new PaintListener() {
- public void paintControl(PaintEvent event) {
- if (fTextViewer != null)
- doubleBufferPaint(event.gc);
- }
- });
-
- fCanvas.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent event) {
- handleDispose();
- fTextViewer= null;
- }
- });
-
- fCanvas.addMouseListener(new MouseAdapter() {
- public void mouseDown(MouseEvent event) {
- handleMouseDown(event);
- }
- });
-
- fCanvas.addMouseMoveListener(new MouseMoveListener() {
- public void mouseMove(MouseEvent event) {
- handleMouseMove(event);
- }
- });
-
- if (fTextViewer != null)
- fTextViewer.addTextListener(fInternalListener);
-
- return fCanvas;
- }
-
- /**
- * Disposes the ruler's resources.
- */
- private void handleDispose() {
-
- if (fTextViewer != null) {
- fTextViewer.removeTextListener(fInternalListener);
- fTextViewer= null;
- }
-
- if (fModel != null)
- fModel.removeAnnotationModelListener(fInternalListener);
-
- if (fBuffer != null) {
- fBuffer.dispose();
- fBuffer= null;
- }
-
- if (fHitDetectionCursor != null) {
- fHitDetectionCursor.dispose();
- fHitDetectionCursor= null;
- }
-
- fConfiguredAnnotationTypes.clear();
- fAllowedAnnotationTypes.clear();
- fConfiguredHeaderAnnotationTypes.clear();
- fAllowedHeaderAnnotationTypes.clear();
- fAnnotationTypes2Colors.clear();
- fAnnotationsSortedByLayer.clear();
- fLayersSortedByLayer.clear();
- }
-
- /**
- * Double buffer drawing.
- *
- * @param dest the gc to draw into
- */
- private void doubleBufferPaint(GC dest) {
-
- Point size= fCanvas.getSize();
-
- if (size.x <= 0 || size.y <= 0)
- return;
-
- if (fBuffer != null) {
- Rectangle r= fBuffer.getBounds();
- if (r.width != size.x || r.height != size.y) {
- fBuffer.dispose();
- fBuffer= null;
- }
- }
- if (fBuffer == null)
- fBuffer= new Image(fCanvas.getDisplay(), size.x, size.y);
-
- GC gc= new GC(fBuffer);
- try {
- gc.setBackground(fCanvas.getBackground());
- gc.fillRectangle(0, 0, size.x, size.y);
-
- if (fTextViewer instanceof ITextViewerExtension5)
- doPaint1(gc);
- else
- doPaint(gc);
-
- } finally {
- gc.dispose();
- }
-
- dest.drawImage(fBuffer, 0, 0);
- }
-
- /**
- * Draws this overview ruler.
- *
- * @param gc the gc to draw into
- */
- private void doPaint(GC gc) {
-
- if (fTextViewer == null)
- return;
-
- Rectangle r= new Rectangle(0, 0, 0, 0);
- int yy, hh= ANNOTATION_HEIGHT;
-
-
- IDocument document= fTextViewer.getDocument();
- IRegion visible= fTextViewer.getVisibleRegion();
-
- StyledText textWidget= fTextViewer.getTextWidget();
- int maxLines= textWidget.getLineCount();
-
- Point size= fCanvas.getSize();
- int writable= maxLines * textWidget.getLineHeight();
- if (size.y > writable)
- size.y= Math.max(writable - fHeader.getSize().y, 0);
-
- for (Iterator iterator= fAnnotationsSortedByLayer.iterator(); iterator.hasNext();) {
- Object annotationType= iterator.next();
-
- if (skip(annotationType))
- continue;
-
- boolean[] temporary= new boolean[] { false, true };
- for (int t=0; t < temporary.length; t++) {
-
- Iterator e= new FilterIterator(annotationType, temporary[t]);
- Color fill= getFillColor(annotationType, temporary[t]);
- Color stroke= getStrokeColor(annotationType, temporary[t]);
-
- for (int i= 0; e.hasNext(); i++) {
-
- Annotation a= (Annotation) e.next();
- Position p= fModel.getPosition(a);
-
- if (p == null || !p.overlapsWith(visible.getOffset(), visible.getLength()))
- continue;
-
- int annotationOffset= Math.max(p.getOffset(), visible.getOffset());
- int annotationEnd= Math.min(p.getOffset() + p.getLength(), visible.getOffset() + visible.getLength());
- int annotationLength= annotationEnd - annotationOffset;
-
- try {
- if (ANNOTATION_HEIGHT_SCALABLE) {
- int numbersOfLines= document.getNumberOfLines(annotationOffset, annotationLength);
- // don't count empty trailing lines
- IRegion lastLine= document.getLineInformationOfOffset(annotationOffset + annotationLength);
- if (lastLine.getOffset() == annotationOffset + annotationLength) {
- numbersOfLines -= 2;
- hh= (numbersOfLines * size.y) / maxLines + ANNOTATION_HEIGHT;
- if (hh < ANNOTATION_HEIGHT)
- hh= ANNOTATION_HEIGHT;
- } else
- hh= ANNOTATION_HEIGHT;
- }
- fAnnotationHeight= hh;
-
- int startLine= textWidget.getLineAtOffset(annotationOffset - visible.getOffset());
- yy= Math.min((startLine * size.y) / maxLines, size.y - hh);
-
- if (fill != null) {
- gc.setBackground(fill);
- gc.fillRectangle(INSET, yy, size.x-(2*INSET), hh);
- }
-
- if (stroke != null) {
- gc.setForeground(stroke);
- r.x= INSET;
- r.y= yy;
- r.width= size.x - (2 * INSET) - 1;
- r.height= hh;
- gc.setLineWidth(1);
- gc.drawRectangle(r);
- }
- } catch (BadLocationException x) {
- }
- }
- }
- }
- }
-
- /**
- * Draws this overview ruler. Uses <code>ITextViewerExtension5</code> for
- * its implementation. Will replace <code>doPaint(GC)</code>.
- *
- * @param gc the gc to draw into
- */
- private void doPaint1(GC gc) {
-
- if (fTextViewer == null)
- return;
-
- Rectangle r= new Rectangle(0, 0, 0, 0);
- int yy, hh= ANNOTATION_HEIGHT;
-
- ITextViewerExtension5 extension= (ITextViewerExtension5) fTextViewer;
- IDocument document= fTextViewer.getDocument();
- StyledText textWidget= fTextViewer.getTextWidget();
-
- int maxLines= textWidget.getLineCount();
- Point size= fCanvas.getSize();
- int writable= maxLines * textWidget.getLineHeight();
- if (size.y > writable)
- size.y= Math.max(writable - fHeader.getSize().y, 0);
-
- for (Iterator iterator= fAnnotationsSortedByLayer.iterator(); iterator.hasNext();) {
- Object annotationType= iterator.next();
-
- if (skip(annotationType))
- continue;
-
- boolean[] temporary= new boolean[] { false, true };
- for (int t=0; t < temporary.length; t++) {
-
- Iterator e= new FilterIterator(annotationType, temporary[t]);
- Color fill= getFillColor(annotationType, temporary[t]);
- Color stroke= getStrokeColor(annotationType, temporary[t]);
-
- for (int i= 0; e.hasNext(); i++) {
-
- Annotation a= (Annotation) e.next();
- Position p= fModel.getPosition(a);
-
- if (p == null)
- continue;
-
- IRegion widgetRegion= extension.modelRange2WidgetRange(new Region(p.getOffset(), p.getLength()));
- if (widgetRegion == null)
- continue;
-
- try {
- if (ANNOTATION_HEIGHT_SCALABLE) {
- int numbersOfLines= document.getNumberOfLines(p.getOffset(), p.getLength());
- // don't count empty trailing lines
- IRegion lastLine= document.getLineInformationOfOffset(p.getOffset() + p.getLength());
- if (lastLine.getOffset() == p.getOffset() + p.getLength()) {
- numbersOfLines -= 2;
- hh= (numbersOfLines * size.y) / maxLines + ANNOTATION_HEIGHT;
- if (hh < ANNOTATION_HEIGHT)
- hh= ANNOTATION_HEIGHT;
- } else
- hh= ANNOTATION_HEIGHT;
- }
- fAnnotationHeight= hh;
-
- int startLine= textWidget.getLineAtOffset(widgetRegion.getOffset());
- yy= Math.min(startLine * (size.y / maxLines), size.y - hh);
-
- if (fill != null) {
- gc.setBackground(fill);
- gc.fillRectangle(INSET, yy, size.x-(2*INSET), hh);
- }
-
- if (stroke != null) {
- gc.setForeground(stroke);
- r.x= INSET;
- r.y= yy;
- r.width= size.x - (2 * INSET) - 1;
- r.height= hh;
- gc.setLineWidth(1);
- gc.drawRectangle(r);
- }
- } catch (BadLocationException x) {
- }
- }
- }
- }
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRuler#update()
- */
- public void update() {
- if (fCanvas != null && !fCanvas.isDisposed()) {
- Display d= fCanvas.getDisplay();
- if (d != null) {
- d.asyncExec(new Runnable() {
- public void run() {
- redraw();
- updateHeader();
- }
- });
- }
- }
- }
-
- /**
- * Redraws the overview ruler.
- */
- private void redraw() {
- if (fCanvas != null && !fCanvas.isDisposed()) {
- GC gc= new GC(fCanvas);
- doubleBufferPaint(gc);
- gc.dispose();
- }
- }
-
- /**
- * Translates a given y-coordinate of this ruler into the corresponding
- * document lines. The number of lines depends on the concrete scaling
- * given as the ration between the height of this ruler and the length
- * of the document.
- *
- * @param y_coordinate the y-coordinate
- * @return the corresponding document lines
- */
- private int[] toLineNumbers(int y_coordinate) {
-
- StyledText textWidget= fTextViewer.getTextWidget();
- int maxLines= textWidget.getContent().getLineCount();
-
- int rulerLength= fCanvas.getSize().y;
- int writable= maxLines * textWidget.getLineHeight();
-
- if (rulerLength > writable)
- rulerLength= Math.max(writable - fHeader.getSize().y, 0);
-
- if (y_coordinate >= writable || y_coordinate >= rulerLength)
- return new int[] {-1, -1};
-
- int[] lines= new int[2];
-
- int pixel= Math.max(y_coordinate - 1, 0);
- lines[0]= (pixel * maxLines) / rulerLength;
-
- pixel= Math.min(rulerLength, y_coordinate + 1);
- lines[1]= (pixel * maxLines) / rulerLength;
-
- if (fTextViewer instanceof ITextViewerExtension5) {
- ITextViewerExtension5 extension= (ITextViewerExtension5) fTextViewer;
- lines[0]= extension.widgetlLine2ModelLine(lines[0]);
- lines[1]= extension.widgetlLine2ModelLine(lines[1]);
- } else {
- try {
- IRegion visible= fTextViewer.getVisibleRegion();
- int lineNumber= fTextViewer.getDocument().getLineOfOffset(visible.getOffset());
- lines[0] += lineNumber;
- lines[1] += lineNumber;
- } catch (BadLocationException x) {
- }
- }
-
- return lines;
- }
-
- /**
- * Returns the position of the first annotation found in the given line range.
- *
- * @param lineNumbers the line range
- * @param ignoreSelectedAnnotation whether to ignore the current selection
- * @return the position of the first found annotation
- */
- private Position getAnnotationPosition(int[] lineNumbers, boolean ignoreSelectedAnnotation) {
- if (lineNumbers[0] == -1)
- return null;
-
- Position found= null;
-
- try {
- IDocument d= fTextViewer.getDocument();
- IRegion line= d.getLineInformation(lineNumbers[0]);
-
- Point currentSelection= fTextViewer.getSelectedRange();
-
- int start= line.getOffset();
-
- line= d.getLineInformation(lineNumbers[lineNumbers.length - 1]);
- int end= line.getOffset() + line.getLength();
-
- for (int i= fAnnotationsSortedByLayer.size() -1; i >= 0; i--) {
-
- Object annotationType= fAnnotationsSortedByLayer.get(i);
-
- Iterator e= new FilterIterator(annotationType);
- while (e.hasNext() && found == null) {
- Annotation a= (Annotation) e.next();
- if (a.isMarkedDeleted())
- continue;
-
- if (skip(fAnnotationAccess.getType(a)))
- continue;
-
- Position p= fModel.getPosition(a);
- if (p == null)
- continue;
-
- int posOffset= p.getOffset();
- int posEnd= posOffset + p.getLength();
- IRegion region= d.getLineInformationOfOffset(posEnd);
- // trailing empty lines don't count
- if (posEnd > posOffset && region.getOffset() == posEnd) {
- posEnd--;
- region= d.getLineInformationOfOffset(posEnd);
- }
-
- if (posOffset <= end && posEnd >= start) {
- if ((found == null || posOffset < found.getOffset()) && (ignoreSelectedAnnotation || currentSelection.x != posOffset || currentSelection.y != p.getLength()))
- found= p;
- }
- }
- }
- } catch (BadLocationException x) {
- }
-
- return found;
- }
-
- /**
- * Returns the line which corresponds best to one of
- * the underlying annotations at the given y-coordinate.
- *
- * @return the best matching line or <code>-1</code> if no such line can be found
- */
- private int findBestMatchingLineNumber(int[] lineNumbers) {
- if (lineNumbers == null || lineNumbers.length < 1)
- return -1;
-
- try {
- Position pos= getAnnotationPosition(lineNumbers, true);
- if (pos == null)
- return -1;
- return fTextViewer.getDocument().getLineOfOffset(pos.getOffset());
- } catch (BadLocationException ex) {
- return -1;
- }
- }
-
- /**
- * Handles mouse clicks.
- *
- * @param event the mouse button down event
- */
- private void handleMouseDown(MouseEvent event) {
- if (fTextViewer != null) {
- int[] lines= toLineNumbers(event.y);
- Position p= getAnnotationPosition(lines, false);
- if (p != null) {
- fTextViewer.revealRange(p.getOffset(), p.getLength());
- fTextViewer.setSelectedRange(p.getOffset(), p.getLength());
- }
- fTextViewer.getTextWidget().setFocus();
- }
- fLastMouseButtonActivityLine= toDocumentLineNumber(event.y);
- }
-
- /**
- * Handles mouse moves.
- *
- * @param event the mouse move event
- */
- private void handleMouseMove(MouseEvent event) {
- if (fTextViewer != null) {
- int[] lines= toLineNumbers(event.y);
- Position p= getAnnotationPosition(lines, true);
- Cursor cursor= (p != null ? fHitDetectionCursor : null);
- if (cursor != fLastCursor) {
- fCanvas.setCursor(cursor);
- fLastCursor= cursor;
- }
- }
- }
-
- /*
- * @see org.eclipse.jface.text.source.IOverviewRuler#addAnnotationType(java.lang.Object)
- */
- public void addAnnotationType(Object annotationType) {
- fConfiguredAnnotationTypes.add(annotationType);
- }
-
- /*
- * @see org.eclipse.jface.text.source.IOverviewRuler#removeAnnotationType(java.lang.Object)
- */
- public void removeAnnotationType(Object annotationType) {
- fConfiguredAnnotationTypes.remove(annotationType);
- fAllowedAnnotationTypes.clear();
- }
-
- /*
- * @see org.eclipse.jface.text.source.IOverviewRuler#setAnnotationTypeLayer(java.lang.Object, int)
- */
- public void setAnnotationTypeLayer(Object annotationType, int layer) {
- Integer layerObj= new Integer(layer);
- if (fAnnotationsSortedByLayer.remove(annotationType))
- fLayersSortedByLayer.remove(layerObj);
-
- if (layer >= 0) {
- int i= 0;
- int size= fLayersSortedByLayer.size();
- while (i < size && layer >= ((Integer)fLayersSortedByLayer.get(i)).intValue())
- i++;
- fLayersSortedByLayer.add(i, layerObj);
- fAnnotationsSortedByLayer.add(i, annotationType);
- }
- }
-
- /*
- * @see org.eclipse.jface.text.source.IOverviewRuler#setAnnotationTypeColor(java.lang.Object, org.eclipse.swt.graphics.Color)
- */
- public void setAnnotationTypeColor(Object annotationType, Color color) {
- if (color != null)
- fAnnotationTypes2Colors.put(annotationType, color);
- else
- fAnnotationTypes2Colors.remove(annotationType);
- }
-
- /**
- * Returns whether the given annotation type should be skipped by the drawing routine.
- *
- * @param annotationType the annotation type
- * @return <code>true</code> if annotation of the given type should be skipped
- */
- private boolean skip(Object annotationType) {
- return !contains(annotationType, fAllowedAnnotationTypes, fConfiguredAnnotationTypes);
- }
-
- /**
- * Returns whether the given annotation type should be skipped by the drawing routine of the header.
- *
- * @param annotationType the annotation type
- * @return <code>true</code> if annotation of the given type should be skipped
- */
- private boolean skipInHeader(Object annotationType) {
- return !contains(annotationType, fAllowedHeaderAnnotationTypes, fConfiguredHeaderAnnotationTypes);
- }
-
- /**
- * Returns whether the given annotation type is contained in the given <code>allowed</code>
- * set. This is the case if the type is either in the set
- * or covered by the <code>configured</code> set.
- *
- * @param annotationType the annotation type
- * @return <code>true</code> if annotation is contained, <code>false</code>
- * otherwise
- * @since 3.0
- */
- private boolean contains(Object annotationType, Set allowed, Set configured) {
- if (allowed.contains(annotationType))
- return true;
-
- boolean covered= isCovered(annotationType, configured);
- if (covered)
- allowed.add(annotationType);
-
- return covered;
- }
-
- /**
- * Computes whether the annotations of the given type are covered by the given <code>configured</code>
- * set. This is the case if either the type of the annotation or any of its
- * super types is contained in the <code>configured</code> set.
- *
- * @param annotation the annotation
- * @param annotationType the annotation type
- * @return <code>true</code> if annotation is covered, <code>false</code>
- * otherwise
- * @since 3.0
- */
- private boolean isCovered(Object annotationType, Set configured) {
- if (fAnnotationAccess instanceof IAnnotationAccessExtension) {
- IAnnotationAccessExtension extension= (IAnnotationAccessExtension) fAnnotationAccess;
- Iterator e= configured.iterator();
- while (e.hasNext()) {
- if (extension.isSubtype(annotationType,e.next()))
- return true;
- }
- return false;
- }
- return configured.contains(annotationType);
- }
-
- /**
- * Returns a specification of a color that lies between the given
- * foreground and background color using the given scale factor.
- *
- * @param fg the foreground color
- * @param bg the background color
- * @param scale the scale factor
- * @return the interpolated color
- */
- private static RGB interpolate(RGB fg, RGB bg, double scale) {
- return new RGB(
- (int) ((1.0-scale) * fg.red + scale * bg.red),
- (int) ((1.0-scale) * fg.green + scale * bg.green),
- (int) ((1.0-scale) * fg.blue + scale * bg.blue)
- );
- }
-
- /**
- * Returns the grey value in which the given color would be drawn in grey-scale.
- *
- * @param rgb the color
- * @return the grey-scale value
- */
- private static double greyLevel(RGB rgb) {
- if (rgb.red == rgb.green && rgb.green == rgb.blue)
- return rgb.red;
- return (0.299 * rgb.red + 0.587 * rgb.green + 0.114 * rgb.blue + 0.5);
- }
-
- /**
- * Returns whether the given color is dark or light depending on the colors grey-scale level.
- *
- * @param rgb the color
- * @return <code>true</code> if the color is dark, <code>false</code> if it is light
- */
- private static boolean isDark(RGB rgb) {
- return greyLevel(rgb) > 128;
- }
-
- /**
- * Returns a color based on the color configured for the given annotation type and the given scale factor.
- *
- * @param annotationType the annotation type
- * @param scale the scale factor
- * @return the computed color
- */
- private Color getColor(Object annotationType, double scale) {
- Color base= findColor(annotationType);
- if (base == null)
- return null;
-
- RGB baseRGB= base.getRGB();
- RGB background= fCanvas.getBackground().getRGB();
-
- boolean darkBase= isDark(baseRGB);
- boolean darkBackground= isDark(background);
- if (darkBase && darkBackground)
- background= new RGB(255, 255, 255);
- else if (!darkBase && !darkBackground)
- background= new RGB(0, 0, 0);
-
- return fSharedTextColors.getColor(interpolate(baseRGB, background, scale));
- }
-
- /**
- * Returns the color for the given annotation type
- *
- * @param annotationType the annotation type
- * @return the color
- */
- private Color findColor(Object annotationType) {
- Color color= (Color) fAnnotationTypes2Colors.get(annotationType);
- if (color != null)
- return color;
-
- if (fAnnotationAccess instanceof IAnnotationAccessExtension) {
- IAnnotationAccessExtension extension= (IAnnotationAccessExtension) fAnnotationAccess;
- Object[] superTypes= extension.getSupertypes(annotationType);
- if (superTypes != null) {
- for (int i= 0; i < superTypes.length; i++) {
- color= (Color) fAnnotationTypes2Colors.get(superTypes[i]);
- if (color != null)
- return color;
- }
- }
- }
-
- return null;
- }
-
- /**
- * Returns the stroke color for the given annotation type and characteristics.
- *
- * @param annotationType the annotation type
- * @param temporary <code>true</code> if for temporary annotations
- * @return the stroke color
- */
- private Color getStrokeColor(Object annotationType, boolean temporary) {
- return getColor(annotationType, temporary ? 0.5 : 0.2);
- }
-
- /**
- * Returns the fill color for the given annotation type and characteristics.
- *
- * @param annotationType the annotation type
- * @param temporary <code>true</code> if for temporary annotations
- * @return the fill color
- */
- private Color getFillColor(Object annotationType, boolean temporary) {
- return getColor(annotationType, temporary ? 0.9 : 0.6);
- }
-
- /*
- * @see IVerticalRulerInfo#getLineOfLastMouseButtonActivity()
- */
- public int getLineOfLastMouseButtonActivity() {
- return fLastMouseButtonActivityLine;
- }
-
- /*
- * @see IVerticalRulerInfo#toDocumentLineNumber(int)
- */
- public int toDocumentLineNumber(int y_coordinate) {
-
- if (fTextViewer == null || y_coordinate == -1)
- return -1;
-
- int[] lineNumbers= toLineNumbers(y_coordinate);
- int bestLine= findBestMatchingLineNumber(lineNumbers);
- if (bestLine == -1 && lineNumbers.length > 0)
- return lineNumbers[0];
- return bestLine;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRuler#getModel()
- */
- public IAnnotationModel getModel() {
- return fModel;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IOverviewRuler#getAnnotationHeight()
- */
- public int getAnnotationHeight() {
- return fAnnotationHeight;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IOverviewRuler#hasAnnotation(int)
- */
- public boolean hasAnnotation(int y) {
- return findBestMatchingLineNumber(toLineNumbers(y)) != -1;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IOverviewRuler#getHeaderControl()
- */
- public Control getHeaderControl() {
- return fHeader;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IOverviewRuler#addHeaderAnnotationType(java.lang.Object)
- */
- public void addHeaderAnnotationType(Object annotationType) {
- fConfiguredHeaderAnnotationTypes.add(annotationType);
- }
-
- /*
- * @see org.eclipse.jface.text.source.IOverviewRuler#removeHeaderAnnotationType(java.lang.Object)
- */
- public void removeHeaderAnnotationType(Object annotationType) {
- fConfiguredHeaderAnnotationTypes.remove(annotationType);
- fAllowedHeaderAnnotationTypes.clear();
- }
-
- /**
- * Updates the header of this ruler.
- */
- private void updateHeader() {
-
- if (fHeader == null || fHeader.isDisposed())
- return;
-
- Object colorType= null;
- outer: for (int i= fAnnotationsSortedByLayer.size() -1; i >= 0; i--) {
-
- Object annotationType= fAnnotationsSortedByLayer.get(i);
-
- if (skipInHeader(annotationType) || skip(annotationType))
- continue;
-
- for (Iterator e= new FilterIterator(annotationType); e.hasNext();) {
- if (e.next() != null) {
- colorType= annotationType;
- break outer;
- }
- }
- }
-
- Color color= null;
- if (colorType != null)
- color= findColor(colorType);
-
- if (color == null) {
- if (fHeaderPainter != null)
- fHeaderPainter.setColor(null);
- } else {
- if (fHeaderPainter == null) {
- fHeaderPainter= new HeaderPainter();
- fHeader.addPaintListener(fHeaderPainter);
- }
- fHeaderPainter.setColor(color);
- }
-
- fHeader.redraw();
- updateHeaderToolTipText();
- }
-
- /**
- * Updates the tool tip text of the header of this ruler.
- *
- * @since 3.0
- */
- private void updateHeaderToolTipText() {
-
- if (fHeader == null || fHeader.isDisposed())
- return;
-
- fHeader.setToolTipText(null);
-
- if (!(fAnnotationAccess instanceof IAnnotationAccessExtension))
- return;
-
- String overview= ""; //$NON-NLS-1$
-
- for (int i= fAnnotationsSortedByLayer.size() -1; i >= 0; i--) {
-
- Object annotationType= fAnnotationsSortedByLayer.get(i);
-
- if (skipInHeader(annotationType) || skip(annotationType))
- continue;
-
- int count= 0;
- String annotationTypeLabel= null;
-
- for (Iterator e= new FilterIterator(annotationType); e.hasNext();) {
- Annotation annotation= (Annotation)e.next();
- if (annotation != null) {
- if (annotationTypeLabel == null)
- annotationTypeLabel= ((IAnnotationAccessExtension)fAnnotationAccess).getTypeLabel(annotation);
- count++;
- }
- }
-
- if (annotationTypeLabel != null) {
- if (overview.length() > 0)
- overview += "\n"; //$NON-NLS-1$
- overview += JFaceTextMessages.getFormattedString("OverviewRulerHeader.toolTipTextEntry", new Object[] {annotationTypeLabel, new Integer(count)}); //$NON-NLS-1$
- }
- }
- if (overview.length() > 0)
- fHeader.setToolTipText(overview);
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRulerHoverManager.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRulerHoverManager.java
deleted file mode 100644
index cab1f91..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRulerHoverManager.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.source;
-
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-
-import org.eclipse.jface.text.IInformationControlCreator;
-import org.eclipse.jface.text.source.AnnotationBarHoverManager;
-import org.eclipse.jface.text.source.IAnnotationHover;
-import org.eclipse.jface.text.source.ISourceViewer;
-
-/**
- * This manager controls the layout, content, and visibility of an information
- * control in reaction to mouse hover events issued by the overview ruler of a
- * source viewer.
- *
- * @since 2.1
- */
-class OverviewRulerHoverManager extends AnnotationBarHoverManager {
-
- /**
- * Creates an overview hover manager with the given parameters. In addition,
- * the hovers anchor is RIGHT and the margin is 5 points to the right.
- *
- * @param ruler the overview ruler this manager connects to
- * @param sourceViewer the source viewer this manager connects to
- * @param annotationHover the annotation hover providing the information to be displayed
- * @param creator the information control creator
- */
- public OverviewRulerHoverManager(IOverviewRuler ruler, ISourceViewer sourceViewer, IAnnotationHover annotationHover, IInformationControlCreator creator) {
- super(ruler, sourceViewer, annotationHover, creator);
- setAnchor(ANCHOR_LEFT);
- }
-
- /*
- * @see AbstractHoverInformationControlManager#computeInformation()
- */
- protected void computeInformation() {
- Point location= getHoverEventLocation();
- int line= getVerticalRulerInfo().toDocumentLineNumber(location.y);
- setInformation(getAnnotationHover().getHoverInfo(getSourceViewer(), line), computeArea(location.y));
- }
-
- /**
- * Determines graphical area covered for which the hover is valid.
- *
- * @param y-coordinate in the vertical ruler
- * @return the graphical extend where the hover is valid
- */
- private Rectangle computeArea(int y) {
- // This is ok (see constructor)
- IOverviewRuler overviewRuler= (IOverviewRuler) getVerticalRulerInfo();
-
- int hover_height= overviewRuler.getAnnotationHeight();
- int hover_width= getVerticalRulerInfo().getControl().getSize().x;
-
- // Calculate y-coordinate for hover
- int hover_y= y;
- boolean hasAnnotation= true;
- while (hasAnnotation && hover_y > y - hover_height) {
- hover_y--;
- hasAnnotation= overviewRuler.hasAnnotation(hover_y);
- }
- hover_y++;
-
- return new Rectangle(0, hover_y, hover_width, hover_height);
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java
deleted file mode 100644
index ed09f46..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java
+++ /dev/null
@@ -1,894 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.source;
-
-import java.util.Stack;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Layout;
-
-import org.eclipse.jface.text.AbstractHoverInformationControlManager;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.DefaultPositionUpdater;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IPositionUpdater;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.IRewriteTarget;
-import org.eclipse.jface.text.ISlaveDocumentManager;
-import org.eclipse.jface.text.ISlaveDocumentManagerExtension;
-import org.eclipse.jface.text.ITextViewerExtension2;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextViewer;
-import org.eclipse.jface.text.contentassist.IContentAssistant;
-import org.eclipse.jface.text.formatter.FormattingContext;
-import org.eclipse.jface.text.formatter.FormattingContextProperties;
-import org.eclipse.jface.text.formatter.IContentFormatter;
-import org.eclipse.jface.text.formatter.IContentFormatterExtension2;
-import org.eclipse.jface.text.formatter.IFormattingContext;
-import org.eclipse.jface.text.information.IInformationPresenter;
-import org.eclipse.jface.text.presentation.IPresentationReconciler;
-import org.eclipse.jface.text.projection.ChildDocument;
-import org.eclipse.jface.text.reconciler.IReconciler;
-
-/**
- * SWT based implementation of <code>ISourceViewer</code>. The same rules apply
- * as for <code>TextViewer</code>. A source viewer uses an <code>IVerticalRuler</code>
- * as its annotation presentation area. The vertical ruler is a small strip shown left
- * of the viewer's text widget. A source viewer uses an <code>IOverviewRuler</code>
- * as its presentation area for the annotation overview. The overview ruler is a small strip
- * shown right of the viewer's text widget.<p>
- * Clients are supposed to instantiate a source viewer and subsequently to communicate
- * with it exclusively using the <code>ISourceViewer</code> interface. Clients should not
- * subclass this class as it is rather likely that subclasses will be broken by future releases.
- */
-public class SourceViewer extends TextViewer implements ISourceViewer, ISourceViewerExtension, ISourceViewerExtension2 {
-
-
- /**
- * Layout of a source viewer. Vertical ruler, text widget, and overview ruler are shown side by side.
- */
- protected class RulerLayout extends Layout {
-
- /** The gap between the text viewer and the vertical ruler. */
- protected int fGap;
-
- /**
- * Creates a new ruler layout with the given gap between text viewer and vertical ruler.
- *
- * @param gap the gap between text viewer and vertical ruler
- */
- public RulerLayout(int gap) {
- fGap= gap;
- }
-
- /*
- * @see Layout#computeSize(Composite, int, int, boolean)
- */
- protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) {
- Control[] children= composite.getChildren();
- Point s= children[children.length - 1].computeSize(SWT.DEFAULT, SWT.DEFAULT, flushCache);
- if (fVerticalRuler != null && fIsVerticalRulerVisible)
- s.x += fVerticalRuler.getWidth() + fGap;
- return s;
- }
-
- /*
- * @see Layout#layout(Composite, boolean)
- */
- protected void layout(Composite composite, boolean flushCache) {
- Rectangle clArea= composite.getClientArea();
- if (fVerticalRuler != null && fIsVerticalRulerVisible) {
-
- Rectangle trim= getTextWidget().computeTrim(0, 0, 0, 0);
- int scrollbarHeight= trim.height;
-
- int verticalRulerWidth= fVerticalRuler.getWidth();
- int overviewRulerWidth= 0;
- if (fOverviewRuler != null && fIsOverviewRulerVisible) {
- overviewRulerWidth= fOverviewRuler.getWidth();
- fOverviewRuler.getControl().setBounds(clArea.width - overviewRulerWidth -1, scrollbarHeight, overviewRulerWidth, clArea.height - 3*scrollbarHeight);
- fOverviewRuler.getHeaderControl().setBounds(clArea.width - overviewRulerWidth -1, 0, overviewRulerWidth, scrollbarHeight);
- }
-
- getTextWidget().setBounds(verticalRulerWidth + fGap, 0, clArea.width - verticalRulerWidth - overviewRulerWidth - 2*fGap, clArea.height);
- fVerticalRuler.getControl().setBounds(0, 0, verticalRulerWidth, clArea.height - scrollbarHeight);
-
- } else
- getTextWidget().setBounds(0, 0, clArea.width, clArea.height);
- }
- }
-
- /** The size of the gap between the vertical ruler and the text widget */
- protected final static int GAP_SIZE= 2;
- /**
- * Partial name of the position category to manage remembered selections.
- * @since 3.0
- */
- protected final static String _SELECTION_POSITION_CATEGORY= "__selection_category"; //$NON-NLS-1$
- /**
- * Key of the model annotation model inside the visual annotation model.
- * @since 3.0
- */
- protected final static Object MODEL_ANNOTATION_MODEL= new Object();
-
- /** The viewer's content assistant */
- protected IContentAssistant fContentAssistant;
- /**
- * Flag indicating whether the viewer's content assistant is installed
- * @since 2.0
- */
- protected boolean fContentAssistantInstalled;
- /** The viewer's content formatter */
- protected IContentFormatter fContentFormatter;
- /** The viewer's model reconciler */
- protected IReconciler fReconciler;
- /** The viewer's presentation reconciler */
- protected IPresentationReconciler fPresentationReconciler;
- /** The viewer's annotation hover */
- protected IAnnotationHover fAnnotationHover;
- /**
- * Stack of saved selections in the underlying document
- * @since 3.0
- */
- protected final Stack fSelections= new Stack();
- /**
- * Position updater for saved selections
- * @since 3.0
- */
- protected IPositionUpdater fSelectionUpdater= null;
- /**
- * Position category used by the selection updater
- * @since 3.0
- */
- protected String fSelectionCategory;
- /**
- * The viewer's overview ruler annotation hover
- * @since 3.0
- */
- protected IAnnotationHover fOverviewRulerAnnotationHover;
- /**
- * The viewer's information presenter
- * @since 2.0
- */
- protected IInformationPresenter fInformationPresenter;
-
- /** Visual vertical ruler */
- private IVerticalRuler fVerticalRuler;
- /** Visibility of vertical ruler */
- private boolean fIsVerticalRulerVisible;
- /** The SWT widget used when supporting a vertical ruler */
- private Composite fComposite;
- /** The vertical ruler's annotation model */
- private IAnnotationModel fVisualAnnotationModel;
- /** The viewer's range indicator to be shown in the vertical ruler */
- private Annotation fRangeIndicator;
- /** The viewer's vertical ruler hovering controller */
- private AbstractHoverInformationControlManager fVerticalRulerHoveringController;
- /**
- * The viewer's overview ruler hovering controller
- * @since 2.1
- */
- private AbstractHoverInformationControlManager fOverviewRulerHoveringController;
-
- /**
- * The overview ruler.
- * @since 2.1
- */
- private IOverviewRuler fOverviewRuler;
- /**
- * The visibility of the overview ruler
- * @since 2.1
- */
- private boolean fIsOverviewRulerVisible;
-
-
- /**
- * Constructs a new source viewer. The vertical ruler is initially visible.
- * The viewer has not yet been initialized with a source viewer configuration.
- *
- * @param parent the parent of the viewer's control
- * @param ruler the vertical ruler used by this source viewer
- * @param styles the SWT style bits
- */
- public SourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
- this(parent, ruler, null, false, styles);
- }
-
- /**
- * Constructs a new source viewer. The vertical ruler is initially visible.
- * The overview ruler visibility is controlled by the value of <code>showAnnotationsOverview</code>.
- * The viewer has not yet been initialized with a source viewer configuration.
- *
- * @param parent the parent of the viewer's control
- * @param verticalRuler the vertical ruler used by this source viewer
- * @param overviewRuler the overview ruler
- * @param showAnnotationsOverview <code>true</code> if the overview ruler should be visible, <code>false</code> otherwise
- * @param styles the SWT style bits
- * @since 2.1
- */
- public SourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler, boolean showAnnotationsOverview, int styles) {
- super();
-
- fVerticalRuler= verticalRuler;
- fIsVerticalRulerVisible= (verticalRuler != null);
- fOverviewRuler= overviewRuler;
- fIsOverviewRulerVisible= (showAnnotationsOverview && overviewRuler != null);
-
- createControl(parent, styles);
- }
-
- /*
- * @see TextViewer#createControl(Composite, int)
- */
- protected void createControl(Composite parent, int styles) {
-
- if (fVerticalRuler != null || fOverviewRuler != null) {
- styles= (styles & ~SWT.BORDER);
- fComposite= new Canvas(parent, SWT.NONE);
- fComposite.setLayout(createLayout());
- parent= fComposite;
- }
-
- super.createControl(parent, styles);
-
- if (fVerticalRuler != null)
- fVerticalRuler.createControl(fComposite, this);
- if (fOverviewRuler != null)
- fOverviewRuler.createControl(fComposite, this);
- }
-
- /**
- * Creates the layout used for this viewer.
- * Subclasses may override this method.
- *
- * @return the layout used for this viewer
- * @since 3.0
- */
- protected Layout createLayout() {
- return new RulerLayout(GAP_SIZE);
- }
-
- /*
- * @see TextViewer#getControl()
- */
- public Control getControl() {
- if (fComposite != null)
- return fComposite;
- return super.getControl();
- }
-
- /*
- * @see ISourceViewer#setAnnotationHover(IAnnotationHover)
- */
- public void setAnnotationHover(IAnnotationHover annotationHover) {
- fAnnotationHover= annotationHover;
- }
-
- /**
- * Sets the overview ruler's annotation hover of this source viewer.
- * The annotation hover provides the information to be displayed in a hover
- * popup window if requested over the overview rulers area. The annotation
- * hover is assumed to be line oriented.
- *
- * @param annotationHover the hover to be used, <code>null</code> is a valid argument
- * @since 3.0
- */
- public void setOverviewRulerAnnotationHover(IAnnotationHover annotationHover) {
- fOverviewRulerAnnotationHover= annotationHover;
- }
-
- /*
- * @see ISourceViewer#configure(SourceViewerConfiguration)
- */
- public void configure(SourceViewerConfiguration configuration) {
-
- if (getTextWidget() == null)
- return;
-
- setDocumentPartitioning(configuration.getConfiguredDocumentPartitioning(this));
-
- // install content type independent plug-ins
- fPresentationReconciler= configuration.getPresentationReconciler(this);
- if (fPresentationReconciler != null)
- fPresentationReconciler.install(this);
-
- fReconciler= configuration.getReconciler(this);
- if (fReconciler != null)
- fReconciler.install(this);
-
- fContentAssistant= configuration.getContentAssistant(this);
- if (fContentAssistant != null) {
- fContentAssistant.install(this);
- fContentAssistantInstalled= true;
- }
-
- fContentFormatter= configuration.getContentFormatter(this);
-
- fInformationPresenter= configuration.getInformationPresenter(this);
- if (fInformationPresenter != null)
- fInformationPresenter.install(this);
-
- setUndoManager(configuration.getUndoManager(this));
-
- getTextWidget().setTabs(configuration.getTabWidth(this));
-
- setAnnotationHover(configuration.getAnnotationHover(this));
- setOverviewRulerAnnotationHover(configuration.getOverviewRulerAnnotationHover(this));
-
- setHoverControlCreator(configuration.getInformationControlCreator(this));
-
- // install content type specific plug-ins
- String[] types= configuration.getConfiguredContentTypes(this);
- for (int i= 0; i < types.length; i++) {
-
- String t= types[i];
-
- setAutoIndentStrategy(configuration.getAutoIndentStrategy(this, t), t);
- setTextDoubleClickStrategy(configuration.getDoubleClickStrategy(this, t), t);
-
- int[] stateMasks= configuration.getConfiguredTextHoverStateMasks(this, t);
- if (stateMasks != null) {
- for (int j= 0; j < stateMasks.length; j++) {
- int stateMask= stateMasks[j];
- setTextHover(configuration.getTextHover(this, t, stateMask), t, stateMask);
- }
- } else {
- setTextHover(configuration.getTextHover(this, t), t, ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK);
- }
-
- String[] prefixes= configuration.getIndentPrefixes(this, t);
- if (prefixes != null && prefixes.length > 0)
- setIndentPrefixes(prefixes, t);
-
- prefixes= configuration.getDefaultPrefixes(this, t);
- if (prefixes != null && prefixes.length > 0)
- setDefaultPrefixes(prefixes, t);
- }
-
- activatePlugins();
- }
-
- /**
- * After this method has been executed the caller knows that any installed annotation hover has been installed.
- */
- protected void ensureAnnotationHoverManagerInstalled() {
- if (fVerticalRuler != null && fAnnotationHover != null && fVerticalRulerHoveringController == null && fHoverControlCreator != null) {
- fVerticalRulerHoveringController= new AnnotationBarHoverManager(fVerticalRuler, this, fAnnotationHover, fHoverControlCreator);
- fVerticalRulerHoveringController.install(fVerticalRuler.getControl());
- }
- }
-
- /**
- * After this method has been executed the caller knows that any installed overview hover has been installed.
- */
- protected void ensureOverviewHoverManagerInstalled() {
- if (fOverviewRuler != null && fOverviewRulerAnnotationHover != null && fOverviewRulerHoveringController == null && fHoverControlCreator != null) {
- fOverviewRulerHoveringController= new OverviewRulerHoverManager(fOverviewRuler, this, fOverviewRulerAnnotationHover, fHoverControlCreator);
- fOverviewRulerHoveringController.install(fOverviewRuler.getControl());
- }
- }
-
- /*
- * @see TextViewer#activatePlugins()
- */
- public void activatePlugins() {
- ensureAnnotationHoverManagerInstalled();
- ensureOverviewHoverManagerInstalled();
- super.activatePlugins();
- }
-
- /*
- * @see ISourceViewer#setDocument(IDocument, IAnnotationModel)
- */
- public void setDocument(IDocument document) {
- setDocument(document, null, -1, -1);
- }
-
- /*
- * @see ISourceViewer#setDocument(IDocument, IAnnotationModel, int, int)
- */
- public void setDocument(IDocument document, int visibleRegionOffset, int visibleRegionLength) {
- setDocument(document, null, visibleRegionOffset, visibleRegionLength);
- }
-
- /*
- * @see ISourceViewer#setDocument(IDocument, IAnnotationModel)
- */
- public void setDocument(IDocument document, IAnnotationModel annotationModel) {
- setDocument(document, annotationModel, -1, -1);
- }
-
- /**
- * Creates the visual annotation model on top of the given annotation model.
- *
- * @param annotationModel the wrapped annotation model
- * @return the visual annotation model on top of the given annotation model
- * @since 3.0
- */
- protected IAnnotationModel createVisualAnnotationModel(IAnnotationModel annotationModel) {
- IAnnotationModelExtension model= new AnnotationModel();
- model.addAnnotationModel(MODEL_ANNOTATION_MODEL, annotationModel);
- return (IAnnotationModel) model;
- }
-
- /*
- * @see ISourceViewer#setDocument(IDocument, IAnnotationModel, int, int)
- */
- public void setDocument(IDocument document, IAnnotationModel annotationModel, int modelRangeOffset, int modelRangeLength) {
- if (fVerticalRuler == null && fOverviewRuler == null) {
-
- if (modelRangeOffset == -1 && modelRangeLength == -1)
- super.setDocument(document);
- else
- super.setDocument(document, modelRangeOffset, modelRangeLength);
-
- } else {
-
- if (fVisualAnnotationModel != null && getDocument() != null)
- fVisualAnnotationModel.disconnect(getDocument());
-
- if (annotationModel != null && document != null) {
- fVisualAnnotationModel= createVisualAnnotationModel(annotationModel);
- fVisualAnnotationModel.connect(document);
- } else {
- fVisualAnnotationModel= null;
- }
-
- if (modelRangeOffset == -1 && modelRangeLength == -1)
- super.setDocument(document);
- else
- super.setDocument(document, modelRangeOffset, modelRangeLength);
-
- if (fVerticalRuler != null)
- fVerticalRuler.setModel(fVisualAnnotationModel);
-
- if (fOverviewRuler != null)
- fOverviewRuler.setModel(fVisualAnnotationModel);
- }
- }
-
- /*
- * @see ISourceViewer#getAnnotationModel()
- */
- public IAnnotationModel getAnnotationModel() {
- if (fVisualAnnotationModel instanceof IAnnotationModelExtension) {
- IAnnotationModelExtension extension= (IAnnotationModelExtension) fVisualAnnotationModel;
- return extension.getAnnotationModel(MODEL_ANNOTATION_MODEL);
- }
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.source.ISourceViewerExtension2#getVisualAnnotationModel()
- * @since 3.0
- */
- public IAnnotationModel getVisualAnnotationModel() {
- return fVisualAnnotationModel;
- }
-
- /*
- * @see org.eclipse.jface.text.source.ISourceViewerExtension2#unconfigure()
- * @since 3.0
- */
- public void unconfigure() {
- clearRememberedSelection();
-
- if (fPresentationReconciler != null) {
- fPresentationReconciler.uninstall();
- fPresentationReconciler= null;
- }
-
- if (fReconciler != null) {
- fReconciler.uninstall();
- fReconciler= null;
- }
-
- if (fContentAssistant != null) {
- fContentAssistant.uninstall();
- fContentAssistantInstalled= false;
- fContentAssistant= null;
- }
-
- fContentFormatter= null;
-
- if (fInformationPresenter != null) {
- fInformationPresenter.uninstall();
- fInformationPresenter= null;
- }
-
- fAutoIndentStrategies= null;
- fDoubleClickStrategies= null;
- fTextHovers= null;
- fIndentChars= null;
- fDefaultPrefixChars= null;
-
- if (fVerticalRulerHoveringController != null) {
- fVerticalRulerHoveringController.dispose();
- fVerticalRulerHoveringController= null;
- }
-
- if (fOverviewRulerHoveringController != null) {
- fOverviewRulerHoveringController.dispose();
- fOverviewRulerHoveringController= null;
- }
- }
-
- /*
- * @see org.eclipse.jface.text.TextViewer#handleDispose()
- */
- protected void handleDispose() {
- unconfigure();
-
- if (fVisualAnnotationModel != null && getDocument() != null) {
- fVisualAnnotationModel.disconnect(getDocument());
- fVisualAnnotationModel= null;
- }
-
- fVerticalRuler= null;
-
- fOverviewRuler= null;
-
- // http://dev.eclipse.org/bugs/show_bug.cgi?id=15300
- fComposite= null;
-
- super.handleDispose();
- }
-
- /*
- * @see ITextOperationTarget#canDoOperation(int)
- */
- public boolean canDoOperation(int operation) {
-
- if (getTextWidget() == null || (!redraws() && operation != FORMAT))
- return false;
-
- if (operation == CONTENTASSIST_PROPOSALS)
- return fContentAssistant != null && fContentAssistantInstalled && isEditable();
-
- if (operation == CONTENTASSIST_CONTEXT_INFORMATION)
- return fContentAssistant != null && fContentAssistantInstalled && isEditable();
-
- if (operation == INFORMATION)
- return fInformationPresenter != null;
-
- if (operation == FORMAT) {
- return fContentFormatter != null && isEditable();
- }
-
- return super.canDoOperation(operation);
- }
-
- /**
- * Creates a new formatting context for a format operation.
- * <p>
- * After the use of the context, clients are required to call
- * its <code>dispose</code> method.
- *
- * @return The new formatting context
- */
- protected IFormattingContext createFormattingContext() {
- return new FormattingContext();
- }
-
- /**
- * Remembers and returns the current selection. The saved selection can be restored
- * by calling <code>restoreSelection()</code>.
- *
- * @return the current selection
- * @see org.eclipse.jface.text.ITextViewer#getSelectedRange()
- * @since 3.0
- */
- protected Point rememberSelection() {
-
- final Point selection= getSelectedRange();
- final IDocument document= getDocument();
-
- if (fSelections.isEmpty()) {
- fSelectionCategory= _SELECTION_POSITION_CATEGORY + hashCode();
- fSelectionUpdater= new DefaultPositionUpdater(fSelectionCategory);
- document.addPositionCategory(fSelectionCategory);
- document.addPositionUpdater(fSelectionUpdater);
- }
-
- try {
-
- final Position position= new Position(selection.x, selection.y);
- document.addPosition(fSelectionCategory, position);
- fSelections.push(position);
-
- } catch (BadLocationException exception) {
- // Should not happen
- } catch (BadPositionCategoryException exception) {
- // Should not happen
- }
-
- return selection;
- }
-
- /**
- * Restores a previously saved selection in the document.
- * <p>
- * If no selection was previously saved, nothing happens.
- *
- * @since 3.0
- */
- protected void restoreSelection() {
-
- if (!fSelections.isEmpty()) {
-
- final IDocument document= getDocument();
- final Position position= (Position) fSelections.pop();
-
- try {
- document.removePosition(fSelectionCategory, position);
- setSelectedRange(position.getOffset(), position.getLength());
-
- if (fSelections.isEmpty()) {
-
- document.removePositionUpdater(fSelectionUpdater);
- fSelectionUpdater= null;
- document.removePositionCategory(fSelectionCategory);
- fSelectionCategory= null;
- }
- } catch (BadPositionCategoryException exception) {
- // Should not happen
- }
- }
- }
-
- protected void clearRememberedSelection() {
- if (fSelections.isEmpty())
- return;
- fSelections.clear();
-
- IDocument document= getDocument();
- document.removePositionUpdater(fSelectionUpdater);
- fSelectionUpdater= null;
-
- try {
- document.removePositionCategory(fSelectionCategory);
- } catch (BadPositionCategoryException e) {
- // ignore
- }
- fSelectionCategory= null;
- }
-
- /*
- * @see ITextOperationTarget#doOperation(int)
- */
- public void doOperation(int operation) {
-
- if (getTextWidget() == null || (!redraws() && operation != FORMAT))
- return;
-
- switch (operation) {
- case CONTENTASSIST_PROPOSALS:
- fContentAssistant.showPossibleCompletions();
- return;
- case CONTENTASSIST_CONTEXT_INFORMATION:
- fContentAssistant.showContextInformation();
- return;
- case INFORMATION:
- fInformationPresenter.showInformation();
- return;
- case FORMAT:
- {
- final Point selection= rememberSelection();
-
- final IRegion region= new Region(selection.x, selection.y);
- final IRewriteTarget target= getRewriteTarget();
- final IFormattingContext context= createFormattingContext();
-
- if (selection.y == 0) {
- context.setProperty(FormattingContextProperties.CONTEXT_DOCUMENT, Boolean.TRUE);
- } else {
- context.setProperty(FormattingContextProperties.CONTEXT_DOCUMENT, Boolean.FALSE);
- context.setProperty(FormattingContextProperties.CONTEXT_REGION, region);
- }
- try {
- setRedraw(false);
- startSequentialRewriteMode(false);
- target.beginCompoundChange();
-
- final IDocument document= getDocument();
- final String rememberedContents= document.get();
-
- try {
-
- if (fContentFormatter instanceof IContentFormatterExtension2) {
- final IContentFormatterExtension2 extension= (IContentFormatterExtension2) fContentFormatter;
- extension.format(document, context);
- } else {
- fContentFormatter.format(document, region);
- }
-
- updateSlaveDocuments(document);
-
- } catch (RuntimeException x) {
- // fire wall for https://bugs.eclipse.org/bugs/show_bug.cgi?id=47472
- // if something went wrong we undo the changes we just did
- // TODO to be removed after 3.0 M8
- document.set(rememberedContents);
- throw x;
- }
-
- } finally {
-
- target.endCompoundChange();
- stopSequentialRewriteMode();
- setRedraw(true);
-
- restoreSelection();
- context.dispose();
- }
- return;
- }
- default:
- super.doOperation(operation);
- }
- }
-
- /**
- * Updates all slave documents of the given document. This default implementation calls <code>updateSlaveDocument</code>
- * for their current visible range. Subclasses may reimplement.
- *
- * @param masterDocument the master document
- * @since 3.0
- */
- protected void updateSlaveDocuments(IDocument masterDocument) {
- ISlaveDocumentManager manager= getSlaveDocumentManager();
- if (manager instanceof ISlaveDocumentManagerExtension) {
- ISlaveDocumentManagerExtension extension= (ISlaveDocumentManagerExtension) manager;
- IDocument[] slaves= extension.getSlaveDocuments(masterDocument);
- if (slaves != null) {
- for (int i= 0; i < slaves.length; i++) {
- if (slaves[i] instanceof ChildDocument) {
- ChildDocument child= (ChildDocument) slaves[i];
- Position p= child.getParentDocumentRange();
- try {
-
- if (!updateSlaveDocument(child, p.getOffset(), p.getLength()))
- child.repairLineInformation();
-
- } catch (BadLocationException e) {
- // ignore
- }
- }
- }
- }
- }
- }
-
- /*
- * @see ITextOperationTargetExtension#enableOperation(int, boolean)
- * @since 2.0
- */
- public void enableOperation(int operation, boolean enable) {
-
- switch (operation) {
- case CONTENTASSIST_PROPOSALS:
- case CONTENTASSIST_CONTEXT_INFORMATION: {
-
- if (fContentAssistant == null)
- return;
-
- if (enable) {
- if (!fContentAssistantInstalled) {
- fContentAssistant.install(this);
- fContentAssistantInstalled= true;
- }
- } else if (fContentAssistantInstalled) {
- fContentAssistant.uninstall();
- fContentAssistantInstalled= false;
- }
- }
- }
- }
-
- /*
- * @see ISourceViewer#setRangeIndicator(Annotation)
- */
- public void setRangeIndicator(Annotation rangeIndicator) {
- fRangeIndicator= rangeIndicator;
- }
-
- /*
- * @see ISourceViewer#setRangeIndication(int, int, boolean)
- */
- public void setRangeIndication(int start, int length, boolean moveCursor) {
-
- if (moveCursor) {
- setSelectedRange(start, 0);
- revealRange(start, length);
- }
-
- if (fRangeIndicator != null && fVisualAnnotationModel instanceof IAnnotationModelExtension) {
- IAnnotationModelExtension extension= (IAnnotationModelExtension) fVisualAnnotationModel;
- extension.modifyAnnotationPosition(fRangeIndicator, new Position(start, length));
- }
- }
-
- /*
- * @see ISourceViewer#getRangeIndication()
- */
- public IRegion getRangeIndication() {
- if (fRangeIndicator != null && fVisualAnnotationModel != null) {
- Position position= fVisualAnnotationModel.getPosition(fRangeIndicator);
- if (position != null)
- return new Region(position.getOffset(), position.getLength());
- }
-
- return null;
- }
-
- /*
- * @see ISourceViewer#removeRangeIndication()
- */
- public void removeRangeIndication() {
- if (fRangeIndicator != null && fVisualAnnotationModel != null)
- fVisualAnnotationModel.removeAnnotation(fRangeIndicator);
- }
-
- /*
- * @see ISourceViewer#showAnnotations(boolean)
- */
- public void showAnnotations(boolean show) {
- boolean old= fIsVerticalRulerVisible;
- fIsVerticalRulerVisible= (show && fVerticalRuler != null);
- if (old != fIsVerticalRulerVisible) {
- if (fComposite != null && !fComposite.isDisposed())
- fComposite.layout();
- if (fIsVerticalRulerVisible) {
- ensureAnnotationHoverManagerInstalled();
- } else if (fVerticalRulerHoveringController != null) {
- fVerticalRulerHoveringController.dispose();
- fVerticalRulerHoveringController= null;
- }
- }
- }
-
- /**
- * Returns the vertical ruler of this viewer.
- *
- * @return the vertical ruler of this viewer
- * @since 3.0
- */
- protected final IVerticalRuler getVerticalRuler() {
- return fVerticalRuler;
- }
-
- /*
- * @see org.eclipse.jface.text.source.ISourceViewerExtension#showAnnotationsOverview(boolean)
- * @since 2.1
- */
- public void showAnnotationsOverview(boolean show) {
- boolean old= fIsOverviewRulerVisible;
- fIsOverviewRulerVisible= (show && fOverviewRuler != null);
- if (old != fIsOverviewRulerVisible) {
- if (fComposite != null && !fComposite.isDisposed())
- fComposite.layout();
- if (fIsOverviewRulerVisible) {
- ensureOverviewHoverManagerInstalled();
- } else if (fOverviewRulerHoveringController != null) {
- fOverviewRulerHoveringController.dispose();
- fOverviewRulerHoveringController= null;
- }
- }
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewerConfiguration.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewerConfiguration.java
deleted file mode 100644
index e5ff781..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewerConfiguration.java
+++ /dev/null
@@ -1,308 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.source;
-
-
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.jface.text.DefaultAutoIndentStrategy;
-import org.eclipse.jface.text.DefaultInformationControl;
-import org.eclipse.jface.text.DefaultTextDoubleClickStrategy;
-import org.eclipse.jface.text.DefaultUndoManager;
-import org.eclipse.jface.text.IAutoIndentStrategy;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentExtension3;
-import org.eclipse.jface.text.IInformationControl;
-import org.eclipse.jface.text.IInformationControlCreator;
-import org.eclipse.jface.text.ITextDoubleClickStrategy;
-import org.eclipse.jface.text.ITextHover;
-import org.eclipse.jface.text.IUndoManager;
-import org.eclipse.jface.text.contentassist.IContentAssistant;
-import org.eclipse.jface.text.formatter.IContentFormatter;
-import org.eclipse.jface.text.information.IInformationPresenter;
-import org.eclipse.jface.text.presentation.IPresentationReconciler;
-import org.eclipse.jface.text.presentation.PresentationReconciler;
-import org.eclipse.jface.text.reconciler.IReconciler;
-
-
-/**
- * This class bundles the whole configuration space of a source viewer.
- * Instances of this class are passed to the <code>configure</code> method of
- * <code>ISourceViewer</code>.<p>
- * Each method in this class get as argument the source viewer for which it should
- * provide a particular configurational setting such as a presentation reconciler.
- * Based on its specific knowledge about the returned object, the configuration
- * might share such objects or compute them according to some rules.<p>
- * Clients should subclass and override just those methods which must be specific to
- * their needs.
- *
- * @see ISourceViewer
- */
-public class SourceViewerConfiguration {
-
-
- /**
- * Creates a new source viewer configuration that behaves according to
- * specification of this class' methods.
- */
- public SourceViewerConfiguration() {
- super();
- }
-
- /**
- * Returns the visual width of the tab character. This implementation always
- * returns 4.
- *
- * @param sourceViewer the source viewer to be configured by this configuration
- * @return the tab width
- */
- public int getTabWidth(ISourceViewer sourceViewer) {
- return 4;
- }
-
- /**
- * Returns the undo manager for the given source viewer. This implementation
- * always returns a new instance of <code>DefaultUndoManager</code> whose
- * history length is set to 25.
- *
- * @param sourceViewer the source viewer to be configured by this configuration
- * @return an undo manager or <code>null</code> if no undo/redo should not be supported
- */
- public IUndoManager getUndoManager(ISourceViewer sourceViewer) {
- return new DefaultUndoManager(25);
- }
-
- /**
- * Returns the reconciler ready to be used with the given source viewer.
- * This implementation always returns <code>null</code>.
- *
- * @param sourceViewer the source viewer to be configured by this configuration
- * @return a reconciler or <code>null</code> if reconciling should not be supported
- */
- public IReconciler getReconciler(ISourceViewer sourceViewer) {
- return null;
- }
-
- /**
- * Returns the presentation reconciler ready to be used with the given source viewer.
- * This implementation always returns <code>null</code>.
- *
- * @return the presentation reconciler or <code>null</code> if presentation reconciling should not be supported
- */
- public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
- PresentationReconciler reconciler= new PresentationReconciler();
- reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
-
- return reconciler;
- }
-
- /**
- * Returns the content formatter ready to be used with the given source viewer.
- * This implementation always returns <code>null</code>.
- *
- * @param sourceViewer the source viewer to be configured by this configuration
- * @return a content formatter or <code>null</code> if formatting should not be supported
- */
- public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
- return null;
- }
-
- /**
- * Returns the content assistant ready to be used with the given source viewer.
- * This implementation always returns <code>null</code>.
- *
- * @param sourceViewer the source viewer to be configured by this configuration
- * @return a content assistant or <code>null</code> if content assist should not be supported
- */
- public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
- return null;
- }
-
- /**
- * Returns the auto indentation strategy ready to be used with the given source viewer
- * when manipulating text of the given content type. This implementation always
- * returns an new instance of <code>DefaultAutoIndentStrategy</code>.
- *
- * @param sourceViewer the source viewer to be configured by this configuration
- * @param contentType the content type for which the strategy is applicable
- * @return the auto indent strategy or <code>null</code> if automatic indentation is not to be enabled
- */
- public IAutoIndentStrategy getAutoIndentStrategy(ISourceViewer sourceViewer, String contentType) {
- return new DefaultAutoIndentStrategy();
- }
- /**
- * Returns the default prefixes to be used by the line-prefix operation
- * in the given source viewer for text of the given content type. This implementation always
- * returns <code>null</code>.
- *
- * @param sourceViewer the source viewer to be configured by this configuration
- * @param contentType the content type for which the prefix is applicable
- * @return the default prefixes or <code>null</code> if the prefix operation should not be supported
- * @since 2.0
- */
- public String[] getDefaultPrefixes(ISourceViewer sourceViewer, String contentType) {
- return null;
- }
-
- /**
- * Returns the double-click strategy ready to be used in this viewer when double clicking
- * onto text of the given content type. This implementation always returns a new instance of
- * <code>DefaultTextDoubleClickStrategy</code>.
- *
- * @param sourceViewer the source viewer to be configured by this configuration
- * @param contentType the content type for which the strategy is applicable
- * @return a double-click strategy or <code>null</code> if double clicking should not be supported
- */
- public ITextDoubleClickStrategy getDoubleClickStrategy(ISourceViewer sourceViewer, String contentType) {
- return new DefaultTextDoubleClickStrategy();
- }
-
- /**
- * Returns the prefixes to be used by the line-shift operation. This implementation
- * always returns <code>new String[] { "\t", " " }</code>.
- *
- * @param sourceViewer the source viewer to be configured by this configuration
- * @param contentType the content type for which the prefix is applicable
- * @return the prefixes or <code>null</code> if the prefix operation should not be supported
- */
- public String[] getIndentPrefixes(ISourceViewer sourceViewer, String contentType) {
- return new String[] { "\t", " ", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- /**
- * Returns the annotation hover which will provide the information to be
- * shown in a hover popup window when requested for the given
- * source viewer.This implementation always returns <code>null</code>.
- *
- * @param sourceViewer the source viewer to be configured by this configuration
- * @return an annotation hover or <code>null</code> if no hover support should be installed
- */
- public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
- return null;
- }
-
- /**
- * Returns the annotation hover which will provide the information to be
- * shown in a hover popup window when requested for the overview ruler
- * of the given source viewer.This implementation always returns the general
- * annotation hover returned by <code>getAnnotationHover</code>.
- *
- * @param sourceViewer the source viewer to be configured by this configuration
- * @return an annotation hover or <code>null</code> if no hover support should be installed
- * @since 3.0
- */
- public IAnnotationHover getOverviewRulerAnnotationHover(ISourceViewer sourceViewer) {
- return getAnnotationHover(sourceViewer);
- }
-
- /**
- * Returns the SWT event state masks for which text hover are configured for
- * the given content type.
- *
- * @param sourceViewer the source viewer to be configured by this configuration
- * @param contentType the content type
- * @return an <code>int</code> array with the configured SWT event state masks
- * or <code>null</code> if text hovers are not supported for the given content type
- * @since 2.1
- */
- public int[] getConfiguredTextHoverStateMasks(ISourceViewer sourceViewer, String contentType) {
- return null;
- }
-
- /**
- * Returns the text hover which will provide the information to be shown
- * in a text hover popup window when requested for the given source viewer and
- * the given content type. This implementation always returns <code>
- * null</code>.
- *
- * @param sourceViewer the source viewer to be configured by this configuration
- * @param contentType the content type
- * @param stateMask the SWT event state mask
- * @return a text hover or <code>null</code> if no hover support should be installed
- * @since 2.1
- */
- public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType, int stateMask) {
- return null;
- }
-
- /**
- * Returns the text hover which will provide the information to be shown
- * in a text hover popup window when requested for the given source viewer and
- * the given content type. This implementation always returns <code>
- * null</code>.
- *
- * @param sourceViewer the source viewer to be configured by this configuration
- * @param contentType the content type
- * @return a text hover or <code>null</code> if no hover support should be installed
- */
- public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) {
- return null;
- }
-
- /**
- * Returns the information control creator. The creator is a factory creating information
- * controls for the given source viewer. This implementation always returns a creator for
- * <code>DefaultInformationControl</code> instances.
- *
- * @param sourceViewer the source viewer to be configured by this configuration
- * @return the information control creator or <code>null</code> if no information support should be installed
- * @since 2.0
- */
- public IInformationControlCreator getInformationControlCreator(ISourceViewer sourceViewer) {
- return new IInformationControlCreator() {
- public IInformationControl createInformationControl(Shell parent) {
- return new DefaultInformationControl(parent);
- }
- };
- }
-
- /**
- * Returns the information presenter which will determine and shown
- * information requested for the current cursor position. This implementation
- * always returns <code>null</code>.
- *
- * @param sourceViewer the source viewer to be configured by this configuration
- * @return an information presenter <code>null</code> if no information presenter should be installed
- * @since 2.0
- */
- public IInformationPresenter getInformationPresenter(ISourceViewer sourceViewer) {
- return null;
- }
-
- /**
- * Returns all configured content types for the given source viewer. This list
- * tells the caller which content types must be configured for the given source
- * viewer, i.e. for which content types the given source viewer's functionalities
- * must be specified. This implementation always returns <code>
- * new String[] { IDocument.DEFAULT_CONTENT_TYPE }</code>.
- *
- * @param sourceViewer the source viewer to be configured by this configuration
- * @return the configured content types for the given viewer
- */
- public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
- return new String[] { IDocument.DEFAULT_CONTENT_TYPE };
- }
-
- /**
- * Returns the configured partitioning for the given source viewer. The partitioning is
- * used when the querying content types from the source viewer's input document. This
- * implementation always returns <code>IDocumentExtension3.DEFAULT_PARTITIONING</code>.
- *
- * @param sourceViewer the source viewer to be configured by this configuration
- * @return the configured partitioning
- * @see #getConfiguredContentTypes(ISourceViewer)
- * @since 3.0
- */
- public String getConfiguredDocumentPartitioning(ISourceViewer sourceViewer) {
- return IDocumentExtension3.DEFAULT_PARTITIONING;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/TagHandlerFactory.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/TagHandlerFactory.java
deleted file mode 100644
index 0cac869..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/TagHandlerFactory.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.source;
-
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.jface.text.Assert;
-
-/**
- * Default implementation of a tag handler factory
- *
- * @since 3.0
- */
-public class TagHandlerFactory implements ITagHandlerFactory {
-
- private Map fHandlers;
-
- public void addTagHandler(String tag, ITagHandler handler) {
- Assert.isNotNull(tag);
- Assert.isNotNull(handler);
-
- fHandlers.put(tag, handler);
- }
-
- public ITagHandler registerHandler(String tag) {
- Assert.isNotNull(tag);
- return (ITagHandler)fHandlers.remove(tag);
- }
-
-
- /*
- * @see org.eclipse.jface.text.source.ITagHandlerFactory#getHandler(java.lang.String)
- */
- public ITagHandler getHandler(String tag) {
- Assert.isNotNull(tag);
-
- return (ITagHandler)fHandlers.get(tag);
- }
-
- /*
- * @see org.eclipse.jface.text.source.ITagHandlerFactory#findHandler(java.lang.String)
- */
- public ITagHandler findHandler(String text) {
- Assert.isNotNull(text);
-
- Iterator iter= fHandlers.values().iterator();
- while (iter.hasNext()) {
- ITagHandler handler= (ITagHandler)iter.next();
- if (handler.canHandleText(text))
- return handler;
- }
- return null;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/VerticalRuler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/VerticalRuler.java
deleted file mode 100644
index 6c2f73e..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/VerticalRuler.java
+++ /dev/null
@@ -1,569 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.source;
-
-
-
-
-import java.util.Iterator;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextListener;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.ITextViewerExtension5;
-import org.eclipse.jface.text.IViewportListener;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextEvent;
-
-
-/**
- * A vertical ruler which is connected to a text viewer. Single column standard
- * implementation of <code>IVerticalRuler</code>. The same can be achieved by
- * using <code>CompositeRuler</code> configured with an <code>AnnotationRulerColumn</code>.
- * Clients may use this class as is.
- *
- * @see ITextViewer
- */
-public final class VerticalRuler implements IVerticalRuler, IVerticalRulerExtension {
-
- /**
- * Internal listener class.
- */
- class InternalListener implements IViewportListener, IAnnotationModelListener, ITextListener {
-
- /*
- * @see IViewportListener#viewportChanged(int)
- */
- public void viewportChanged(int verticalPosition) {
- if (verticalPosition != fScrollPos)
- redraw();
- }
-
- /*
- * @see IAnnotationModelListener#modelChanged(IAnnotationModel)
- */
- public void modelChanged(IAnnotationModel model) {
- update();
- }
-
- /*
- * @see ITextListener#textChanged(TextEvent)
- */
- public void textChanged(TextEvent e) {
- if (fTextViewer != null && e.getViewerRedrawState())
- redraw();
- }
- }
-
- /** The vertical ruler's text viewer */
- private ITextViewer fTextViewer;
- /** The ruler's canvas */
- private Canvas fCanvas;
- /** The vertical ruler's model */
- private IAnnotationModel fModel;
- /** Cache for the actual scroll position in pixels */
- private int fScrollPos;
- /** The drawable for double buffering */
- private Image fBuffer;
- /** The line of the last mouse button activity */
- private int fLastMouseButtonActivityLine= -1;
- /** The internal listener */
- private InternalListener fInternalListener= new InternalListener();
- /** The width of this vertical ruler */
- private int fWidth;
- /**
- * The annotation access of this vertical ruler
- * @since 3.0
- */
- private IAnnotationAccess fAnnotationAccess;
-
- /**
- * Constructs a vertical ruler with the given width.
- *
- * @param width the width of the vertical ruler
- */
- public VerticalRuler(int width) {
- this(width, null);
- }
-
- /**
- * Constructs a vertical ruler with the given width and the given annotation
- * access.
- *
- * @param width the width of the vertical ruler
- * @param annotationAcccess the annotation access
- */
- public VerticalRuler(int width, IAnnotationAccess annotationAcccess) {
- fWidth= width;
- fAnnotationAccess= annotationAcccess;
- }
-
- /*
- * @see IVerticalRuler#getControl()
- */
- public Control getControl() {
- return fCanvas;
- }
-
- /*
- * @see IVerticalRuler#createControl(Composite, ITextViewer)
- */
- public Control createControl(Composite parent, ITextViewer textViewer) {
-
- fTextViewer= textViewer;
-
- fCanvas= new Canvas(parent, SWT.NO_BACKGROUND);
-
- fCanvas.addPaintListener(new PaintListener() {
- public void paintControl(PaintEvent event) {
- if (fTextViewer != null)
- doubleBufferPaint(event.gc);
- }
- });
-
- fCanvas.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- handleDispose();
- fTextViewer= null;
- }
- });
-
- fCanvas.addMouseListener(new MouseListener() {
- public void mouseUp(MouseEvent event) {
- }
-
- public void mouseDown(MouseEvent event) {
- fLastMouseButtonActivityLine= toDocumentLineNumber(event.y);
- }
-
- public void mouseDoubleClick(MouseEvent event) {
- fLastMouseButtonActivityLine= toDocumentLineNumber(event.y);
- }
- });
-
- if (fTextViewer != null) {
- fTextViewer.addViewportListener(fInternalListener);
- fTextViewer.addTextListener(fInternalListener);
- }
-
- return fCanvas;
- }
-
- /**
- * Disposes the ruler's resources.
- */
- private void handleDispose() {
-
- if (fTextViewer != null) {
- fTextViewer.removeViewportListener(fInternalListener);
- fTextViewer.removeTextListener(fInternalListener);
- fTextViewer= null;
- }
-
- if (fModel != null)
- fModel.removeAnnotationModelListener(fInternalListener);
-
- if (fBuffer != null) {
- fBuffer.dispose();
- fBuffer= null;
- }
- }
-
-
- /**
- * Double buffer drawing.
- *
- * @param dest the gc to draw into
- */
- private void doubleBufferPaint(GC dest) {
-
- Point size= fCanvas.getSize();
-
- if (size.x <= 0 || size.y <= 0)
- return;
-
- if (fBuffer != null) {
- Rectangle r= fBuffer.getBounds();
- if (r.width != size.x || r.height != size.y) {
- fBuffer.dispose();
- fBuffer= null;
- }
- }
- if (fBuffer == null)
- fBuffer= new Image(fCanvas.getDisplay(), size.x, size.y);
-
- GC gc= new GC(fBuffer);
- gc.setFont(fTextViewer.getTextWidget().getFont());
- try {
- gc.setBackground(fCanvas.getBackground());
- gc.fillRectangle(0, 0, size.x, size.y);
-
- if (fTextViewer instanceof ITextViewerExtension5)
- doPaint1(gc);
- else
- doPaint(gc);
-
- } finally {
- gc.dispose();
- }
-
- dest.drawImage(fBuffer, 0, 0);
- }
-
- /**
- * Returns the document offset of the upper left corner of the
- * widgets viewport, possibly including partially visible lines.
- *
- * @return the document offset of the upper left corner including partially visible lines
- * @since 2.0
- */
- private int getInclusiveTopIndexStartOffset() {
-
- StyledText textWidget= fTextViewer.getTextWidget();
- if (textWidget != null && !textWidget.isDisposed()) {
- int top= fTextViewer.getTopIndex();
- if ((textWidget.getTopPixel() % textWidget.getLineHeight()) != 0)
- top--;
- try {
- IDocument document= fTextViewer.getDocument();
- return document.getLineOffset(top);
- } catch (BadLocationException ex) {
- }
- }
-
- return -1;
- }
-
- /**
- * Draws the vertical ruler w/o drawing the Canvas background.
- *
- * @param gc the gc to draw into
- */
- protected void doPaint(GC gc) {
-
- if (fModel == null || fTextViewer == null)
- return;
-
- IAnnotationAccessExtension annotationAccessExtension= null;
- if (fAnnotationAccess instanceof IAnnotationAccessExtension)
- annotationAccessExtension= (IAnnotationAccessExtension) fAnnotationAccess;
-
- StyledText styledText= fTextViewer.getTextWidget();
- IDocument doc= fTextViewer.getDocument();
-
- int topLeft= getInclusiveTopIndexStartOffset();
- int bottomRight= fTextViewer.getBottomIndexEndOffset();
- int viewPort= bottomRight - topLeft;
-
- Point d= fCanvas.getSize();
- fScrollPos= styledText.getTopPixel();
- int lineheight= styledText.getLineHeight();
-
- int shift= fTextViewer.getTopInset();
-
- int topLine= -1, bottomLine= -1;
- try {
- IRegion region= fTextViewer.getVisibleRegion();
- topLine= doc.getLineOfOffset(region.getOffset());
- bottomLine= doc.getLineOfOffset(region.getOffset() + region.getLength());
- } catch (BadLocationException x) {
- return;
- }
-
- // draw Annotations
- Rectangle r= new Rectangle(0, 0, 0, 0);
- int maxLayer= 1; // loop at least once thru layers.
-
- for (int layer= 0; layer < maxLayer; layer++) {
- Iterator iter= fModel.getAnnotationIterator();
- while (iter.hasNext()) {
- Annotation annotation= (Annotation) iter.next();
-
- int lay= IAnnotationAccessExtension.DEFAULT_LAYER;
- if (annotationAccessExtension != null)
- lay= annotationAccessExtension.getLayer(annotation);
- maxLayer= Math.max(maxLayer, lay+1); // dynamically update layer maximum
- if (lay != layer) // wrong layer: skip annotation
- continue;
-
- Position position= fModel.getPosition(annotation);
- if (position == null)
- continue;
-
- if (!position.overlapsWith(topLeft, viewPort))
- continue;
-
- try {
-
- int offset= position.getOffset();
- int length= position.getLength();
-
- int startLine= doc.getLineOfOffset(offset);
- if (startLine < topLine)
- startLine= topLine;
-
- int endLine= startLine;
- if (length > 0)
- endLine= doc.getLineOfOffset(offset + length - 1);
- if (endLine > bottomLine)
- endLine= bottomLine;
-
- startLine -= topLine;
- endLine -= topLine;
-
- r.x= 0;
- r.y= (startLine * lineheight) - fScrollPos + shift;
- r.width= d.x;
- int lines= endLine - startLine;
- if (lines < 0)
- lines= -lines;
- r.height= (lines+1) * lineheight;
-
- if (r.y < d.y && annotationAccessExtension != null) // annotation within visible area
- annotationAccessExtension.paint(annotation, gc, fCanvas, r);
-
- } catch (BadLocationException e) {
- }
- }
- }
- }
-
- /**
- * Draws the vertical ruler w/o drawing the Canvas background. Uses
- * <code>ITextViewerExtension5</code> for its implementation. Will replace
- * <code>doPaint(GC)</code>.
- *
- * @param gc the gc to draw into
- */
- protected void doPaint1(GC gc) {
-
- if (fModel == null || fTextViewer == null)
- return;
-
- IAnnotationAccessExtension annotationAccessExtension= null;
- if (fAnnotationAccess instanceof IAnnotationAccessExtension)
- annotationAccessExtension= (IAnnotationAccessExtension) fAnnotationAccess;
-
- ITextViewerExtension5 extension= (ITextViewerExtension5) fTextViewer;
- StyledText textWidget= fTextViewer.getTextWidget();
-
- fScrollPos= textWidget.getTopPixel();
- int lineheight= textWidget.getLineHeight();
- Point dimension= fCanvas.getSize();
- int shift= fTextViewer.getTopInset();
-
- // draw Annotations
- Rectangle r= new Rectangle(0, 0, 0, 0);
- int maxLayer= 1; // loop at least once thru layers.
-
- for (int layer= 0; layer < maxLayer; layer++) {
- Iterator iter= fModel.getAnnotationIterator();
- while (iter.hasNext()) {
- Annotation annotation= (Annotation) iter.next();
-
- int lay= IAnnotationAccessExtension.DEFAULT_LAYER;
- if (annotationAccessExtension != null)
- lay= annotationAccessExtension.getLayer(annotation);
- maxLayer= Math.max(maxLayer, lay+1); // dynamically update layer maximum
- if (lay != layer) // wrong layer: skip annotation
- continue;
-
- Position position= fModel.getPosition(annotation);
- if (position == null)
- continue;
-
- IRegion widgetRegion= extension.modelRange2WidgetRange(new Region(position.getOffset(), position.getLength()));
- if (widgetRegion == null)
- continue;
-
- int startLine= extension.widgetLineOfWidgetOffset(widgetRegion.getOffset());
- if (startLine == -1)
- continue;
-
- int endLine= extension.widgetLineOfWidgetOffset(widgetRegion.getOffset() + Math.max(widgetRegion.getLength() -1, 0));
- if (endLine == -1)
- continue;
-
- r.x= 0;
- r.y= (startLine * lineheight) - fScrollPos + shift;
- r.width= dimension.x;
- int lines= endLine - startLine;
- if (lines < 0)
- lines= -lines;
- r.height= (lines+1) * lineheight;
-
- if (r.y < dimension.y && annotationAccessExtension != null) // annotation within visible area
- annotationAccessExtension.paint(annotation, gc, fCanvas, r);
- }
- }
- }
-
- /**
- * Thread-safe implementation.
- * Can be called from any thread.
- */
- /*
- * @see IVerticalRuler#update()
- */
- public void update() {
- if (fCanvas != null && !fCanvas.isDisposed()) {
- Display d= fCanvas.getDisplay();
- if (d != null) {
- d.asyncExec(new Runnable() {
- public void run() {
- redraw();
- }
- });
- }
- }
- }
-
- /**
- * Redraws the vertical ruler.
- */
- private void redraw() {
- if (fCanvas != null && !fCanvas.isDisposed()) {
- GC gc= new GC(fCanvas);
- doubleBufferPaint(gc);
- gc.dispose();
- }
- }
-
- /*
- * @see IVerticalRuler#setModel(IAnnotationModel)
- */
- public void setModel(IAnnotationModel model) {
- if (model != fModel) {
-
- if (fModel != null)
- fModel.removeAnnotationModelListener(fInternalListener);
-
- fModel= model;
-
- if (fModel != null)
- fModel.addAnnotationModelListener(fInternalListener);
-
- update();
- }
- }
-
- /*
- * @see IVerticalRuler#getModel()
- */
- public IAnnotationModel getModel() {
- return fModel;
- }
-
- /*
- * @see IVerticalRulerInfo#getWidth()
- */
- public int getWidth() {
- return fWidth;
- }
-
- /*
- * @see IVerticalRulerInfo#getLineOfLastMouseButtonActivity()
- */
- public int getLineOfLastMouseButtonActivity() {
- return fLastMouseButtonActivityLine;
- }
-
- /*
- * @see IVerticalRulerInfo#toDocumentLineNumber(int)
- */
- public int toDocumentLineNumber(int y_coordinate) {
-
- if (fTextViewer == null)
- return -1;
-
- StyledText text= fTextViewer.getTextWidget();
- int line= ((y_coordinate + fScrollPos) / text.getLineHeight());
- return widgetLine2ModelLine(fTextViewer, line);
- }
-
- /**
- * Returns the line of the viewer's document that corresponds to the given widget line.
- *
- * @param viewer the viewer
- * @param widgetLine the widget line
- * @return the corresponding line of the viewer's document
- * @since 2.1
- */
- protected final static int widgetLine2ModelLine(ITextViewer viewer, int widgetLine) {
-
- if (viewer instanceof ITextViewerExtension5) {
- ITextViewerExtension5 extension= (ITextViewerExtension5) viewer;
- return extension.widgetlLine2ModelLine(widgetLine);
- }
-
- try {
- IRegion r= viewer.getVisibleRegion();
- IDocument d= viewer.getDocument();
- return widgetLine += d.getLineOfOffset(r.getOffset());
- } catch (BadLocationException x) {
- }
- return widgetLine;
- }
-
- /*
- * @see IVerticalRulerExtension#setFont(Font)
- * @since 2.0
- */
- public void setFont(Font font) {
- }
-
- /*
- * @see IVerticalRulerExtension#setLocationOfLastMouseButtonActivity(int, int)
- * @since 2.0
- */
- public void setLocationOfLastMouseButtonActivity(int x, int y) {
- fLastMouseButtonActivityLine= toDocumentLineNumber(y);
- }
-
- /**
- * @deprecated will be removed
- * @since 2.0
- */
- public void addMouseListener(MouseListener listener) {
- if (fCanvas != null && !fCanvas.isDisposed())
- fCanvas.addMouseListener(listener);
- }
-
- /**
- * @deprecated will be removed
- * @since 2.0
- */
- public void removeMouseListener(MouseListener listener) {
- if (fCanvas != null && !fCanvas.isDisposed())
- fCanvas.removeMouseListener(listener);
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/VisualAnnotationModel.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/VisualAnnotationModel.java
deleted file mode 100644
index f757c30..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/VisualAnnotationModel.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.source;
-
-
-
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.Position;
-
-
-
-/**
- * Annotation model for visual annotations. Assume a viewer's input element is annotated with
- * some semantic annotation such as a breakpoint and that it is simultanously shown in multiple
- * viewers. A source viewer, e.g., supports visual range indication for which it utilizes
- * annotations. The range indicating annotation is specific to the visual presentation
- * of the input element in this viewer and thus should only be visible in this viewer. The
- * breakpoints however are independent from the input element's presentation and thus should
- * be shown in all viewers in which the element is shown. As a viewer supports one vertical
- * ruler which is based on one annotation model, there must be a visual annotation model for
- * each viewer which all wrap the same element specific model annotation model.
- */
-class VisualAnnotationModel extends AnnotationModel implements IAnnotationModelListener {
-
- /** The wrapped model annotation model */
- private IAnnotationModel fModel;
-
- /**
- * Constructs a visual annotation model which wraps the given
- * model based annotation model
- *
- * @param modelAnnotationModel the model based annotation model
- */
- public VisualAnnotationModel(IAnnotationModel modelAnnotationModel) {
- fModel= modelAnnotationModel;
- }
-
- /**
- * Returns the visual annotation model's wrapped model based annotation model.
- *
- * @return the model based annotation model
- */
- public IAnnotationModel getModelAnnotationModel() {
- return fModel;
- }
-
- /*
- * @see IAnnotationModel#addAnnotationModelListener(IAnnotationModelListener)
- */
- public void addAnnotationModelListener(IAnnotationModelListener listener) {
-
- if (fModel != null && fAnnotationModelListeners.isEmpty())
- fModel.addAnnotationModelListener(this);
-
- super.addAnnotationModelListener(listener);
- }
-
- /*
- * @see IAnnotationModel#connect(IDocument)
- */
- public void connect(IDocument document) {
- super.connect(document);
- if (fModel != null)
- fModel.connect(document);
- }
-
- /*
- * @see IAnnotationModel#disconnect(IDocument)
- */
- public void disconnect(IDocument document) {
- super.disconnect(document);
- if (fModel != null)
- fModel.disconnect(document);
- }
-
- /*
- * @see IAnnotationModel#getAnnotationIterator()
- */
- public Iterator getAnnotationIterator() {
-
- if (fModel == null)
- return super.getAnnotationIterator();
-
- ArrayList a= new ArrayList(20);
-
- Iterator e= fModel.getAnnotationIterator();
- while (e.hasNext())
- a.add(e.next());
-
- e= super.getAnnotationIterator();
- while (e.hasNext())
- a.add(e.next());
-
- return a.iterator();
- }
-
- /*
- * @see IAnnotationModel#getPosition(Annotation)
- */
- public Position getPosition(Annotation annotation) {
-
- Position p= (Position) getAnnotationMap().get(annotation);
- if (p != null)
- return p;
-
- if (fModel != null)
- return fModel.getPosition(annotation);
-
- return null;
- }
-
- /*
- * @see IAnnotationModelListener#modelChanged(IAnnotationModel)
- */
- public void modelChanged(IAnnotationModel model) {
- if (model == fModel) {
- Iterator iter= new ArrayList(fAnnotationModelListeners).iterator();
- while (iter.hasNext()) {
- IAnnotationModelListener l= (IAnnotationModelListener)iter.next();
- l.modelChanged(this);
- }
- }
- }
-
- /*
- * @see IAnnotationModel#removeAnnotationModelListener(IAnnotationModelListener)
- */
- public void removeAnnotationModelListener(IAnnotationModelListener listener) {
- super.removeAnnotationModelListener(listener);
-
- if (fModel != null && fAnnotationModelListeners.isEmpty())
- fModel.removeAnnotationModelListener(this);
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/package.html b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/package.html
deleted file mode 100644
index e03b194..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/package.html
+++ /dev/null
@@ -1,26 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="Author" content="IBM">
- <meta name="GENERATOR" content="Mozilla/4.51 [en] (WinNT; I) [Netscape]">
- <title>Package-level Javadoc</title>
-</head>
-<body>
-Provides a framework for connecting document regions
-with annotations and for displaying those annotations in combination with
-an <tt>ITextViewer</tt>. <tt>ISourceViewer</tt> combines annotation support
-and all text viewer add-ons.
-<h2>
-Package Specification</h2>
- <tt>ISourceViewer</tt> defines the concept of a document based, editable
-viewer supporting visual annotations. <tt>ISourceViewer</tt> supports document-specific
-and viewer-specific annotations attached to the viewer's input document.
-An <tt>ISourceViewer</tt> uses an <tt>IAnnotationModel</tt> to manage annotations
-and to inform implementers of <tt>IAnnotationModelListener</tt> about changes
-in respect to annotations. An <tt>IVerticalRuler</tt> represents an <tt>IAnnotationModel</tt>
-access adapter for an SWT widget capapble of display annotations.
-This package also provides default implementations for all defined interfaces.
-<br>
-</body>
-</html>
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/ContextTypeRegistry.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/ContextTypeRegistry.java
deleted file mode 100644
index 85161cc..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/ContextTypeRegistry.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.templates;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.Platform;
-
-import org.eclipse.jface.text.Assert;
-
-/**
- * A registry for context types. Editor implementors will usually instantiate a
- * registry and configure the context types available in their editor.
- * <code>ContextType</code>s can be added either directly using
- * {@link #addContextType(ContextType)} or by instantiating and adding a
- * contributed context type using {@link #addContextType(String)}.
- *
- * @since 3.0
- */
-public class ContextTypeRegistry {
-
- /* extension point string literals */
- private static final String TEMPLATES_EXTENSION_POINT= "org.eclipse.ui.editors.templates"; //$NON-NLS-1$
-
- private static final String CONTEXT_TYPE= "contextType"; //$NON-NLS-1$
- private static final String ID= "id"; //$NON-NLS-1$
- private static final String NAME= "name"; //$NON-NLS-1$
- private static final String CLASS= "class"; //$NON-NLS-1$
-
- private static final String RESOLVER= "resolver"; //$NON-NLS-1$
- private static final String CONTEXT_TYPE_ID= "contextTypeId"; //$NON-NLS-1$
- private static final String DESCRIPTION= "description"; //$NON-NLS-1$
- private static final String TYPE= "type"; //$NON-NLS-1$
-
- /** all known context types */
- private final Map fContextTypes= new HashMap();
-
- /**
- * Adds a context type to the registry.
- *
- * @param contextType the context type to add
- */
- public void addContextType(ContextType contextType) {
- fContextTypes.put(contextType.getId(), contextType);
- }
-
- /**
- * Returns the context type if the id is valid, <code>null</code> otherwise.
- *
- * @param id the id of the context type to retrieve
- * @return the context type if <code>name</code> is valid, <code>null</code> otherwise
- */
- public ContextType getContextType(String id) {
- return (ContextType) fContextTypes.get(id);
- }
-
- /**
- * Returns an iterator over all registered context types.
- *
- * @return an iterator over all registered context types
- */
- public Iterator contextTypes() {
- return fContextTypes.values().iterator();
- }
-
- /**
- * Tries to create a context type given an id. If there is already a context
- * type registered under <code>id</code>, nothing happens. Otherwise,
- * contributions to the <code>org.eclipse.ui.editors.templates</code>
- * extension point are searched for the given identifier and the specified
- * context type instantiated if it is found.
- *
- * @param id the id for the context type as specified in XML
- */
- public void addContextType(String id) {
- Assert.isNotNull(id);
- if (fContextTypes.containsKey(id))
- return;
-
- ContextType type= createContextType(id);
- if (type != null)
- addContextType(type);
-
- }
-
- /**
- * Tries to create a context type given an id. Contributions to the
- * <code>org.eclipse.ui.editors.templates</code> extension point are
- * searched for the given identifier and the specified context type
- * instantiated if it is found. Any contributed
- * <code>TemplateVariableResolver</code> s are also instantiated and added
- * to the context type.
- *
- * @param id the id for the context type as specified in XML
- * @return the instantiated and configured context type, or <code>null</code> if it is not found or cannot be instantiated
- */
- public static ContextType createContextType(String id) {
- Assert.isNotNull(id);
-
- IConfigurationElement[] extensions= getTemplateExtensions();
- ContextType type= createContextType(extensions, id);
-
- if (type != null) {
- TemplateVariableResolver[] resolvers= createResolvers(extensions, id);
- for (int i= 0; i < resolvers.length; i++)
- type.addResolver(resolvers[i]);
- }
-
- return type;
- }
-
- private static ContextType createContextType(IConfigurationElement[] extensions, String contextTypeId) {
- for (int i= 0; i < extensions.length; i++) {
- // TODO create half-order over contributions
- if (extensions[i].getName().equals(CONTEXT_TYPE)) {
- String id= extensions[i].getAttributeAsIs(ID);
- if (contextTypeId.equals(id))
- return createContextType(extensions[i]);
- }
- }
-
- return null;
- }
-
- private static TemplateVariableResolver[] createResolvers(IConfigurationElement[] extensions, String contextTypeId) {
- List resolvers= new ArrayList();
- for (int i= 0; i < extensions.length; i++) {
- if (extensions[i].getName().equals(RESOLVER)) {
- String declaredId= extensions[i].getAttributeAsIs(CONTEXT_TYPE_ID);
- if (contextTypeId.equals(declaredId)) {
- TemplateVariableResolver resolver= createResolver(extensions[i]);
- if (resolver != null)
- resolvers.add(resolver);
- }
- }
- }
-
- return (TemplateVariableResolver[]) resolvers.toArray(new TemplateVariableResolver[resolvers.size()]);
-
- }
-
- private static IConfigurationElement[] getTemplateExtensions() {
- return Platform.getExtensionRegistry().getConfigurationElementsFor(TEMPLATES_EXTENSION_POINT);
- }
-
- private static ContextType createContextType(IConfigurationElement element) {
- String id= element.getAttributeAsIs(ID);
- try {
- ContextType contextType= (ContextType) element.createExecutableExtension(CLASS);
- String name= element.getAttribute(NAME);
- if (name == null)
- name= id;
-
- contextType.setId(id);
- contextType.setName(name);
-
- return contextType;
- } catch (ClassCastException e) {
- // ignore
- } catch (CoreException e) {
- // ignore
- }
- return null;
- }
-
- private static TemplateVariableResolver createResolver(IConfigurationElement element) {
- try {
- String type= element.getAttributeAsIs(TYPE);
- if (type != null) {
-
- TemplateVariableResolver resolver= (TemplateVariableResolver) element.createExecutableExtension(CLASS);
- resolver.setType(type);
-
- String desc= element.getAttribute(DESCRIPTION);
- if (desc == null)
- desc= new String();
- resolver.setDescription(desc);
-
- return resolver;
- }
- } catch (CoreException e) {
- // ignore
- } catch (ClassCastException e) {
- // ignore
- }
-
- return null;
- }
-
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/PositionBasedCompletionProposal.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/PositionBasedCompletionProposal.java
deleted file mode 100644
index 7e5970e..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/PositionBasedCompletionProposal.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.templates;
-
-
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.contentassist.ICompletionProposalExtension2;
-import org.eclipse.jface.text.contentassist.IContextInformation;
-
-
-/**
- * An enhanced implementation of the <code>ICompletionProposal</code> interface implementing all the extension interfaces.
- */
-final class PositionBasedCompletionProposal implements ICompletionProposal, ICompletionProposalExtension2 {
-
- /** The string to be displayed in the completion proposal popup */
- private String fDisplayString;
- /** The replacement string */
- private String fReplacementString;
- /** The replacement position. */
- private Position fReplacementPosition;
- /** The cursor position after this proposal has been applied */
- private int fCursorPosition;
- /** The image to be displayed in the completion proposal popup */
- private Image fImage;
- /** The context information of this proposal */
- private IContextInformation fContextInformation;
- /** The additional info of this proposal */
- private String fAdditionalProposalInfo;
-
- /**
- * Creates a new completion proposal based on the provided information. The replacement string is
- * considered being the display string too. All remaining fields are set to <code>null</code>.
- *
- * @param replacementString the actual string to be inserted into the document
- * @param replacementPosition the position of the text to be replaced
- * @param cursorPosition the position of the cursor following the insert relative to replacementOffset
- */
- public PositionBasedCompletionProposal(String replacementString, Position replacementPosition, int cursorPosition) {
- this(replacementString, replacementPosition, cursorPosition, null, null, null, null);
- }
-
- /**
- * Creates a new completion proposal. All fields are initialized based on the provided information.
- *
- * @param replacementString the actual string to be inserted into the document
- * @param replacementPosition the position of the text to be replaced
- * @param cursorPosition the position of the cursor following the insert relative to replacementOffset
- * @param image the image to display for this proposal
- * @param displayString the string to be displayed for the proposal
- * @param contextInformation the context information associated with this proposal
- * @param additionalProposalInfo the additional information associated with this proposal
- */
- public PositionBasedCompletionProposal(String replacementString, Position replacementPosition, int cursorPosition, Image image, String displayString, IContextInformation contextInformation, String additionalProposalInfo) {
- Assert.isNotNull(replacementString);
- Assert.isTrue(replacementPosition != null);
-
- fReplacementString= replacementString;
- fReplacementPosition= replacementPosition;
- fCursorPosition= cursorPosition;
- fImage= image;
- fDisplayString= displayString;
- fContextInformation= contextInformation;
- fAdditionalProposalInfo= additionalProposalInfo;
- }
-
- /*
- * @see ICompletionProposal#apply(IDocument)
- */
- public void apply(IDocument document) {
- try {
- document.replace(fReplacementPosition.getOffset(), fReplacementPosition.getLength(), fReplacementString);
- } catch (BadLocationException x) {
- // ignore
- }
- }
-
- /*
- * @see ICompletionProposal#getSelection(IDocument)
- */
- public Point getSelection(IDocument document) {
- return new Point(fReplacementPosition.getOffset() + fCursorPosition, 0);
- }
-
- /*
- * @see ICompletionProposal#getContextInformation()
- */
- public IContextInformation getContextInformation() {
- return fContextInformation;
- }
-
- /*
- * @see ICompletionProposal#getImage()
- */
- public Image getImage() {
- return fImage;
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getDisplayString()
- */
- public String getDisplayString() {
- if (fDisplayString != null)
- return fDisplayString;
- return fReplacementString;
- }
-
- /*
- * @see ICompletionProposal#getAdditionalProposalInfo()
- */
- public String getAdditionalProposalInfo() {
- return fAdditionalProposalInfo;
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#apply(org.eclipse.jface.text.ITextViewer, char, int, int)
- */
- public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) {
- apply(viewer.getDocument());
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#selected(org.eclipse.jface.text.ITextViewer, boolean)
- */
- public void selected(ITextViewer viewer, boolean smartToggle) {
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#unselected(org.eclipse.jface.text.ITextViewer)
- */
- public void unselected(ITextViewer viewer) {
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#validate(org.eclipse.jface.text.IDocument, int, org.eclipse.jface.text.DocumentEvent)
- */
- public boolean validate(IDocument document, int offset, DocumentEvent event) {
- try {
- String content= document.get(fReplacementPosition.getOffset(), fReplacementPosition.getLength());
- if (content.startsWith(fReplacementString))
- return true;
- } catch (BadLocationException e) {
- // ignore concurrently modified document
- }
- return false;
- }
-
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/TemplateCompletionProcessor.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/TemplateCompletionProcessor.java
deleted file mode 100644
index da1a99d..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/TemplateCompletionProcessor.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.templates;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
-import org.eclipse.swt.graphics.Image;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.text.contentassist.IContextInformation;
-import org.eclipse.jface.text.contentassist.IContextInformationValidator;
-
-
-/**
- * A completion processor that computes template proposals.
- *
- * @since 3.0
- */
-public abstract class TemplateCompletionProcessor implements IContentAssistProcessor {
-
- private static final class ProposalComparator implements Comparator {
- public int compare(Object o1, Object o2) {
- return ((TemplateProposal) o2).getRelevance() - ((TemplateProposal) o1).getRelevance();
- }
- }
-
- private static final Comparator fgProposalComparator= new ProposalComparator();
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeCompletionProposals(org.eclipse.jface.text.ITextViewer,
- * int)
- */
- public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
-
- ITextSelection selection= (ITextSelection) viewer.getSelectionProvider().getSelection();
-
- // adjust offset to end of normalized selection
- if (selection.getOffset() == offset)
- offset= selection.getOffset() + selection.getLength();
-
- String prefix= extractPrefix(viewer, offset);
- Region region= new Region(offset - prefix.length(), prefix.length());
- TemplateContext context= createContext(viewer, region);
- if (context == null)
- return new ICompletionProposal[0];
-
- context.setVariable("selection", selection.getText()); // name of the selection variables {line, word}_selection //$NON-NLS-1$
-
- Template[] templates= getTemplates(context.getContextType().getId());
-
- List matches= new ArrayList();
- for (int i= 0; i < templates.length; i++) {
- Template template= templates[i];
- if (context.getContextType().validate(template.getPattern()) != null)
- continue;
- if (template.matches(prefix, context.getContextType().getId()))
- matches.add(new TemplateProposal(template, context, region, getImage(template), getRelevance(template, prefix)));
- }
-
- Collections.sort(matches, fgProposalComparator);
-
- return (ICompletionProposal[]) matches.toArray(new ICompletionProposal[matches.size()]);
- }
-
- /**
- * Returns the templates valid for the context type specified by <code>contextTypeId</code>.
- *
- * @param contextTypeId the context type id
- * @return the templates valid for this context type id
- */
- protected abstract Template[] getTemplates(String contextTypeId);
-
- /**
- * Creates a concrete template context for the given region in the document. This involves finding out which
- * context type is valid at the given location, and then creating a context of this type. The default implementation
- * returns a <code>DocumentTemplateContext</code> for the context type at the given location.
- *
- * @param viewer the viewer for which the context is created
- * @param region the region into <code>document</code> for which the context is created
- * @return a template context that can handle template insertion at the given location, or <code>null</code>
- */
- protected TemplateContext createContext(ITextViewer viewer, IRegion region) {
- ContextType contextType= getContextType(viewer, region);
- if (contextType != null) {
- IDocument document= viewer.getDocument();
- return new DocumentTemplateContext(contextType, document, region.getOffset(), region.getLength());
- }
- return null;
- }
-
- /**
- * Returns the context type that can handle template insertion at the given region
- * in the viewer's document.
- *
- * @param viewer the text viewer
- * @param region the region into the document displayed by viewer
- * @return the context type that can handle template expansion for the given location, or <code>null</code> if none exists
- */
- protected abstract ContextType getContextType(ITextViewer viewer, IRegion region);
-
- /**
- * Returns the relevance of a template given a prefix. The default
- * implementation returns a number greater than zero if the template name
- * starts with the prefix, and zero otherwise.
- *
- * @param template the template to compute the relevance for
- * @param prefix the prefix after which content assist was requested
- * @return the relevance of <code>template</code>
- * @see #extractPrefix(ITextViewer, int)
- */
- protected int getRelevance(Template template, String prefix) {
- if (template.getName().startsWith(prefix))
- return 90;
- return 0;
- }
-
- /**
- * Heuristically extracts the prefix used for determining template relevance
- * from the viewer's document. The default implementation returns the String from
- * offset backwards that forms a java identifier.
- *
- * @param viewer the viewer
- * @param offset offset into document
- * @return the prefix to consider
- * @see #getRelevance(Template, String)
- */
- protected String extractPrefix(ITextViewer viewer, int offset) {
- int i= offset;
- IDocument document= viewer.getDocument();
- if (i > document.getLength())
- return ""; //$NON-NLS-1$
-
- try {
- while (i > 0) {
- char ch= document.getChar(i - 1);
- if (!Character.isJavaIdentifierPart(ch))
- break;
- i--;
- }
-
- return document.get(i, offset - i);
- } catch (BadLocationException e) {
- return ""; //$NON-NLS-1$
- }
- }
-
- /**
- * Returns the image to be used for the proposal for <code>template</code>.
- *
- * @param template the template for which an image should be returned
- * @return the image for <code>template</code>
- */
- protected abstract Image getImage(Template template);
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeContextInformation(org.eclipse.jface.text.ITextViewer, int)
- */
- public IContextInformation[] computeContextInformation(ITextViewer viewer, int documentOffset) {
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getCompletionProposalAutoActivationCharacters()
- */
- public char[] getCompletionProposalAutoActivationCharacters() {
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationAutoActivationCharacters()
- */
- public char[] getContextInformationAutoActivationCharacters() {
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getErrorMessage()
- */
- public String getErrorMessage() {
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationValidator()
- */
- public IContextInformationValidator getContextInformationValidator() {
- return null;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/TemplateProposal.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/TemplateProposal.java
deleted file mode 100644
index 0e0abcc..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/TemplateProposal.java
+++ /dev/null
@@ -1,385 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.templates;
-
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.jface.dialogs.MessageDialog;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IInformationControlCreator;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.Region;
-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.ICompletionProposalExtension3;
-import org.eclipse.jface.text.contentassist.IContextInformation;
-import org.eclipse.jface.text.link.ILinkedListener;
-import org.eclipse.jface.text.link.InclusivePositionUpdater;
-import org.eclipse.jface.text.link.LinkedEnvironment;
-import org.eclipse.jface.text.link.LinkedPosition;
-import org.eclipse.jface.text.link.LinkedPositionGroup;
-import org.eclipse.jface.text.link.LinkedUIControl;
-import org.eclipse.jface.text.link.ProposalPosition;
-
-
-/**
- * A template proposal.
- *
- * XXX This is work in progress.
- *
- * @since 3.0
- */
-public class TemplateProposal implements ICompletionProposal, ICompletionProposalExtension, ICompletionProposalExtension2, ICompletionProposalExtension3 {
-
- private final Template fTemplate;
- private final TemplateContext fContext;
- private final Image fImage;
- private final IRegion fRegion;
- private int fRelevance;
-
- private IRegion fSelectedRegion; // initialized by apply()
- private String fDisplayString;
-
- /**
- * Creates a template proposal with a template and its context.
- * @param template the template
- * @param context the context in which the template was requested.
- * @param region the region this proposal is applied to
- * @param image the icon of the proposal.
- */
- public TemplateProposal(Template template, TemplateContext context, IRegion region, Image image) {
- this(template, context, region, image, 0);
- }
-
- /**
- * Creates a template proposal with a template and its context.
- * @param template the template
- * @param context the context in which the template was requested.
- * @param image the icon of the proposal.
- * @param region the region this proposal is applied to
- * @param relevance the relevance of the proposal
- */
- public TemplateProposal(Template template, TemplateContext context, IRegion region, Image image, int relevance) {
- Assert.isNotNull(template);
- Assert.isNotNull(context);
- Assert.isNotNull(region);
-
- fTemplate= template;
- fContext= context;
- fImage= image;
- fRegion= region;
-
- fDisplayString= null;
-
- fRelevance= relevance;
- }
-
- /*
- * @see ICompletionProposal#apply(IDocument)
- */
- public final void apply(IDocument document) {
- // not called anymore
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#apply(org.eclipse.jface.text.ITextViewer, char, int, int)
- */
- public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) {
-
- try {
- fContext.setReadOnly(false);
- TemplateBuffer templateBuffer= fContext.evaluate(fTemplate);
- if (templateBuffer == null) {
- fSelectedRegion= fRegion;
- return;
- }
-
- int start, end;
- if (fContext instanceof DocumentTemplateContext) {
- DocumentTemplateContext docContext = (DocumentTemplateContext)fContext;
- start= docContext.getStart();
- end= docContext.getEnd();
- } else {
- start= fRegion.getOffset();
- end= start + fRegion.getLength();
- }
-
- // insert template string
- IDocument document= viewer.getDocument();
- String templateString= templateBuffer.getString();
- document.replace(start, end - start, templateString);
-
-
- // translate positions
- LinkedEnvironment env= new LinkedEnvironment();
- TemplateVariable[] variables= templateBuffer.getVariables();
- boolean hasPositions= false;
- for (int i= 0; i != variables.length; i++) {
- TemplateVariable variable= variables[i];
-
- if (variable.isUnambiguous())
- continue;
-
- LinkedPositionGroup group= new LinkedPositionGroup();
-
- int[] offsets= variable.getOffsets();
- int length= variable.getLength();
-
- String[] values= variable.getValues();
- ICompletionProposal[] proposals= new ICompletionProposal[values.length];
- for (int j= 0; j < values.length; j++) {
- ensurePositionCategoryInstalled(document, env);
- Position pos= new Position(offsets[0] + start, length);
- document.addPosition(getCategory(), pos);
- proposals[j]= new PositionBasedCompletionProposal(values[j], pos, length);
- }
-
- for (int j= 0; j != offsets.length; j++)
- if (j == 0 && proposals.length > 1)
- group.addPosition(new ProposalPosition(document, offsets[j] + start, length, proposals));
- else
- group.addPosition(new LinkedPosition(document, offsets[j] + start, length));
-
- env.addGroup(group);
- hasPositions= true;
- }
-
- if (hasPositions) {
- env.forceInstall();
- LinkedUIControl editor= new LinkedUIControl(env, viewer);
- editor.setExitPosition(viewer, getCaretOffset(templateBuffer) + start, 0, Integer.MAX_VALUE);
- editor.enter();
-
- fSelectedRegion= editor.getSelectedRegion();
- } else
- fSelectedRegion= new Region(getCaretOffset(templateBuffer) + start, 0);
-
- } catch (BadLocationException e) {
- openErrorDialog(viewer.getTextWidget().getShell(), e);
- fSelectedRegion= fRegion;
- } catch (BadPositionCategoryException e) {
- openErrorDialog(viewer.getTextWidget().getShell(), e);
- fSelectedRegion= fRegion;
- }
-
- }
-
- private void ensurePositionCategoryInstalled(final IDocument document, LinkedEnvironment env) {
- if (!document.containsPositionCategory(getCategory())) {
- document.addPositionCategory(getCategory());
- final InclusivePositionUpdater updater= new InclusivePositionUpdater(getCategory());
- document.addPositionUpdater(updater);
-
- env.addLinkedListener(new ILinkedListener() {
-
- /*
- * @see org.eclipse.jface.text.link.ILinkedListener#left(org.eclipse.jface.text.link.LinkedEnvironment, int)
- */
- public void left(LinkedEnvironment environment, int flags) {
- try {
- document.removePositionCategory(getCategory());
- } catch (BadPositionCategoryException e) {
- // ignore
- }
- document.removePositionUpdater(updater);
- }
-
- public void suspend(LinkedEnvironment environment) {}
- public void resume(LinkedEnvironment environment, int flags) {}
- });
- }
- }
-
- private String getCategory() {
- return "TemplateProposalCategory_" + toString(); //$NON-NLS-1$
- }
-
- private int getCaretOffset(TemplateBuffer buffer) {
-
- TemplateVariable[] variables= buffer.getVariables();
- for (int i= 0; i != variables.length; i++) {
- TemplateVariable variable= variables[i];
- if (variable.getType().equals(GlobalVariables.Cursor.NAME))
- return variable.getOffsets()[0];
- }
-
- return buffer.getString().length();
- }
-
- /*
- * @see ICompletionProposal#getSelection(IDocument)
- */
- public Point getSelection(IDocument document) {
- return new Point(fSelectedRegion.getOffset(), fSelectedRegion.getLength());
- }
-
- /*
- * @see ICompletionProposal#getAdditionalProposalInfo()
- */
- public String getAdditionalProposalInfo() {
- try {
- fContext.setReadOnly(true);
- TemplateBuffer templateBuffer= fContext.evaluate(fTemplate);
-
- if (templateBuffer == null)
- return null;
-
- return templateBuffer.getString();
-
- } catch (BadLocationException e) {
- // FIXME do something
- return null;
- }
- }
-
- /*
- * @see ICompletionProposal#getDisplayString()
- */
- public String getDisplayString() {
- if (fDisplayString == null) {
- fDisplayString= fTemplate.getName() + TemplateMessages.getString("TemplateProposal.delimiter") + fTemplate.getDescription(); //$NON-NLS-1$
- }
- return fDisplayString;
- }
-
- /*
- * @see ICompletionProposal#getImage()
- */
- public Image getImage() {
- return fImage;
- }
-
- /*
- * @see ICompletionProposal#getContextInformation()
- */
- public IContextInformation getContextInformation() {
- return null;
- }
-
- private void openErrorDialog(Shell shell, Exception e) {
- MessageDialog.openError(shell, TemplateMessages.getString("TemplateEvaluator.error.title"), e.getMessage()); //$NON-NLS-1$
- }
-
- /**
- * Returns the relevance.
- *
- * @return the relevance
- */
- public int getRelevance() {
- return fRelevance;
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension3#getInformationControlCreator()
- */
- public IInformationControlCreator getInformationControlCreator() {
-// return new TemplateInformationControlCreator();
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#selected(org.eclipse.jface.text.ITextViewer, boolean)
- */
- public void selected(ITextViewer viewer, boolean smartToggle) {
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#unselected(org.eclipse.jface.text.ITextViewer)
- */
- public void unselected(ITextViewer viewer) {
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#validate(org.eclipse.jface.text.IDocument, int, org.eclipse.jface.text.DocumentEvent)
- */
- public boolean validate(IDocument document, int offset, DocumentEvent event) {
- return false;
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension3#getReplacementString()
- */
- public CharSequence getCompletionText() {
- return new String();
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension3#getReplacementOffset()
- */
- public int getCompletionOffset() {
- return fRegion.getOffset();
- }
-
- /**
- * {@inheritdoc}
- */
- public void apply(IDocument document, char trigger, int offset) {
- // not called any longer
- }
-
- /**
- * {@inheritdoc}
- */
- public boolean isValidFor(IDocument document, int offset) {
- // not called any longer
- return false;
- }
-
- /**
- * {@inheritdoc}
- */
- public char[] getTriggerCharacters() {
- // no triggers
- return new char[0];
- }
-
- /**
- * {@inheritdoc}
- */
- public int getContextInformationPosition() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- /**
- * {@inheritDoc}
- */
- public void updateReplacementOffset(int offset) {
- // TODO Auto-generated method stub
-
- }
-
- /**
- * {@inheritDoc}
- */
- public String getReplacementString() {
- // TODO Auto-generated method stub
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public void updateReplacementLength(int length) {
- // TODO Auto-generated method stub
-
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateMessages.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateMessages.java
deleted file mode 100644
index 06b9aa3..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateMessages.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.templates.persistence;
-
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-/**
- * @since 3.0
- */
-class TemplateMessages {
-
- private static final String RESOURCE_BUNDLE= TemplateMessages.class.getName();
- private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
-
- private TemplateMessages() {
- }
-
- /**
- * @param key
- * @return
- */
- public static String getString(String key) {
- try {
- return fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return '!' + key + '!';
- }
- }
-
- /**
- * Gets a string from the resource bundle and formats it with the argument
- *
- * @param key the string used to get the bundle value, must not be null
- * @param arg
- * @return
- */
- public static String getFormattedString(String key, Object arg) {
- return MessageFormat.format(getString(key), new Object[] { arg });
- }
-
-
- /**
- * Gets a string from the resource bundle and formats it with arguments
- * @param key
- * @param args
- * @return
- */
- public static String getFormattedString(String key, Object[] args) {
- return MessageFormat.format(getString(key), args);
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateMessages.properties b/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateMessages.properties
deleted file mode 100644
index 83861ee..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateMessages.properties
+++ /dev/null
@@ -1,16 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2003 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-TemplateReaderWriter.duplicate.id= Duplicate template id
-TemplateReaderWriter.error.missing_attribute= Missing required attribute
-TemplateReaderWriter.error.read=Error occurred while reading templates.
-TemplateReaderWriter.error.write=Error occurred while writing templates.
-TemplateReaderWriter.error.illegal_boolean_attribute= Illegal boolean attribute, must be "true" or "false".
\ No newline at end of file
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplatePersistenceData.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplatePersistenceData.java
deleted file mode 100644
index 9289143..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplatePersistenceData.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.templates.persistence;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.templates.Template;
-
-
-/**
- * TemplatePersistenceData stores information about a template. It uniquely
- * references contributed templates via their id. Contributed templates may be
- * deleted or modified. All template may be enabled or not.
- *
- * @since 3.0
- */
-public class TemplatePersistenceData {
- private final Template fOriginalTemplate;
- private final String fId;
- private final boolean fOriginalIsEnabled;
-
- private Template fCustomTemplate= null;
- private boolean fIsDeleted= false;
- private boolean fCustomIsEnabled= true;
-
- /**
- * Creates a new, user-added instance that is not linked to a contributed
- * template.
- *
- * @param template the template which is stored by the new instance
- * @param enabled whether the template is enabled
- */
- public TemplatePersistenceData(Template template, boolean enabled) {
- this(template, enabled, null);
- }
-
- /**
- * Creates a new instance. If <code>id</code> is not <code>null</code>,
- * the instance is represents a template that is contributed and can be
- * identified via its id.
- *
- * @param template the template which is stored by the new instance
- * @param enabled whether the template is enabled
- * @param id the id of the template, or <code>null</code> if a user-added
- * instance should be created
- */
- public TemplatePersistenceData(Template template, boolean enabled, String id) {
- Assert.isNotNull(template);
- fOriginalTemplate= template;
- fCustomTemplate= template;
- fOriginalIsEnabled= enabled;
- fCustomIsEnabled= enabled;
- fId= id;
- }
-
- /**
- * Returs the id of this template store, or <code>null</code> if there is none.
- *
- * @return the id of this template store
- */
- public String getId() {
- return fId;
- }
-
- /**
- * Returns the deletion state of the stored template. This is only relevant
- * of contributed templates.
- *
- * @return the deletion state of the stored template
- */
- public boolean isDeleted() {
- return fIsDeleted;
- }
-
- /**
- * Sets the deletion state of the stored template.
- *
- * @param isDeleted the deletion state of the stored template
- */
- public void setDeleted(boolean isDeleted) {
- fIsDeleted= isDeleted;
- }
-
- /**
- * Returns the template encapsulated by the receiver.
- *
- * @return the template encapsulated by the receiver
- */
- public Template getTemplate() {
- return fCustomTemplate;
- }
-
-
- /**
- * Sets the template encapsulated by the receiver.
- *
- * @param template the new template
- */
- public void setTemplate(Template template) {
- fCustomTemplate= template;
- }
-
- /**
- * Returns whether the receiver represents a custom template, i.e. is either
- * a user-added template or a contributed template that has been modified.
- *
- * @return <code>true</code> if the contained template is a custom
- * template and cannot be reconstructed from the contributed
- * templates
- */
- public boolean isCustom() {
- return fId == null
- || fIsDeleted
- || fOriginalIsEnabled != fCustomIsEnabled
- || !fOriginalTemplate.equals(fCustomTemplate);
- }
-
- /**
- * Returns whether the receiver represents a modified template, i.e. a
- * contributed template that has been changed.
- *
- * @return <code>true</code> if the contained template is contributed but has been modified, <code>false</code> otherwise
- */
- public boolean isModified() {
- return isCustom() && !isUserAdded();
- }
-
- /**
- * Returns <code>true</code> if the contained template was added by a
- * user, i.e. does not reference a contributed template.
- *
- * @return <code>true</code> if the contained template was added by a user, <code>false</code> otherwise
- */
- public boolean isUserAdded() {
- return fId == null;
- }
-
-
- /**
- * Reverts the template to its original setting.
- */
- public void revert() {
- fCustomTemplate= fOriginalTemplate;
- fCustomIsEnabled= fOriginalIsEnabled;
- fIsDeleted= false;
- }
-
-
- /**
- * Returns the enablement state of the contained template.
- *
- * @return the enablement state of the contained template
- */
- public boolean isEnabled() {
- return fCustomIsEnabled;
- }
-
- /**
- * Sets the enablement state of the contained template.
- *
- * @param isEnabled the new enablement state of the contained template
- */
- public void setEnabled(boolean isEnabled) {
- fCustomIsEnabled= isEnabled;
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateReaderWriter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateReaderWriter.java
deleted file mode 100644
index 4cd1294..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateReaderWriter.java
+++ /dev/null
@@ -1,288 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.templates.persistence;
-
-import java.io.IOException;
-import java.io.Reader;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-import java.util.Set;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.templates.Template;
-
-/**
- * <code>TemplateSet</code> manages a collection of templates and makes them
- * persistent.
- *
- * @since 3.0
- */
-public class TemplateReaderWriter {
-
- private static final String TEMPLATE_ROOT = "templates"; //$NON-NLS-1$
- private static final String TEMPLATE_ELEMENT = "template"; //$NON-NLS-1$
- private static final String NAME_ATTRIBUTE= "name"; //$NON-NLS-1$
- private static final String ID_ATTRIBUTE= "id"; //$NON-NLS-1$
- private static final String DESCRIPTION_ATTRIBUTE= "description"; //$NON-NLS-1$
- private static final String CONTEXT_ATTRIBUTE= "context"; //$NON-NLS-1$
- private static final String ENABLED_ATTRIBUTE= "enabled"; //$NON-NLS-1$
- private static final String DELETED_ATTRIBUTE= "deleted"; //$NON-NLS-1$
-
- /**
- * Reads templates from an XML reader and adds them to the templates.
- *
- * @param reader the XML reader to read templates from
- * @return the read templates, encapsulated in instances of <code>TemplatePersistenceData</code>
- * @throws SAXException if the XML is not valid
- * @throws IOException if reading from the stream fails
- */
- public TemplatePersistenceData[] read(Reader reader) throws SAXException, IOException {
- return read(reader, null);
- }
-
- /**
- * Reads templates from an XML stream and adds them to the templates.
- *
- * @param reader the XML reader to read templates from
- * @param bundle a resource bundle to use for translating the read templates, or <code>null</code> if no translation should occur
- * @return the read templates, encapsulated in instances of <code>TemplatePersistenceData</code>
- * @throws SAXException if the XML is not valid
- * @throws IOException if reading from the stream fails
- */
- public TemplatePersistenceData[] read(Reader reader, ResourceBundle bundle) throws SAXException, IOException {
-
- try {
- Collection templates= new ArrayList();
- Set ids= new HashSet();
-
- DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance();
- DocumentBuilder parser= factory.newDocumentBuilder();
- Document document= parser.parse(new InputSource(reader));
-
- NodeList elements= document.getElementsByTagName(TEMPLATE_ELEMENT);
-
- int count= elements.getLength();
- for (int i= 0; i != count; i++) {
- Node node= elements.item(i);
- NamedNodeMap attributes= node.getAttributes();
-
- if (attributes == null)
- continue;
-
- String id= getStringValue(attributes, ID_ATTRIBUTE, null);
- if (id != null && ids.contains(id))
- throw new SAXException(TemplateMessages.getString("TemplateReaderWriter.duplicate.id")); //$NON-NLS-1$
-
- boolean deleted = getBooleanValue(attributes, DELETED_ATTRIBUTE, false);
-
- String name= getStringValue(attributes, NAME_ATTRIBUTE);
- name= translateString(name, bundle);
-
- String description= getStringValue(attributes, DESCRIPTION_ATTRIBUTE, ""); //$NON-NLS-1$
- description= translateString(description, bundle);
-
- String context= getStringValue(attributes, CONTEXT_ATTRIBUTE);
-
- if (name == null || context == null)
- throw new SAXException(TemplateMessages.getString("TemplateReaderWriter.error.missing_attribute")); //$NON-NLS-1$
-
- boolean enabled = getBooleanValue(attributes, ENABLED_ATTRIBUTE, true);
-
- StringBuffer buffer= new StringBuffer();
- NodeList children= node.getChildNodes();
- for (int j= 0; j != children.getLength(); j++) {
- String value= children.item(j).getNodeValue();
- if (value != null)
- buffer.append(value);
- }
- String pattern= buffer.toString();
- pattern= translateString(pattern, bundle);
-
- Template template= new Template(name, description, context, pattern);
- TemplatePersistenceData data= new TemplatePersistenceData(template, enabled, id);
- data.setDeleted(deleted);
-
- templates.add(data);
- }
-
- return (TemplatePersistenceData[]) templates.toArray(new TemplatePersistenceData[templates.size()]);
-
- } catch (ParserConfigurationException e) {
- Assert.isTrue(false);
- }
-
- return null; // dummy
- }
-
- /**
- * Saves the templates as XML.
- *
- * @param templates the templates to save
- * @param writer the writer to write the templates to in XML
- * @throws IOException if writing the templates fails
- */
- public void save(TemplatePersistenceData[] templates, Writer writer) throws IOException {
- try {
- DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance();
- DocumentBuilder builder= factory.newDocumentBuilder();
- Document document= builder.newDocument();
-
- Node root= document.createElement(TEMPLATE_ROOT); //$NON-NLS-1$
- document.appendChild(root);
-
- for (int i= 0; i < templates.length; i++) {
- TemplatePersistenceData data= templates[i];
- Template template= data.getTemplate();
-
- Node node= document.createElement(TEMPLATE_ELEMENT);
- root.appendChild(node);
-
- NamedNodeMap attributes= node.getAttributes();
-
- String id= data.getId();
- if (id != null) {
- Attr idAttr= document.createAttribute(ID_ATTRIBUTE);
- idAttr.setValue(id);
- attributes.setNamedItem(idAttr);
- }
-
- if (template != null) {
- Attr name= document.createAttribute(NAME_ATTRIBUTE);
- name.setValue(template.getName());
- attributes.setNamedItem(name);
- }
-
- if (template != null) {
- Attr description= document.createAttribute(DESCRIPTION_ATTRIBUTE);
- description.setValue(template.getDescription());
- attributes.setNamedItem(description);
- }
-
- if (template != null) {
- Attr context= document.createAttribute(CONTEXT_ATTRIBUTE);
- context.setValue(template.getContextTypeId());
- attributes.setNamedItem(context);
- }
-
- Attr enabled= document.createAttribute(ENABLED_ATTRIBUTE);
- enabled.setValue(data.isEnabled() ? Boolean.toString(true) : Boolean.toString(false)); //$NON-NLS-1$ //$NON-NLS-2$
- attributes.setNamedItem(enabled);
-
- Attr deleted= document.createAttribute(DELETED_ATTRIBUTE);
- deleted.setValue(data.isDeleted() ? Boolean.toString(true) : Boolean.toString(false)); //$NON-NLS-1$ //$NON-NLS-2$
- attributes.setNamedItem(deleted);
-
- if (template != null) {
- Text pattern= document.createTextNode(template.getPattern());
- node.appendChild(pattern);
- }
- }
-
-
- Transformer transformer=TransformerFactory.newInstance().newTransformer();
- transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
- transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$
- DOMSource source = new DOMSource(document);
- StreamResult result = new StreamResult(writer);
-
- transformer.transform(source, result);
-
- } catch (ParserConfigurationException e) {
- Assert.isTrue(false);
- } catch (TransformerException e) {
- if (e.getException() instanceof IOException)
- throw (IOException) e.getException();
- Assert.isTrue(false);
- }
- }
-
- private boolean getBooleanValue(NamedNodeMap attributes, String attribute, boolean defaultValue) throws SAXException {
- Node enabledNode= attributes.getNamedItem(attribute);
- if (enabledNode == null)
- return defaultValue;
- else if (enabledNode.getNodeValue().equals(Boolean.toString(true)))
- return true;
- else if (enabledNode.getNodeValue().equals(Boolean.toString(false)))
- return false;
- else
- throw new SAXException(TemplateMessages.getString("TemplateReaderWriter.error.illegal_boolean_attribute")); //$NON-NLS-1$
- }
-
- private String getStringValue(NamedNodeMap attributes, String name) throws SAXException {
- String val= getStringValue(attributes, name, null);
- if (val == null)
- throw new SAXException(TemplateMessages.getString("TemplateReaderWriter.error.missing_attribute")); //$NON-NLS-1$
- return val;
- }
-
- private String getStringValue(NamedNodeMap attributes, String name, String defaultValue) {
- Node node= attributes.getNamedItem(name);
- return node == null ? defaultValue : node.getNodeValue();
- }
-
- private String translateString(String str, ResourceBundle bundle) {
- if (bundle == null)
- return str;
-
- int idx= str.indexOf('%');
- if (idx == -1) {
- return str;
- }
- StringBuffer buf= new StringBuffer();
- int k= 0;
- while (idx != -1) {
- buf.append(str.substring(k, idx));
- for (k= idx + 1; k < str.length() && !Character.isWhitespace(str.charAt(k)); k++) {
- // loop
- }
- String key= str.substring(idx + 1, k);
- buf.append(getBundleString(key, bundle));
- idx= str.indexOf('%', k);
- }
- buf.append(str.substring(k));
- return buf.toString();
- }
-
- private String getBundleString(String key, ResourceBundle bundle) {
- if (bundle != null) {
- try {
- return bundle.getString(key);
- } catch (MissingResourceException e) {
- return '!' + key + '!';
- }
- } else
- return TemplateMessages.getString(key); // default messages
- }
-}
-
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateSet.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateSet.java
deleted file mode 100644
index 64c702a..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateSet.java
+++ /dev/null
@@ -1,386 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.templates.persistence;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
-
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-
-import org.eclipse.jface.text.templates.ContextType;
-import org.eclipse.jface.text.templates.ContextTypeRegistry;
-import org.eclipse.jface.text.templates.Template;
-import org.eclipse.jface.text.templates.TemplateMessages;
-
-/**
- * <code>TemplateSet</code> manages a collection of templates and makes them
- * persistent.
- *
- * @deprecated use TemplateStore instead
- * @since 3.0
- */
-public class TemplateSet {
-
- private static final String NAME_ATTRIBUTE= "name"; //$NON-NLS-1$
- private static final String DESCRIPTION_ATTRIBUTE= "description"; //$NON-NLS-1$
- private static final String CONTEXT_ATTRIBUTE= "context"; //$NON-NLS-1$
-
- private List fTemplates= new ArrayList();
- private String fTemplateTag;
-
- // FIXME move constants somewhere else
- private static final int TEMPLATE_PARSE_EXCEPTION= 10002;
- private static final int TEMPLATE_IO_EXCEPTION= 10005;
- private ContextTypeRegistry fRegistry;
-
- public TemplateSet(String templateTag, ContextTypeRegistry registry) {
- fTemplateTag= templateTag;
- fRegistry= registry;
- }
-
- /**
- * Convenience method for reading templates from a file.
- *
- * @see #addFromStream(InputStream, boolean, boolean)
- */
- public void addFromFile(File file, boolean allowDuplicates, ResourceBundle bundle) throws CoreException {
- InputStream stream= null;
-
- try {
- stream= new FileInputStream(file);
- addFromStream(stream, allowDuplicates, false, bundle);
-
- } catch (IOException e) {
- throwReadException(e);
-
- } finally {
- try {
- if (stream != null)
- stream.close();
- } catch (IOException e) {}
- }
- }
-
- public String getTemplateTag() {
- return fTemplateTag;
- }
-
-
- /**
- * Reads templates from a XML stream and adds them to the templates
- */
- public void addFromStream(InputStream stream, boolean allowDuplicates, boolean doTranslations, ResourceBundle bundle) throws CoreException {
- try {
- DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance();
- DocumentBuilder parser= factory.newDocumentBuilder();
- Document document= parser.parse(new InputSource(stream));
-
- NodeList elements= document.getElementsByTagName(getTemplateTag());
-
- int count= elements.getLength();
- for (int i= 0; i != count; i++) {
- Node node= elements.item(i);
- NamedNodeMap attributes= node.getAttributes();
-
- if (attributes == null)
- continue;
-
- String name= getAttributeValue(attributes, NAME_ATTRIBUTE);
- String description= getAttributeValue(attributes, DESCRIPTION_ATTRIBUTE);
- if (name == null || description == null)
- continue;
-
- if (doTranslations) {
- description= translateString(description, bundle);
- }
- String context= getAttributeValue(attributes, CONTEXT_ATTRIBUTE);
-
- if (name == null || description == null || context == null)
- throw new SAXException(TemplateMessages.getString("TemplateSet.error.missing.attribute")); //$NON-NLS-1$
-
- StringBuffer buffer= new StringBuffer();
- NodeList children= node.getChildNodes();
- for (int j= 0; j != children.getLength(); j++) {
- String value= children.item(j).getNodeValue();
- if (value != null)
- buffer.append(value);
- }
- String pattern= buffer.toString().trim();
- if (doTranslations) {
- pattern= translateString(pattern, bundle);
- }
-
- Template template= new Template(name, description, context, pattern);
-
- String message= validateTemplate(template);
- if (message == null) {
- if (!allowDuplicates) {
- Template[] templates= getTemplates(name);
- for (int k= 0; k < templates.length; k++) {
- remove(templates[k]);
- }
- }
- add(template);
- } else {
- throwReadException(null);
- }
- }
- } catch (ParserConfigurationException e) {
- throwReadException(e);
- } catch (IOException e) {
- throwReadException(e);
- } catch (SAXException e) {
- throwReadException(e);
- }
- }
-
- private String translateString(String str, ResourceBundle bundle) {
- int idx= str.indexOf('%');
- if (idx == -1) {
- return str;
- }
- StringBuffer buf= new StringBuffer();
- int k= 0;
- while (idx != -1) {
- buf.append(str.substring(k, idx));
- for (k= idx + 1; k < str.length() && !Character.isWhitespace(str.charAt(k)); k++) {
- // loop
- }
- String key= str.substring(idx + 1, k);
- buf.append(getBundleString(key, bundle));
- idx= str.indexOf('%', k);
- }
- buf.append(str.substring(k));
- return buf.toString();
- }
-
- private String getBundleString(String key, ResourceBundle bundle) {
- if (bundle != null) {
- try {
- return bundle.getString(key);
- } catch (MissingResourceException e) {
- return '!' + key + '!';
- }
- } else
- return TemplateMessages.getString(key); // default messages
- }
-
- protected String validateTemplate(Template template) throws CoreException {
- ContextType type= fRegistry.getContextType(template.getContextTypeId());
- if (type == null) {
- return "Unknown context type: " + template.getContextTypeId(); //$NON-NLS-1$
- }
- return type.validate(template.getPattern());
- }
-
- private String getAttributeValue(NamedNodeMap attributes, String name) {
- Node node= attributes.getNamedItem(name);
-
- return node == null
- ? null
- : node.getNodeValue();
- }
-
- /**
- * Convenience method for saving to a file.
- *
- * @see #saveToStream(OutputStream)
- */
- public void saveToFile(File file) throws CoreException {
- OutputStream stream= null;
-
- try {
- stream= new FileOutputStream(file);
- saveToStream(stream);
-
- } catch (IOException e) {
- throwWriteException(e);
-
- } finally {
- try {
- if (stream != null)
- stream.close();
- } catch (IOException e) {}
- }
- }
-
- /**
- * Saves the template set as XML.
- */
- public void saveToStream(OutputStream stream) throws CoreException {
- try {
- DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance();
- DocumentBuilder builder= factory.newDocumentBuilder();
- Document document= builder.newDocument();
-
- Node root= document.createElement("templates"); //$NON-NLS-1$
- document.appendChild(root);
-
- for (int i= 0; i != fTemplates.size(); i++) {
- Template template= (Template) fTemplates.get(i);
-
- Node node= document.createElement(getTemplateTag());
- root.appendChild(node);
-
- NamedNodeMap attributes= node.getAttributes();
-
- Attr name= document.createAttribute(NAME_ATTRIBUTE);
- name.setValue(template.getName());
- attributes.setNamedItem(name);
-
- Attr description= document.createAttribute(DESCRIPTION_ATTRIBUTE);
- description.setValue(template.getDescription());
- attributes.setNamedItem(description);
-
- Attr context= document.createAttribute(CONTEXT_ATTRIBUTE);
- context.setValue(template.getContextTypeId());
- attributes.setNamedItem(context);
-
- Text pattern= document.createTextNode(template.getPattern());
- node.appendChild(pattern);
- }
-
-
- Transformer transformer=TransformerFactory.newInstance().newTransformer();
- transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
- transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$
- DOMSource source = new DOMSource(document);
- StreamResult result = new StreamResult(stream);
-
- transformer.transform(source, result);
-
- } catch (ParserConfigurationException e) {
- throwWriteException(e);
- } catch (TransformerException e) {
- throwWriteException(e);
- }
- }
-
- private static void throwReadException(Throwable t) throws CoreException {
- int code;
- if (t instanceof SAXException)
- code= TEMPLATE_PARSE_EXCEPTION;
- else
- code= TEMPLATE_IO_EXCEPTION;
-// IStatus status= JavaUIStatus.createError(code, TemplateMessages.getString("TemplateSet.error.read"), t); //$NON-NLS-1$
-// throw new JavaUIException(status);
- throw new CoreException(new Status(IStatus.ERROR, "org.eclipse.jface.text", code, TemplateMessages.getString("TemplateSet.error.read"), t)); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- private static void throwWriteException(Throwable t) throws CoreException {
-// IStatus status= JavaUIStatus.createError(IJavaStatusConstants.TEMPLATE_IO_EXCEPTION,
-// TemplateMessages.getString("TemplateSet.error.write"), t); //$NON-NLS-1$
-// throw new JavaUIException(status);
- throw new CoreException(new Status(IStatus.ERROR, "org.eclipse.jface.text", TEMPLATE_IO_EXCEPTION, TemplateMessages.getString("TemplateSet.error.write"), t)); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * Adds a template to the set.
- */
- public void add(Template template) {
- if (exists(template))
- return; // ignore duplicate
-
- fTemplates.add(template);
- }
-
- private boolean exists(Template template) {
- for (Iterator iterator = fTemplates.iterator(); iterator.hasNext();) {
- Template anotherTemplate = (Template) iterator.next();
-
- if (template.equals(anotherTemplate))
- return true;
- }
-
- return false;
- }
-
- /**
- * Removes a template to the set.
- */
- public void remove(Template template) {
- fTemplates.remove(template);
- }
-
- /**
- * Empties the set.
- */
- public void clear() {
- fTemplates.clear();
- }
-
- /**
- * Returns all templates.
- */
- public Template[] getTemplates() {
- return (Template[]) fTemplates.toArray(new Template[fTemplates.size()]);
- }
-
- /**
- * Returns all templates with a given name.
- */
- public Template[] getTemplates(String name) {
- ArrayList res= new ArrayList();
- for (Iterator iterator= fTemplates.iterator(); iterator.hasNext();) {
- Template curr= (Template) iterator.next();
- if (curr.getName().equals(name)) {
- res.add(curr);
- }
- }
- return (Template[]) res.toArray(new Template[res.size()]);
- }
-
- /**
- * Returns the first templates with the given name.
- */
- public Template getFirstTemplate(String name) {
- for (Iterator iterator= fTemplates.iterator(); iterator.hasNext();) {
- Template curr= (Template) iterator.next();
- if (curr.getName().equals(name)) {
- return curr;
- }
- }
- return null;
- }
-
-}
-
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateStore.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateStore.java
deleted file mode 100644
index b42ab7f..0000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateStore.java
+++ /dev/null
@@ -1,418 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.templates.persistence;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.PropertyResourceBundle;
-import java.util.ResourceBundle;
-
-import org.xml.sax.SAXException;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.templates.ContextTypeRegistry;
-import org.eclipse.jface.text.templates.Template;
-
-/**
- * Manages templates. Handles reading default templates contributed via XML and
- * user-defined (or overridden) templates stored in the preferences. Clients may
- * instantiate this class.
- *
- * <p>This class will become final.</p>
- *
- * @since 3.0
- */
-public class TemplateStore {
- /* extension point string literals */
- private static final String TEMPLATES_EXTENSION_POINT= "org.eclipse.ui.editors.templates"; //$NON-NLS-1$
-
- private static final String ID= "id"; //$NON-NLS-1$
- private static final String NAME= "name"; //$NON-NLS-1$
-
- private static final String CONTEXT_TYPE_ID= "contextTypeId"; //$NON-NLS-1$
- private static final String DESCRIPTION= "description"; //$NON-NLS-1$
-
- private static final String TEMPLATE= "template"; //$NON-NLS-1$
- private static final String PATTERN= "pattern"; //$NON-NLS-1$
-
- private static final String INCLUDE= "include"; //$NON-NLS-1$
- private static final String FILE= "file"; //$NON-NLS-1$
- private static final String TRANSLATIONS= "translations"; //$NON-NLS-1$
-
- /** The stored templates. */
- private final List fTemplates= new ArrayList();
- /** The preference store. */
- private IPreferenceStore fPreferenceStore;
- /**
- * The key into <code>fPreferenceStore</code> the value of which holds custom templates
- * encoded as XML.
- */
- private String fKey;
- /**
- * The context type registry, or <code>null</code> if all templates regardless
- * of context type should be loaded.
- */
- private ContextTypeRegistry fRegistry;
-
-
- /**
- * Creates a new template store.
- *
- * @param store the preference store in which to store custom templates
- * under <code>key</code>
- * @param key the key into <code>store</code> where to store custom
- * templates
- */
- public TemplateStore(IPreferenceStore store, String key) {
- Assert.isNotNull(store);
- Assert.isNotNull(key);
- fPreferenceStore= store;
- fKey= key;
- }
-
- /**
- * Creates a new template store with a context type registry. Only templates
- * that specify a context type contained in the registry will be loaded by
- * this store if the registry is not <code>null</code>.
- *
- * @param registry a context type registry, or <code>null</code> if all
- * templates should be loaded
- * @param store the preference store in which to store custom templates
- * under <code>key</code>
- * @param key the key into <code>store</code> where to store custom
- * templates
- */
- public TemplateStore(ContextTypeRegistry registry, IPreferenceStore store, String key) {
- this(store, key);
- fRegistry= registry;
- }
-
- /**
- * Loads the templates from contributions and preferences.
- *
- * @throws IOException if a contributed templates file cannot be read
- */
- public void load() throws IOException {
- fTemplates.clear();
- loadDefaultTemplates();
- loadCustomTemplates();
- }
-
- /**
- * Saves the templates to the preferences.
- *
- * @throws IOException if the templates cannot be written
- */
- public void save() throws IOException {
- ArrayList custom= new ArrayList();
- for (Iterator it= fTemplates.iterator(); it.hasNext();) {
- TemplatePersistenceData data= (TemplatePersistenceData) it.next();
- if (data.isCustom() && !(data.isUserAdded() && data.isDeleted())) // don't save deleted user-added templates
- custom.add(data);
- }
-
- StringWriter output= new StringWriter();
- TemplateReaderWriter writer= new TemplateReaderWriter();
- writer.save((TemplatePersistenceData[]) custom.toArray(new TemplatePersistenceData[custom.size()]), output);
-
- fPreferenceStore.setValue(fKey, output.toString());
- }
-
- /**
- * Adds a template encapsulated in its persistent form.
- *
- * @param data the template to add
- */
- public void add(TemplatePersistenceData data) {
-
- if (!validateTemplate(data.getTemplate()))
- return;
-
- if (data.isUserAdded()) {
- fTemplates.add(data);
- } else {
- for (Iterator it= fTemplates.iterator(); it.hasNext();) {
- TemplatePersistenceData d2= (TemplatePersistenceData) it.next();
- if (d2.getId() != null && d2.getId().equals(data.getId())) {
- d2.setTemplate(data.getTemplate());
- d2.setDeleted(data.isDeleted());
- d2.setEnabled(data.isEnabled());
- return;
- }
- }
-
- // add an id which is not contributed as add-on
- if (data.getTemplate() != null) {
- TemplatePersistenceData newData= new TemplatePersistenceData(data.getTemplate(), data.isEnabled());
- fTemplates.add(newData);
- }
- }
- }
-
- /**
- * Removes a template from the store.
- *
- * @param data the template to remove
- */
- public void delete(TemplatePersistenceData data) {
- if (data.isUserAdded())
- fTemplates.remove(data);
- else
- data.setDeleted(true);
- }
-
- /**
- * Restores all contributed templates that have been deleted.
- */
- public void restoreDeleted() {
- for (Iterator it= fTemplates.iterator(); it.hasNext();) {
- TemplatePersistenceData data= (TemplatePersistenceData) it.next();
- if (data.isDeleted())
- data.setDeleted(false);
- }
- }
-
- /**
- * Deletes all user-added templates and reverts all contributed templates.
- */
- public void restoreDefaults() {
- for (Iterator it= fTemplates.iterator(); it.hasNext();) {
- TemplatePersistenceData data= (TemplatePersistenceData) it.next();
- if (data.isUserAdded())
- it.remove();
- else
- data.revert();
- }
- }
-
- /**
- * Returns all enabled templates.
- *
- * @return all enabled templates
- */
- public Template[] getTemplates() {
- return getTemplates(null);
- }
-
- /**
- * Returns all enabled templates for the given context type.
- *
- * @param contextTypeId the id of the context type of the requested templates, or <code>null</code> if all templates should be returned
- * @return all enabled templates for the given context type
- */
- public Template[] getTemplates(String contextTypeId) {
- List templates= new ArrayList();
- for (Iterator it= fTemplates.iterator(); it.hasNext();) {
- TemplatePersistenceData data= (TemplatePersistenceData) it.next();
- if (data.isEnabled() && !data.isDeleted() && (contextTypeId == null || contextTypeId.equals(data.getTemplate().getContextTypeId())))
- templates.add(data.getTemplate());
- }
-
- return (Template[]) templates.toArray(new Template[templates.size()]);
- }
-
- /**
- * Returns the first enabled template that matches the name.
- *
- * @param name the name of the template searched for
- * @return the first enabled template that matches both name and context type id, or <code>null</code> if none is found
- */
- public Template findTemplate(String name) {
- return findTemplate(name, null);
- }
-
- /**
- * Returns the first enabled template that matches both name and context type id.
- *
- * @param name the name of the template searched for
- * @param contextTypeId the context type id to clip unwanted templates, or <code>null</code> if any context type is ok
- * @return the first enabled template that matches both name and context type id, or <code>null</code> if none is found
- */
- public Template findTemplate(String name, String contextTypeId) {
- Assert.isNotNull(name);
-
- for (Iterator it= fTemplates.iterator(); it.hasNext();) {
- TemplatePersistenceData data= (TemplatePersistenceData) it.next();
- Template template= data.getTemplate();
- if (data.isEnabled() && !data.isDeleted()
- && (contextTypeId == null || contextTypeId.equals(template.getContextTypeId()))
- && name.equals(template.getName()))
- return template;
- }
-
- return null;
- }
-
- /**
- * Returns all template datas.
- *
- * @param includeDeleted whether to include deleted datas
- * @return all template datas, whether enabled or not
- */
- public TemplatePersistenceData[] getTemplateData(boolean includeDeleted) {
- List datas= new ArrayList();
- for (Iterator it= fTemplates.iterator(); it.hasNext();) {
- TemplatePersistenceData data= (TemplatePersistenceData) it.next();
- if (includeDeleted || !data.isDeleted())
- datas.add(data);
- }
-
- return (TemplatePersistenceData[]) datas.toArray(new TemplatePersistenceData[datas.size()]);
- }
-
- private void loadCustomTemplates() throws IOException {
- try {
- String pref= fPreferenceStore.getString(fKey);
- if (pref != null && pref.trim().length() > 0) {
- Reader input= new StringReader(pref);
- TemplateReaderWriter reader= new TemplateReaderWriter();
- TemplatePersistenceData[] datas= reader.read(input);
- for (int i= 0; i < datas.length; i++) {
- TemplatePersistenceData data= datas[i];
- add(data);
- }
- }
- } catch (SAXException e) {
- // won't happen unless someone messes with our preferences.
- throw (IOException) new IOException("Illegal XML content: " + e.getLocalizedMessage()).fillInStackTrace(); //$NON-NLS-1$
- }
- }
-
- private void loadDefaultTemplates() throws IOException {
- IConfigurationElement[] extensions= getTemplateExtensions();
- fTemplates.addAll(readContributedTemplates(extensions));
- }
-
- private Collection readContributedTemplates(IConfigurationElement[] extensions) throws IOException {
- Collection templates= new ArrayList();
- for (int i= 0; i < extensions.length; i++) {
- if (extensions[i].getName().equals(TEMPLATE))
- createTemplate(templates, extensions[i]);
- else if (extensions[i].getName().equals(INCLUDE)) {
- readIncludedTemplates(templates, extensions[i]);
- }
- }
-
- return templates;
- }
-
- private void readIncludedTemplates(Collection templates, IConfigurationElement element) throws IOException {
- String file= element.getAttributeAsIs(FILE);
- if (file != null) {
- IPluginDescriptor descriptor= element.getDeclaringExtension().getDeclaringPluginDescriptor();
- URL url= descriptor.find(new Path(file));
- if (url != null) {
- try {
- ResourceBundle bundle= null;
- String translations= element.getAttributeAsIs(TRANSLATIONS);
- if (translations != null) {
- URL bundleURL= descriptor.find(new Path(translations));
- if (url != null) {
- bundle= new PropertyResourceBundle(bundleURL.openStream());
- }
- }
-
- InputStream stream= url.openStream();
- Reader input= new InputStreamReader(stream);
- TemplateReaderWriter reader= new TemplateReaderWriter();
- TemplatePersistenceData[] datas= reader.read(input, bundle);
- for (int i= 0; i < datas.length; i++) {
- TemplatePersistenceData data= datas[i];
- if (!data.isCustom() && validateTemplate(data.getTemplate()))
- templates.add(data);
- }
- } catch (SAXException e) {
- // someone contributed an xml template file with invalid syntax. Propagate as IOException
- throw (IOException) new IOException("Illegal XML content: " + e.getLocalizedMessage()).fillInStackTrace(); //$NON-NLS-1$
- }
- }
- }
- }
-
- /**
- * Validates a template against the context type registered in the context
- * type registry. Returns always <code>true</code> if no registry is
- * present.
- *
- * @param template the template to validate
- * @return <code>true</code> if validation is successful or no context
- * type registry is specified, <code>false</code> if validation
- * fails
- */
- private boolean validateTemplate(Template template) {
- String contextTypeId= template.getContextTypeId();
- return contextExists(contextTypeId) && (fRegistry == null || fRegistry.getContextType(contextTypeId).validate(template.getPattern()) == null);
- }
-
- /**
- * Returns <code>true</code> if a context type id specifies a valid context type
- * or if no context type registry is present.
- *
- * @param contextTypeId the context type id to look for
- * @return <code>true</code> if the context type specified by the id
- * is present in the context type registry, or if no registry is
- * specified
- */
- private boolean contextExists(String contextTypeId) {
- return contextTypeId != null && (fRegistry == null || fRegistry.getContextType(contextTypeId) != null);
- }
-
- private static IConfigurationElement[] getTemplateExtensions() {
- return Platform.getExtensionRegistry().getConfigurationElementsFor(TEMPLATES_EXTENSION_POINT);
- }
-
- private void createTemplate(Collection map, IConfigurationElement element) {
- String contextTypeId= element.getAttributeAsIs(CONTEXT_TYPE_ID);
- if (contextExists(contextTypeId)) {
- String id= element.getAttributeAsIs(ID);
- if (isValidTemplateId(id)) {
-
- String name= element.getAttribute(NAME);
- if (name != null) {
-
- String desc= element.getAttribute(DESCRIPTION);
- if (desc == null)
- desc= new String();
-
- String pattern= element.getChildren(PATTERN)[0].getValue();
- if (pattern != null) {
-
- Template template= new Template(name, desc, contextTypeId, pattern);
- TemplatePersistenceData data= new TemplatePersistenceData(template, true, id);
- if (validateTemplate(template))
- map.add(data);
- }
- }
- }
- }
- }
-
- private static boolean isValidTemplateId(String id) {
- return id != null && id.trim().length() != 0; // TODO test validity?
- }
-}
-
diff --git a/org.eclipse.search.tests/.classpath b/org.eclipse.search.tests/.classpath
deleted file mode 100644
index 065ac06..0000000
--- a/org.eclipse.search.tests/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/org.eclipse.search.tests/.cvsignore b/org.eclipse.search.tests/.cvsignore
deleted file mode 100644
index c5e82d7..0000000
--- a/org.eclipse.search.tests/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
\ No newline at end of file
diff --git a/org.eclipse.search.tests/.project b/org.eclipse.search.tests/.project
deleted file mode 100644
index 414e31f..0000000
--- a/org.eclipse.search.tests/.project
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.search.tests</name>
- <comment></comment>
- <projects>
- <project>org.eclipse.jface.text</project>
- <project>org.eclipse.search</project>
- <project>org.eclipse.ui.editors</project>
- <project>org.eclipse.ui.workbench.texteditor</project>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/org.eclipse.search.tests/.template b/org.eclipse.search.tests/.template
deleted file mode 100644
index f3bcd41..0000000
--- a/org.eclipse.search.tests/.template
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<form>
- <p/><p><b>Tips on working with this plug-in project</b></p><li>For the view of the new plug-in at a glance, go to the <img href="pageImage"/><a href="OverviewPage">Overview</a>.</li><li>You can test the contributions of this plug-in by launching another instance of the workbench. On the <b>Run</b> menu, click <b>Run As</b> and choose <img href="runTimeWorkbenchImage"/><a href="action.run">Run-time Workbench</a> from the available choices.</li><li>You can add more functionality to this plug-in by adding extensions using the <a href="action.newExtension">New Extension Wizard</a>.</li><li>The plug-in project contains Java code that you can debug. Place breakpoints in Java classes. On the <b>Run</b> menu, select <b>Debug As</b> and choose <img href="runTimeWorkbenchImage"/><a href="action.debug">Run-time Workbench</a> from the available choices.</li>
-</form>
diff --git a/org.eclipse.search.tests/build.properties b/org.eclipse.search.tests/build.properties
deleted file mode 100644
index d8a5bfd..0000000
--- a/org.eclipse.search.tests/build.properties
+++ /dev/null
@@ -1,4 +0,0 @@
-source.tests.jar = src/
-output.tests.jar = bin/
-bin.includes = plugin.xml,\
- tests.jar
diff --git a/org.eclipse.search.tests/plugin.xml b/org.eclipse.search.tests/plugin.xml
deleted file mode 100644
index c939996..0000000
--- a/org.eclipse.search.tests/plugin.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
-<plugin
- id="org.eclipse.search.tests"
- name="Tests Plug-in"
- version="1.0.0"
- provider-name=""
- class="org.eclipse.search.tests.SearchTestPlugin">
-
- <runtime>
- <library name="tests.jar">
- <export name="*"/>
- </library>
- </runtime>
- <requires>
- <import plugin="org.eclipse.ui"/>
- <import plugin="org.eclipse.core.runtime.compatibility"/>
- <import plugin="org.eclipse.ui.ide"/>
- <import plugin="org.eclipse.search"/>
- <import plugin="org.eclipse.core.resources"/>
- <import plugin="org.junit"/>
- <import plugin="org.eclipse.ui.workbench.texteditor"/>
- <import plugin="org.eclipse.jface.text"/>
- <import plugin="org.eclipse.ui.editors"/>
- </requires>
-
-
-</plugin>
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/core/tests/AllSearchModelTests.java b/org.eclipse.search.tests/src/org/eclipse/search/core/tests/AllSearchModelTests.java
deleted file mode 100644
index d97135e..0000000
--- a/org.eclipse.search.tests/src/org/eclipse/search/core/tests/AllSearchModelTests.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.core.tests;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @author Thomas Mäder
- *
- */
-public class AllSearchModelTests extends TestSuite {
-
- /**
- * Returns the suite. This is required to
- * use the JUnit Launcher.
- */
- public static Test suite() {
- return new AllSearchModelTests();
- }
-
- /**
- * Construct the test suite.
- */
- public AllSearchModelTests() {
- addTest(new TestSuite(QueryManagerTest.class));
- addTest(new TestSuite(TestSearchResult.class));
- addTest(new TestSuite(QueryManagerTest.class));
- }
-
-}
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/core/tests/LongQuery.java b/org.eclipse.search.tests/src/org/eclipse/search/core/tests/LongQuery.java
deleted file mode 100644
index 31a8864..0000000
--- a/org.eclipse.search.tests/src/org/eclipse/search/core/tests/LongQuery.java
+++ /dev/null
@@ -1,43 +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.search.core.tests;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-
-/**
- */
-public class LongQuery extends NullQuery {
-
- private boolean fIsRunning= false;
-
- public boolean canRunInBackground() {
- return true;
- }
-
- public IStatus run(IProgressMonitor monitor) {
- fIsRunning= true;
- while (!monitor.isCanceled()) {
- try {
- Thread.sleep(50);
- } catch (InterruptedException e) {
- // should not happen
- }
- }
- fIsRunning= false;
- return new Status(IStatus.OK, "some plugin", 0, "No message", null);
- }
-
- public boolean isRunning() {
- return fIsRunning;
- }
-}
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/core/tests/NullQuery.java b/org.eclipse.search.tests/src/org/eclipse/search/core/tests/NullQuery.java
deleted file mode 100644
index edd2a35..0000000
--- a/org.eclipse.search.tests/src/org/eclipse/search/core/tests/NullQuery.java
+++ /dev/null
@@ -1,42 +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.search.core.tests;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-
-import org.eclipse.search.ui.ISearchQuery;
-import org.eclipse.search.ui.ISearchResult;
-
-public class NullQuery implements ISearchQuery {
-
- public IStatus run(IProgressMonitor monitor) {
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.ISearchQuery#getName()
- */
- public String getLabel() {
- return "Null Query"; //$NON-NLS-1$
- }
-
- public boolean canRerun() {
- return true;
- }
-
- public boolean canRunInBackground() {
- return true;
- }
-
- public ISearchResult getSearchResult() {
- return new NullSearchResult();
- }
-}
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/core/tests/NullSearchResult.java b/org.eclipse.search.tests/src/org/eclipse/search/core/tests/NullSearchResult.java
deleted file mode 100644
index c164fb9..0000000
--- a/org.eclipse.search.tests/src/org/eclipse/search/core/tests/NullSearchResult.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.search.core.tests;
-
-import org.eclipse.core.resources.IFile;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-
-import org.eclipse.ui.IEditorPart;
-
-import org.eclipse.search.ui.ISearchQuery;
-import org.eclipse.search.ui.text.AbstractTextSearchResult;
-import org.eclipse.search.ui.text.Match;
-
-/**
- * @author Thomas Mäder
- *
- */
-public class NullSearchResult extends AbstractTextSearchResult {
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.text.AbstractSearchResult#findContainedMatches(org.eclipse.search.ui.text.AbstractSearchResult, org.eclipse.core.resources.IFile)
- */
- public Match[] findContainedMatches(IFile file) {
- // TODO Auto-generated method stub
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.text.AbstractSearchResult#getFile(java.lang.Object)
- */
- public IFile getFile(Object element) {
- // TODO Auto-generated method stub
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.text.AbstractSearchResult#isShownInEditor(org.eclipse.search.ui.text.Match, org.eclipse.ui.IEditorPart)
- */
- public boolean isShownInEditor(Match match, IEditorPart editor) {
- // TODO Auto-generated method stub
- return false;
- }
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.text.AbstractSearchResult#findContainedMatches(org.eclipse.search.ui.text.AbstractSearchResult, org.eclipse.ui.IEditorPart)
- */
- public Match[] findContainedMatches(IEditorPart editor) {
- // TODO Auto-generated method stub
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.ISearchResult#getText(org.eclipse.search.ui.ISearchResult)
- */
- public String getLabel() {
- // TODO Auto-generated method stub
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.ISearchResult#getTooltip(org.eclipse.search.ui.ISearchResult)
- */
- public String getTooltip() {
- // TODO Auto-generated method stub
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.ISearchResult#getImageDescriptor(org.eclipse.search.ui.ISearchResult)
- */
- public ImageDescriptor getImageDescriptor() {
- // TODO Auto-generated method stub
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.ISearchResult#getQuery()
- */
- public ISearchQuery getQuery() {
- // TODO Auto-generated method stub
- return null;
- }
-}
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/core/tests/QueryManagerTest.java b/org.eclipse.search.tests/src/org/eclipse/search/core/tests/QueryManagerTest.java
deleted file mode 100644
index a5b305f..0000000
--- a/org.eclipse.search.tests/src/org/eclipse/search/core/tests/QueryManagerTest.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.core.tests;
-
-import junit.framework.TestCase;
-
-import org.eclipse.search.ui.IQueryListener;
-import org.eclipse.search.ui.ISearchQuery;
-import org.eclipse.search.ui.NewSearchUI;
-
-import org.eclipse.search2.internal.ui.InternalSearchUI;
-
-/**
- * @author Thomas Mäder
- *
- */
-public class QueryManagerTest extends TestCase {
- public void testRemoveQuery() {
- ISearchQuery query= new NullQuery();
- InternalSearchUI.getInstance().addQuery(query);
- InternalSearchUI.getInstance().removeQuery(query);
- ISearchQuery[] all= InternalSearchUI.getInstance().getQueries();
- for (int i= 0; i < all.length; i++) {
- if (query == all[i])
- assertTrue(false);
- }
- }
-
- public void testAddQuery() {
- ISearchQuery query= new NullQuery();
- InternalSearchUI.getInstance().addQuery(query);
- ISearchQuery[] all= NewSearchUI.getQueries();
- for (int i= 0; i < all.length; i++) {
- if (query == all[i])
- return;
- }
- assertTrue(false);
- }
-
- public void testQueryListener() {
- final boolean [] wasAdded= { false };
- final boolean [] wasRemoved= { false };
- IQueryListener l= new IQueryListener() {
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.IQueryListener#queryAdded(org.eclipse.search.ui.ISearchQuery)
- */
- public void queryAdded(ISearchQuery query) {
- wasAdded[0]= true;
- }
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.IQueryListener#queryRemoved(org.eclipse.search.ui.ISearchQuery)
- */
- public void queryRemoved(ISearchQuery query) {
- wasRemoved[0]= true;
- }
- public void queryStarting(ISearchQuery query) {
- // not interested
- }
- public void queryFinished(ISearchQuery query) {
- // not interested
- }
- } ;
- NewSearchUI.addQueryListener(l);
- ISearchQuery query= new NullQuery();
- InternalSearchUI.getInstance().addQuery(query);
- assertTrue(wasAdded[0]);
- InternalSearchUI.getInstance().removeQuery(query);
- assertTrue(wasRemoved[0]);
- InternalSearchUI.getInstance().removeQueryListener(l);
- wasAdded[0]= false;
- wasRemoved[0]= false;
- InternalSearchUI.getInstance().addQuery(query);
- assertFalse(wasAdded[0]);
- InternalSearchUI.getInstance().removeQuery(query);
- assertFalse(wasRemoved[0]);
- }
-
- public void testRemoveCancels() {
- LongQuery query= new LongQuery();
- NewSearchUI.runQuery(query);
- try {
- // give the other thread some time to finish.
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- // should not happen
- }
- assertTrue(query.isRunning());
- assertTrue(InternalSearchUI.getInstance().isQueryRunning(query));
- InternalSearchUI.getInstance().removeQuery(query);
- try {
- // give the other thread some time to finish.
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- // should not happen
- }
- assertFalse(query.isRunning());
- assertFalse(InternalSearchUI.getInstance().isQueryRunning(query));
- }
-
- public void testRemoveAllCancels() {
- LongQuery query= new LongQuery();
- NewSearchUI.runQuery(query);
- InternalSearchUI.getInstance().removeQuery(query);
- try {
- // give the other thread some time to finish.
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- // should not happen
- }
- assertFalse(query.isRunning());
- }
-}
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/core/tests/TestSearchResult.java b/org.eclipse.search.tests/src/org/eclipse/search/core/tests/TestSearchResult.java
deleted file mode 100644
index b8bb4e4..0000000
--- a/org.eclipse.search.tests/src/org/eclipse/search/core/tests/TestSearchResult.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.core.tests;
-
-import junit.framework.TestCase;
-import org.eclipse.search.ui.ISearchQuery;
-import org.eclipse.search.ui.ISearchResultListener;
-import org.eclipse.search.ui.SearchResultEvent;
-import org.eclipse.search.ui.text.AbstractTextSearchResult;
-import org.eclipse.search.ui.text.Match;
-import org.eclipse.search.ui.text.MatchEvent;
-import org.eclipse.search2.internal.ui.InternalSearchUI;
-
-
-/**
- * @author Thomas Mäder
- *
- */
-public class TestSearchResult extends TestCase {
-
- public void testAddMatch() {
- ISearchQuery query= new NullQuery();
- AbstractTextSearchResult result= (AbstractTextSearchResult) query.getSearchResult();
- InternalSearchUI.getInstance().addQuery(query);
-
- String object= "object"; //$NON-NLS-1$
-
- Match match1= new Match(object, 0, 0);
- result.addMatch(match1);
- assertEquals(result.getMatchCount(), 1);
- Match match2= new Match(object, 0, 0);
- result.addMatch(match2);
- assertEquals(result.getMatchCount(), 2);
- result.addMatch(match1);
- assertEquals(result.getMatchCount(), 2);
- }
-
- public void testAddMatches() {
- ISearchQuery query= new NullQuery();
- AbstractTextSearchResult result= (AbstractTextSearchResult) query.getSearchResult();
- InternalSearchUI.getInstance().addQuery(query);
-
- String object= "object"; //$NON-NLS-1$
-
- Match match1= new Match(object, 0, 0);
- Match match2= new Match(object, 0, 0);
- result.addMatches(new Match[] { match1, match2 });
- assertEquals(result.getMatchCount(), 2);
- result.addMatch(match1);
- assertEquals(result.getMatchCount(), 2);
- }
-
- public void testRemoveMatch() {
- ISearchQuery query= new NullQuery();
- AbstractTextSearchResult result= (AbstractTextSearchResult) query.getSearchResult();
- InternalSearchUI.getInstance().addQuery(query);
-
- String object= "object"; //$NON-NLS-1$
-
- Match match1= new Match(object, 0, 0);
- result.addMatch(match1);
- Match match2= new Match(object, 0, 0);
- result.addMatch(match2);
- assertEquals(result.getMatchCount(), 2);
-
- result.removeMatch(match1);
- assertEquals(result.getMatchCount(), 1);
- result.removeMatch(match1);
- assertEquals(result.getMatchCount(), 1);
-
- }
-
- public void testRemoveMatches() {
- ISearchQuery query= new NullQuery();
- AbstractTextSearchResult result= (AbstractTextSearchResult) query.getSearchResult();
- InternalSearchUI.getInstance().addQuery(query);
-
- String object= "object"; //$NON-NLS-1$
-
- Match match1= new Match(object, 0, 0);
- Match match2= new Match(object, 0, 0);
- result.addMatches(new Match[] { match1, match2 });
- assertEquals(result.getMatchCount(), 2);
-
- result.removeMatches(new Match[] { match1, match2 });
- assertEquals(result.getMatchCount(), 0);
-
- }
-
- public void testMatchEvent() {
- final boolean [] wasAdded= { false };
- final boolean [] wasRemoved= { false };
-
- ISearchQuery query= new NullQuery();
- AbstractTextSearchResult result= (AbstractTextSearchResult) query.getSearchResult();
- InternalSearchUI.getInstance().addQuery(query);
-
- result.addListener(new ISearchResultListener() {
- public void searchResultChanged(SearchResultEvent e) {
- if (e instanceof MatchEvent) {
- MatchEvent evt= (MatchEvent) e;
- if (evt.getKind() == MatchEvent.ADDED) {
- wasAdded[0]= true;
- } else {
- wasRemoved[0]= true;
- }
- }
- }
- });
-
- String object= "object"; //$NON-NLS-1$
-
- Match match1= new Match(object, 0, 0);
- result.addMatch(match1);
- assertTrue(wasAdded[0]);
- wasAdded[0]= false;
- result.addMatch(match1);
- assertFalse(wasAdded[0]);
-
- Match match2= new Match(object, 0, 0);
- result.addMatch(match2);
- assertTrue(wasAdded[0]);
- wasAdded[0]= false;
-
- result.removeMatch(match2);
- assertTrue(wasRemoved[0]);
- wasRemoved[0]= false;
-
- result.removeMatch(match2);
- assertFalse(wasRemoved[0]);
- }
-
- public void testBatchedMatchEvent() {
- final boolean [] wasAdded= { false };
- final boolean [] wasRemoved= { false };
-
- ISearchQuery query= new NullQuery();
- AbstractTextSearchResult result= (AbstractTextSearchResult) query.getSearchResult();
- InternalSearchUI.getInstance().addQuery(query);
-
- result.addListener(new ISearchResultListener() {
- public void searchResultChanged(SearchResultEvent e) {
- if (e instanceof MatchEvent) {
- MatchEvent evt= (MatchEvent) e;
- if (evt.getKind() == MatchEvent.ADDED) {
- wasAdded[0]= true;
- } else {
- wasRemoved[0]= true;
- }
- }
- }
- });
-
- String object= "object"; //$NON-NLS-1$
-
- Match match1= new Match(object, 0, 0);
- result.addMatches(new Match[] { match1 });
- assertTrue(wasAdded[0]);
- wasAdded[0]= false;
- result.addMatches(new Match[] { match1 });
- assertFalse(wasAdded[0]);
-
- Match match2= new Match(object, 0, 0);
- result.addMatches(new Match[] { match2 });
- assertTrue(wasAdded[0]);
- wasAdded[0]= false;
-
- result.removeMatches(new Match[] { match2 });
- assertTrue(wasRemoved[0]);
- wasRemoved[0]= false;
-
- result.removeMatches(new Match[] { match2 });
- assertFalse(wasRemoved[0]);
- }
-}
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/AllSearchTests.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/AllSearchTests.java
deleted file mode 100644
index 11932f7..0000000
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/AllSearchTests.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.tests;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.eclipse.search.tests.filesearch.AllFileSearchTests;
-import org.eclipse.search.core.tests.AllSearchModelTests;
-
-public class AllSearchTests extends TestSuite {
-
- public static Test suite() {
- return new AllSearchTests();
- }
-
- public AllSearchTests() {
- addTest(AllFileSearchTests.suite());
- addTest(AllSearchModelTests.suite());
- }
-
-}
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/SearchTestPlugin.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/SearchTestPlugin.java
deleted file mode 100644
index c51453f..0000000
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/SearchTestPlugin.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package org.eclipse.search.tests;
-
-import java.io.File;
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.net.URL;
-import java.util.zip.ZipFile;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-
-import org.eclipse.ui.dialogs.IOverwriteQuery;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.eclipse.ui.wizards.datatransfer.ImportOperation;
-import org.eclipse.ui.wizards.datatransfer.ZipFileStructureProvider;
-
-import org.eclipse.search.ui.NewSearchUI;
-
-import org.eclipse.search.internal.ui.SearchPlugin;
-
-import org.eclipse.search2.internal.ui.InternalSearchUI;
-import org.eclipse.search2.internal.ui.SearchView;
-
-/**
- * Plugin class for search tests.
- */
-public class SearchTestPlugin extends AbstractUIPlugin {
- //The shared instance.
- private static SearchTestPlugin plugin;
-
- public SearchTestPlugin(IPluginDescriptor descriptor) {
- super(descriptor);
- plugin = this;
- }
-
- /**
- * Returns the shared instance.
- */
- public static SearchTestPlugin getDefault() {
- return plugin;
- }
-
- public static void importFilesFromZip(ZipFile srcZipFile, IPath destPath, IProgressMonitor monitor) throws InvocationTargetException {
- ZipFileStructureProvider structureProvider= new ZipFileStructureProvider(srcZipFile);
- try {
- ImportOperation op= new ImportOperation(destPath, structureProvider.getRoot(), structureProvider, new IOverwriteQuery() {
- public String queryOverwrite(String pathString) {
- return ALL;
- }
- });
- op.run(monitor);
- } catch (InterruptedException e) {
- // should not happen
- }
- }
-
- public File getFileInPlugin(IPath path) {
- try {
- URL installURL= new URL(getDescriptor().getInstallURL(), path.toString());
- URL localURL= Platform.asLocalURL(installURL);
- return new File(localURL.getFile());
- } catch (IOException e) {
- return null;
- }
- }
-
- public SearchView getSearchView() {
- NewSearchUI.activateSearchResultView();
- return (SearchView) SearchPlugin.getActivePage().findView(InternalSearchUI.SEARCH_VIEW_ID);
- }
-
-}
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/AllFileSearchTests.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/AllFileSearchTests.java
deleted file mode 100644
index 31a8281..0000000
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/AllFileSearchTests.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.tests.filesearch;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class AllFileSearchTests extends TestSuite {
-
- public static Test suite() {
- return new AllFileSearchTests();
- }
-
- public AllFileSearchTests() {
- addTest(new TestSuite(AnnotationManagerTest.class));
- addTest(new TestSuite(SearchResultPageTest.class));
- }
-
-}
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/AnnotationManagerTest.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/AnnotationManagerTest.java
deleted file mode 100644
index 0d731ab..0000000
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/AnnotationManagerTest.java
+++ /dev/null
@@ -1,177 +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.search.tests.filesearch;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.zip.ZipFile;
-
-import junit.framework.TestCase;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.runtime.Path;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.jface.text.source.IAnnotationModel;
-
-import org.eclipse.ui.editors.text.EditorsUI;
-
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.ui.texteditor.AnnotationTypeLookup;
-import org.eclipse.ui.texteditor.ITextEditor;
-
-import org.eclipse.search.tests.SearchTestPlugin;
-
-import org.eclipse.search.ui.NewSearchUI;
-import org.eclipse.search.ui.SearchUI;
-import org.eclipse.search.ui.text.AbstractTextSearchResult;
-import org.eclipse.search.ui.text.Match;
-
-import org.eclipse.search.internal.core.text.TextSearchScope;
-import org.eclipse.search.internal.ui.text.FileSearchQuery;
-import org.eclipse.search.internal.ui.text.FileSearchResult;
-
-import org.eclipse.search2.internal.ui.InternalSearchUI;
-
-public class AnnotationManagerTest extends TestCase {
- FileSearchQuery fQuery1;
- FileSearchQuery fQuery2;
-
- private AnnotationTypeLookup fAnnotationTypeLookup= EditorsUI.getAnnotationTypeLookup();
-
- public AnnotationManagerTest(String name) {
- super(name);
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- ZipFile zip= new ZipFile(SearchTestPlugin.getDefault().getFileInPlugin(new Path("testresources/junit37-noUI-src.zip"))); //$NON-NLS-1$
-
- SearchTestPlugin.importFilesFromZip(zip, new Path("Test"), null); //$NON-NLS-1$
-
- TextSearchScope scope= TextSearchScope.newWorkspaceScope();
- scope.addExtension("*.java");
- fQuery1= new FileSearchQuery(scope, "", "Test");
- fQuery2= new FileSearchQuery(scope, "", "TestCase");
- }
-
- public void testAddAnnotation() throws Exception {
- NewSearchUI.activateSearchResultView();
- NewSearchUI.runQueryInForeground(null, fQuery1);
- AbstractTextSearchResult result= (AbstractTextSearchResult) fQuery1.getSearchResult();
- Object[] files= result.getElements();
- for (int i= 0; i < files.length; i++) {
- IFile file= (IFile) files[0];
- ITextEditor editor= (ITextEditor)IDE.openEditor(SearchTestPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage(), file, true);
- IAnnotationModel annotationModel= editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput());
- annotationModel.getAnnotationIterator();
- HashSet positions= new HashSet();
- for (Iterator iter= annotationModel.getAnnotationIterator(); iter.hasNext();) {
- Annotation annotation= (Annotation) iter.next();
- if (annotation.getType().equals(fAnnotationTypeLookup.getAnnotationType(SearchUI.SEARCH_MARKER, IMarker.SEVERITY_INFO))) {
- positions.add(annotationModel.getPosition(annotation));
- }
- }
-
- Match[] matches= result.getMatches(file);
- for (int j= 0; j < matches.length; j++) {
- Position position= new Position(matches[j].getOffset(), matches[j].getLength());
- assertTrue("position not found at: "+j, positions.remove(position));
- }
- assertEquals(0, positions.size());
-
- }
- }
-
- public void testBogusAnnotation() throws Exception {
- NewSearchUI.activateSearchResultView();
- NewSearchUI.runQueryInForeground(null, fQuery1);
- FileSearchResult result= (FileSearchResult) fQuery1.getSearchResult();
- IFile file= (IFile) result.getElements()[0];
- IDE.openEditor(SearchTestPlugin.getDefault().getWorkbench().getWorkbenchWindows()[0].getPages()[0], file, true);
- result.addMatch(new Match(file, -1, -1));
- }
-
- public void testRemoveQuery() throws Exception {
- NewSearchUI.activateSearchResultView();
- NewSearchUI.runQueryInForeground(null, fQuery1);
- AbstractTextSearchResult result= (AbstractTextSearchResult) fQuery1.getSearchResult();
- Object[] files= result.getElements();
- InternalSearchUI.getInstance().removeQuery(fQuery1);
- for (int i= 0; i < files.length; i++) {
- IFile file= (IFile) files[0];
- ITextEditor editor= (ITextEditor)IDE.openEditor(SearchTestPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage(), file, true);
- IAnnotationModel annotationModel= editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput());
- int annotationCount= 0;
- for (Iterator annotations= annotationModel.getAnnotationIterator(); annotations.hasNext();) {
- Annotation annotation= (Annotation) annotations.next();
- if (annotation.getType().equals(fAnnotationTypeLookup.getAnnotationType(SearchUI.SEARCH_MARKER, IMarker.SEVERITY_INFO))) {
- annotationCount++;
- }
- }
- assertEquals(0, annotationCount);
- }
- }
-
-
- public void testReplaceQuery() throws Exception {
- NewSearchUI.activateSearchResultView();
- NewSearchUI.runQueryInForeground(null, fQuery1);
- AbstractTextSearchResult result= (AbstractTextSearchResult) fQuery1.getSearchResult();
- Object[] files= result.getElements();
- NewSearchUI.runQueryInForeground(null, fQuery2);
- for (int i= 0; i < files.length; i++) {
- IFile file= (IFile) files[0];
- ITextEditor editor= (ITextEditor)IDE.openEditor(SearchTestPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage(), file, true);
- IAnnotationModel annotationModel= editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput());
- int annotationCount= 0;
- IDocument document= editor.getDocumentProvider().getDocument(editor.getEditorInput());
- for (Iterator annotations= annotationModel.getAnnotationIterator(); annotations.hasNext();) {
- Annotation annotation= (Annotation) annotations.next();
- if (annotation.getType().equals(fAnnotationTypeLookup.getAnnotationType(SearchUI.SEARCH_MARKER, IMarker.SEVERITY_INFO))) {
- Position p= annotationModel.getPosition(annotation);
- String text= document.get(p.getOffset(), p.getLength());
- assertTrue(text.equalsIgnoreCase(fQuery2.getSearchString()));
- }
- }
- assertEquals(0, annotationCount);
- }
- }
-
- public void testSwitchQuery() throws Exception {
- NewSearchUI.activateSearchResultView();
- NewSearchUI.runQueryInForeground(null, fQuery1);
- AbstractTextSearchResult result= (AbstractTextSearchResult) fQuery1.getSearchResult();
- Object[] files= result.getElements();
- NewSearchUI.runQueryInForeground(null, fQuery2);
- SearchTestPlugin.getDefault().getSearchView().showSearchResult(result);
- for (int i= 0; i < files.length; i++) {
- IFile file= (IFile) files[0];
- ITextEditor editor= (ITextEditor)IDE.openEditor(SearchTestPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage(), file, true);
- IAnnotationModel annotationModel= editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput());
- int annotationCount= 0;
- IDocument document= editor.getDocumentProvider().getDocument(editor.getEditorInput());
- for (Iterator annotations= annotationModel.getAnnotationIterator(); annotations.hasNext();) {
- Annotation annotation= (Annotation) annotations.next();
- if (annotation.getType().equals(fAnnotationTypeLookup.getAnnotationType(SearchUI.SEARCH_MARKER, IMarker.SEVERITY_INFO))) {
- Position p= annotationModel.getPosition(annotation);
- String text= document.get(p.getOffset(), p.getLength());
- assertTrue(text.equalsIgnoreCase(fQuery1.getSearchString()));
- }
- }
- assertEquals(0, annotationCount);
- }
- }
-
-}
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SearchResultPageTest.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SearchResultPageTest.java
deleted file mode 100644
index ee1e28d..0000000
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SearchResultPageTest.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.search.tests.filesearch;
-
-import java.util.zip.ZipFile;
-
-import junit.framework.TestCase;
-
-import org.eclipse.core.runtime.Path;
-
-import org.eclipse.swt.widgets.Item;
-import org.eclipse.swt.widgets.Widget;
-
-import org.eclipse.jface.viewers.AbstractTreeViewer;
-import org.eclipse.jface.viewers.StructuredViewer;
-
-import org.eclipse.search.tests.SearchTestPlugin;
-
-import org.eclipse.search.ui.ISearchResultViewPart;
-import org.eclipse.search.ui.NewSearchUI;
-import org.eclipse.search.ui.text.AbstractTextSearchResult;
-import org.eclipse.search.ui.text.AbstractTextSearchViewPage;
-import org.eclipse.search.ui.text.Match;
-
-import org.eclipse.search.internal.core.text.TextSearchScope;
-import org.eclipse.search.internal.ui.text.FileSearchPage;
-import org.eclipse.search.internal.ui.text.FileSearchQuery;
-
-public class SearchResultPageTest extends TestCase {
- FileSearchQuery fQuery1;
-
- public SearchResultPageTest(String name) {
- super(name);
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- ZipFile zip= new ZipFile(SearchTestPlugin.getDefault().getFileInPlugin(new Path("testresources/junit37-noUI-src.zip"))); //$NON-NLS-1$
- SearchTestPlugin.importFilesFromZip(zip, new Path("Test"), null); //$NON-NLS-1$
- TextSearchScope scope= TextSearchScope.newWorkspaceScope();
- scope.addExtension("*.java");
- fQuery1= new FileSearchQuery(scope, "", "Test");
- }
-
- public void testBasicDisplay() throws Exception {
- ISearchResultViewPart view= NewSearchUI.activateSearchResultView();
- NewSearchUI.runQueryInForeground(null, fQuery1);
- FileSearchPage page= (FileSearchPage) view.getActivePage();
- page.setLayout(AbstractTextSearchViewPage.FLAG_LAYOUT_TREE);
- checkViewerDisplay(page);
- page.setLayout(AbstractTextSearchViewPage.FLAG_LAYOUT_FLAT);
- checkViewerDisplay(page);
- }
-
- private void checkViewerDisplay(FileSearchPage page) {
- StructuredViewer viewer= page.getViewer();
- AbstractTextSearchResult result= (AbstractTextSearchResult) fQuery1.getSearchResult();
- // make sure all elements have items.
- if (viewer instanceof AbstractTreeViewer)
- ((AbstractTreeViewer)viewer).expandAll();
- Object[] elements= result.getElements();
- for (int i= 0; i < elements.length; i++) {
- // make sure all elements in the test result are present in the viewer and have the proper count displayed
- checkElementDisplay(viewer, result, elements[i]);
- }
- }
-
- public void testRemoveTreeMatches() throws Exception {
- ISearchResultViewPart view= NewSearchUI.activateSearchResultView();
- NewSearchUI.runQueryInForeground(null, fQuery1);
- FileSearchPage page= (FileSearchPage) view.getActivePage();
- page.setLayout(AbstractTextSearchViewPage.FLAG_LAYOUT_TREE);
- AbstractTreeViewer viewer= (AbstractTreeViewer) page.getViewer();
- AbstractTextSearchResult result= (AbstractTextSearchResult) fQuery1.getSearchResult();
- // make sure all elements have items.
- viewer.expandAll();
- Object[] elements= result.getElements();
- for (int i= 0; i < elements.length; i++) {
- Match[] matches= result.getMatches(elements[i]);
- viewer.reveal(elements[i]);
- for (int j= 0; j < matches.length; j++) {
- checkElementDisplay(viewer, result, elements[i]);
- result.removeMatch(matches[j]);
- }
- }
- }
-
- private void checkElementDisplay(StructuredViewer viewer, AbstractTextSearchResult result, Object element) {
- Widget widget= viewer.testFindItem(element);
- assertTrue(widget instanceof Item);
- Item item= (Item) widget;
- int itemCount= result.getMatchCount(element);
- assertTrue(itemCount > 0);
- assertTrue(item.getText().indexOf(String.valueOf(itemCount)) >= 0);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.search.tests/testresources/junit37-noUI-src.zip b/org.eclipse.search.tests/testresources/junit37-noUI-src.zip
deleted file mode 100644
index 4f95d30..0000000
--- a/org.eclipse.search.tests/testresources/junit37-noUI-src.zip
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.search/.classpath b/org.eclipse.search/.classpath
deleted file mode 100644
index 30b8037..0000000
--- a/org.eclipse.search/.classpath
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="search"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="src" path="new search"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/org.eclipse.search/.cvsignore b/org.eclipse.search/.cvsignore
deleted file mode 100644
index ba077a4..0000000
--- a/org.eclipse.search/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
diff --git a/org.eclipse.search/.project b/org.eclipse.search/.project
deleted file mode 100644
index aa7e58b..0000000
--- a/org.eclipse.search/.project
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.search</name>
- <comment></comment>
- <projects>
- <project>org.eclipse.core.boot</project>
- <project>org.eclipse.core.filebuffers</project>
- <project>org.eclipse.core.resources</project>
- <project>org.eclipse.core.runtime</project>
- <project>org.eclipse.core.runtime.compatibility</project>
- <project>org.eclipse.jface.text</project>
- <project>org.eclipse.swt</project>
- <project>org.eclipse.ui</project>
- <project>org.eclipse.ui.editors</project>
- <project>org.eclipse.ui.ide</project>
- <project>org.eclipse.ui.workbench.texteditor</project>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.eclipse.pde.PluginNature</nature>
- </natures>
-</projectDescription>
diff --git a/org.eclipse.search/about.html b/org.eclipse.search/about.html
deleted file mode 100644
index 9db411a..0000000
--- a/org.eclipse.search/about.html
+++ /dev/null
@@ -1,30 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<html>
-<head>
-<title>About</title>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</head>
-<body lang="EN-US">
-<h2>About This Content</h2>
-
-<p>20th June, 2002</p>
-<h3>License</h3>
-<p>Eclipse.org makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
-Common Public License Version 1.0 ("CPL"). A copy of the CPL is available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>.
-For purposes of the CPL, "Program" will mean the Content.</p>
-
-<h3>Contributions</h3>
-
-<p>If this Content is licensed to you under the terms and conditions of the CPL, any Contributions, as defined in the CPL, uploaded, submitted, or otherwise
-made available to Eclipse.org, members of Eclipse.org and/or the host of Eclipse.org web site, by you that relate to such
-Content are provided under the terms and conditions of the CPL and can be made available to others under the terms of the CPL.</p>
-
-<p>If this Content is licensed to you under license terms and conditions other than the CPL ("Other License"), any modifications, enhancements and/or
-other code and/or documentation ("Modifications") uploaded, submitted, or otherwise made available to Eclipse.org, members of Eclipse.org and/or the
-host of Eclipse.org, by you that relate to such Content are provided under terms and conditions of the Other License and can be made available
-to others under the terms of the Other License. In addition, with regard to Modifications for which you are the copyright holder, you are also
-providing the Modifications under the terms and conditions of the CPL and such Modifications can be made available to others under the terms of
-the CPL.</p>
-
-</body>
-</html>
\ No newline at end of file
diff --git a/org.eclipse.search/build.properties b/org.eclipse.search/build.properties
deleted file mode 100644
index bc2af03..0000000
--- a/org.eclipse.search/build.properties
+++ /dev/null
@@ -1,19 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2003 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-bin.includes = plugin.xml,\
- about.html,\
- icons/,\
- plugin.properties,\
- *.jar
-src.includes = about.html,\
- schema/
-source.search.jar = search/,\
- new search/
diff --git a/org.eclipse.search/buildnotes_search.html b/org.eclipse.search/buildnotes_search.html
deleted file mode 100644
index 4d0fd6f..0000000
--- a/org.eclipse.search/buildnotes_search.html
+++ /dev/null
@@ -1,202 +0,0 @@
-<!--
- DO NOT EDIT THIS FILE WITH HTML EDITORS
--->
-
-<!DOCTYPE doctype PUBLIC "-//w3c//dtd html 4.0 transitional//en">
-<html>
-
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="GENERATOR" content="Mozilla/4.76 [en] (Windows NT 5.0; U) [Netscape]">
- <title>Eclipse Platform Build Notes - Search</title>
-</head>
-
-<body>
-<h1>
-Eclipse Platform Build Notes<br>
-Search</h1>
-To see which bugs have been addressed in one of the builds simply open the <a href="http://bugs.eclipse.org/bugs/query.cgi?short_desc_type=allwordssubstr&product=Platform&component=Search&long_desc_type=allwordssubstr&long_desc=&bug_file_loc_type=allwordssubstr&bug_file_loc=&keywords_type=allwords&keywords=&emailtype1=substring&email1=&emailtype2=substring&email2=&bugidtype=include&bug_id=&votes=&changedin=&chfieldfrom=&chfieldto=Now&chfieldvalue=&namedcmd=Assigned&newqueryname=&field0-0-0=noop&type0-0-0=noop&value0-0-0=">Search bugzilla query page</a>, select status, resolution and the time frame.
-<br>
-<br>
-<br>
-========== Eclipse Build Input March 29rd 2004 ==========<br>
-<H3>Breaking API Changes</H3>
-Subclasses of <code>AbstractTextSearchResultPage</code> now can decide if they want to support
-flat list and/or tree layout by passing the appropriate flags (<code>FLAG_LAYOUT_FLAT, FLAG_LAYOUT_TREE</code>) to
-the super constructor. Methods dealing with flat vs. tree layout have been changed to use the
-flags instead of a boolean now, for example <code>setFlatLayout(boolean)</code> changed to <code>setLayout(int layout)</code>.
-<br>
-<br>
-========== Eclipse Build Input March 23rd 2004 ==========<br>
-The new search API should be reasonably stable by now. See source folder "new search" in the non-internal packages.
-Some (minor changes) should be expected as we move along, but clients are now welcome to go ahead and use the API.
-<br>
-<br>
-========== Eclipse Build Input December 16th 2003 ==========<br>
-
-<!-- Add what's new below and end each line with br tag -->
-<pre>
-- bug fixing
-</pre>
-<br>
-<br>
-========== Eclipse Build Input November 18th 2003 ==========<br>
-
-<!-- Add what's new below and end each line with br tag -->
-<pre>
-- Added a new interface IReplacePage. If an ISearchPage implements IReplacePage,
- a "Replace" button will be shown in the search dialog (when the page is active).
- The text search page implements that interface.
-- Extended the text replace dialog to support "Replace in File" and "Replace All" actions.
-</pre>
-<br>
-<br>
-========== Eclipse Build Input November 11th 2003 ==========<br>
-<!-- Add what's new below and end each line with br tag -->
-<pre>
-- Converted to RPC
-</pre>
-<br>
-<br>
-
-========== Eclipse Build Input October 28th 2003 ==========<br>
-<!-- Add what's new below and end each line with br tag -->
-<pre>
-- A new preference has been introduced which allows to prevent the
- Search view from being activated.
-- Search annotations can be configured to be highlighted using background painter
-</pre>
-<br>
-<br>
-========== Eclipse Build Input October 21th 2003 ==========<br>
-<!-- Add what's new below and end each line with br tag -->
-<pre>
-- 1 bug fixed
-</pre>
-<br>
-<br>
-========== Eclipse Build Input October 7th 2003 ==========<br>
-<!-- Add what's new below and end each line with br tag -->
-<pre>
-- Added F1 help for File search page's regular expression support
-</pre>
-<br>
-<br>
-========== Eclipse Build Input September 30th 2003 ==========<br>
-<!-- Add what's new below and end each line with br tag -->
-<br>
-<br>
-========== Eclipse Build Input September 23th 2003 ==========<br>
-<!-- Add what's new below and end each line with br tag -->
-<br>
-<br>
-========== Eclipse Build Input September 16th 2003 ==========<br>
-<!-- Add what's new below and end each line with br tag -->
-<pre>
-- File Search page now supports regular expressions
-- 1 bug fixed
-</pre
-<br>
-========== Eclipse Build Input September 9th 2003 ==========<br>
-<!-- Add what's new below and end each line with br tag -->
-<br>
-<br>
-========== Eclipse Build Input September 3th 2003 ==========<br>
-<!-- Add what's new below and end each line with br tag -->
-<br>
-<br>
-========== Eclipse Build Input August 26th 2003 ==========<br>
-<!-- Add what's new below and end each line with br tag -->
-<br>
-<br>
-========== Eclipse Build Input August 19th 2003 ==========<br>
-<!-- Add what's new below and end each line with br tag -->
-<pre>
-- Added a new attribute "canSearchEnclosingProjects" to the extension point
- "org.eclipse.search.searchPages". If the attribute is set to true, the search
- dialog scope area will have a new radio button labeled "Enclosing Projects".
- Search page contributors whishing to support search in projects enclosing the
- current selection have to set this attribute to true and handle the new search
- scope constant org.eclipse.search.ui.ISearchPageContainer.SELECTED_PROJECTS_SCOPE.
- The file search page supports search in enclosing projects.
-- Improved project scope
-</pre>
-<br>
-<br>
-========== Eclipse Build Input August 12th 2003 ==========<br>
-<!-- Add what's new below and end each line with br tag -->
-- Project scope has been added to the Search dialog (see feature 16287)
-<br>
-<br>
-========== Eclipse Build Input August 5th 2003 ==========<br>
-<!-- Add what's new below and end each line with br tag -->
-<br>
-<br>
-========== Eclipse Build Input July 29th 2003 ==========<br>
-<!-- Add what's new below and end each line with br tag -->
-<br>
-<br>
-========== Eclipse Build Input July 22th 2003 ==========<br>
-<!-- Add what's new below and end each line with br tag -->
-<br>
-<br>
-========== Eclipse Build Input July 15th 2003 ==========<br>
-<!-- Add what's new below and end each line with br tag -->
-<br>
-<br>
-========== Eclipse Build Input July 8st 2003 ==========<br>
-<!-- Add what's new below and end each line with br tag -->
-- searchPage contributors can now specify a custom help context ID for the Search view.<br>
-<br>
-<br>
-========== Eclipse Build Input July 1st 2003 ==========<br>
-<!-- Add what's new below and end each line with br tag -->
-- 1 bug fixed<br>
-<br>
-<br>
-========== Eclipse Build Input June 24th 2003 ==========<br>
-<!-- Add what's new below and end each line with br tag -->
-<br>
-<br>
-========== Eclipse Build Input June 17th 2003 ==========<br>
-<!-- Add what's new below and end each line with br tag -->
-- Added missing requirement in schema documentation
-<br>
-<br>
-========== Eclipse Build Input June 10th 2003 ==========<br>
-<!-- Add what's new below and end each line with br tag -->
-<br>
-<br>
-========== Eclipse Build Input June 3rd 2003 ==========<br>
-<!-- Add what's new below and end each line with br tag -->
-- 1 bug fixed<br>
-<br>
-<br>
-========== Eclipse Build Input May 27th 2003 ==========<br>
-<!-- Add what's new below and end each line with br tag -->
-<br>
-<br>
-========== Eclipse Build Input May 20th 2003 ==========<br>
-<!-- Add what's new below and end each line with br tag -->
-<br>
-<br>
-========== Eclipse Build Input May 13th 2003 ==========<br>
-<!-- Add what's new below and end each line with br tag -->
-- 1 bug fixed<br>
-<br>
-<br>
-========== Eclipse Build Input May 6th 2003 ==========<br>
-<!-- Add what's new below and end each line with br tag -->
-- 1 bug fixed<br>
-<br>
-<br>
-========== Eclipse Build Input April 29th 2003 ==========<br>
-<!-- Add what's new below and end each line with br tag -->
-<br>
-<br>
-========== Eclipse Build Input April 22nd 2003 ==========<br>
-<!-- Add what's new below and end each line with br tag -->
-- 1 bug fixed<br>
-<br>
-<br>
-</body></html>
\ No newline at end of file
diff --git a/org.eclipse.search/hglegal2003.htm b/org.eclipse.search/hglegal2003.htm
deleted file mode 100644
index 47c8540..0000000
--- a/org.eclipse.search/hglegal2003.htm
+++ /dev/null
@@ -1,14 +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">
- <LINK REL="stylesheet" HREF="book.css" CHARSET="ISO-8859-1" TYPE="text/css">
- <title>Legal Notices</title>
-</head>
-<body>
-
-<h3>
-<a NAME="Notices"></a>Notices</h3>
-(c) Copyright (c) 2000, 2003 IBM Corporation and others. All Rights Reserved.
-</body>
-</html>
diff --git a/org.eclipse.search/icons/full/clcl16/flatLayout.gif b/org.eclipse.search/icons/full/clcl16/flatLayout.gif
deleted file mode 100644
index b84df08..0000000
--- a/org.eclipse.search/icons/full/clcl16/flatLayout.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.search/icons/full/clcl16/hierarchicalLayout.gif b/org.eclipse.search/icons/full/clcl16/hierarchicalLayout.gif
deleted file mode 100644
index e597c3d..0000000
--- a/org.eclipse.search/icons/full/clcl16/hierarchicalLayout.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.search/icons/full/clcl16/search_goto.gif b/org.eclipse.search/icons/full/clcl16/search_goto.gif
deleted file mode 100644
index 8048478..0000000
--- a/org.eclipse.search/icons/full/clcl16/search_goto.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.search/icons/full/clcl16/search_history.gif b/org.eclipse.search/icons/full/clcl16/search_history.gif
deleted file mode 100644
index 151fe13..0000000
--- a/org.eclipse.search/icons/full/clcl16/search_history.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.search/icons/full/clcl16/search_next.gif b/org.eclipse.search/icons/full/clcl16/search_next.gif
deleted file mode 100644
index 8392f33..0000000
--- a/org.eclipse.search/icons/full/clcl16/search_next.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.search/icons/full/clcl16/search_prev.gif b/org.eclipse.search/icons/full/clcl16/search_prev.gif
deleted file mode 100644
index 9b278e6..0000000
--- a/org.eclipse.search/icons/full/clcl16/search_prev.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.search/icons/full/clcl16/search_rem.gif b/org.eclipse.search/icons/full/clcl16/search_rem.gif
deleted file mode 100644
index 12a9167..0000000
--- a/org.eclipse.search/icons/full/clcl16/search_rem.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.search/icons/full/clcl16/search_remall.gif b/org.eclipse.search/icons/full/clcl16/search_remall.gif
deleted file mode 100644
index 2c069ab..0000000
--- a/org.eclipse.search/icons/full/clcl16/search_remall.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.search/icons/full/clcl16/search_sortmatch.gif b/org.eclipse.search/icons/full/clcl16/search_sortmatch.gif
deleted file mode 100644
index 9ed470d..0000000
--- a/org.eclipse.search/icons/full/clcl16/search_sortmatch.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.search/icons/full/clcl16/stop.gif b/org.eclipse.search/icons/full/clcl16/stop.gif
deleted file mode 100644
index d47876f..0000000
--- a/org.eclipse.search/icons/full/clcl16/stop.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.search/icons/full/ctool16/search.gif b/org.eclipse.search/icons/full/ctool16/search.gif
deleted file mode 100644
index 6dc3ebe..0000000
--- a/org.eclipse.search/icons/full/ctool16/search.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.search/icons/full/cview16/searchres.gif b/org.eclipse.search/icons/full/cview16/searchres.gif
deleted file mode 100644
index 8b39ab3..0000000
--- a/org.eclipse.search/icons/full/cview16/searchres.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.search/icons/full/dlcl16/flatLayout.gif b/org.eclipse.search/icons/full/dlcl16/flatLayout.gif
deleted file mode 100644
index aa0160d..0000000
--- a/org.eclipse.search/icons/full/dlcl16/flatLayout.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.search/icons/full/dlcl16/hierarchicalLayout.gif b/org.eclipse.search/icons/full/dlcl16/hierarchicalLayout.gif
deleted file mode 100644
index 76f3360..0000000
--- a/org.eclipse.search/icons/full/dlcl16/hierarchicalLayout.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.search/icons/full/dlcl16/search_goto.gif b/org.eclipse.search/icons/full/dlcl16/search_goto.gif
deleted file mode 100644
index 4d8cd04..0000000
--- a/org.eclipse.search/icons/full/dlcl16/search_goto.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.search/icons/full/dlcl16/search_history.gif b/org.eclipse.search/icons/full/dlcl16/search_history.gif
deleted file mode 100644
index ee26f79..0000000
--- a/org.eclipse.search/icons/full/dlcl16/search_history.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.search/icons/full/dlcl16/search_next.gif b/org.eclipse.search/icons/full/dlcl16/search_next.gif
deleted file mode 100644
index 6cbeced..0000000
--- a/org.eclipse.search/icons/full/dlcl16/search_next.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.search/icons/full/dlcl16/search_prev.gif b/org.eclipse.search/icons/full/dlcl16/search_prev.gif
deleted file mode 100644
index a3441a0..0000000
--- a/org.eclipse.search/icons/full/dlcl16/search_prev.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.search/icons/full/dlcl16/search_rem.gif b/org.eclipse.search/icons/full/dlcl16/search_rem.gif
deleted file mode 100644
index 7e0ad4a..0000000
--- a/org.eclipse.search/icons/full/dlcl16/search_rem.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.search/icons/full/dlcl16/search_remall.gif b/org.eclipse.search/icons/full/dlcl16/search_remall.gif
deleted file mode 100644
index 7ace43e..0000000
--- a/org.eclipse.search/icons/full/dlcl16/search_remall.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.search/icons/full/dlcl16/search_sortmatch.gif b/org.eclipse.search/icons/full/dlcl16/search_sortmatch.gif
deleted file mode 100644
index 8a47d61..0000000
--- a/org.eclipse.search/icons/full/dlcl16/search_sortmatch.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.search/icons/full/dlcl16/stop.gif b/org.eclipse.search/icons/full/dlcl16/stop.gif
deleted file mode 100644
index bf15460..0000000
--- a/org.eclipse.search/icons/full/dlcl16/stop.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.search/icons/full/dtool16/search.gif b/org.eclipse.search/icons/full/dtool16/search.gif
deleted file mode 100644
index 5fe80f3..0000000
--- a/org.eclipse.search/icons/full/dtool16/search.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.search/icons/full/elcl16/flatLayout.gif b/org.eclipse.search/icons/full/elcl16/flatLayout.gif
deleted file mode 100644
index 9f9ca48..0000000
--- a/org.eclipse.search/icons/full/elcl16/flatLayout.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.search/icons/full/elcl16/hierarchicalLayout.gif b/org.eclipse.search/icons/full/elcl16/hierarchicalLayout.gif
deleted file mode 100644
index b50b2c3..0000000
--- a/org.eclipse.search/icons/full/elcl16/hierarchicalLayout.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.search/icons/full/elcl16/search_goto.gif b/org.eclipse.search/icons/full/elcl16/search_goto.gif
deleted file mode 100644
index d02e028..0000000
--- a/org.eclipse.search/icons/full/elcl16/search_goto.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.search/icons/full/elcl16/search_history.gif b/org.eclipse.search/icons/full/elcl16/search_history.gif
deleted file mode 100644
index d1e6b85..0000000
--- a/org.eclipse.search/icons/full/elcl16/search_history.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.search/icons/full/elcl16/search_next.gif b/org.eclipse.search/icons/full/elcl16/search_next.gif
deleted file mode 100644
index 1d0b40a..0000000
--- a/org.eclipse.search/icons/full/elcl16/search_next.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.search/icons/full/elcl16/search_prev.gif b/org.eclipse.search/icons/full/elcl16/search_prev.gif
deleted file mode 100644
index 1372957..0000000
--- a/org.eclipse.search/icons/full/elcl16/search_prev.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.search/icons/full/elcl16/search_rem.gif b/org.eclipse.search/icons/full/elcl16/search_rem.gif
deleted file mode 100644
index 310510e..0000000
--- a/org.eclipse.search/icons/full/elcl16/search_rem.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.search/icons/full/elcl16/search_remall.gif b/org.eclipse.search/icons/full/elcl16/search_remall.gif
deleted file mode 100644
index 33908b1..0000000
--- a/org.eclipse.search/icons/full/elcl16/search_remall.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.search/icons/full/elcl16/search_sortmatch.gif b/org.eclipse.search/icons/full/elcl16/search_sortmatch.gif
deleted file mode 100644
index 336c0ec..0000000
--- a/org.eclipse.search/icons/full/elcl16/search_sortmatch.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.search/icons/full/elcl16/stop.gif b/org.eclipse.search/icons/full/elcl16/stop.gif
deleted file mode 100644
index 8ea6ff7..0000000
--- a/org.eclipse.search/icons/full/elcl16/stop.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.search/icons/full/etool16/search.gif b/org.eclipse.search/icons/full/etool16/search.gif
deleted file mode 100644
index 57ed3b4..0000000
--- a/org.eclipse.search/icons/full/etool16/search.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.search/icons/full/eview16/searchres.gif b/org.eclipse.search/icons/full/eview16/searchres.gif
deleted file mode 100644
index 7425e60..0000000
--- a/org.eclipse.search/icons/full/eview16/searchres.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.search/icons/full/obj16/searchm_obj.gif b/org.eclipse.search/icons/full/obj16/searchm_obj.gif
deleted file mode 100644
index 657b67e..0000000
--- a/org.eclipse.search/icons/full/obj16/searchm_obj.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.search/icons/full/obj16/tsearch_dpdn_obj.gif b/org.eclipse.search/icons/full/obj16/tsearch_dpdn_obj.gif
deleted file mode 100644
index e6be562..0000000
--- a/org.eclipse.search/icons/full/obj16/tsearch_dpdn_obj.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.search/icons/full/obj16/tsearch_obj.gif b/org.eclipse.search/icons/full/obj16/tsearch_obj.gif
deleted file mode 100644
index 73ac91b..0000000
--- a/org.eclipse.search/icons/full/obj16/tsearch_obj.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/IQueryListener.java b/org.eclipse.search/new search/org/eclipse/search/ui/IQueryListener.java
deleted file mode 100644
index 5b9ebb7..0000000
--- a/org.eclipse.search/new search/org/eclipse/search/ui/IQueryListener.java
+++ /dev/null
@@ -1,47 +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.search.ui;
-/**
- * A listener for changes to the set of search queries. Queries are added by running
- * them via the appropriate methods in the <code>NewSearchUI</code> facade class.<br>
- * see {@link org.eclipse.search.ui.NewSearchUI#runQuery(ISearchQuery)}<br>
- * see {@link org.eclipse.search.ui.NewSearchUI#runQueryInForeground(IRunnableContext, ISearchQuery) }<br>
- * The search UI determines when queries are rerun, stopped or deleted (and will notify
- * interested parties via this interface).
- * This interface may be implemented by clients.
- *
- * This API is preliminary and subject to change at any time.
- *
- * @since 3.0
- */
-public interface IQueryListener {
- /**
- * Called when an query has been added to the system.
- *
- * @param query The query that has been added
- */
- void queryAdded(ISearchQuery query);
- /**
- * Called when a query has been removed.
- *
- * @param query The query that has been removed
- */
- void queryRemoved(ISearchQuery query);
-
- /**
- * Called before an <code>ISearchQuery</code> is starting.
- * @param query the query about to start
- */
- void queryStarting(ISearchQuery query);
- /**
- * Called after an <code>ISearchQuery</code> has finished.
- * @param query the query that has finished
- */
- void queryFinished(ISearchQuery query);
-}
diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/ISearchQuery.java b/org.eclipse.search/new search/org/eclipse/search/ui/ISearchQuery.java
deleted file mode 100644
index 7552f4c..0000000
--- a/org.eclipse.search/new search/org/eclipse/search/ui/ISearchQuery.java
+++ /dev/null
@@ -1,57 +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.search.ui;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-/**
- * Represents a particular search query (e.g. "find all occurrences of 'foo' in
- * workspace"). When run, the query must update its <code>ISearchResult</code>
- * with the results of the query.
- * This interface may be implemented by clients.
- *
- * This API is preliminary and subject to change at any time.
- *
- * @since 3.0
- */
-public interface ISearchQuery {
- /**
- * This is the method that actually does the work, i.e. finds the results
- * of the search query.
- *
- * @param monitor The progress monitor to be used
- * @return The status after completion of the search job.
- */
- IStatus run(IProgressMonitor monitor);
- /**
- * Returns the a user readable label for this query. This will be used, for example to
- * set the <code>Job</code> name if this query is executed in the
- * background. Note that progress notification (for example, the number of matches
- * found) should be done via the progress monitor passed into the <code>run(IProgressMonitor)</code> method
- *
- * @return The user readable label of this query.
- */
- String getLabel();
- /**
- * Returns whether the query can be run more than once. Some queries may depend on transient
- * information and return <code>false</code>.
- * @return Whether this query can be run more than once.
- */
- boolean canRerun();
- /**
- * Returns whether this query can be run in the background. Note that queries must do proper locking
- * when they are run in the background (e.g. get the appropriate workspace locks).
- * @return Whether this query can be run in the background.
- */
- boolean canRunInBackground();
- /**
- * Returns the search result associated with this query.
- * @return This query's search result.
- */
- ISearchResult getSearchResult();
-}
diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/ISearchResult.java b/org.eclipse.search/new search/org/eclipse/search/ui/ISearchResult.java
deleted file mode 100644
index 85a2b54..0000000
--- a/org.eclipse.search/new search/org/eclipse/search/ui/ISearchResult.java
+++ /dev/null
@@ -1,60 +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.search.ui;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-
-/**
- * Represents the result of a search. The class of an <code>ISearchResult</code>
- * is used to determine which <code>ISearchResultPage</code> is used
- * to display it, by matching the <code>targetClass</code> attribute in the
- * <code>searchResultViewPages</code> extension point to the class of the seaarch
- * result.
- * Clients may implement this interface.
- *
- * This API is preliminary and subject to change at any time.
- * @since 3.0
- */
-public interface ISearchResult {
- /**
- * Adds a <code>ISearchResultListener</code>. Has no effect when the
- * listener has already been added.
- * @param l The listener to be added
- */
- public void addListener(ISearchResultListener l);
- /**
- * Removes a <code>ISearchResultChangedListener</code>. Has no effect when the
- * listener hasn't previously been added.
- * @param l The listener to be removed.
- */
- public void removeListener(ISearchResultListener l);
- /**
- * Returns a user readable label for this search result.
- * @return The label for this search result.
- */
- String getLabel();
- /**
- * Returns a tooltip to be used when this search result is shown in the UI.
- * @return A user readable String.
- */
- public String getTooltip();
- /**
- * Returns an image descriptor for the given ISearchResult.
- * @return An image representing this search result or <code>null</code>.
- */
- ImageDescriptor getImageDescriptor();
-
- /**
- * Returns the query that produced this search result.
- * @return The query producing this result.
- */
- ISearchQuery getQuery();
-}
diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/ISearchResultListener.java b/org.eclipse.search/new search/org/eclipse/search/ui/ISearchResultListener.java
deleted file mode 100644
index fd6c0bb..0000000
--- a/org.eclipse.search/new search/org/eclipse/search/ui/ISearchResultListener.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.search.ui;
-/**
- * Listener interface for changes to <code>ISearchResult</code>.
- * Implementers of <code>ISearchResult</code> should define subclasses of
- * <code>SearchResultEvent</code> and send those to registered listeners. Implementers of
- * <code>ISearchResultListener</code> will in general know the concrete class of search
- * result they are listening to, and therefore the kind of events they
- * have to handle.
- *
- * This API is preliminary and subject to change at any time.
- * Clients may implement this interface.
- *
- * @since 3.0
- */
-public interface ISearchResultListener {
- /**
- * Called to notify listeners of changes in a <code>ISearchResult</code>.
- * The event object <code>e</code> is only guarantueed to be valid for
- * the duration of the call.
- *
- * @param e The event object describing the change. Note that
- * implementers of <code>ISearchResult</code> will be sending
- * subclasses of <code>SearchResultEvent</code>.
- */
- void searchResultChanged(SearchResultEvent e);
-}
diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/ISearchResultPage.java b/org.eclipse.search/new search/org/eclipse/search/ui/ISearchResultPage.java
deleted file mode 100644
index df4ca08..0000000
--- a/org.eclipse.search/new search/org/eclipse/search/ui/ISearchResultPage.java
+++ /dev/null
@@ -1,83 +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.search.ui;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.part.IPageBookViewPage;
-/**
- * Extensions of extension point org.eclipse.search.ui.searchResultViewPages
- * must implement this interface.
- * When the user selects an <code>ISearchResult</code> in the search results
- * view, the corresponding (as configured in the extension) <code>ISearchResultPage</code>
- * will be used to display the search result.
- * Clients may implement this interface.
- *
- * This API is preliminary and subject to change at any time.
- *
- * @since 3.0
- */
-public interface ISearchResultPage extends IPageBookViewPage {
- /**
- * Returns an Object representing the current state of the page UI. For
- * example, the current selection in a viewer. The UI state will be later
- * passed into the <code>setInput()</code> method when the currently
- * shown <code>ISearchResult</code> is shown again.
- *
- * @return An object representing the UI state of this page.
- */
- Object getUIState();
- /**
- * Sets the search result to be shown in this search results page. Implementers
- * should restore UI state (e.g. selection) from the previously saved <code>uiState</code>
- * object.
- * @see ISearchResultPage#getUIState()
- *
- * @param search the search result to be shown
- * @param uiState the previously saved UI state.
- */
- void setInput(ISearchResult search, Object uiState);
- /**
- * Sets the search view this search results page is shown in. This method will be called before the page is shown
- * for the first time (i.e. before the page control is created).
- *
- * @param part the parent search view.
- */
- void setViewPart(ISearchResultViewPart part);
-
- /**
- * Restores the page state. Note that this applies only to state that is saved
- * across sessions. For restoring state that is transient:
- *
- * @see #setInput(ISearchResult, Object)
- *
- * @param memento a memento to restore the page state from or <code>null</code>
- * if no previous state was saved.
- */
- void restoreState(IMemento memento);
-
- /**
- * Saves the page state in a memento. Note that this applies to state that
- * should persist across sessions. For transient state:
- *
- * @see #getUIState()
- *
- * @param memento a memento to receive the object state
- */
- void saveState(IMemento memento);
-
- /**
- * Sets the id for this page. This method will be called before any other initialization is done.
- * @param id assigns an id to this page.
- */
- void setID(String id);
- /**
- * Returns the id set via <code>setID</code>.
- * @return the id of this page
- */
- String getID();
-}
diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/ISearchResultViewPart.java b/org.eclipse.search/new search/org/eclipse/search/ui/ISearchResultViewPart.java
deleted file mode 100644
index 2bc7d6a..0000000
--- a/org.eclipse.search/new search/org/eclipse/search/ui/ISearchResultViewPart.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.search.ui;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.ui.IViewPart;
-/**
- * Interface for the search result view. The search result view part is responsible
- * for managing the set of search result and delegates display of search results
- * to the appropriate <code>ISearchResultPage</code>.
- * This insterface must not be implemented by clients.
- *
- * This API is preliminary and subject to change at any time.
- *
- * @since 3.0
- */
-public interface ISearchResultViewPart extends IViewPart {
- /**
- * Search result pages should call this method to have the search results view
- * contribute to their context menus.
- *
- * @param menuManager the menu manager the search result view should contribute to.
- */
- void fillContextMenu(IMenuManager menuManager);
- /**
- * Returns the <code>ISearchResultPage</code> currently shown in this
- * search view. Returns <code>null</code> if no page is currently shown.
- * @return the active <code>ISearchResultPage</code> or <code>null</code>
- */
- ISearchResultPage getActivePage();
-}
diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/NewSearchUI.java b/org.eclipse.search/new search/org/eclipse/search/ui/NewSearchUI.java
deleted file mode 100644
index 9a22f33..0000000
--- a/org.eclipse.search/new search/org/eclipse/search/ui/NewSearchUI.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Common Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.search.ui;
-import org.eclipse.core.runtime.IStatus;
-
-import org.eclipse.jface.operation.IRunnableContext;
-
-import org.eclipse.search2.internal.ui.InternalSearchUI;
-/**
- * A facade for access to the new search ui.
- * This API is preliminary and subject to change at any time.
- *
- * @since 3.0
- */
-public class NewSearchUI {
- /**
- * Activates a search result view in the current workbench window page..
- */
- public static ISearchResultViewPart activateSearchResultView() {
- return InternalSearchUI.getInstance().activateSearchView();
- }
-
- /**
- * Gets the search result view shown in the current worbench window.
- * @return the search result view or <code>null</code>, if none is open in the
- * current workbench window page
- */
- public static ISearchResultViewPart getSearchResultView() {
- return InternalSearchUI.getInstance().getSearchView();
- }
- /**
- * Runs the given search query. This method may run the given query in a separate thread
- * if <code>ISearchQuery#canRunInBackground()</code> returns <code>true</code>.
- * Running a query adds it to the set of known queries.
- *
- * @param query the query to execute.
- */
- public static void runQuery(ISearchQuery query) {
- if (query.canRunInBackground())
- InternalSearchUI.getInstance().runSearchInBackground(query);
- else
- InternalSearchUI.getInstance().runSearchInForeground(null, query);
- }
-
- /**
- * Runs the given search query. This method will execute the query in the same thread
- * as the caller. This method blocks until the query is finished.
- * Running a query adds it to the set of known queries.
- *
- * @param context the runnable context to run the query in.
- * @param query the query to execute.
- */
- public static IStatus runQueryInForeground(IRunnableContext context, ISearchQuery query) {
- return InternalSearchUI.getInstance().runSearchInForeground(context, query);
- }
-
- /**
- * Adds the given query listener. Does nothing when the listener is already
- * present.
- *
- * @param l the listener to be added.
- */
- public static void addQueryListener(IQueryListener l) {
- InternalSearchUI.getInstance().addQueryListener(l);
- }
- /**
- * Removes the given query listener. Does nothing if the listener is
- * not present.
- *
- * @param l the listener to be removed.
- */
- public static void removeQueryListener(IQueryListener l) {
- InternalSearchUI.getInstance().removeQueryListener(l);
- }
-
- /**
- * Returns all search queries know to the search ui.
- *
- * @return all search result.
- */
- public static ISearchQuery[] getQueries() {
- return InternalSearchUI.getInstance().getQueries();
- }
-
- /**
- * Returns whether the given query is currently running. Queries
- * may be run by client request or by actions in the search UI.
- * @see #runQuery(ISearchQuery)
- * @see #runQueryInForeground(IRunnableContext, ISearchQuery)
- * @param query the query
- * @return whether the given query is currently running.
- */
- public static boolean isQueryRunning(ISearchQuery query) {
- return InternalSearchUI.getInstance().isQueryRunning(query);
- }
-}
diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/SearchResultEvent.java b/org.eclipse.search/new search/org/eclipse/search/ui/SearchResultEvent.java
deleted file mode 100644
index b35f2b3..0000000
--- a/org.eclipse.search/new search/org/eclipse/search/ui/SearchResultEvent.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Common Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.search.ui;
-/**
- * The common superclass of all events sent from ISearchResults. This class is
- * supposed to be subclassed to provide more specific notification.
- * see {@link org.eclipse.search.ui.ISearchResultListener#searchResultChanged(SearchResultEvent)}
- *
- * This API is preliminary and subject to change at any time.
- *
- * @since 3.0
- */
-public abstract class SearchResultEvent {
- protected ISearchResult fSearchResult;
- protected SearchResultEvent(ISearchResult searchResult) {
- fSearchResult= searchResult;
- }
- protected SearchResultEvent() {
- this(null);
- }
- /**
- * Gets the <code>ISearchResult</code> for this event.
- *
- * @return The source of this event.
- */
- public ISearchResult getSearchResult() {
- return fSearchResult;
- }
- /**
- * Sets the search result for this event.
- * @param searchResult The searchResult to set.
- */
- protected void setSearchResult(ISearchResult searchResult) {
- fSearchResult= searchResult;
- }
-}
diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/package.html b/org.eclipse.search/new search/org/eclipse/search/ui/package.html
deleted file mode 100644
index c250509..0000000
--- a/org.eclipse.search/new search/org/eclipse/search/ui/package.html
+++ /dev/null
@@ -1,16 +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.75 [en] (WinNT; U) [Netscape]"><title>Package-level Javadoc</title>
-</head>
-<body>Provides classes and interfaces to run search queries and manage
-their results. Clients can contribute search result pages into the
-search result view by implementing an extension point.<br>
-
-<h2>
-Package Specification</h2>
-Each search result page must implement <tt>ISearchResultPage</tt>. The class <tt>NewSearchUI</tt> can activate the search
-results view and provide access to the active search results view (<tt>ISearchResultView</tt>).
-<p>Clients create instances of <code>ISearchResult</code>. They must also provide a matching search result page. Clients can register to receive SearchResultEvents when a search result changes.<br>
-
-</p></body></html>
\ No newline at end of file
diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchResult.java b/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchResult.java
deleted file mode 100644
index 2310bce..0000000
--- a/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchResult.java
+++ /dev/null
@@ -1,317 +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.search.ui.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.Set;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.search.ui.ISearchResult;
-import org.eclipse.search.ui.ISearchResultListener;
-import org.eclipse.search.ui.SearchResultEvent;
-import org.eclipse.ui.IEditorPart;
-
-/**
- * An abstract superclass for text-match based search results. This search
- * result implementation consists of a list of matches. No assumptions are made about
- * the kind of elements these matches are reported against.
- * see {@link org.eclipse.search.ui.text.Match}
- * This class has abstract methods to map matches to both editors and files.
- * If a client implements the methods related to editors, matches will be highlighted
- * automatically in participating editors. Editors must implement or adapt to ITextEditor,
- * or they must adapt to IAnnotationModel in order for match highlighting to work.<br>
- * see {@link #findContainedMatches(IEditorPart)}<br>
- * see {@link #isShownInEditor(Match,IEditorPart)}<br>
- * If a client implements the methods related to files, matches will be automatically
- * updated if the file is changed via the filebuffer infrastructure.<br>
- * see {@link org.eclipse.core.filebuffers.FileBuffers}<br>
- * see {@link #findContainedMatches(IFile)<br>
- * see {@link #getFile(Object)<br>
- */
-public abstract class AbstractTextSearchResult implements ISearchResult {
- private Map fElementsToMatches;
- private List fListeners;
- private static final Match[] EMPTY_ARRAY= new Match[0];
- private MatchEvent fMatchEvent;
-
- /**
- * Constructor
- */
- protected AbstractTextSearchResult() {
- fElementsToMatches= new HashMap();
- fListeners= new ArrayList();
- fMatchEvent= new MatchEvent(this);
- }
-
- /**
- * Returns an array with all matches reported against the given element.
- *
- * @see Match#getElement()
- * @param element The element to report matches for.
- * @return All matches reported for this element.
- */
- public Match[] getMatches(Object element) {
- synchronized (fElementsToMatches) {
- return doGetMatches(element);
- }
- }
-
- private Match[] doGetMatches(Object element) {
- List matches= (List) fElementsToMatches.get(element);
- if (matches != null)
- return (Match[]) matches.toArray(new Match[matches.size()]);
- return EMPTY_ARRAY;
- }
-
- /**
- * Adds a Match to this search result. This method does nothing if the
- * Match is already present.
- * Subclasses may extend this method.
- *
- * @param match The match to add.
- */
- public void addMatch(Match match) {
- boolean hasAdded= false;
- synchronized (fElementsToMatches) {
- hasAdded= doAddMatch(match);
- }
- if (hasAdded)
- fireChange(getSearchResultEvent(match, MatchEvent.ADDED));
- }
-
- /**
- * Adds a number of Matches to this search result. This method does nothing for
- * matches that are already present.
- * Subclasses may extend this method.
- * @param matches the matches to add.
- */
- public void addMatches(Match[] matches) {
-
- Set reallyAdded= new HashSet();
- synchronized (fElementsToMatches) {
- for (int i = 0; i < matches.length; i++) {
- if (doAddMatch(matches[i]))
- reallyAdded.add(matches[i]);
- }
- }
- if (reallyAdded.size() > 0)
- fireChange(getSearchResultEvent(reallyAdded, MatchEvent.ADDED));
- }
-
- private MatchEvent getSearchResultEvent(Match match, int eventKind) {
- fMatchEvent.setKind(eventKind);
- fMatchEvent.setMatch(match);
- return fMatchEvent;
- }
-
- private MatchEvent getSearchResultEvent(Set matches, int eventKind) {
- fMatchEvent.setKind(eventKind);
- Match[] matchArray= new Match[matches.size()];
- matches.toArray(matchArray);
- fMatchEvent.setMatches(matchArray);
- return fMatchEvent;
- }
-
- private boolean doAddMatch(Match match) {
- List matches= (List) fElementsToMatches.get(match.getElement());
- if (matches == null) {
- matches= new ArrayList();
- fElementsToMatches.put(match.getElement(), matches);
- }
- if (!matches.contains(match)) {
- matches.add(match);
- return true;
- }
- return false;
- }
-
- /**
- * Removes all matches from this search result.
- * Subclasses may extend this method.
- */
- public void removeAll() {
- synchronized (fElementsToMatches) {
- doRemoveAll();
- }
- fireChange(new RemoveAllEvent(this));
- }
- private void doRemoveAll() {
- fElementsToMatches.clear();
- }
-
- /**
- * Removes the given match from this search result. This method has no
- * effect if the match is not found.
- * Subclasses may extend this method.
- *
- * @param match the match to remove.
- */
- public void removeMatch(Match match) {
- boolean existed= false;
- synchronized (fElementsToMatches) {
- existed= doRemoveMatch(match);
- }
- if (existed)
- fireChange(getSearchResultEvent(match, MatchEvent.REMOVED));
- }
-
- /**
- * Removes the given matches from this search result. This method has no
- * effect for matches that are not found
- * Subclasses may extend this method.
- *
- * @param matches the matches to remove.
- */
- public void removeMatches(Match[] matches) {
- Set existing= new HashSet();
- synchronized (fElementsToMatches) {
- for (int i = 0; i < matches.length; i++) {
- if (doRemoveMatch(matches[i]))
- existing.add(matches[i]);
- }
- }
- if (existing.size() > 0)
- fireChange(getSearchResultEvent(existing, MatchEvent.REMOVED));
- }
-
-
- private boolean doRemoveMatch(Match match) {
- boolean existed= false;
- List matches= (List) fElementsToMatches.get(match.getElement());
- if (matches != null) {
- existed= matches.remove(match);
- if (matches.isEmpty())
- fElementsToMatches.remove(match.getElement());
- }
- return existed;
- }
- /**
- * {@inheritDoc}
- */
- public void addListener(ISearchResultListener l) {
- synchronized (fListeners) {
- fListeners.add(l);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void removeListener(ISearchResultListener l) {
- synchronized (fListeners) {
- fListeners.remove(l);
- }
- }
-
- /**
- * Send the given <code>SearchResultEvent<code> to all registered search
- * result listeners
- * @see ISearchResultListener
- * @param e The event to be sent.
- */
- protected void fireChange(SearchResultEvent e) {
- HashSet copiedListeners= new HashSet();
- synchronized (fListeners) {
- copiedListeners.addAll(fListeners);
- }
- Iterator listeners= copiedListeners.iterator();
- while (listeners.hasNext()) {
- ((ISearchResultListener) listeners.next()).searchResultChanged(e);
- }
- }
- /**
- * Returns the total number of matches contained in this search result.
- *
- * @return Total number of matches.
- */
- public int getMatchCount() {
- int count= 0;
- synchronized (fElementsToMatches) {
- for (Iterator elements= fElementsToMatches.values().iterator(); elements.hasNext();) {
- List element= (List) elements.next();
- if (element != null)
- count+= element.size();
- }
- }
- return count;
- }
- /**
- * Returns the number of matches reported against a given element. This is
- * equivalent to calling <code>getMatches(element).length</code>
- *
- * @param element The element to get the match count for.
- * @return The number of matches reported against the element.
- */
- public int getMatchCount(Object element) {
- List matches= (List) fElementsToMatches.get(element);
- if (matches != null)
- return matches.size();
- return 0;
- }
- /**
- * Returns an array containing the set of all elements that matches are
- * reported against in this search result.
- *
- * @return The set of elements in this search result.
- */
- public Object[] getElements() {
- synchronized (fElementsToMatches) {
- return fElementsToMatches.keySet().toArray();
- }
- }
-
-
- /**
- * Returns an array with all matches contained in the given file. If the
- * matches are not contained within an <code>IFile</code>, this method
- * must return an empty array.
- *
- * @param file The file to find matches in.
- * @return An array of matches (possibly empty).
- */
- public abstract Match[] findContainedMatches(IFile file);
- /**
- * Returns the file associated with the given element (usually the file
- * the element is contained in). If the element is not associated with a
- * file, this method should return <code>null</code>.
- *
- * @param element An element associated with a match.
- * @return The file associated with the element or null.
- */
- public abstract IFile getFile(Object element);
- /**
- * Determines whether a match should be displayed in the given editor.
- * For example, if a match is reported in a file, This method should return
- * <code>true</code>, if the given editor displays the file.
- *
- * @param match The match.
- * @param editor The editor that possibly contains the matches element.
- * @return
- */
- public abstract boolean isShownInEditor(Match match, IEditorPart editor);
- /**
- * Returns all matches that are contained in the element shown in the given
- * editor.
- * For example, if the editor shows a particular file, all matches in that file should
- * be returned.
- *
- * @param editor The editor.
- * @return All matches that are contained in the element that is shown in
- * the given editor.
- */
- public abstract Match[] findContainedMatches(IEditorPart editor);
-
-
-}
diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java b/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java
deleted file mode 100644
index 553b21a..0000000
--- a/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java
+++ /dev/null
@@ -1,800 +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.search.ui.text;
-import java.util.HashSet;
-import java.util.Set;
-import org.eclipse.core.runtime.ISafeRunnable;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.GroupMarker;
-import org.eclipse.jface.action.IContributionManager;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.viewers.IOpenListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.OpenEvent;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.search.internal.ui.CopyToClipboardAction;
-import org.eclipse.search.internal.ui.SearchPlugin;
-import org.eclipse.search.internal.ui.SearchPluginImages;
-import org.eclipse.search.ui.IContextMenuConstants;
-import org.eclipse.search.ui.IQueryListener;
-import org.eclipse.search.ui.ISearchQuery;
-import org.eclipse.search.ui.ISearchResult;
-import org.eclipse.search.ui.ISearchResultListener;
-import org.eclipse.search.ui.ISearchResultPage;
-import org.eclipse.search.ui.ISearchResultViewPart;
-import org.eclipse.search.ui.NewSearchUI;
-import org.eclipse.search.ui.SearchResultEvent;
-import org.eclipse.search2.internal.ui.InternalSearchUI;
-import org.eclipse.search2.internal.ui.SearchMessages;
-import org.eclipse.search2.internal.ui.basic.views.INavigate;
-import org.eclipse.search2.internal.ui.basic.views.RemoveAllResultsAction;
-import org.eclipse.search2.internal.ui.basic.views.RemoveMatchAction;
-import org.eclipse.search2.internal.ui.basic.views.SearchResultsTableViewer;
-import org.eclipse.search2.internal.ui.basic.views.SearchResultsTreeViewer;
-import org.eclipse.search2.internal.ui.basic.views.SetLayoutAction;
-import org.eclipse.search2.internal.ui.basic.views.ShowNextResultAction;
-import org.eclipse.search2.internal.ui.basic.views.ShowPreviousResultAction;
-import org.eclipse.search2.internal.ui.text.AnnotationManager;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.part.IPageSite;
-import org.eclipse.ui.part.Page;
-import org.eclipse.ui.part.PageBook;
-/**
- * An abstract superclass for classes showing
- * <code>AbstractTextSearchResult</code> instances. This class assumes that
- * the input element (see {@link AbstractTextSearchViewPage#setInput(ISearchResult,Object)}) is a subclass of
- * <code>AbstractTextSearchResult</code>. This results page supports a tree
- * and/or a table presentation of search results. Subclasses can determine which
- * presentations they want to support at construction time. Subclasses must
- * customize the viewers for each presentation with a label provider and a
- * content provider. <br>
- * see {@link #configureTableViewer(TableViewer)}<br>
- * see {@link #configureTreeViewer(TreeViewer))<br>
- *
- * Changes in the search result are handled by updating the viewer in the
- * <code>elementsChanged()</code> and <code>clear()</code> methods.
- */
-public abstract class AbstractTextSearchViewPage extends Page implements ISearchResultPage {
- private static final String KEY_LAYOUT = "org.eclipse.search.resultpage.layout"; //$NON-NLS-1$
- private StructuredViewer fViewer;
- private Composite fViewerContainer;
- private Control fBusyLabel;
- private PageBook fPagebook;
- private boolean fIsBusyShown;
- private ISearchResultViewPart fViewPart;
- private Set fBatchedUpdates;
- private ISearchResultListener fListener;
- private IQueryListener fQueryListener;
- private MenuManager fMenu;
- // Actions
- private Action fCopyToClipboardAction;
- private Action fRemoveResultsAction;
- private Action fRemoveAllResultsAction;
- private Action fShowNextAction;
- private Action fShowPreviousAction;
- private SetLayoutAction fFlatAction;
- private SetLayoutAction fHierarchicalAction;
- private int fCurrentLayout;
- private int fCurrentMatchIndex = 0;
- private String fId;
- private int fSupportedLayouts;
- /**
- * Flag denoting tree layout.
- */
- public static final int FLAG_LAYOUT_FLAT = 1;
- /**
- * Flag denoting flat list layout.
- */
- public static final int FLAG_LAYOUT_TREE = 2;
- private boolean fIsUpdatePosted;
- /**
- * This constructor must be passed a combination of layout flags combined
- * with bitwise or. At least one flag musst be passed in (i.e. 0 is not a
- * permitted value).
- *
- * @param supportedLayouts
- * Flags determining which layout options this page supports.
- * Must not be 0.
- * @see #FLAG_LAYOUT_FLAT
- * @see #FLAG_LAYOUT_TREE
- */
- protected AbstractTextSearchViewPage(int supportedLayouts) {
- fSupportedLayouts = supportedLayouts;
- initLayout();
- fRemoveAllResultsAction = new RemoveAllResultsAction(this);
- fRemoveResultsAction = new RemoveMatchAction(this);
- fShowNextAction = new ShowNextResultAction(this);
- fShowPreviousAction = new ShowPreviousResultAction(this);
- createLayoutActions();
- fBatchedUpdates = new HashSet();
- fListener = new ISearchResultListener() {
- public void searchResultChanged(SearchResultEvent e) {
- handleSearchResultsChanged(e);
- }
- };
- }
- /**
- *
- */
- private void initLayout() {
- if (supportsFlatLayout())
- fCurrentLayout = FLAG_LAYOUT_FLAT;
- else
- fCurrentLayout = FLAG_LAYOUT_TREE;
- }
- /**
- * Constructs this page with the default layout flags.
- *
- * @see #AbstractTextSearchViewPage(int)
- */
- protected AbstractTextSearchViewPage() {
- this(FLAG_LAYOUT_FLAT | FLAG_LAYOUT_TREE);
- }
- private void createLayoutActions() {
- if (countBits(fSupportedLayouts) > 1) {
- fFlatAction = new SetLayoutAction(
- this,
- SearchMessages
- .getString("AbstractTextSearchViewPage.flat_layout.label"),
- SearchMessages
- .getString("AbstractTextSearchViewPage.flat_layout.tooltip"),
- FLAG_LAYOUT_FLAT); //$NON-NLS-1$ //$NON-NLS-2$
- fHierarchicalAction = new SetLayoutAction(
- this,
- SearchMessages
- .getString("AbstractTextSearchViewPage.hierarchical_layout.label"),
- SearchMessages
- .getString("AbstractTextSearchViewPage.hierarchical_layout.tooltip"),
- FLAG_LAYOUT_TREE); //$NON-NLS-1$ //$NON-NLS-2$
- SearchPluginImages.setImageDescriptors(fFlatAction,
- SearchPluginImages.T_LCL,
- SearchPluginImages.IMG_LCL_SEARCH_FLAT_LAYOUT);
- SearchPluginImages.setImageDescriptors(fHierarchicalAction,
- SearchPluginImages.T_LCL,
- SearchPluginImages.IMG_LCL_SEARCH_HIERARCHICAL_LAYOUT);
- }
- }
- private int countBits(int layoutFlags) {
- int bitCount = 0;
- for (int i = 0; i < 32; i++) {
- if (layoutFlags % 2 == 1)
- bitCount++;
- layoutFlags >>= 1;
- }
- return bitCount;
- }
- private boolean supportsFlatLayout() {
- return isLayoutSupported(FLAG_LAYOUT_FLAT);
- }
- /**
- * Gets a dialog settings object for this search result page. There will be
- * one dialog settings object per search result page id.
- *
- * @see #getID()
- * @return The dialog settings for this search result page.
- */
- protected IDialogSettings getSettings() {
- IDialogSettings parent = SearchPlugin.getDefault().getDialogSettings();
- IDialogSettings settings = parent.getSection(getID());
- if (settings == null)
- settings = parent.addNewSection(getID());
- return settings;
- }
- /**
- * {@inheritDoc}
- */
- public void setID(String id) {
- fId = id;
- }
- /**
- * {@inheritDoc}
- */
- public String getID() {
- return fId;
- }
- /**
- * Opens an editor on the given element and selects the given range of text.
- * The location of matches are automatically updated when a file is editor
- * through the file buffer infrastructure (see {@link org.eclipse.core.filebuffers.ITextFileBufferManager}).
- * When a file buffer is saved, the current positions are written back to the
- * match.
- *
- * @param match
- * The match to show
- * @param currentOffset
- * The current start offset of the match
- * @param currentLength
- * The current length of the selection
- * @throws PartInitException
- * If an editor can't be opened.
- */
- protected abstract void showMatch(Match match, int currentOffset,
- int currentLength) throws PartInitException;
- /**
- * This method is called whenever the set of matches for the given elements
- * changes. This method is guaranteed to be called in the UI thread. Note
- * that this notification is asynchronous. i.e. further changes may have
- * occured by the time this method is called. They will be described in a
- * future call.
- *
- * @param objects
- * Array of objects that has to be refreshed.
- */
- protected abstract void elementsChanged(Object[] objects);
- /**
- * This method is called whenever all elements have been removed from the
- * shown <code>AbstractSearchResult</code>. This method is guaranteed to
- * be called in the UI thread. Note that this notification is asynchronous.
- * i.e. further changes may have occured by the time this method is called.
- * They will be described in a future call.
- */
- protected abstract void clear();
- /**
- * Configures the given viewer. Implementers have to set at least a content
- * provider and a label provider. This method may be called if the page was
- * constructed with the flag <code>FLAG_LAYOUT_TREE</code>.
- *
- * @param viewer
- * The viewer to be configured
- */
- protected abstract void configureTreeViewer(TreeViewer viewer);
- /**
- * Configures the given viewer. Implementers have to set at least a content
- * provider and a label provider. This method may be called if the page was
- * constructed with the flag <code>FLAG_LAYOUT_FLAT</code>.
- *
- * @param viewer
- * The viewer to be configured
- */
- protected abstract void configureTableViewer(TableViewer viewer);
- private static void createStandardGroups(IContributionManager menu) {
- menu.add(new Separator(IContextMenuConstants.GROUP_NEW));
- menu.add(new GroupMarker(IContextMenuConstants.GROUP_GOTO));
- menu.add(new GroupMarker(IContextMenuConstants.GROUP_OPEN));
- menu.add(new Separator(IContextMenuConstants.GROUP_SHOW));
- menu.add(new Separator(IContextMenuConstants.GROUP_BUILD));
- menu.add(new Separator(IContextMenuConstants.GROUP_REORGANIZE));
- menu.add(new Separator(IContextMenuConstants.GROUP_REMOVE_MATCHES));
- menu.add(new GroupMarker(IContextMenuConstants.GROUP_GENERATE));
- menu.add(new Separator(IContextMenuConstants.GROUP_SEARCH));
- menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
- menu.add(new Separator(IContextMenuConstants.GROUP_VIEWER_SETUP));
- menu.add(new Separator(IContextMenuConstants.GROUP_PROPERTIES));
- }
- /**
- * Fills the context menu for this page. Subclasses may override this
- * method.
- *
- * @param tbm
- */
- protected void fillContextMenu(IMenuManager mgr) {
- mgr.appendToGroup(IContextMenuConstants.GROUP_ADDITIONS,
- fCopyToClipboardAction);
- mgr.appendToGroup(IContextMenuConstants.GROUP_SHOW, fShowNextAction);
- mgr
- .appendToGroup(IContextMenuConstants.GROUP_SHOW,
- fShowPreviousAction);
- if (getCurrentMatch() != null)
- mgr.appendToGroup(IContextMenuConstants.GROUP_REMOVE_MATCHES,
- fRemoveResultsAction);
- mgr.appendToGroup(IContextMenuConstants.GROUP_REMOVE_MATCHES,
- fRemoveAllResultsAction);
- }
- /**
- * {@inheritDoc}
- */
- public void createControl(Composite parent) {
- fQueryListener = createQueryListener();
- fMenu = new MenuManager("#PopUp"); //$NON-NLS-1$
- fMenu.setRemoveAllWhenShown(true);
- fMenu.setParent(getSite().getActionBars().getMenuManager());
- fMenu.addMenuListener(new IMenuListener() {
- public void menuAboutToShow(IMenuManager mgr) {
- createStandardGroups(mgr);
- fillContextMenu(mgr);
- fViewPart.fillContextMenu(mgr);
- }
- });
- fPagebook = new PageBook(parent, SWT.NULL);
- fPagebook.setLayoutData(new GridData(GridData.FILL_BOTH));
- fBusyLabel = createBusyControl();
- fViewerContainer = new Composite(fPagebook, SWT.NULL);
- fViewerContainer.setLayoutData(new GridData(GridData.FILL_BOTH));
- fViewerContainer.setSize(100, 100);
- fViewerContainer.setLayout(new FillLayout());
- createViewer(fViewerContainer, fCurrentLayout);
- showBusyLabel(fIsBusyShown);
- NewSearchUI.addQueryListener(fQueryListener);
- }
- private Control createBusyControl() {
- Table busyLabel = new Table(fPagebook, SWT.NULL);
- TableItem item = new TableItem(busyLabel, SWT.NULL);
- item.setText(SearchMessages
- .getString("AbstractTextSearchViewPage.searching.label")); //$NON-NLS-1$
- busyLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- return busyLabel;
- }
- private IQueryListener createQueryListener() {
- final Runnable runnable = new Runnable() {
- public void run() {
- updateBusyLabel();
- }
- };
- return new IQueryListener() {
- public void queryAdded(ISearchQuery query) {
- // ignore
- }
- public void queryRemoved(ISearchQuery query) {
- // ignore
- }
- public void queryStarting(ISearchQuery query) {
- asyncExec(runnable);
- }
- public void queryFinished(ISearchQuery query) {
- asyncExec(runnable);
- }
- };
- }
- private void updateBusyLabel() {
- AbstractTextSearchResult result = getInput();
- boolean shouldShowBusy = result != null
- && NewSearchUI.isQueryRunning(result.getQuery())
- && result.getMatchCount() == 0;
- if (shouldShowBusy == fIsBusyShown)
- return;
- fIsBusyShown = shouldShowBusy;
- showBusyLabel(fIsBusyShown);
- }
- private void showBusyLabel(boolean shouldShowBusy) {
- if (shouldShowBusy)
- fPagebook.showPage(fBusyLabel);
- else
- fPagebook.showPage(fViewerContainer);
- }
- /**
- * Determines whether a certain layout is supported by this search result
- * page.
- *
- * @see #AbstractTextSearchViewPage(int)
- * @param layout the layout to test for
- * @return whether the given layout is suppported.
- */
- public boolean isLayoutSupported(int layout) {
- return (layout & fSupportedLayouts) == layout;
- }
- /**
- * Sets the layout of this search result page. The layout must be on of
- * <code>FLAG_LAYOUT_FLAT</code> or <code>FLAG_LAYOUT_TREE</code>.
- * <code>layout</code> must be one of the values passed during
- * construction of this search result page.
- *
- * @see #isLayoutSupported(int)
- */
- public void setLayout(int layout) {
- Assert.isTrue(countBits(layout) == 1);
- Assert.isTrue(isLayoutSupported(layout));
- if (countBits(fSupportedLayouts) < 2)
- return;
- if (fCurrentLayout == layout)
- return;
- fCurrentLayout = layout;
- ISelection selection = fViewer.getSelection();
- ISearchResult result = disconnectViewer();
- fViewer.getControl().dispose();
- fViewer = null;
- createViewer(fViewerContainer, layout);
- fViewerContainer.layout(true);
- connectViewer(result);
- fViewer.setSelection(selection, true);
- getSettings().put(KEY_LAYOUT, layout);
- }
- private void updateLayoutActions() {
- if (fFlatAction != null)
- fFlatAction.setChecked(fCurrentLayout == fFlatAction.getLayout());
- if (fHierarchicalAction != null)
- fHierarchicalAction
- .setChecked(fCurrentLayout == fHierarchicalAction
- .getLayout());
- }
- /**
- * Return the layout this page is currently using.
- *
- * @see #FLAG_LAYOUT_FLAT
- * @see #FLAG_LAYOUT_TREE
- * @return The layout this page is currently using.
- */
- public int getLayout() {
- return fCurrentLayout;
- }
- private void createViewer(Composite parent, int layout) {
- if ((layout & FLAG_LAYOUT_FLAT) != 0) {
- TableViewer viewer = new SearchResultsTableViewer(parent, SWT.MULTI
- | SWT.H_SCROLL | SWT.V_SCROLL);
- fViewer = viewer;
- configureTableViewer(viewer);
- } else if ((layout & FLAG_LAYOUT_TREE) != 0) {
- TreeViewer viewer = new SearchResultsTreeViewer(parent, SWT.MULTI
- | SWT.H_SCROLL | SWT.V_SCROLL);
- fViewer = viewer;
- configureTreeViewer(viewer);
- }
- IToolBarManager tbm = getSite().getActionBars().getToolBarManager();
- tbm.removeAll();
- createStandardGroups(tbm);
- fillToolbar(tbm);
- tbm.update(false);
- fViewer.addOpenListener(new IOpenListener() {
- public void open(OpenEvent event) {
- boolean hasCurrentMatch = showCurrentMatch();
- if (event.getViewer() instanceof TreeViewer
- && event.getSelection() instanceof IStructuredSelection) {
- TreeViewer tv = (TreeViewer) event.getViewer();
- Object element = ((IStructuredSelection) event
- .getSelection()).getFirstElement();
- tv.setExpandedState(element, !tv.getExpandedState(element));
- return;
- } else if (!hasCurrentMatch) {
- gotoNextMatch();
- }
- }
- });
- fViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- fCurrentMatchIndex = 0;
- }
- });
- Menu menu = fMenu.createContextMenu(fViewer.getControl());
- fViewer.getControl().setMenu(menu);
- getSite().setSelectionProvider(fViewer);
- // Register menu
- getSite().registerContextMenu(fViewPart.getViewSite().getId(), fMenu,
- fViewer);
- updateLayoutActions();
- }
- /**
- * {@inheritDoc}
- */
- public void setFocus() {
- Control control = fViewer.getControl();
- if (control != null && !control.isDisposed())
- control.setFocus();
- }
- /**
- * {@inheritDoc}
- */
- public Control getControl() {
- return fPagebook;
- }
-
- /**
- * {@inheritDoc}
- */
- public void setInput(ISearchResult search, Object viewState) {
- ISearchResult oldSearch = disconnectViewer();
- if (oldSearch != null)
- oldSearch.removeListener(fListener);
- AnnotationManager.searchResultActivated(getSite().getWorkbenchWindow(),
- (AbstractTextSearchResult) search);
- if (search != null) {
- search.addListener(fListener);
- connectViewer(search);
- if (viewState instanceof ISelection)
- fViewer.setSelection((ISelection) viewState, true);
- else
- gotoNextMatch();
- }
- updateBusyLabel();
- }
- /**
- * {@inheritDoc}
- */
- public Object getUIState() {
- return fViewer.getSelection();
- }
- private void connectViewer(ISearchResult search) {
- fCopyToClipboardAction = new CopyToClipboardAction(fViewer);
- fViewer.setInput(search);
- }
- private ISearchResult disconnectViewer() {
- ISearchResult result = (ISearchResult) fViewer.getInput();
- fViewer.setInput(null);
- return result;
- }
- /**
- * Returns the viewer currently used in this page.
- *
- * @return The currently used viewer or <code>null</code> if none has been
- * created yet.
- */
- protected StructuredViewer getViewer() {
- return fViewer;
- }
- private void showMatch(final Match match) {
- ISafeRunnable runnable = new ISafeRunnable() {
- public void handleException(Throwable exception) {
- if (exception instanceof PartInitException) {
- PartInitException pie = (PartInitException) exception;
- ErrorDialog
- .openError(
- getSite().getShell(),
- SearchMessages
- .getString("DefaultSearchViewPage.show_match"),
- SearchMessages
- .getString("DefaultSearchViewPage.error.no_editor"),
- pie.getStatus()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- public void run() throws Exception {
- Position currentPosition = InternalSearchUI.getInstance()
- .getPositionTracker().getCurrentPosition(match);
- if (currentPosition != null) {
- showMatch(match, currentPosition.getOffset(),
- currentPosition.getLength());
- } else {
- showMatch(match, match.getOffset(), match.getLength());
- }
- }
- };
- Platform.run(runnable);
- }
- /**
- * Returns the currently shown result.
- *
- * @see AbstractTextSearchViewPage#setInput(ISearchResult, Object)
- * @return The previously set result or <code>null</code>
- */
- public AbstractTextSearchResult getInput() {
- if (fViewer != null)
- return (AbstractTextSearchResult) fViewer.getInput();
- return null;
- }
- /**
- * Selects the element corresponding to the next match and shows the match
- * in an editor. Note that this will cycle back to the first match after the
- * last match.
- */
- public void gotoNextMatch() {
- fCurrentMatchIndex++;
- Match nextMatch = getCurrentMatch();
- if (nextMatch == null) {
- navigateNext(true);
- fCurrentMatchIndex = 0;
- }
- showCurrentMatch();
- }
- /**
- * Selects the element corresponding to the previous match and shows the
- * match in an editor. Note that this will cycle back to the last match
- * after the first match.
- */
- public void gotoPreviousMatch() {
- fCurrentMatchIndex--;
- Match nextMatch = getCurrentMatch();
- if (nextMatch == null) {
- navigateNext(false);
- fCurrentMatchIndex = getInput().getMatchCount(
- getFirstSelectedElement()) - 1;
- }
- showCurrentMatch();
- }
- private void navigateNext(boolean forward) {
- if (fViewer instanceof INavigate) {
- ((INavigate) fViewer).navigateNext(forward);
- }
- }
- private boolean showCurrentMatch() {
- Match currentMatch = getCurrentMatch();
- if (currentMatch != null) {
- showMatch(currentMatch);
- return true;
- } else {
- return false;
- }
- }
- /**
- * Returns the currently selected match.
- *
- * @return The selected match or null if none are selected.
- */
- public Match getCurrentMatch() {
- Object element = getFirstSelectedElement();
- if (element != null) {
- Match[] matches = getInput().getMatches(element);
- if (fCurrentMatchIndex >= 0 && fCurrentMatchIndex < matches.length)
- return matches[fCurrentMatchIndex];
- }
- return null;
- }
- private Object getFirstSelectedElement() {
- IStructuredSelection selection = (IStructuredSelection) fViewer
- .getSelection();
- if (selection.size() > 0)
- return selection.getFirstElement();
- return null;
- }
- /**
- * {@inheritDoc}
- */
- public void dispose() {
- //disconnectViewer();
- super.dispose();
- NewSearchUI.removeQueryListener(fQueryListener);
- }
- /**
- * {@inheritDoc}
- */
- public void init(IPageSite pageSite) {
- super.init(pageSite);
- addLayoutActions(pageSite.getActionBars().getMenuManager());
- }
- /**
- * Fills the toolbar contribution for this page. Subclasses may override
- * this method.
- *
- * @param tbm
- */
- protected void fillToolbar(IToolBarManager tbm) {
- tbm.appendToGroup(IContextMenuConstants.GROUP_SHOW, fShowNextAction); //$NON-NLS-1$
- tbm
- .appendToGroup(IContextMenuConstants.GROUP_SHOW,
- fShowPreviousAction); //$NON-NLS-1$
- tbm.appendToGroup(IContextMenuConstants.GROUP_REMOVE_MATCHES,
- fRemoveResultsAction); //$NON-NLS-1$
- tbm.appendToGroup(IContextMenuConstants.GROUP_REMOVE_MATCHES,
- fRemoveAllResultsAction); //$NON-NLS-1$
- IActionBars actionBars = getSite().getActionBars();
- if (actionBars != null) {
- actionBars.setGlobalActionHandler(ActionFactory.NEXT.getId(),
- fShowNextAction);
- actionBars.setGlobalActionHandler(ActionFactory.PREVIOUS.getId(),
- fShowPreviousAction);
- }
- }
- private void addLayoutActions(IMenuManager menuManager) {
- if (fFlatAction != null)
- menuManager.add(fFlatAction);
- if (fHierarchicalAction != null)
- menuManager.add(fHierarchicalAction);
- }
- /**
- * { @inheritDoc }
- */
- public void setViewPart(ISearchResultViewPart part) {
- fViewPart = part;
- }
- // multithreaded update handling.
- private synchronized void handleSearchResultsChanged(
- final SearchResultEvent e) {
- if (e instanceof MatchEvent) {
- MatchEvent me = (MatchEvent) e;
- postUpdate(me.getMatches());
- AbstractTextSearchResult result = (AbstractTextSearchResult) me
- .getSearchResult();
- if (result.getMatchCount() == 1)
- asyncExec(new Runnable() {
- public void run() {
- navigateNext(true);
- }
- });
- } else if (e instanceof RemoveAllEvent) {
- postClear();
- }
- }
- private synchronized void postUpdate(Match[] matches) {
- for (int i = 0; i < matches.length; i++) {
- fBatchedUpdates.add(matches[i].getElement());
- }
- if (!fIsUpdatePosted) {
- fIsUpdatePosted= true;
- asyncExec(new Runnable() {
- public void run() {
- runBatchedUpdates();
- }
- });
- }
- }
- private void runBatchedUpdates() {
- synchronized (this) {
- elementsChanged(fBatchedUpdates.toArray());
- fBatchedUpdates.clear();
- updateBusyLabel();
- fIsUpdatePosted= false;
- }
- }
- private void postClear() {
- asyncExec(new Runnable() {
- public void run() {
- runClear();
- }
- });
- }
- private void runClear() {
- synchronized (this) {
- fBatchedUpdates.clear();
- updateBusyLabel();
- }
- clear();
- }
- private void asyncExec(Runnable runnable) {
- Control control = getControl();
- if (control != null && !control.isDisposed()) {
- Display currentDisplay = Display.getCurrent();
- if (currentDisplay == null
- || !currentDisplay.equals(control.getDisplay()))
- // meaning we're not executing on the display thread of the
- // control
- control.getDisplay().asyncExec(runnable);
- else
- runnable.run();
- }
- }
- /**
- * {@inheritDoc}
- * Subclasses may exend this method.
- */
- public void restoreState(IMemento memento) {
- if (countBits(fSupportedLayouts) > 1) {
- try {
- fCurrentLayout = getSettings().getInt(KEY_LAYOUT);
- // workaround because the saved value may be 0
- if (fCurrentLayout == 0)
- initLayout();
- } catch (NumberFormatException e) {
- // ignore, signals no value stored.
- }
- if (memento != null) {
- Integer layout = memento.getInteger(KEY_LAYOUT);
- if (layout != null) {
- fCurrentLayout = layout.intValue();
- // workaround because the saved value may be 0
- if (fCurrentLayout == 0)
- initLayout();
- }
- }
- }
- }
- /**
- * { @inheritDoc }
- * Subclasses my extend this method.
- */
- public void saveState(IMemento memento) {
- if (countBits(fSupportedLayouts) > 1) {
- memento.putInteger(KEY_LAYOUT, fCurrentLayout);
- }
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/text/Match.java b/org.eclipse.search/new search/org/eclipse/search/ui/text/Match.java
deleted file mode 100644
index dc861c5..0000000
--- a/org.eclipse.search/new search/org/eclipse/search/ui/text/Match.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.ui.text;
-
-
-/**
- * A textual match in a given object. This class may be subclassed to,
- * for example, add additional match state (i.e. accuracy, etc).
- * This API is preliminary and subject to change at any time.
- * @since 3.0
- */
-public class Match {
- private Object fElement;
- private int fOffset;
- private int fLength;
-
- /**
- * Constructs a new Match object.
- * @param element
- * @param offset
- * @param length
- */
- public Match(Object element, int offset, int length) {
- fElement= element;
- fOffset= offset;
- fLength= length;
- }
-
- /**
- * @return The offset.
- */
- public int getOffset() {
- return fOffset;
- }
-
- /**
- * Sets the offset field.
- * @param offset
- */
- public void setOffset(int offset) {
- fOffset= offset;
- }
-
- /**
- * @return The length.
- */
- public int getLength() {
- return fLength;
- }
-
- /**
- * Sets the length.
- * @param length
- */
- public void setLength(int length) {
- fLength= length;
- }
-
- /**
- * @return The element this match points to.
- */
- public Object getElement() {
- return fElement;
- }
-
-
-
-
-}
diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/text/MatchEvent.java b/org.eclipse.search/new search/org/eclipse/search/ui/text/MatchEvent.java
deleted file mode 100644
index 93077d1..0000000
--- a/org.eclipse.search/new search/org/eclipse/search/ui/text/MatchEvent.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Common Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.search.ui.text;
-import org.eclipse.search.ui.ISearchResult;
-import org.eclipse.search.ui.SearchResultEvent;
-/**
- * An event describing adding and removing of Matches. This API is preliminary
- * and subject to change at any time.
- *
- * @since 3.0
- */
-public class MatchEvent extends SearchResultEvent {
- private int fKind;
- private Match[] fMatches;
- private Match[] fMatchContainer= new Match[1];
- /**
- * Constant for a match being added.
- *
- * @see MatchEvent#getKind()
- */
- public static final int ADDED= 1;
- /**
- * Constant for a match being removed.
- *
- * @see MatchEvent#getKind()
- */
- public static final int REMOVED= 2;
-
- private static final Match[] fgEmtpyMatches= new Match[0];
-
- public MatchEvent(ISearchResult searchResult) {
- super(searchResult);
- }
- /**
- * Tells whether this is a remove or an add.
- *
- * @return One of <code>ADDED</code> or <code>REMOVED</code>.
- */
- public int getKind() {
- return fKind;
- }
- /**
- * Returns the concerned match.
- *
- * @return The match this event is about.
- */
- public Match[] getMatches() {
- if (fMatches != null)
- return fMatches;
- else if (fMatchContainer[0] != null)
- return fMatchContainer;
- else
- return fgEmtpyMatches;
- }
- /**
- * @param kind The kind to set.
- */
- protected void setKind(int kind) {
- fKind= kind;
- }
- /**
- * @param match The match to set.
- */
- protected void setMatch(Match match) {
- fMatchContainer[0]= match;
- fMatches= null;
- }
-
- protected void setMatches(Match[] matches) {
- fMatchContainer[0]= null;
- fMatches= matches;
- }
-
-}
diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/text/RemoveAllEvent.java b/org.eclipse.search/new search/org/eclipse/search/ui/text/RemoveAllEvent.java
deleted file mode 100644
index 998f5ea..0000000
--- a/org.eclipse.search/new search/org/eclipse/search/ui/text/RemoveAllEvent.java
+++ /dev/null
@@ -1,22 +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.search.ui.text;
-import org.eclipse.search.ui.ISearchResult;
-import org.eclipse.search.ui.SearchResultEvent;
-/**
- * An event indicating that all matches have been removed from a <code>AbstractTextSearchResult</code>.
- * This API is preliminary and subject to change at any time.
- *
- * @since 3.0
- */
-public class RemoveAllEvent extends SearchResultEvent {
- public RemoveAllEvent(ISearchResult searchResult) {
- super(searchResult);
- }
-}
diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/text/package.html b/org.eclipse.search/new search/org/eclipse/search/ui/text/package.html
deleted file mode 100644
index 10c3b00..0000000
--- a/org.eclipse.search/new search/org/eclipse/search/ui/text/package.html
+++ /dev/null
@@ -1,14 +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.75 [en] (WinNT; U) [Netscape]"><title>Package-level Javadoc</title>
-</head>
-<body>
-Provides the interface for a default search result page for textual
-searches. Clients can configure a ITextSearchResult with the proper UI
-elements factories.<br>
-
-<h2>
-Package Specification</h2>
-Clients create a <code>ITextSearchResult </code>and must configure it with proper <code>IStructureProvider </code>and <code>ISearchElementPresentation </code>for their search elements. The clients then add <code>Matches </code>or subclasses thereof to the <code>ITextSearchResult</code>. <br>
-</body></html>
\ No newline at end of file
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/CancelSearchAction.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/CancelSearchAction.java
deleted file mode 100644
index 268ac2f..0000000
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/CancelSearchAction.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search2.internal.ui;
-
-import org.eclipse.jface.action.Action;
-
-import org.eclipse.search.ui.ISearchResult;
-
-import org.eclipse.search.internal.ui.SearchPluginImages;
-
-public class CancelSearchAction extends Action {
-
- private SearchView fView;
-
- public CancelSearchAction(SearchView view) {
- super(SearchMessages.getString("CancelSearchAction.label")); //$NON-NLS-1$
- fView= view;
- setToolTipText(SearchMessages.getString("CancelSearchAction.tooltip")); //$NON-NLS-1$
- SearchPluginImages.setImageDescriptors(this, SearchPluginImages.T_LCL, SearchPluginImages.IMG_LCL_SEARCH_CANCEL);
- }
-
- public void run() {
- ISearchResult result= fView.getCurrentSearchResult();
- InternalSearchUI.getInstance().cancelSearch(result.getQuery());
- }
-}
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/InternalSearchUI.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/InternalSearchUI.java
deleted file mode 100644
index 4703a9a..0000000
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/InternalSearchUI.java
+++ /dev/null
@@ -1,263 +0,0 @@
-package org.eclipse.search2.internal.ui;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.HashMap;
-import java.util.Iterator;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.jobs.Job;
-
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.util.Assert;
-
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.WorkbenchException;
-
-import org.eclipse.search.ui.IQueryListener;
-import org.eclipse.search.ui.ISearchQuery;
-import org.eclipse.search.ui.ISearchResultViewPart;
-import org.eclipse.search.ui.SearchUI;
-
-import org.eclipse.search.internal.ui.SearchPlugin;
-import org.eclipse.search.internal.ui.SearchPreferencePage;
-import org.eclipse.search.internal.ui.util.ExceptionHandler;
-
-import org.eclipse.search2.internal.ui.text.PositionTracker;
-
-public class InternalSearchUI {
- //The shared instance.
- private static InternalSearchUI plugin;
- private HashMap fSearchJobs;
-
- private QueryManager fSearchResultsManager;
- private PositionTracker fPositionTracker;
-
- public static final String SEARCH_VIEW_ID= "org.eclipse.search.ui.views.SearchView"; //$NON-NLS-1$
-
- private class SearchJobRecord {
- public ISearchQuery fQuery;
- public Job fJob;
- public boolean fBackground;
- public boolean fIsRunning;
-
- SearchJobRecord(ISearchQuery job, boolean bg) {
- fQuery= job;
- fBackground= bg;
- fIsRunning= false;
- }
- }
-
- private class InternalSearchJob extends Job {
- SearchJobRecord fSearchJobRecord;
- public InternalSearchJob(SearchJobRecord sjr) {
- super(sjr.fQuery.getLabel());
- fSearchJobRecord= sjr;
- }
-
- protected IStatus run(IProgressMonitor monitor) {
- fSearchJobRecord.fJob= this;
- searchJobStarted(fSearchJobRecord);
- IStatus status= null;
- try{
- status= fSearchJobRecord.fQuery.run(monitor);
- } finally {
- searchJobFinished(fSearchJobRecord);
- }
- fSearchJobRecord.fJob= null;
- return status;
- }
-
-
- }
-
- private void searchJobStarted(SearchJobRecord record) {
- record.fIsRunning= true;
- getSearchManager().queryStarting(record.fQuery);
- }
-
- private void searchJobFinished(SearchJobRecord record) {
- record.fIsRunning= false;
- getSearchManager().queryFinished(record.fQuery);
- }
-
- /**
- * The constructor.
- */
- public InternalSearchUI() {
- plugin= this;
- fSearchJobs= new HashMap();
- fSearchResultsManager= new QueryManager();
- fPositionTracker= new PositionTracker();
- }
-
- /**
- * Returns the shared instance.
- */
- public static InternalSearchUI getInstance() {
- if (plugin ==null)
- plugin= new InternalSearchUI();
- return plugin;
- }
-
- public ISearchResultViewPart getSearchView() {
- return (ISearchResultViewPart) SearchPlugin.getActivePage().findView(SEARCH_VIEW_ID);
- }
-
- public boolean runSearchInBackground(ISearchQuery query) {
- Assert.isTrue(fSearchJobs.get(query) == null);
-
- getSearchManager().addQuery(query);
-
- if (isQueryRunning(query))
- return false;
- SearchJobRecord sjr= new SearchJobRecord(query, true);
- fSearchJobs.put(query, sjr);
- doRunSearchInBackground(sjr);
- return true;
- }
-
- public boolean isQueryRunning(ISearchQuery query) {
- SearchJobRecord sjr= (SearchJobRecord) fSearchJobs.get(query);
- return sjr != null && sjr.fIsRunning;
- }
-
- public IStatus runSearchInForeground(IRunnableContext context, final ISearchQuery query) {
- Assert.isTrue(fSearchJobs.get(query) == null);
- getSearchManager().addQuery(query);
- SearchJobRecord sjr= new SearchJobRecord(query, false);
- fSearchJobs.put(query, sjr);
-
- return doRunSearchInForeground(sjr, context);
- }
-
- private void doRunSearchInBackground(SearchJobRecord jobRecord) {
- if (jobRecord.fJob == null) {
- jobRecord.fJob= new InternalSearchJob(jobRecord);
- jobRecord.fJob.setPriority(Job.BUILD);
- }
- jobRecord.fJob.schedule();
- }
-
- public boolean runAgain(ISearchQuery job) {
- final SearchJobRecord rec= (SearchJobRecord) fSearchJobs.get(job);
- if (rec == null)
- return false;
- if (rec.fBackground) {
- doRunSearchInBackground(rec);
- } else {
- ProgressMonitorDialog pmd= new ProgressMonitorDialog(getSearchView().getSite().getShell());
- doRunSearchInForeground(rec, pmd);
- }
- return true;
- }
-
- private IStatus doRunSearchInForeground(final SearchJobRecord rec, IRunnableContext context) {
- final IStatus[] temp= new IStatus[1];
- if (context == null)
- context= getContext();
- try {
- context.run(true, true, new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) {
- searchJobStarted(rec);
- try {
- temp[0]= rec.fQuery.run(monitor);
- } finally {
- searchJobFinished(rec);
- }
- }
- });
- } catch (InvocationTargetException e) {
- // this will not happen.
- } catch (InterruptedException e) {
- // this will not happen
- }
- return temp[0];
- }
-
- /**
- * @return
- */
- private IRunnableContext getContext() {
- return new ProgressMonitorDialog(null);
- }
-
- public void shutdown() {
- Iterator jobRecs= fSearchJobs.values().iterator();
- while (jobRecs.hasNext()) {
- SearchJobRecord element= (SearchJobRecord) jobRecs.next();
- if (element.fJob != null)
- element.fJob.cancel();
- }
- fPositionTracker.dispose();
- }
-
- public void cancelSearch(ISearchQuery job) {
- SearchJobRecord rec= (SearchJobRecord) fSearchJobs.get(job);
- if (rec != null && rec.fJob != null)
- rec.fJob.cancel();
- }
-
- public ISearchResultViewPart activateSearchView() {
- String defaultPerspectiveId= SearchUI.getDefaultPerspectiveId();
- if (defaultPerspectiveId != null) {
- IWorkbenchWindow window= window= SearchPlugin.getActiveWorkbenchWindow();
- if (window != null && window.getShell() != null && !window.getShell().isDisposed()) {
- try {
- PlatformUI.getWorkbench().showPerspective(defaultPerspectiveId, window);
- } catch (WorkbenchException ex) {
- // show view in current perspective
- }
- }
- }
-
- try {
- ISearchResultViewPart viewPart= (ISearchResultViewPart) SearchPlugin.getActivePage().findView(SEARCH_VIEW_ID);
- if (viewPart == null || SearchPreferencePage.isViewBroughtToFront()) {
- viewPart= (ISearchResultViewPart) SearchPlugin.getActivePage().showView(SEARCH_VIEW_ID, null, IWorkbenchPage.VIEW_ACTIVATE);
- }
- return viewPart;
- } catch (PartInitException ex) {
- ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.openResultView.title"), SearchMessages.getString("Search.Error.openResultView.message")); //$NON-NLS-2$ //$NON-NLS-1$
- }
- return null;
- }
-
- public QueryManager getSearchManager() {
- return fSearchResultsManager;
- }
-
- public PositionTracker getPositionTracker() {
- return fPositionTracker;
- }
-
- public void addQueryListener(IQueryListener l) {
- getSearchManager().addQueryListener(l);
- }
- public ISearchQuery[] getQueries() {
- return getSearchManager().getQueries();
- }
- public void removeQueryListener(IQueryListener l) {
- getSearchManager().removeQueryListener(l);
- }
-
- public void removeQuery(ISearchQuery query) {
- cancelSearch(query);
- getSearchManager().removeQuery(query);
- fSearchJobs.remove(query);
- }
-
- public void addQuery(ISearchQuery query) {
- getSearchManager().addQuery(query);
- }
-
- public void removeAllQueries() {
- fSearchJobs.clear();
- getSearchManager().removeAll();
- }
-}
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/ListDialog.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/ListDialog.java
deleted file mode 100644
index c5f0b43..0000000
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/ListDialog.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search2.internal.ui;
-
-import java.util.List;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TableViewer;
-
-import org.eclipse.ui.dialogs.SelectionDialog;
-
-/**
- * Dialog that shows a list of items with icon and label.
- */
-public class ListDialog extends SelectionDialog {
-
- private static final int WIDTH_IN_CHARACTERS= 55;
-
- private IStructuredContentProvider fContentProvider;
- private ILabelProvider fLabelProvider;
- private Object fInput;
- private TableViewer fViewer;
- private boolean fCreateCancelButton= true;
-
- public ListDialog(Shell parent, Object input, String title, String message, IStructuredContentProvider sp, ILabelProvider lp) {
- super(parent);
- setTitle(title);
- setMessage(message);
- fInput= input;
- fContentProvider= sp;
- fLabelProvider= lp;
- }
-
- public void setCreateCancelButton(boolean value) {
- fCreateCancelButton= value;
- }
-
- /*
- * Overrides method from Dialog
- */
- protected Label createMessageArea(Composite composite) {
- Label label = new Label(composite,SWT.WRAP);
- label.setText(getMessage());
- GridData gd= new GridData(GridData.FILL_BOTH);
- gd.widthHint= convertWidthInCharsToPixels(WIDTH_IN_CHARACTERS);
- label.setLayoutData(gd);
- applyDialogFont(label);
- return label;
- }
-
- /*
- * Overrides method from Dialog
- */
- protected Control createDialogArea(Composite container) {
- Composite parent= (Composite) super.createDialogArea(container);
- createMessageArea(parent);
- fViewer= new TableViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
- fViewer.setContentProvider(fContentProvider);
-
- final Table table= fViewer.getTable();
- table.addMouseListener(new MouseAdapter() {
- public void mouseDoubleClick(MouseEvent e) {
- if (fCreateCancelButton)
- okPressed();
- }
- });
- fViewer.setLabelProvider(fLabelProvider);
- fViewer.setInput(fInput);
- List initialSelection= getInitialElementSelections();
- if (initialSelection != null)
- fViewer.setSelection(new StructuredSelection(initialSelection));
- GridData gd= new GridData(GridData.FILL_BOTH);
- gd.heightHint= convertHeightInCharsToPixels(15);
- gd.widthHint= convertWidthInCharsToPixels(WIDTH_IN_CHARACTERS);
- table.setLayoutData(gd);
- applyDialogFont(table);
- return table;
- }
-
- /*
- * Overrides method from Dialog
- */
- protected void createButtonsForButtonBar(Composite parent) {
- if (! fCreateCancelButton)
- createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
- else
- super.createButtonsForButtonBar(parent);
- }
-
- /*
- * Overrides method from Dialog
- */
- protected void okPressed() {
- // Build a list of selected children.
- ISelection selection= fViewer.getSelection();
- if (selection instanceof IStructuredSelection)
- setResult(((IStructuredSelection)fViewer.getSelection()).toList());
- super.okPressed();
- }
-}
-
-
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/QueryManager.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/QueryManager.java
deleted file mode 100644
index b55efb9..0000000
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/QueryManager.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search2.internal.ui;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.search.ui.IQueryListener;
-import org.eclipse.search.ui.ISearchQuery;
-
-class QueryManager {
- private List fQueries;
- private List fListeners;
- public QueryManager() {
- super();
- // an ArrayList should be plenty fast enough (few searches).
- fQueries= new ArrayList();
- fListeners= new ArrayList();
- }
- synchronized ISearchQuery[] getQueries() {
- ISearchQuery[] result= new ISearchQuery[fQueries.size()];
- return (ISearchQuery[]) fQueries.toArray(result);
- }
-
- void removeQuery(ISearchQuery query) {
- synchronized (fQueries) {
- fQueries.remove(query);
- }
- fireRemoved(query);
- }
-
- void addQuery(ISearchQuery query) {
- synchronized (fQueries) {
- if (fQueries.contains(query))
- return;
- fQueries.add(0, query);
- }
- fireAdded(query);
- }
-
- void addQueryListener(IQueryListener l) {
- synchronized (fListeners) {
- fListeners.add(l);
- }
- }
-
- void removeQueryListener(IQueryListener l) {
- synchronized (fListeners) {
- fListeners.remove(l);
- }
- }
-
- void fireAdded(ISearchQuery query) {
- Set copiedListeners= new HashSet();
- synchronized (fListeners) {
- copiedListeners.addAll(fListeners);
- }
- Iterator listeners= copiedListeners.iterator();
- while (listeners.hasNext()) {
- IQueryListener l= (IQueryListener) listeners.next();
- l.queryAdded(query);
- }
- }
-
- void fireRemoved(ISearchQuery query) {
- Set copiedListeners= new HashSet();
- synchronized (fListeners) {
- copiedListeners.addAll(fListeners);
- }
- Iterator listeners= copiedListeners.iterator();
- while (listeners.hasNext()) {
- IQueryListener l= (IQueryListener) listeners.next();
- l.queryRemoved(query);
- }
- }
-
- void fireStarting(ISearchQuery query) {
- Set copiedListeners= new HashSet();
- synchronized (fListeners) {
- copiedListeners.addAll(fListeners);
- }
- Iterator listeners= copiedListeners.iterator();
- while (listeners.hasNext()) {
- IQueryListener l= (IQueryListener) listeners.next();
- l.queryStarting(query);
- }
- }
-
- void fireFinished(ISearchQuery query) {
- Set copiedListeners= new HashSet();
- synchronized (fListeners) {
- copiedListeners.addAll(fListeners);
- }
- Iterator listeners= copiedListeners.iterator();
- while (listeners.hasNext()) {
- IQueryListener l= (IQueryListener) listeners.next();
- l.queryFinished(query);
- }
- }
-
- void removeAll() {
- Set copiedSearches= new HashSet();
- synchronized (fQueries) {
- copiedSearches.addAll(fQueries);
- fQueries.clear();
- Iterator iter= copiedSearches.iterator();
- while (iter.hasNext()) {
- ISearchQuery element= (ISearchQuery) iter.next();
- fireRemoved(element);
- }
- }
- }
-
- void queryFinished(ISearchQuery query) {
- fireFinished(query);
- }
-
- void queryStarting(ISearchQuery query) {
- fireStarting(query);
- }
-
-}
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/RemoveAllSearchesAction.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/RemoveAllSearchesAction.java
deleted file mode 100644
index 2707277..0000000
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/RemoveAllSearchesAction.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search2.internal.ui;
-
-import org.eclipse.jface.action.Action;
-
-
-class RemoveAllSearchesAction extends Action {
-
- public RemoveAllSearchesAction() {
- super(SearchMessages.getString("RemoveAllSearchesAction.label")); //$NON-NLS-1$
- setToolTipText(SearchMessages.getString("RemoveAllSearchesAction.tooltip")); //$NON-NLS-1$
- }
-
- public void run() {
- InternalSearchUI.getInstance().removeAllQueries();
- }
-}
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchAgainAction.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchAgainAction.java
deleted file mode 100644
index 024e63f..0000000
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchAgainAction.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search2.internal.ui;
-
-import org.eclipse.jface.action.Action;
-
-import org.eclipse.search.ui.ISearchResult;
-
-import org.eclipse.search.internal.ui.SearchPluginImages;
-
-class SearchAgainAction extends Action {
- private SearchView fView;
-
- /**
- * Create a new instance of this class
- */
- public SearchAgainAction(SearchView view) {
- setText(SearchMessages.getString("SearchAgainAction.label")); //$NON-NLS-1$
- setToolTipText(SearchMessages.getString("SearchAgainAction.tooltip")); //$NON-NLS-1$
- SearchPluginImages.setImageDescriptors(this, SearchPluginImages.T_TOOL, SearchPluginImages.IMG_TOOL_SEARCH);
- fView= view;
- }
- /**
- * Invoke the resource wizard selection wizard
- *
- * @param browser org.eclipse.jface.parts.Window
- */
- public void run() {
- final ISearchResult search= fView.getCurrentSearchResult();
- if (search != null) {
- InternalSearchUI.getInstance().cancelSearch(search.getQuery());
- InternalSearchUI.getInstance().runAgain(search.getQuery());
- }
- }
-}
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchDropDownAction.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchDropDownAction.java
deleted file mode 100644
index 238cce0..0000000
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchDropDownAction.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search2.internal.ui;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IMenuCreator;
-import org.eclipse.jface.resource.ImageDescriptor;
-
-import org.eclipse.search.ui.ISearchQuery;
-import org.eclipse.search.ui.ISearchResult;
-
-import org.eclipse.search.internal.ui.SearchPluginImages;
-
-class SearchDropDownAction extends Action implements IMenuCreator {
-
-
- public static final int RESULTS_IN_DROP_DOWN= 10;
-
- private Menu fMenu;
- private SearchView fSearchView;
-
- public SearchDropDownAction(SearchView searchView) {
- setText(SearchMessages.getString("SearchDropDownAction.label")); //$NON-NLS-1$
- setToolTipText(SearchMessages.getString("SearchDropDownAction.tooltip")); //$NON-NLS-1$
- SearchPluginImages.setImageDescriptors(this, SearchPluginImages.T_LCL, SearchPluginImages.IMG_LCL_SEARCH_HISTORY);
- fSearchView= searchView;
- setMenuCreator(this);
- }
-
- public void dispose() {
- disposeMenu();
- }
-
- void disposeMenu() {
- if (fMenu != null)
- fMenu.dispose();
- }
-
- public Menu getMenu(Menu parent) {
- return null;
- }
-
- public Menu getMenu(Control parent) {
- ISearchResult currentSearch= fSearchView.getCurrentSearchResult();
- disposeMenu();
-
- fMenu= new Menu(parent);
- ISearchQuery[] searches= InternalSearchUI.getInstance().getSearchManager().getQueries();
- for (int i= 0; i < searches.length; i++) {
- ISearchResult search= searches[i].getSearchResult();
- String label= search.getLabel();
- String tooltip= search.getTooltip();
- ImageDescriptor image= search.getImageDescriptor();
- if (InternalSearchUI.getInstance().isQueryRunning(search.getQuery()))
- label= label+ SearchMessages.getString("SearchDropDownAction.running.message"); //$NON-NLS-1$
- ShowSearchAction action= new ShowSearchAction(fSearchView, search, label, image, tooltip );
- if (searches[i].equals(currentSearch))
- action.setChecked(true);
- addActionToMenu(fMenu, action);
- }
- if (searches.length > 0) {
- new MenuItem(fMenu, SWT.SEPARATOR);
- addActionToMenu(fMenu, new RemoveAllSearchesAction());
- }
- return fMenu;
- }
-
- protected void addActionToMenu(Menu parent, Action action) {
- ActionContributionItem item= new ActionContributionItem(action);
- item.fill(parent, -1);
- }
-
- public void run() {
- new ShowSearchesAction(fSearchView).run();
- }
-}
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchMessages.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchMessages.java
deleted file mode 100644
index e0961f2..0000000
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchMessages.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search2.internal.ui;
-
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-/**
- * @author Thomas Mäder
- *
- */
-public class SearchMessages {
-
- private static final String BUNDLE_NAME= "org.eclipse.search2.internal.ui.SearchMessages"; //$NON-NLS-1$
-
- private static final ResourceBundle RESOURCE_BUNDLE= ResourceBundle.getBundle(BUNDLE_NAME);
-
- /**
- * @param key
- * @return
- */
- public static String getString(String key) {
- try {
- return RESOURCE_BUNDLE.getString(key);
- } catch (MissingResourceException e) {
- return '!' + key + '!';
- }
- }
-}
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchMessages.properties b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchMessages.properties
deleted file mode 100644
index acc4af2..0000000
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchMessages.properties
+++ /dev/null
@@ -1,36 +0,0 @@
-SearchAgainAction.label=SearchAgain
-SearchAgainAction.tooltip=Run the current search again
-SearchDropDownAction.label=Previous Searches
-SearchDropDownAction.tooltip=Show Previous Searches
-SearchDropDownAction.running.message= (running)
-ShowSearchesAction.label=Show Searches
-ShowSearchesAction.tooltip=Show other searches
-ShowSearchesAction.dialog.title=Show Search
-ShowSearchesAction.dialog.message=Select a search to display its results
-SearchView.empty.message=No Search Results Available
-SearchView.title.search=Search
-SearchView.title.running= [running]
-RemoveAllSearchesAction.label=Clear History
-RemoveAllSearchesAction.tooltip=Clear Search History
-RemoveAllResultsAction.label=Remove All Matches
-RemoveAllResultsAction.tooltip=Remove all Matches
-ShowNextResultAction.label=Show Next Match
-ShowNextResultAction.tooltip=Show the next match
-SortDropDownActon.label=Sort By
-SortDropDownActon.tooltip=Select the sort order
-SortDropDownActon.ascending.label=Sort ascending
-SortDropDownActon.descending.label=Sort descending
-SortDropDownActon.nosort.label=Do not sort
-ShowPreviousResultAction.label=Show Previous Match
-ShowPreviousResultAction.tooltip=Show the previous match
-RemoveMatchAction.label=Remove Match
-RemoveMatchAction.tooltip=Remove the currently shown match
-DefaultSearchViewPage.show_match=Show Match
-DefaultSearchViewPage.error.no_editor=Could not find an editor for the current match
-AbstractTextSearchViewPage.flat_layout.label=Flat Layout
-AbstractTextSearchViewPage.flat_layout.tooltip=Set Flat Layout
-AbstractTextSearchViewPage.hierarchical_layout.label=Hierarchical Layout
-AbstractTextSearchViewPage.hierarchical_layout.tooltip=Set Hierarchical Layout
-CancelSearchAction.label=Cancel
-CancelSearchAction.tooltip=Cancel the current search
-AbstractTextSearchViewPage.searching.label=Searching...
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchPageRegistry.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchPageRegistry.java
deleted file mode 100644
index e9d9a96..0000000
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchPageRegistry.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search2.internal.ui;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.Platform;
-
-import org.eclipse.search.ui.ISearchResultPage;
-
-import org.eclipse.search.internal.ui.SearchPlugin;
-
-/**
- * @author Thomas Mäder
- *
- */
-public class SearchPageRegistry {
- private Map fClassToInstance;
- private Map fTargetClassNameToExtension;
- private Map fExtensionToInstance;
- private String fIdAttribute;
-
- public SearchPageRegistry(String extensionPoint, String targetClassAttribute, String idAttribute) {
- super();
- fExtensionToInstance= new HashMap();
- fClassToInstance= new HashMap();
- initializeExtensionCache(extensionPoint, targetClassAttribute);
- fIdAttribute= idAttribute;
- }
-
- private void initializeExtensionCache(String extensionPoint, String targetClassAttribute) {
- fTargetClassNameToExtension= new HashMap();
- IConfigurationElement[] extensions=
- Platform.getPluginRegistry().getConfigurationElementsFor(
- extensionPoint);
- for (int i= 0; i < extensions.length; i++) {
- fTargetClassNameToExtension.put(extensions[i].getAttribute(targetClassAttribute), extensions[i]);
- }
-
- }
-
- public ISearchResultPage getExtensionObject(Object element, Class expectedType) {
- ISearchResultPage page= (ISearchResultPage) fClassToInstance.get(element.getClass());
- if (page != null)
- return page;
- if (fClassToInstance.containsKey(element.getClass()))
- return null;
- page= internalGetExtensionObject(element, expectedType);
- if (page != null)
- fClassToInstance.put(element.getClass(), page);
- return page;
- }
-
- private ISearchResultPage internalGetExtensionObject(Object element, Class expectedType) {
- IConfigurationElement configElement= (IConfigurationElement) fTargetClassNameToExtension.get(element.getClass().getName());
- if (configElement == null) {
- if (fTargetClassNameToExtension.containsKey(element.getClass().getName()))
- return null;
- configElement= getConfigElement(element.getClass());
- if (configElement != null)
- fTargetClassNameToExtension.put(element.getClass().getName(), configElement);
- }
-
- if (configElement != null) {
- ISearchResultPage lp= (ISearchResultPage) fExtensionToInstance.get(configElement);
- if (lp == null) {
- if (fExtensionToInstance.containsKey(configElement))
- return null;
- ISearchResultPage instance;
- try {
- instance= (ISearchResultPage) configElement.createExecutableExtension("class"); //$NON-NLS-1$
- String id= configElement.getAttribute(fIdAttribute);
- instance.setID(id);
- if (expectedType.isAssignableFrom(instance.getClass())) {
- fExtensionToInstance.put(configElement, instance);
- return instance;
- }
- } catch (CoreException e) {
- // programming error. Log it.
- SearchPlugin.getDefault().getLog().log(e.getStatus());
- }
- } else {
- return lp;
- }
- }
- return null;
- }
-
- private IConfigurationElement getConfigElement(Class clazz) {
- return searchInSupertypes(clazz);
- }
-
- private IConfigurationElement searchInSupertypes(Class clazz) {
- IConfigurationElement foundExtension= null;
- Class superclass= clazz.getSuperclass();
- if (superclass != null)
- foundExtension= (IConfigurationElement) fTargetClassNameToExtension.get(superclass.getName());
- if (foundExtension != null)
- return foundExtension;
- Class[] interfaces= clazz.getInterfaces();
- for (int i= 0; i < interfaces.length; i++) {
- foundExtension= (IConfigurationElement) fTargetClassNameToExtension.get(interfaces[i].getName());
- if (foundExtension != null)
- return foundExtension;
- }
- if (superclass != null)
- foundExtension= searchInSupertypes(superclass);
- if (foundExtension != null)
- return foundExtension;
- for (int i= 0; i < interfaces.length; i++) {
- foundExtension= searchInSupertypes(interfaces[i]);
- if (foundExtension != null)
- return foundExtension;
- }
- return null;
- }
-
-}
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchView.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchView.java
deleted file mode 100644
index ee4e8d6..0000000
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchView.java
+++ /dev/null
@@ -1,419 +0,0 @@
-package org.eclipse.search2.internal.ui;
-
-import java.util.HashMap;
-import java.util.Iterator;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Tree;
-
-import org.eclipse.jface.action.GroupMarker;
-import org.eclipse.jface.action.IContributionManager;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.Separator;
-
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IPropertyListener;
-import org.eclipse.ui.IViewSite;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.part.IPage;
-import org.eclipse.ui.part.IPageBookViewPage;
-import org.eclipse.ui.part.IPageSite;
-import org.eclipse.ui.part.Page;
-import org.eclipse.ui.part.PageBook;
-import org.eclipse.ui.part.PageBookView;
-
-import org.eclipse.search.ui.IContextMenuConstants;
-import org.eclipse.search.ui.IQueryListener;
-import org.eclipse.search.ui.ISearchQuery;
-import org.eclipse.search.ui.ISearchResult;
-import org.eclipse.search.ui.ISearchResultListener;
-import org.eclipse.search.ui.ISearchResultPage;
-import org.eclipse.search.ui.ISearchResultViewPart;
-import org.eclipse.search.ui.SearchResultEvent;
-
-import org.eclipse.search.internal.ui.SearchPluginImages;
-
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-/**
- * @author Thomas Mäder
- *
- */
-public class SearchView extends PageBookView implements ISearchResultViewPart, IQueryListener, ISearchResultListener {
- private static final String MEMENTO_TYPE= "view"; //$NON-NLS-1$
- private HashMap fPartsToPages;
- private HashMap fPagesToParts;
- private HashMap fSearchViewStates;
- private SearchPageRegistry fSearchViewPageService;
- private SearchDropDownAction fSearchesDropDownAction;
- private ISearchResult fCurrentSearch;
- private DummyPart fDefaultPart;
- private long fLastUpdateTime= 0;
- private SearchAgainAction fSearchAgainAction;
- private CancelSearchAction fCancelAction;
-
- private IMemento fPageState;
-
- private static void createStandardGroups(IContributionManager menu) {
- menu.add(new Separator(IContextMenuConstants.GROUP_NEW));
- menu.add(new GroupMarker(IContextMenuConstants.GROUP_GOTO));
- menu.add(new GroupMarker(IContextMenuConstants.GROUP_OPEN));
- menu.add(new Separator(IContextMenuConstants.GROUP_SHOW));
- menu.add(new Separator(IContextMenuConstants.GROUP_BUILD));
- menu.add(new Separator(IContextMenuConstants.GROUP_REORGANIZE));
- menu.add(new Separator(IContextMenuConstants.GROUP_REMOVE_MATCHES));
- menu.add(new GroupMarker(IContextMenuConstants.GROUP_GENERATE));
- menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
- menu.add(new Separator(IContextMenuConstants.GROUP_VIEWER_SETUP));
- menu.add(new Separator(IContextMenuConstants.GROUP_PROPERTIES));
- menu.add(new Separator(IContextMenuConstants.GROUP_SEARCH));
- }
-
- class DummyPart implements IWorkbenchPart {
- public void addPropertyListener(IPropertyListener listener) {/*dummy*/}
- public void createPartControl(Composite parent) {/*dummy*/}
- public void dispose() {/*dummy*/}
- public IWorkbenchPartSite getSite() { return null; }
- public String getTitle() { return null; }
- public Image getTitleImage() { return null; }
- public String getTitleToolTip() { return null; }
- public void removePropertyListener(IPropertyListener listener) {/*dummy*/}
- public void setFocus() {/*dummy*/}
- public Object getAdapter(Class adapter) { return null; }
- }
-
- class EmptySearchView extends Page implements ISearchResultPage {
- Control fControl;
- private String fId;
-
- public void createControl(Composite parent) {
- fControl= new Tree(parent, SWT.NONE);
- //fControl.setText(SearchMessages.getString("SearchView.empty.message")); //$NON-NLS-1$
- }
-
- public Control getControl() {
- return fControl;
- }
-
- public void setFocus() {
- if (fControl != null)
- fControl.setFocus();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.search2.ui.ISearchResultsPage#setInput(org.eclipse.search2.ui.ISearchResult, java.lang.Object)
- */
- public void setInput(ISearchResult search, Object viewState) {
- // do nothing
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.search2.ui.ISearchResultsPage#setViewPart(org.eclipse.search2.ui.ISearchResultView)
- */
- public void setViewPart(ISearchResultViewPart part) {
- // do nothing
- }
-
- /** (non-Javadoc)
- * @see org.eclipse.search2.ui.ISearchResultsPage#getUIState()
- */
- public Object getUIState() {
- // empty implementation
- return null;
- }
-
-
- public void init(IPageSite pageSite) {
- super.init(pageSite);
- getSite().setSelectionProvider(null);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.ISearchResultPage#saveState(org.eclipse.ui.IMemento)
- */
- public void saveState(IMemento memento) {
- // do nothing
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.ISearchResultPage#restoreState(org.eclipse.ui.IMemento)
- */
- public void restoreState(IMemento memento) {
- // do nothing
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.ISearchResultPage#setID(java.lang.String)
- */
- public void setID(String id) {
- fId= id;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.ISearchResultPage#getID()
- */
- public String getID() {
- return fId;
- }
- }
-
- public SearchView() {
- super();
- fPartsToPages= new HashMap();
- fPagesToParts= new HashMap();
- setTitleImage(SearchPluginImages.get(SearchPluginImages.T_VIEW));
- fSearchViewPageService= new SearchPageRegistry("org.eclipse.search.searchResultViewPages", "targetClass", "id"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- fSearchViewStates= new HashMap();
- }
-
- protected IPage createDefaultPage(PageBook book) {
- IPageBookViewPage page= new EmptySearchView();
- page.createControl(book);
- initPage(page);
- DummyPart part= new DummyPart();
- fPartsToPages.put(part, page);
- fPagesToParts.put(page, part);
- fDefaultPart= part;
- return page;
- }
-
- protected PageRec doCreatePage(IWorkbenchPart part) {
- IPageBookViewPage page = (IPageBookViewPage) fPartsToPages.get(part);
- initPage(page);
- page.createControl(getPageBook());
- PageRec rec = new PageRec(part, page);
- return rec;
- }
-
- protected void doDestroyPage(IWorkbenchPart part, PageRec pageRecord) {
- IPage page = pageRecord.page;
- page.dispose();
- pageRecord.dispose();
-
- // empty cross-reference cache
- fPartsToPages.remove(part);
- }
-
- protected IWorkbenchPart getBootstrapPart() {
- return null;
- }
-
- protected boolean isImportant(IWorkbenchPart part) {
- return part instanceof DummyPart;
- }
-
- public void showSearchResult(ISearchResult search) {
- ISearchResultPage page= null;
- if (search != null) {
- page= fSearchViewPageService.getExtensionObject(search, ISearchResultPage.class);
- if (page == null)
- return;
- }
-
- // detach the previous page.
- ISearchResultPage currentPage= (ISearchResultPage) getCurrentPage();
- Object uiState= currentPage.getUIState();
- if (fCurrentSearch != null) {
- if (uiState != null)
- fSearchViewStates.put(fCurrentSearch, uiState);
- fCurrentSearch.removeListener(this);
- }
- currentPage.setInput(null, null);
-
- // switch to a new page
- if (page != null && page != currentPage) {
- IWorkbenchPart part= (IWorkbenchPart) fPagesToParts.get(page);
- if (part == null) {
- part= new DummyPart();
- fPagesToParts.put(page, part);
- fPartsToPages.put(part, page);
- page.setViewPart(this);
- }
- partActivated(part);
- }
-
- // connect to the new pages
- fCurrentSearch= search;
- if (fCurrentSearch != null)
- fCurrentSearch.addListener(this);
- if (page != null)
- page.setInput(search, fSearchViewStates.get(search));
- updateTitle(search);
- }
-
- private void updateTitle(ISearchResult search) {
- String label= SearchMessages.getString("SearchView.title.search"); //$NON-NLS-1$
-
- // TODO workaround for bug 53391
- label+= "("; //$NON-NLS-1$
- if (search != null) {
- boolean queryRunning= InternalSearchUI.getInstance().isQueryRunning(search.getQuery());
- fCancelAction.setEnabled(queryRunning);
- if (queryRunning) {
- label= label+SearchMessages.getString("SearchView.title.running"); //$NON-NLS-1$
- }
- label= label+" "+search.getLabel(); //$NON-NLS-1$ //$NON-NLS-2$
- }
- // TODO workaround for bug 53391
- label+= ")"; //$NON-NLS-1$
- setTitle(label);
- }
-
- public void updateTitle() {
- if (getPageBook() != null && !getPageBook().isDisposed()) {
- getPageBook().getDisplay().asyncExec(new Runnable() {
- public void run() {
- updateTitle(fCurrentSearch);
- }
- });
- }
- }
-
- public ISearchResult getCurrentSearchResult() {
- return fCurrentSearch;
- }
-
- public void createPartControl(Composite parent) {
- super.createPartControl(parent);
- createActions();
- initializeToolBar();
- InternalSearchUI.getInstance().getSearchManager().addQueryListener(this);
- }
-
- private void initializeToolBar() {
- IToolBarManager tbm= getViewSite().getActionBars().getToolBarManager();
- createStandardGroups(tbm);
- tbm.appendToGroup(IContextMenuConstants.GROUP_SEARCH, fCancelAction); //$NON-NLS-1$
- tbm.appendToGroup(IContextMenuConstants.GROUP_SEARCH, fSearchesDropDownAction); //$NON-NLS-1$
- getViewSite().getActionBars().updateActionBars();
- }
-
- private void createActions() {
- fSearchesDropDownAction= new SearchDropDownAction(this);
- fSearchesDropDownAction.setEnabled(InternalSearchUI.getInstance().getSearchManager().getQueries().length != 0);
- fSearchAgainAction= new SearchAgainAction(this);
- fCancelAction= new CancelSearchAction(this);
- fCancelAction.setEnabled(false);
- }
-
- public void dispose() {
- InternalSearchUI.getInstance().getSearchManager().removeQueryListener(this);
- if (fCurrentSearch != null)
- fCurrentSearch.removeListener(this);
- super.dispose();
- }
-
- public void queryAdded(ISearchQuery query) {
- showSearchResult(query.getSearchResult());
- fSearchesDropDownAction.setEnabled(InternalSearchUI.getInstance().getSearchManager().getQueries().length != 0);
- }
-
- public void queryRemoved(ISearchQuery query) {
- InternalSearchUI.getInstance().cancelSearch(query);
- if (query.getSearchResult().equals(fCurrentSearch)) {
- showSearchResult(null);
- partActivated(fDefaultPart);
- }
- fSearchViewStates.remove(query.getSearchResult());
- fSearchesDropDownAction.disposeMenu();
- fSearchesDropDownAction.setEnabled(InternalSearchUI.getInstance().getSearchManager().getQueries().length != 0);
- }
-
- public void searchResultChanged(SearchResultEvent e) {
- long now= System.currentTimeMillis();
- if (now-fLastUpdateTime > 500) {
- fLastUpdateTime= now;
- updateTitle();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.search2.ui.ISearchView#fillContextMenu(org.eclipse.jface.action.IMenuManager)
- */
- public void fillContextMenu(IMenuManager menuManager) {
- menuManager.appendToGroup(IContextMenuConstants.GROUP_SEARCH, fSearchAgainAction);
- }
-
- public void queryStarting(ISearchQuery query) {
- updateTitle();
- }
-
- public void queryFinished(ISearchQuery query) {
- updateTitle();
- }
-
- // Methods related to saving page state. -------------------------------------------
- /**
- * { @inheritDoc }
- */
- public void saveState(IMemento memento) {
- for (Iterator pages = fPagesToParts.keySet().iterator(); pages.hasNext(); ) {
- ISearchResultPage page = (ISearchResultPage) pages.next();
- IMemento child= memento.createChild(MEMENTO_TYPE, page.getID()); //$NON-NLS-1$
- page.saveState(child);
- }
- }
-
- /**
- * { @inheritDoc }
- */
- public void init(IViewSite site, IMemento memento) throws PartInitException {
- super.init(site, memento);
- fPageState= memento;
- }
-
- /**
- * { @inheritDoc }
- */
- protected void initPage(IPageBookViewPage page) {
- super.initPage(page);
- ISearchResultPage srPage= (ISearchResultPage) page;
- IMemento memento= null;
- if (fPageState != null) {
- IMemento[] mementos= fPageState.getChildren(MEMENTO_TYPE);
- for (int i= 0; i < mementos.length; i++) {
- if (mementos[i].getID().equals(srPage.getID())) {
- memento= mementos[i];
- break;
- }
- }
- }
- srPage.restoreState(memento);
- }
-
- /*
- * TODO workaround for focus problem. Clarify focus behaviour.
- * @see org.eclipse.ui.IWorkbenchPart#setFocus()
- */
- public void setFocus() {
- IPage currentPage= getCurrentPage();
- if (currentPage != null)
- currentPage.setFocus();
- else
- super.setFocus();
- }
-
- public ISearchResultPage getActivePage() {
- IPage page= getCurrentPage();
- if (page instanceof ISearchResultPage)
- return (ISearchResultPage) page;
- return null;
- }
-}
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/ShowSearchAction.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/ShowSearchAction.java
deleted file mode 100644
index b155628..0000000
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/ShowSearchAction.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search2.internal.ui;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.resource.ImageDescriptor;
-
-import org.eclipse.search.ui.ISearchResult;
-
-
-class ShowSearchAction extends Action {
- private ISearchResult fSearch;
- private SearchView fView;
-
- /**
- * Create a new instance of this class
- */
- public ShowSearchAction(SearchView view, ISearchResult search, String text, ImageDescriptor image, String tooltip) {
- fSearch= search;
- fView= view;
- // fix for bug 38049
- if (text.indexOf('@') >= 0)
- text+= '@';
- setText(text);
- setImageDescriptor(image);
- setToolTipText(tooltip);
- }
-
- public void run() {
- fView.showSearchResult(fSearch);
- }
-}
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/ShowSearchesAction.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/ShowSearchesAction.java
deleted file mode 100644
index f0013a2..0000000
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/ShowSearchesAction.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search2.internal.ui;
-
-import java.util.ArrayList;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.resource.ImageDescriptor;
-
-import org.eclipse.search.ui.ISearchQuery;
-import org.eclipse.search.ui.ISearchResult;
-
-/**
- * Invoke the resource creation wizard selection Wizard.
- * This action will retarget to the active view.
- */
-class ShowSearchesAction extends Action {
- private SearchView fSearchView;
-
- /*private static final class SearchesLabelProvider extends LabelProvider {
-
- private ArrayList fImages= new ArrayList();
-
- public String getText(Object element) {
- if (!(element instanceof ShowSearchAction))
- return ""; //$NON-NLS-1$
- return ((ShowSearchAction)element).getText();
- }
- public Image getImage(Object element) {
- if (!(element instanceof ShowSearchAction))
- return null;
-
- ImageDescriptor imageDescriptor= ((ShowSearchAction)element).getImageDescriptor();
- if (imageDescriptor == null)
- return null;
-
- Image image= imageDescriptor.createImage();
- fImages.add(image);
-
- return image;
- }
-
- public void dispose() {
- Iterator iter= fImages.iterator();
- while (iter.hasNext())
- ((Image)iter.next()).dispose();
-
- fImages= null;
- }
- }*/
-
- /**
- * Create a new instance of this class
- */
- public ShowSearchesAction(SearchView searchView) {
- super(SearchMessages.getString("ShowSearchesAction.label")); //$NON-NLS-1$
- setToolTipText(SearchMessages.getString("ShowSearchesAction.tooltip")); //$NON-NLS-1$
- fSearchView= searchView;
- }
-
- public void run() {
- QueryManager sm= InternalSearchUI.getInstance().getSearchManager();
- ISearchQuery[] queries= sm.getQueries();
-
- ArrayList input= new ArrayList();
- int i= 0;
- for (int j= 0; j < queries.length; j++) {
- ISearchResult search= queries[i].getSearchResult();
- String label= search.getLabel();
- String tooltip= search.getTooltip();
- ImageDescriptor image= search.getImageDescriptor();
- ShowSearchAction action= new ShowSearchAction(fSearchView, search, label, image, tooltip );
- input.add(action);
- }
- }
-}
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/ThrottlingProgressMonitor.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/ThrottlingProgressMonitor.java
deleted file mode 100644
index 04a5381..0000000
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/ThrottlingProgressMonitor.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search2.internal.ui;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-
-/**
- * @author Thomas Mäder
- *
- */
-public class ThrottlingProgressMonitor implements IProgressMonitor {
- private IProgressMonitor fWrappedMonitor;
- private float fThrottleRatio;
- private long fLastCalled;
- private long fSubMilis;
-
- public ThrottlingProgressMonitor(IProgressMonitor wrapped, float throttleRatio) {
- fWrappedMonitor= wrapped;
- fThrottleRatio= throttleRatio;
- fSubMilis= 0;
- }
-
- public void beginTask(String name, int totalWork) {
- fWrappedMonitor.beginTask(name, totalWork);
- }
-
- public void done() {
- fWrappedMonitor.done();
- }
-
- public void internalWorked(double work) {
- fWrappedMonitor.internalWorked(work);
- if (fLastCalled != 0) {
- long sleepTime= System.currentTimeMillis()-fLastCalled;
- sleepTime *= fThrottleRatio;
- sleepTime= Math.min(100, sleepTime);
- if (sleepTime < 1) {
- fSubMilis++;
- if (fSubMilis > 50) {
- sleepTime= 1;
- fSubMilis= 0;
- }
- }
- fLastCalled= System.currentTimeMillis();
- try {
- Thread.sleep(sleepTime);
- } catch (InterruptedException e) {
- // ignore
- e.printStackTrace();
- }
- } else {
- fLastCalled= System.currentTimeMillis();
- }
- }
-
- public boolean isCanceled() {
- return fWrappedMonitor.isCanceled();
- }
-
- public void setCanceled(boolean value) {
- fWrappedMonitor.setCanceled(value);
- }
-
- public void setTaskName(String name) {
- fWrappedMonitor.setTaskName(name);
- }
-
- public void subTask(String name) {
- fWrappedMonitor.subTask(name);
- }
-
- public void worked(int work) {
- fWrappedMonitor.worked(work);
- }
-}
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/INavigate.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/INavigate.java
deleted file mode 100644
index c70d90f..0000000
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/INavigate.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search2.internal.ui.basic.views;
-
-/**
- * @author Thomas Mäder
- *
- */
-public interface INavigate {
-
- void navigateNext(boolean forward);
-
-}
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/RemoveAllResultsAction.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/RemoveAllResultsAction.java
deleted file mode 100644
index 9203130..0000000
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/RemoveAllResultsAction.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search2.internal.ui.basic.views;
-
-import org.eclipse.jface.action.Action;
-
-import org.eclipse.search.ui.text.*;
-import org.eclipse.search.ui.text.AbstractTextSearchResult;
-
-import org.eclipse.search.internal.ui.SearchPluginImages;
-
-import org.eclipse.search2.internal.ui.SearchMessages;
-
-public class RemoveAllResultsAction extends Action {
- AbstractTextSearchViewPage fPage;
-
- public RemoveAllResultsAction(AbstractTextSearchViewPage page) {
- super(SearchMessages.getString("RemoveAllResultsAction.label")); //$NON-NLS-1$
- SearchPluginImages.setImageDescriptors(this, SearchPluginImages.T_LCL, SearchPluginImages.IMG_LCL_SEARCH_REM_ALL);
- setToolTipText(SearchMessages.getString("RemoveAllResultsAction.tooltip")); //$NON-NLS-1$
- fPage= page;
- }
-
- public void run() {
- AbstractTextSearchResult search= fPage.getInput();
- if (search != null)
- search.removeAll();
- }
-}
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/RemoveMatchAction.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/RemoveMatchAction.java
deleted file mode 100644
index c3e94f1..0000000
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/RemoveMatchAction.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search2.internal.ui.basic.views;
-
-import org.eclipse.jface.action.Action;
-
-import org.eclipse.search.ui.text.*;
-
-import org.eclipse.search.internal.ui.SearchPluginImages;
-
-import org.eclipse.search2.internal.ui.SearchMessages;
-
-public class RemoveMatchAction extends Action {
-
- private AbstractTextSearchViewPage fPage;
-
- public RemoveMatchAction(AbstractTextSearchViewPage page) {
- fPage= page;
- setText(SearchMessages.getString("RemoveMatchAction.label")); //$NON-NLS-1$
- setToolTipText(SearchMessages.getString("RemoveMatchAction.tooltip")); //$NON-NLS-1$
- SearchPluginImages.setImageDescriptors(this, SearchPluginImages.T_LCL, SearchPluginImages.IMG_LCL_SEARCH_REM);
- }
-
- public void run() {
- Match match= fPage.getCurrentMatch();
- AbstractTextSearchResult result= fPage.getInput();
- if (match != null && result != null)
- result.removeMatch(match);
- }
-
-}
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/SearchResultsTableViewer.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/SearchResultsTableViewer.java
deleted file mode 100644
index e42dab3..0000000
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/SearchResultsTableViewer.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search2.internal.ui.basic.views;
-
-import org.eclipse.swt.widgets.Composite;
-
-import org.eclipse.jface.viewers.TableViewer;
-
-/**
- * @author Thomas Mäder
- *
- */
-public class SearchResultsTableViewer extends TableViewer implements INavigate {
-
-
- public SearchResultsTableViewer(Composite parent, int style) {
- super(parent, style);
- setUseHashlookup(true);
- }
-
- public void navigateNext(boolean forward) {
- int itemCount= getTable().getItemCount();
- if (itemCount == 0)
- return;
- int[] selection= getTable().getSelectionIndices();
- int nextIndex= 0;
- if (selection.length > 0) {
- if (forward) {
- nextIndex= selection[selection.length-1]+1;
- if (nextIndex > itemCount)
- nextIndex= 0;
- } else {
- nextIndex= selection[0]-1;
- if (nextIndex < 0)
- nextIndex= itemCount-1;
- }
- }
- getTable().setSelection(nextIndex);
- }
-
- public void add(Object element) {
- if (findItem(element) != null)
- return;
- super.add(element);
- }
-
-}
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/SearchResultsTreeViewer.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/SearchResultsTreeViewer.java
deleted file mode 100644
index 316bea3..0000000
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/SearchResultsTreeViewer.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search2.internal.ui.basic.views;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Item;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.swt.widgets.Widget;
-
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-
-/**
- * @author Thomas Mäder
- *
- */
-public class SearchResultsTreeViewer extends TreeViewer implements INavigate {
-
- /**
- * @param parent
- * @param style
- */
- public SearchResultsTreeViewer(Composite parent, int style) {
- super(parent, style);
- }
-
-
- private TreeItem getNextItem(TreeItem item, boolean forward) {
- while (true) {
- if (item == null)
- return null;
- TreeItem[] siblings= getSiblings(item);
- for (int i= 0; i < siblings.length; i++) {
- if (item.getData().equals(siblings[i].getData())) {
- if (forward) {
- if (i < siblings.length-1)
- return siblings[i+1];
- else
- break;
- } else {
- if (i > 0) {
- return siblings[i-1];
- } else {
- break;
- }
- }
- }
- }
- item= item.getParentItem();
- }
- }
-
- private TreeItem[] getSiblings(TreeItem item) {
- TreeItem parentItem= item.getParentItem();
- if (parentItem != null)
- return parentItem.getItems();
- Tree tree= item.getParent();
- return tree.getItems();
- }
-
- private TreeItem getLeaf(TreeItem item, boolean forward) {
- while (true) {
- createChildren(item);
- TreeItem[] children= item.getItems();
- if (children.length == 0)
- return item;
- if (forward)
- item= children[0];
- else
- item= children[children.length-1];
- }
- }
-
- private TreeItem getNextLeaf(TreeItem item, boolean forward) {
- if (item != null && forward && item.getItemCount() > 0)
- return getLeaf(item, forward);
- TreeItem nextItem= getNextItem(item, forward);
- if (nextItem == null) {
- TreeItem[] roots= getTree().getItems();
- if (roots.length > 0) {
- if (forward)
- nextItem= roots[0];
- else
- nextItem= roots[roots.length-1];
- }
- }
- if (nextItem != null)
- return getLeaf(nextItem, forward);
- return null;
- }
-
- public void navigateNext(boolean forward) {
- Item[] selection= getSelection(getTree());
- TreeItem nextItem= null;
- if (selection.length > 0) {
- nextItem= getNextLeaf((TreeItem) (forward?selection[0]:selection[selection.length-1]), forward);
- } else {
- nextItem= getNextLeaf(null, forward);
- }
- if (nextItem != null) {
- internalSetSelection(nextItem);
- }
- }
-
- private void internalSetSelection(TreeItem ti) {
- if (ti != null) {
- Object data= ti.getData();
- if (data != null) {
- ISelection selection= new StructuredSelection(data);
- setSelection(selection, true);
- }
- }
- }
-
-
- // reimplementation of AbstractTreeViewer methods to avoid flickering.
- public void add(Object parentElement, Object[] childElements) {
- Assert.isNotNull(parentElement);
- Assert.isNotNull(childElements);
- Widget widget = findItem(parentElement);
- // If parent hasn't been realized yet, just ignore the add.
- if (widget == null)
- return;
-
- // optimization!
- // if the widget is not expanded we just invalidate the subtree
- if (widget instanceof Item) {
- Item ti = (Item) widget;
- if (!getExpanded(ti)) {
- boolean needDummy = isExpandable(parentElement);
- // remove all children
- Item[] items = getItems(ti);
- boolean haveDummy = false;
- for (int i = 1; i < items.length; i++) {
- if (items[i].getData() != null) {
- disassociate(items[i]);
- items[i].dispose();
- } else {
- if (needDummy && !haveDummy) {
- haveDummy = true;
- } else {
- items[i].dispose();
- }
- }
- }
- if (items.length > 0) {
- if (items[0].getData() != null) {
- disassociate(items[0]);
- items[0].setData(null);
- }
- haveDummy= true;
- }
- // append a dummy if necessary
- if (needDummy && !haveDummy) {
- newItem(ti, SWT.NULL, -1);
- } else {
- // XXX: Workaround (PR missing)
- //tree.redraw();
- }
-
- return;
- }
- }
-
- if (childElements.length > 0) {
- Object[] filtered = filter(childElements);
- for (int i = 0; i < filtered.length; i++) {
- createAddedElement(widget,filtered[i]);
- }
- }
- }
- /**
- * Create the new element in the parent widget. If the
- * child already exists do nothing.
- * @param widget
- * @param element
- */
- private void createAddedElement(Widget widget, Object element){
-
- if(equals(element,widget.getData()))
- return;
-
- Item[] items = getChildren(widget);
- for(int i = 0; i < items.length; i++){
- if(items[i].getData().equals(element))
- return;
- }
-
- int index = indexForElement(widget, element);
- createTreeItem(widget, element, index);
- }
-
-}
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/SetLayoutAction.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/SetLayoutAction.java
deleted file mode 100644
index 123c9a9..0000000
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/SetLayoutAction.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search2.internal.ui.basic.views;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.search.ui.text.AbstractTextSearchViewPage;
-
-public class SetLayoutAction extends Action {
-
- private AbstractTextSearchViewPage fPage;
- private int fLayout;
-
- public SetLayoutAction(AbstractTextSearchViewPage page, String label, String tooltip, int layout) {
- super(label, IAction.AS_CHECK_BOX);
- fPage= page;
- setToolTipText(tooltip); //$NON-NLS-1$
- fLayout= layout;
- }
-
- public void run() {
- fPage.setLayout(fLayout);
- }
-
- public int getLayout() {
- return fLayout;
- }
-}
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/ShowNextResultAction.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/ShowNextResultAction.java
deleted file mode 100644
index 70cf19b..0000000
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/ShowNextResultAction.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search2.internal.ui.basic.views;
-
-import org.eclipse.jface.action.Action;
-
-import org.eclipse.search.ui.text.*;
-
-import org.eclipse.search.internal.ui.SearchPluginImages;
-
-import org.eclipse.search2.internal.ui.SearchMessages;
-
-public class ShowNextResultAction extends Action {
-
- private AbstractTextSearchViewPage fPage;
-
- public ShowNextResultAction(AbstractTextSearchViewPage page) {
- super(SearchMessages.getString("ShowNextResultAction.label")); //$NON-NLS-1$
- SearchPluginImages.setImageDescriptors(this, SearchPluginImages.T_LCL, SearchPluginImages.IMG_LCL_SEARCH_NEXT);
- setToolTipText(SearchMessages.getString("ShowNextResultAction.tooltip")); //$NON-NLS-1$
- fPage= page;
- }
-
- public void run() {
- fPage.gotoNextMatch();
- }
-}
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/ShowPreviousResultAction.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/ShowPreviousResultAction.java
deleted file mode 100644
index 6414517..0000000
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/ShowPreviousResultAction.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search2.internal.ui.basic.views;
-
-import org.eclipse.jface.action.Action;
-
-import org.eclipse.search.ui.text.*;
-
-import org.eclipse.search.internal.ui.SearchPluginImages;
-
-import org.eclipse.search2.internal.ui.SearchMessages;
-
-public class ShowPreviousResultAction extends Action {
-
- private AbstractTextSearchViewPage fPage;
-
- public ShowPreviousResultAction(AbstractTextSearchViewPage page) {
- super(SearchMessages.getString("ShowPreviousResultAction.label")); //$NON-NLS-1$
- SearchPluginImages.setImageDescriptors(this, SearchPluginImages.T_LCL, SearchPluginImages.IMG_LCL_SEARCH_PREV);
- setToolTipText(SearchMessages.getString("ShowPreviousResultAction.tooltip")); //$NON-NLS-1$
- fPage= page;
- }
-
- public void run() {
- fPage.gotoPreviousMatch();
- }
-}
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/AnnotationManager.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/AnnotationManager.java
deleted file mode 100644
index 17fd9fc..0000000
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/AnnotationManager.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- */
-
-package org.eclipse.search2.internal.ui.text;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.jface.text.source.IAnnotationModel;
-import org.eclipse.jface.text.source.IAnnotationModelExtension;
-import org.eclipse.search.ui.ISearchResultListener;
-import org.eclipse.search.ui.SearchResultEvent;
-import org.eclipse.search.ui.SearchUI;
-import org.eclipse.search.ui.text.AbstractTextSearchResult;
-import org.eclipse.search.ui.text.Match;
-import org.eclipse.search.ui.text.MatchEvent;
-import org.eclipse.search.ui.text.RemoveAllEvent;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IPartListener;
-import org.eclipse.ui.IWindowListener;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.editors.text.EditorsUI;
-import org.eclipse.ui.texteditor.AnnotationTypeLookup;
-import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.ui.texteditor.ITextEditor;
-
-public class AnnotationManager implements ISearchResultListener, IPartListener {
- private AbstractTextSearchResult fResult;
- private Map fMatchesToAnnotations;
- private AnnotationTypeLookup fAnnotationTypeLookup= EditorsUI.getAnnotationTypeLookup();
- private IEditorPart fEditor;
- private IWorkbenchWindow fWindow;
- private static HashMap fSearchResultMap;
- private static AnnotationManager fgManager;
- static {
- fSearchResultMap= new HashMap();
- fgManager= new AnnotationManager();
- IWindowListener listener= new IWindowListener() {
- public void windowActivated(IWorkbenchWindow window) {
- switchedTo(window);
- }
-
- public void windowDeactivated(IWorkbenchWindow window) {
- // ignore
- }
-
- public void windowClosed(IWorkbenchWindow window) {
- fSearchResultMap.remove(window);
- }
-
- public void windowOpened(IWorkbenchWindow window) {
- // ignore
- }
- };
- PlatformUI.getWorkbench().addWindowListener(listener);
- }
-
- public static void searchResultActivated(IWorkbenchWindow window, AbstractTextSearchResult result) {
- fSearchResultMap.put(window, result);
- switchedTo(window);
- }
-
- public static void switchedTo(IWorkbenchWindow window) {
- fgManager.setWindow(window);
- AbstractTextSearchResult result= (AbstractTextSearchResult) fSearchResultMap.get(window);
- fgManager.setSearchResult(result);
- }
-
- public AnnotationManager() {
- fMatchesToAnnotations= new HashMap();
- }
-
- public synchronized void setSearchResult(AbstractTextSearchResult result) {
- if (result == fResult)
- return;
- if (fResult != null) {
- removeAnnotations();
- fResult.removeListener(this);
- }
- fResult= result;
- if (fResult != null) {
- fResult.addListener(this);
- addAnnotations();
- }
- }
-
- public synchronized void searchResultChanged(SearchResultEvent e) {
- if (e instanceof MatchEvent) {
- MatchEvent me= (MatchEvent) e;
- Match[] matches = me.getMatches();
- int kind = me.getKind();
- for (int i = 0; i < matches.length; i++) {
- updateMatch(matches[i], kind);
- }
- } else if (e instanceof RemoveAllEvent)
- removeAnnotations();
- }
-
- private void updateMatch(Match match, int kind) {
- if (fEditor != null && fResult.isShownInEditor(match, fEditor)) {
- if (kind == MatchEvent.ADDED) {
- addAnnotations(fEditor, new Match[]{match});
- } else {
- removeAnnotations(fEditor, new Match[]{match});
- }
- }
- }
-
- public synchronized void partActivated(IWorkbenchPart part) {
-
- if (part instanceof IEditorPart && part != fEditor) {
- if (fResult != null)
- removeAnnotations();
- fEditor= (IEditorPart) part;
- addAnnotations();
- }
- }
-
- private void addAnnotations() {
- if (fEditor == null || fResult == null)
- return;
- Match[] matches= fResult.findContainedMatches(fEditor);
- if (matches == null)
- return;
- addAnnotations(fEditor, matches);
- }
-
- private void removeAnnotations() {
- IEditorPart editor= fEditor;
- if (editor == null)
- return;
- Set matchSet= fMatchesToAnnotations.keySet();
- Match[] matches= new Match[matchSet.size()];
- removeAnnotations(editor, (Match[]) matchSet.toArray(matches));
- }
-
- public void partBroughtToTop(IWorkbenchPart part) {
- partActivated(part);
- }
-
- public void partClosed(IWorkbenchPart part) {
- if (part == fEditor) {
- removeAnnotations();
- fEditor= null;
- }
- }
-
- public void setWindow(IWorkbenchWindow window) {
- if (fWindow != null)
- fWindow.getPartService().removePartListener(AnnotationManager.this);
- fWindow= window;
- fWindow.getPartService().addPartListener(this);
- IEditorPart editor= window.getActivePage().getActiveEditor();
- if (editor != null)
- partActivated(editor);
- }
-
- public void partDeactivated(IWorkbenchPart part) {
- //partClosed(part);
- }
-
- public void partOpened(IWorkbenchPart part) {
- // ignore, will be handled by activate
- }
-
- private void addAnnotations(IEditorPart editor, Match[] matches) {
- HashMap map= new HashMap(matches.length);
- for (int i= 0; i < matches.length; i++) {
- int offset= matches[i].getOffset();
- int length= matches[i].getLength();
- if (offset >= 0 && length >= 0) {
- Annotation annotation= new Annotation(fAnnotationTypeLookup.getAnnotationType(SearchUI.SEARCH_MARKER, IMarker.SEVERITY_INFO), true, null);
- fMatchesToAnnotations.put(matches[i], annotation);
- map.put(annotation, new Position(matches[i].getOffset(), matches[i].getLength()));
- }
- }
- addAnnotations(editor, map);
- }
-
- private void removeAnnotations(IEditorPart editor, Match[] matches) {
- HashSet annotations= new HashSet(matches.length);
- for (int i= 0; i < matches.length; i++) {
- Annotation annotation= (Annotation) fMatchesToAnnotations.remove(matches[i]);
- if (annotation != null) {
- annotations.add(annotation);
- }
- }
- removeAnnotations(editor, annotations);
- }
-
- /**
- * Removes annotations from the given editor. The default implementation works for editors that
- * implement <code>ITextEditor</code>.
- * Subclasses may override this method.
- * @param editor
- * @param annotions A set containing the annotations to be removed.
- * @see Annotation
- */
- private void removeAnnotations(IWorkbenchPart editor, Set annotations) {
- IAnnotationModel model= getAnnotationModel(editor);
- if (model == null)
- return;
- if (model instanceof IAnnotationModelExtension) {
- IAnnotationModelExtension ame= (IAnnotationModelExtension) model;
- Annotation[] annotationArray= new Annotation[annotations.size()];
- ame.replaceAnnotations((Annotation[]) annotations.toArray(annotationArray), Collections.EMPTY_MAP);
- } else {
- for (Iterator iter= annotations.iterator(); iter.hasNext();) {
- Annotation element= (Annotation) iter.next();
- model.removeAnnotation(element);
- }
- }
- }
-
- /**
- * Adds annotations to the given editor. The default implementation works for editors that
- * implement <code>ITextEditor</code>.
- * Subclasses may override this method.
- * @param editor
- * @param annotationToPositionMap A map containing annotations as keys and Positions as values.
- * @see Annotation
- * @see Position
- */
- private void addAnnotations(IWorkbenchPart editor, Map annotationToPositionMap) {
- IAnnotationModel model= getAnnotationModel(editor);
- if (model == null) {
- return;
- }
- if (model instanceof IAnnotationModelExtension) {
- IAnnotationModelExtension ame= (IAnnotationModelExtension) model;
- ame.replaceAnnotations(new Annotation[0], annotationToPositionMap);
- } else {
- for (Iterator elements= annotationToPositionMap.keySet().iterator(); elements.hasNext();) {
- Annotation element= (Annotation) elements.next();
- Position p= (Position) annotationToPositionMap.get(element);
- model.addAnnotation(element, p);
- }
- }
- }
-
- private IAnnotationModel getAnnotationModel(IWorkbenchPart part) {
- IAnnotationModel model= null;
- model= (IAnnotationModel) part.getAdapter(IAnnotationModel.class);
- if (model == null) {
- ITextEditor textEditor= null;
- if (part instanceof ITextEditor) {
- textEditor= (ITextEditor) part;
- }
- if (textEditor != null) {
- IDocumentProvider dp= textEditor.getDocumentProvider();
- if (dp != null)
- model= dp.getAnnotationModel(textEditor.getEditorInput());
- }
- }
- return model;
- }
-
-}
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/PositionTracker.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/PositionTracker.java
deleted file mode 100644
index ab43f1b..0000000
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/PositionTracker.java
+++ /dev/null
@@ -1,330 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search2.internal.ui.text;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import org.eclipse.core.filebuffers.FileBuffers;
-import org.eclipse.core.filebuffers.IFileBuffer;
-import org.eclipse.core.filebuffers.IFileBufferListener;
-import org.eclipse.core.filebuffers.ITextFileBuffer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.Position;
-import org.eclipse.search.ui.IQueryListener;
-import org.eclipse.search.ui.ISearchQuery;
-import org.eclipse.search.ui.ISearchResult;
-import org.eclipse.search.ui.ISearchResultListener;
-import org.eclipse.search.ui.NewSearchUI;
-import org.eclipse.search.ui.SearchResultEvent;
-import org.eclipse.search.ui.text.AbstractTextSearchResult;
-import org.eclipse.search.ui.text.Match;
-import org.eclipse.search.ui.text.MatchEvent;
-import org.eclipse.search.ui.text.RemoveAllEvent;
-
-
-/**
- * @author Thomas Mäder
- *
- */
-public class PositionTracker implements IQueryListener, ISearchResultListener, IFileBufferListener {
-
- private Map fMatchesToPositions= new HashMap();
- private Map fMatchesToSearchResults= new HashMap();
- private Map fFileBuffersToMatches= new HashMap();
-
- private interface IFileBufferMatchOperation {
- void run(ITextFileBuffer buffer, Match match);
- }
-
- public PositionTracker() {
- NewSearchUI.addQueryListener(this);
- FileBuffers.getTextFileBufferManager().addFileBufferListener(this);
- }
-
- // tracking search results --------------------------------------------------------------
- public void queryAdded(ISearchQuery query) {
- if (query.getSearchResult() instanceof AbstractTextSearchResult) {
- query.getSearchResult().addListener(this);
- }
- }
-
- public void queryRemoved(ISearchQuery query) {
- ISearchResult result= query.getSearchResult();
- if (result instanceof AbstractTextSearchResult) {
- untrackAll((AbstractTextSearchResult)result);
- result.removeListener(this);
- }
- }
-
- // tracking matches ---------------------------------------------------------------------
- public void searchResultChanged(SearchResultEvent e) {
- if (e instanceof MatchEvent) {
- MatchEvent evt= (MatchEvent)e;
- Match[] matches = evt.getMatches();
- int kind = evt.getKind();
- AbstractTextSearchResult result = (AbstractTextSearchResult) e.getSearchResult();
- for (int i = 0; i < matches.length; i++) {
- ITextFileBuffer fb= getTrackedFileBuffer(result, matches[i].getElement());
- updateMatch(matches[i], fb, kind, result);
- }
- } else if (e instanceof RemoveAllEvent) {
- RemoveAllEvent evt= (RemoveAllEvent)e;
- ISearchResult result= evt.getSearchResult();
- untrackAll((AbstractTextSearchResult)result);
- }
- }
-
- private void updateMatch(Match match, ITextFileBuffer fb, int kind, AbstractTextSearchResult result) {
- if (fb != null) {
- if (kind == MatchEvent.ADDED) {
- trackPosition(result, fb, match);
- } else if (kind == MatchEvent.REMOVED) {
- untrackPosition(fb, match);
- }
- }
- }
-
- private void untrackAll(AbstractTextSearchResult result) {
- Set matchSet= new HashSet(fMatchesToPositions.keySet());
- for (Iterator matches= matchSet.iterator(); matches.hasNext();) {
- Match match= (Match) matches.next();
- AbstractTextSearchResult matchContainer= (AbstractTextSearchResult) fMatchesToSearchResults.get(match);
- if (result.equals(matchContainer)) {
- ITextFileBuffer fb= getTrackedFileBuffer(result, match.getElement());
- if (fb != null) {
- untrackPosition(fb, match);
- }
- }
- }
- }
-
- private void untrackPosition(ITextFileBuffer fb, Match match) {
- Position position= (Position) fMatchesToPositions.get(match);
- if (position != null) {
- removeFileBufferMapping(fb, match);
- fMatchesToSearchResults.remove(match);
- fMatchesToPositions.remove(match);
- fb.getDocument().removePosition(position);
- }
- }
-
- private void trackPosition(AbstractTextSearchResult result, ITextFileBuffer fb, Match match) {
- int offset = match.getOffset();
- int length = match.getLength();
- if (offset < 0 || length < 0)
- return;
- Position position= new Position(offset, length);
- try {
- fb.getDocument().addPosition(position);
- fMatchesToSearchResults.put(match, result);
- fMatchesToPositions.put(match, position);
- addFileBufferMapping(fb, match);
- } catch (BadLocationException e) {
- e.printStackTrace();
- }
- }
-
- private void addFileBufferMapping(ITextFileBuffer fb, Match match) {
- Set matches= (Set) fFileBuffersToMatches.get(fb);
- if (matches == null) {
- matches= new HashSet();
- fFileBuffersToMatches.put(fb, matches);
- }
- matches.add(match);
- }
-
- private void removeFileBufferMapping(ITextFileBuffer fb, Match match) {
- Set matches= (Set) fFileBuffersToMatches.get(fb);
- if (matches != null) {
- matches.remove(match);
- if (matches.size() == 0)
- fFileBuffersToMatches.remove(fb);
- }
- }
-
- private ITextFileBuffer getTrackedFileBuffer(AbstractTextSearchResult result, Object element) {
- IFile file= result.getFile(element);
- if (file == null)
- return null;
- return FileBuffers.getTextFileBufferManager().getTextFileBuffer(file.getLocation());
- }
-
- public Position getCurrentPosition(Match position) {
- return (Position)fMatchesToPositions.get(position);
- }
-
- public void dispose() {
- NewSearchUI.removeQueryListener(this);
- FileBuffers.getTextFileBufferManager().removeFileBufferListener(this);
- }
-
- // IFileBufferListener implementation ---------------------------------------------------------------------
- /* (non-Javadoc)
- * @see org.eclipse.core.filebuffers.IFileBufferListener#bufferCreated(org.eclipse.core.filebuffers.IFileBuffer)
- */
- public void bufferCreated(IFileBuffer buffer) {
- final int[] trackCount= new int[1];
- if (!(buffer instanceof ITextFileBuffer))
- return;
- IWorkspace ws= ResourcesPlugin.getWorkspace();
- IFile file= ws.getRoot().getFileForLocation(buffer.getLocation());
- if (file == null)
- file= ws.getRoot().getFile(buffer.getLocation());
- ISearchQuery[] queries= NewSearchUI.getQueries();
- for (int i= 0; i < queries.length; i++) {
- ISearchResult result= queries[i].getSearchResult();
- if (result instanceof AbstractTextSearchResult) {
- Match[] matches= ((AbstractTextSearchResult)result).findContainedMatches(file);
- for (int j= 0; j < matches.length; j++) {
- trackCount[0]++;
- trackPosition((AbstractTextSearchResult)result, (ITextFileBuffer) buffer, matches[j]);
- }
- }
- }
- }
-
- private void doForExistingMatchesIn(IFileBuffer buffer, IFileBufferMatchOperation operation) {
- if (!(buffer instanceof ITextFileBuffer))
- return;
- Set matches= (Set) fFileBuffersToMatches.get(buffer);
- if (matches != null) {
- Set matchSet= new HashSet(matches);
- for (Iterator matchIterator= matchSet.iterator(); matchIterator.hasNext();) {
- Match element= (Match) matchIterator.next();
- operation.run((ITextFileBuffer) buffer, element);
- }
- }
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.core.filebuffers.IFileBufferListener#bufferDisposed(org.eclipse.core.filebuffers.IFileBuffer)
- */
- public void bufferDisposed(IFileBuffer buffer) {
- final int[] trackCount= new int[1];
- doForExistingMatchesIn(buffer, new IFileBufferMatchOperation() {
- /* (non-Javadoc)
- * @see org.eclipse.search.internal.model.PositionTracker.FileBufferMatchRunnable#run(org.eclipse.core.filebuffers.ITextFileBuffer, org.eclipse.search.ui.model.text.Match)
- */
- public void run(ITextFileBuffer textBuffer, Match match) {
- trackCount[0]++;
- untrackPosition(textBuffer, match);
- }
- });
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.filebuffers.IFileBufferListener#bufferContentAboutToBeReplaced(org.eclipse.core.filebuffers.IFileBuffer)
- */
- public void bufferContentAboutToBeReplaced(IFileBuffer buffer) {
- // not interesting for us.
- }
-
- public void bufferContentReplaced(IFileBuffer buffer) {
- final int[] trackCount= new int[1];
- doForExistingMatchesIn(buffer, new IFileBufferMatchOperation() {
- public void run(ITextFileBuffer textBuffer, Match match) {
- trackCount[0]++;
- untrackPosition(textBuffer, match);
- AbstractTextSearchResult result= (AbstractTextSearchResult) fMatchesToSearchResults.get(match);
- trackPosition(result, textBuffer, match);
- }
- });
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.filebuffers.IFileBufferListener#stateChanging(org.eclipse.core.filebuffers.IFileBuffer)
- */
- public void stateChanging(IFileBuffer buffer) {
- // not interesting for us
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.filebuffers.IFileBufferListener#dirtyStateChanged(org.eclipse.core.filebuffers.IFileBuffer, boolean)
- */
- public void dirtyStateChanged(IFileBuffer buffer, boolean isDirty) {
- if (isDirty)
- return;
- final int[] trackCount= new int[1];
- doForExistingMatchesIn(buffer, new IFileBufferMatchOperation() {
- /* (non-Javadoc)
- * @see org.eclipse.search.internal.model.PositionTracker.FileBufferMatchRunnable#run(org.eclipse.core.filebuffers.ITextFileBuffer, org.eclipse.search.ui.model.text.Match)
- */
- public void run(ITextFileBuffer textBuffer, Match match) {
- trackCount[0]++;
- Position pos= (Position) fMatchesToPositions.get(match);
- if (pos != null) {
- if (pos.isDeleted()) {
- AbstractTextSearchResult result= (AbstractTextSearchResult) fMatchesToSearchResults.get(match);
- // might be that the containing element has been removed.
- if (result != null) {
- result.removeMatch(match);
- }
- untrackPosition(textBuffer, match);
- } else {
- match.setOffset(pos.getOffset());
- match.setLength(pos.getLength());
- }
- }
- }
- });
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.filebuffers.IFileBufferListener#stateValidationChanged(org.eclipse.core.filebuffers.IFileBuffer, boolean)
- */
- public void stateValidationChanged(IFileBuffer buffer, boolean isStateValidated) {
- // not interesting for us.
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.filebuffers.IFileBufferListener#underlyingFileMoved(org.eclipse.core.filebuffers.IFileBuffer, org.eclipse.core.runtime.IPath)
- */
- public void underlyingFileMoved(IFileBuffer buffer, IPath path) {
- // not interesting for us.
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.filebuffers.IFileBufferListener#underlyingFileDeleted(org.eclipse.core.filebuffers.IFileBuffer)
- */
- public void underlyingFileDeleted(IFileBuffer buffer) {
- // not interesting for us.
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.filebuffers.IFileBufferListener#stateChangeFailed(org.eclipse.core.filebuffers.IFileBuffer)
- */
- public void stateChangeFailed(IFileBuffer buffer) {
- // not interesting for us.
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.IQueryListener#queryStarting(org.eclipse.search.ui.ISearchQuery)
- */
- public void queryStarting(ISearchQuery query) {
- // not interested here
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.IQueryListener#queryFinished(org.eclipse.search.ui.ISearchQuery)
- */
- public void queryFinished(ISearchQuery query) {
- // not interested
- }
-
-}
diff --git a/org.eclipse.search/ngibmcpy2003.gif b/org.eclipse.search/ngibmcpy2003.gif
deleted file mode 100644
index c786e43..0000000
--- a/org.eclipse.search/ngibmcpy2003.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.search/old_buildnotes_search_2.1.html b/org.eclipse.search/old_buildnotes_search_2.1.html
deleted file mode 100644
index 7822f77..0000000
--- a/org.eclipse.search/old_buildnotes_search_2.1.html
+++ /dev/null
@@ -1,3403 +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="GENERATOR" content="Mozilla/4.75 [en] (WinNT; U) [Netscape]">
-
-
-
- <meta name="Author" content="IBM"><title>Eclipse Platform Release Notes - Search</title></head><body>
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Eclipse Build Input 20030227
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2> What's new in this drop</h2>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<ul>
-<li><br></li>
-</ul>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2>Problem Reports</h2>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2003%2F02%2F20&chfieldto=2003%2F02%2F27&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a> to see BRs which have been marked as RESOLVED or CLOSED between 2003/02/20 and 2003/02/27.<br>
-<br>
-<br>
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Eclipse Build Input 20030220
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2> What's new in this drop</h2>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<ul>
-<li><br></li>
-</ul>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2>Problem Reports</h2>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2003%2F02%2F18&chfieldto=2003%2F02%2F20&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a> to see BRs which have been marked as RESOLVED or CLOSED between 2003/02/18 and 2003/02/20.<br>
-<br>
-
-<br>
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Eclipse Build Input 20030218
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2> What's new in this drop</h2>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<ul>
-<li><br></li>
-</ul>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2>Problem Reports</h2>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2003%2F02%2F13&chfieldto=2003%2F02%2F18&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a> to see BRs which have been marked as RESOLVED or CLOSED between 2003/02/13 and 2003/02/18.<br>
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Eclipse Build Input 20030213
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2> What's new in this drop</h2>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<ul>
-<li><br></li>
-</ul>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2>Problem Reports</h2>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2003%2F02%2F11&chfieldto=2003%2F02%2F13&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a> to see BRs which have been marked as RESOLVED or CLOSED between 2003/02/11 and 2003/02/13.<br>
-<br>
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Eclipse Build Input 20030211
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2> What's new in this drop</h2>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<ul>
-<li><br></li>
-</ul>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2>Problem Reports</h2>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2003%2F02%2F07&chfieldto=2003%2F02%2F11&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a> to see BRs which have been marked as RESOLVED or CLOSED between 2003/02/07 and 2003/02/11.<br>
-<br>
-
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Eclipse Build Input 20030206
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2> What's new in this drop</h2>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<ul>
-<li><br></li>
-</ul>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2>Problem Reports</h2>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2003%2F02%2F05&chfieldto=2003%2F02%2F06&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a> to see BRs which have been marked as RESOLVED or CLOSED between 2003/02/05 and 2003/02/06.<br>
-
-<br>
-
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Eclipse Build Input 20030205
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2> What's new in this drop</h2>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<ul>
-<li><br></li>
-</ul>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2>Problem Reports</h2>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2003%2F01%2F28&chfieldto=2003%2F02%2F05&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a> to see BRs which have been marked as RESOLVED or CLOSED between 2003/01/28 and 2003/02/05.<br>
-<br>
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Eclipse Build Input 20030128
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2> What's new in this drop</h2>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<ul>
-<li><br></li>
-</ul>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2>Problem Reports</h2>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2003%2F01%2F21&chfieldto=2003%2F01%2F28&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a> to see BRs which have been marked as RESOLVED or CLOSED between 2003/01/21 and 2003/01/28.<br>
-<br>
-
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Eclipse Build Input 20030121
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2> What's new in this drop</h2>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<ul>
-<li><br></li>
-</ul>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2>Problem Reports</h2>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2003%2F01%2F14&chfieldto=2003%2F01%2F21&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a> to see BRs which have been marked as RESOLVED or CLOSED between 2003/01/14 and 2003/01/21.<br>
-
-<br>
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Eclipse Build Input 20030114
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2> What's new in this drop</h2>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<ul>
-<li><br></li>
-</ul>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2>Problem Reports</h2>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2003%2F01%2F07&chfieldto=2003%2F01%2F14&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a> to see BRs which have been marked as RESOLVED or CLOSED between 2003/01/07 and 2003/01/14.<br>
-
-<br>
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Eclipse Build Input 20030107
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2> What's new in this drop</h2>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<ul>
-<li><br></li>
-</ul>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2>Problem Reports</h2>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2002%2F12%2F16&chfieldto=2003%2F01%2F07&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a> to see BRs which have been marked as RESOLVED or CLOSED between 2002/12/16 and 2003/01/07.<br>
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Eclipse Build Input 20021216
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2> What's new in this drop</h2>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<ul>
-<li><br></li>
-</ul>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2>Problem Reports</h2>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2002%2F12%2F13&chfieldto=2002%2F12%2F16&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a> to see BRs which have been marked as RESOLVED or CLOSED between 2002/12/13 and 2002/12/16.<br>
-
-<br>
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Eclipse Build Input 20021213
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2> What's new in this drop</h2>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<ul>
-<li><br></li>
-</ul>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2>Problem Reports</h2>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2002%2F12%2F10&chfieldto=2002%2F12%2F13&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a> to see BRs which have been marked as RESOLVED or CLOSED between 2002/12/10 and 2002/12/13.<br>
-<br>
-<br>
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Eclipse Build Input 20021210
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2> What's new in this drop</h2>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<ul>
-<li><br></li>
-</ul>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2>Problem Reports</h2>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2002%2F11%2F26&chfieldto=2002%2F12%2F10&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a> to see BRs which have been marked as RESOLVED or CLOSED between 2002/11/26 and 2002/12/10.<br>
-<br>
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Eclipse Build Input 20021126
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2> What's new in this drop</h2>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<ul>
-<li><br></li>
-</ul>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2>Problem Reports</h2>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2002%2F11%2F19&chfieldto=2002%2F11%2F26&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a> to see BRs which have been marked as RESOLVED or CLOSED between 2002/11/19 and 2002/11/26.<br>
-<br>
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Eclipse Build Input 20021119
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2> What's new in this drop</h2>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<ul>
-<li><br></li>
-</ul>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2>Problem Reports</h2>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2002%2F11%2F13&chfieldto=2002%2F11%2F19&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a> to see BRs which have been marked as RESOLVED or CLOSED between 2002/11/13 and 2002/11/19.
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Eclipse Build Input 20021113
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2> What's new in this drop</h2>
-
-
-
-
-
-
-
-
-
-
-
-
-
-<ul>
-<li><br></li>
-</ul>
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2>Problem Reports</h2>
-
-
-
-
-
-
-
-
-
-
-
-
-
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2002%2F11%2F12&chfieldto=2002%2F11%2F13&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a> to see BRs which have been marked as RESOLVED or CLOSED between 2002/11/12 and 2002/11/13.
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Eclipse Build Input 20021112
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2> What's new in this drop</h2>
-
-
-
-
-
-
-
-
-
-
-
-
-<ul>
-<li><br></li>
-</ul>
-
-
-
-
-
-
-
-
-
-
-
-
-<h2>Problem Reports</h2>
-
-
-
-
-
-
-
-
-
-
-
-
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2002%2F10%2F29&chfieldto=2002%2F11%2F12&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a> to see BRs which have been marked as RESOLVED or CLOSED between 2002/10/29 and 2002/11/12.
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Eclipse Build Input 20021029
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2> What's new in this drop</h2>
-
-
-
-
-
-
-
-
-
-
-
-<ul>
-<li>A default perspective can be configured for the Search view.<br></li>
-</ul>
-
-
-
-
-
-
-
-
-
-
-
-<h2>Problem Reports</h2>
-
-
-
-
-
-
-
-
-
-
-
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2002%2F10%2F15&chfieldto=2002%2F10%2F29&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a> to see BRs which have been marked as RESOLVED or CLOSED between 2002/10/15 and 2002/10/29.<br>
-<br>
-
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Eclipse Build Input 20021015
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2> What's new in this drop</h2>
-
-
-
-
-
-
-
-
-
-
-<ul>
-<li><br></li>
-</ul>
-
-
-
-
-
-
-
-
-
-
-<h2>Problem Reports</h2>
-
-
-
-
-
-
-
-
-
-
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2002%2F10%2F08&chfieldto=2002%2F10%2F15&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a> to see BRs which have been marked as RESOLVED or CLOSED between 2002/10/08 and 2002/10/15.<br>
-<br>
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Eclipse Build Input 20021008
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2> What's new in this drop</h2>
-
-
-
-
-
-
-
-
-
-<ul>
-<li><br></li>
-</ul>
-
-
-
-
-
-
-
-
-
-<h2>Problem Reports</h2>
-
-
-
-
-
-
-
-
-
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2002%2F10%2F01&chfieldto=2002%2F10%2F08&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a> to see BRs which have been marked as RESOLVED or CLOSED between 2002/10/01 and 2002/10/08.<br>
-<br>
-
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Eclipse Build Input 20021001
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2> What's new in this drop</h2>
-
-
-
-
-
-
-
-
-<ul>
-<li><br></li>
-</ul>
-
-
-
-
-
-
-
-
-<h2>Problem Reports</h2>
-
-
-
-
-
-
-
-
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2002%2F09%2F19&chfieldto=2002%2F10%2F01&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a> to see BRs which have been marked as RESOLVED or CLOSED between 2002/09/19 and 2002/10/01.<br>
-<br>
-
-<br>
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Eclipse Build Input 20020919
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2> What's new in this drop</h2>
-
-
-
-
-
-
-
-<ul>
-<li>Added "openWith" context menu<br></li>
-</ul>
-
-
-
-
-
-
-
-<h2>Problem Reports</h2>
-
-
-
-
-
-
-
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2002%2F09%2F10&chfieldto=2002%2F09%2F20&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a> to see BRs which have been marked as RESOLVED or CLOSED between 2002/09/10 and 2002/09/19.<br>
-<br>
-<br>
-
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Eclipse Build Input 20020910
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2> What's new in this drop</h2>
-
-
-
-
-
-
-<ul>
-<li><br></li>
-</ul>
-
-
-
-
-
-
-<h2>Problem Reports</h2>
-
-
-
-
-
-
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2002%2F09%2F03&chfieldto=2002%2F09%2F10&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a> to see BRs which have been marked as RESOLVED or CLOSED between 2002/09/03 and 2002/09/10.<br>
-<br>
-
-<br>
-
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Eclipse Build Input 20020903
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2> What's new in this drop</h2>
-
-
-
-
-
-<ul>
-<li><br></li>
-</ul>
-
-
-
-
-
-<h2>Problem Reports</h2>
-
-
-
-
-
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2002%2F08%2F27&chfieldto=2002%2F09%2F03&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a> to see BRs which have been marked as RESOLVED or CLOSED between 2002/08/27 and 2002/09/03.<br>
-<br>
-
-<br>
-
-
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Eclipse Build Input 20020827
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2> What's new in this drop</h2>
-
-
-
-
-<ul>
-<li><br></li>
-</ul>
-
-
-
-
-<h2>Problem Reports</h2>
-
-
-
-
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2002%2F08%2F20&chfieldto=2002%2F08%2F27&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a> to see BRs which have been marked as RESOLVED or CLOSED between 2002/08/20 and 2002/08/27.<br>
-
-<br>
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Eclipse Build Input 20020820
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2> What's new in this drop</h2>
-
-
-
-<ul>
-<li>Search view supports select all<br></li>
-</ul>
-
-
-
-<h2>Problem Reports</h2>
-
-
-
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2002%2F08%2F13&chfieldto=2002%2F08%2F20&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a> to see BRs which have been marked as RESOLVED or CLOSED between 2002/08/13 and 2002/08/20.<br>
-
-<br>
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Eclipse Build Input 20020813
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2> What's new in this drop</h2>
-
-
-<ul>
-<li><br></li>
-</ul>
-
-
-<h2>Problem Reports</h2>
-
-
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2002%2F07%2F23&chfieldto=2002%2F08%2F13&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a> to see BRs which have been marked as RESOLVED or CLOSED between 2002/07/23 and 2002/08/13.<br>
-
-<br>
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Eclipse Build Input 20020723
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2> What's new in this drop</h2>
-
-<ul>
-
-<li>Removed all 2.0 build notes. They can be found in <a href="buildnotes_search_2_0.html">buildnotes_search_2_0.html</a><br></li>
-</ul>
-
-<h2>Problem Reports</h2>
-
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2002%2F06%2F29&chfieldto=2002%2F07%2F23&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a> to see BRs which have been marked as RESOLVED or CLOSED between 2002/06/29 and 2002/07/23.<br>
-
-<br>
-
-<br>
-
-<a href="hglegal2003.htm"><img src="ngibmcpy2003.gif" border="0" height="14" width="324" alt="Copyright IBM Corporation and others 2000, 2003."></a>
-<br>
-
-<br>
-
-<br>
-
-<br>
-
-<br>
-<br>
-<br>
-<br>
-<br>
-<br>
-<br>
-<br>
-<br>
-<br>
-<br>
-<br>
-<br>
-<br>
-<br>
-<br>
-</body></html>
diff --git a/org.eclipse.search/old_buildnotes_search_2_0.html b/org.eclipse.search/old_buildnotes_search_2_0.html
deleted file mode 100644
index d36c4a7..0000000
--- a/org.eclipse.search/old_buildnotes_search_2_0.html
+++ /dev/null
@@ -1,925 +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="GENERATOR" content="Mozilla/4.75 [en] (WinNT; U) [Netscape]">
-
- <meta name="Author" content="IBM"><title>Eclipse Platform Release Notes - Search</title></head><body>
-
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Eclipse Build Input 20020618
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2> What's new in this drop</h2>
-<ul>
-<li>Reverted File/Text search back to only ignore derived resoureces<br></li><li>Removed dependency on Team Support Core plug-in<br></li>
-</ul>
-<h2>Problem Reports</h2>
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2002%2F06%2F06&chfieldto=2002%2F06%2F18&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- to see BRs which have been marked as RESOLVED or CLOSED between 2002/06/06 and 2002/06/18.<br>
-<br>
-<hr size="1" width="100%"><br>
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Eclipse Build Input 20020606
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2> What's new in this drop</h2>
-<ul>
-<li>Reverted File/Text search back to only ignore derived resoureces<br>
-</li><li>Removed dependency on Team Support Core plug-in<br></li>
-</ul>
-<h2>Problem Reports</h2>
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2002%2F05%2F31&chfieldto=2002%2F06%2F06&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- to see BRs which have been marked as RESOLVED or CLOSED between 2002/05/31 and 2002/06/06.<br>
-<br>
-<hr size="1" width="100%"><br>
-
-
-
-
-
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Eclipse Build Input 20020531
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2> What's new in this drop</h2>
-<ul>
-<li>File search ignores derived and to be ignored resource (see Team preference page)</li><li>Text search ignores binary files<br></li>
-</ul>
-<h2>Problem Reports</h2>
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2002%2F05%2F28&chfieldto=2002%2F05%2F31&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- to see BRs which have been marked as RESOLVED or CLOSED between 2002/05/28 and 2002/05/31.<br>
-<br>
-<hr size="1" width="100%">
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Eclipse Build Input 20020528
-
-
-
-
-
-
-
-
-
-
-
-
-
-<h2> What's new in this drop</h2>
-<ul>
-<li><br></li>
-</ul>
-<h2>Problem Reports</h2>
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2002%2F05%2F21&chfieldto=2002%2F05%2F28&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a>
-
-
-
-
-
-
-
-
-
-
-
-
-
- to see BRs which have been marked as RESOLVED or CLOSED between 2002/05/21 and 2002/05/28.<br>
-<br>
-<hr size="1" width="100%"><br>
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Eclipse Build Input 20020521
-
-
-
-
-
-
-
-
-
-
-
-
-<h2> What's new in this drop</h2>
-<ul>
-<li><br></li>
-</ul>
-<h2>Problem Reports</h2>
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2002%2F05%2F18&chfieldto=2002%2F05%2F21&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a>
-
-
-
-
-
-
-
-
-
-
-
-
- to see BRs which have been marked as RESOLVED or CLOSED between 2002/05/18 and 2002/05/21.<br>
-<br>
-<hr size="1" width="100%">
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Eclipse Build Input 20020518
-
-
-
-
-
-
-
-
-
-
-
-<h2> What's new in this drop</h2>
-<ul>
-<li>Global menu for Search actions</li><li>Replace is now available on text search results<br></li>
-</ul>
-<h2>Problem Reports</h2>
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2002%2F05%2F14&chfieldto=2002%2F05%2F18&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a>
-
-
-
-
-
-
-
-
-
-
-
- to see BRs which have been marked as RESOLVED or CLOSED between 2002/05/14 and 2002/05/18.<br>
-<br>
-<hr size="1" width="100%">
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Eclipse Build Input 20020514
-
-
-
-
-
-
-
-
-
-
-<h2> What's new in this drop</h2>
-<ul>
-<li><br></li>
-</ul>
-<h2>Problem Reports</h2>
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2002%2F05%2F08&chfieldto=2002%2F05%2F14&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a>
-
-
-
-
-
-
-
-
-
-
- to see BRs which have been marked as RESOLVED or CLOSED between 2002/05/08 and 2002/05/14.<br>
-<br>
-<hr size="1" width="100%"><br>
-
-
-
-
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
-
-
-
-
-
-
-
-
-
-
-
- Eclipse Build Input 20020508
-
-
-
-
-
-
-
-
-
-<h2> What's new in this drop</h2>
-<ul>
-<li>The visible search pages can be configured in the Search dialog.<br>
-</li>
-</ul>
-<h2>Problem Reports</h2>
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2002%2F04%2F30&chfieldto=2002%2F05%2F08&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a>
-
-
-
-
-
-
-
-
-
- to see BRs which have been marked as RESOLVED or CLOSED between 2002/04/30 and 2002/05/08.<br>
-<br>
-<hr size="1" width="100%"><br>
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
-
-
-
-
-
-
-
-
-
-
- Eclipse Build Input 20020430
-
-
-
-
-
-
-
-
-<h2> What's new in this drop</h2>
-<ul>
-<li>Removed the deprecated working set API</li><li>Search dialog no longer reserves space for scope for all pages but only those that require it<br></li>
-
-</ul>
-<h2>Problem Reports</h2>
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2002%2F04%2F23&chfieldto=2002%2F04%2F30&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a>
-
-
-
-
-
-
-
-
- to see BRs which have been marked as RESOLVED or CLOSED between 2002/04/23 and 2002/04/30.<br>
-<br>
-<hr size="1" width="100%"><br>
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
-
-
-
-
-
-
-
-
- Eclipse Build Input 20020423
-
-
-
-
-
-
-
-<h2> What's new in this drop</h2>
-<ul>
-<li><br></li>
-</ul>
-<h2>Problem Reports</h2>
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2002%2F04%2F19&chfieldto=2002%2F04%2F23&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a>
-
-
-
-
-
-
-
- to see BRs which have been marked as RESOLVED or CLOSED between 2002/04/18 and 2002/04/23.<br>
-<br>
-<hr size="1" width="100%">
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
-
-
-
-
-
-
- Eclipse Build Input 20020418
-
-
-
-
-
-
-<h2> What's new in this drop</h2>
-<ul>
-<li><br></li>
-</ul>
-<h2>Problem Reports</h2>
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2002%2F04%2F16&chfieldto=2002%2F04%2F19&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a>
-
-
-
-
-
-
- to see BRs which have been marked as RESOLVED or CLOSED between 2002/04/16 and 2002/04/18.<br>
-<br>
-<hr size="1" width="100%">
-
-
-
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
-
-
-
-
- Eclipse Build Input 20020416
-
-
-
-
-
-<h2> What's new in this drop</h2>
-<ul>
-<li>Search no longer uses its own implementation of working sets but takes
-advantage of the workbench working set support. As a consequence you will
-have to redefine your existing working sets.<br></li>
-</ul>
-<h2>Problem Reports</h2>
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2002%2F04%2F11&chfieldto=2002%2F04%2F17&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a>
-
-
-
-
-
- to see BRs which have been marked as RESOLVED or CLOSED between 2002/04/11 and 2002/04/16.<br>
-<br>
-<hr size="1" width="100%"><br>
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
-
-
-
-
- Eclipse Build Input 20020411
-
-
-
-
-<h2> What's new in this drop</h2>
-<ul>
-<li><br></li>
-</ul>
-<h2>Problem Reports</h2>
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2002%2F04%2F09&chfieldto=2002%2F04%2F12&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a>
-
-
-
-
- to see BRs which have been marked as RESOLVED or CLOSED between 2002/04/09
-and 2002/04/11.<br>
-<br>
-<hr size="1" width="100%"><br>
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
-
-
- Eclipse Build Input 20020409
-
-
-
-<h2> What's new in this drop</h2>
-<ul>
-<li><i>Text Search</i> has been changed to <i>File Search</i> and now allows to search for files with a given file name pattern.<br></li>
-</ul>
-<h2>Problem Reports</h2>
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2002%2F04%2F02&chfieldto=2002%2F04%2F09&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a>
-
-
-
- to see BRs which have been marked as RESOLVED or CLOSED between 2002/04/02
-and 2002/04/09.<br>
-<br>
-<hr size="1" width="100%"><br>
-
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
-
- Eclipse Build Input 20020402
-
-
-<h2> What's new in this drop</h2>
-<ul>
-<li><br></li>
-</ul>
-<h2>Problem Reports</h2>
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2002%2F03%2F19&chfieldto=2002%2F03%2F26&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a>
-
-
- to see BRs which have been marked as RESOLVED or CLOSED between 2002/03/26
-and 2002/04/02.<br>
-<br>
-<hr size="1" width="100%"><br>
-
-
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
- Eclipse Build Input 20020326
-
-<h2> What's new in this drop</h2>
-<ul>
-<li>Text search also finds matches in dirty editors.<br></li>
-</ul>
-<h2>Problem Reports</h2>
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2002%2F03%2F26&chfieldto=2002%2F04%2F02&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a>
-
- to see BRs which have been marked as RESOLVED or CLOSED between 2002/03/19
-and 2002/03/26.<br>
-<br>
-<hr size="1" width="100%"><br>
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
-
- Eclipse Build Input 20020226
-<h2> What's new in this drop</h2>
-<ul>
- <li>Previous file name patterns are now available through a combo box.</li>
- <li>The file name pattern is only derived the first time from the selection
-and after that the previous value is used to initialize the field.<br>
- </li>
-</ul>
-<h2>Problem Reports</h2>
-<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2002%2F02%2F14&chfieldto=2002%2F02%2F26&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a>
- to see BRs which have been marked as RESOLVED or CLOSED between 2002/02/14
-and 2002/02/26.<br>
-<br>
-<hr size="1" width="100%"><br>
-<br>
-
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
- Eclipse Build Input 20020214
-<h2> What's new in this drop</h2>
-
-<ul>
- <li>Reuse of editors when stepping through search matches now managed
-by platform and no longer directly by the Search plug-in.<br>
- </li>
-
-</ul>
-
-<h2>Problem Reports</h2>
- <a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2002%2F02%2F05&chfieldto=2002%2F02%2F14&product=Platform&component=Search&cmdtype=doit&&order=Bug+Number">
- Click here</a>
- to see BRs which have been marked as RESOLVED or CLOSED between 2002/02/05
-and 2002/02/14.<br>
- <br>
-
-<hr size="1" width="100%"><br>
-
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
- Eclipse Integration Build 20020205
-<h2> What's new in this drop</h2>
-
-<h3> API changes</h3>
-
-<h3> API additions</h3>
-
-<h3> Other highlights</h3>
-
-<h2> Known deficiencies</h2>
-
-<h2> Problem reports fixed</h2>
- <a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=8611">8611</a>
- NPE in text search with Compare to a Version editor open<br>
- <a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=9007">9007</a>
- Working Set; OK button not disabled<br>
-
-<h2> Problem reports closed</h2>
-
-<hr size="1" width="100%"><br>
-
-<h1> Eclipse Platform Build Notes<br>
- Search</h1>
- Eclipse Integration Build 20020129
-<h2>What's new in this drop</h2>
-
-<ul>
- <li>A new attribute called <i>showScopeSection</i> has been added to
- the markup language for Search pages. If this attribute is missing or set
- to <tt>false</tt> then the scope section is not shown in the Search dialog.
- To see the scope section this attribute has to be set to <tt>true</tt>
-. Plug-ins which add their own Search page and want to see the scope section
- will have to add the new attribute to their plugin.xml</li>
-
-</ul>
-
-<h3> API changes</h3>
-
-<ul>
- <li>Activation of the Search view has been moved from the dialog to
-the individual Search page. Plug-ins which want the Search page to appear
- when Search is invoked have to call <tt>SearchUI.activateSearchResultView()</tt><br>
- </li>
-
-</ul>
-
-<h3> API additions</h3>
-
-<h3> Other highlights</h3>
-
-<h2> Known deficiencies</h2>
-
-<h2> Problem reports fixed</h2>
- <a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=7918">7918</a>
- Missing busy cursor in search dialog when flipping pages<br>
- <a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=7919">7919</a>
- Search: scope section doesn't apply to Help search<br>
- <a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=8024">8024</a>
- SearchResultsView opens without calling SearchUI.activateSearchView<br>
- <a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=8025">8025</a>
- Scope section added to ISearchPage<br>
-
-<h2> Problem reports closed</h2>
- <a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=8456">8456</a>
- Widget is disposed error in Search<br>
- <br>
- <br>
-
-<hr size="1" width="100%">
-<h1>Eclipse Platform Build Notes<br>
- Search</h1>
- Eclipse Integration Build 20020122
-<h2> What's new in this drop</h2>
-
-<h3> API changes</h3>
-
-<h3> API additions</h3>
-
-<h3> Other highlights</h3>
-
-<h2> Known deficiencies</h2>
-
-<h2> Problem reports fixed</h2>
- <a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=7813">7813</a>
- NPE in SearchPageDescriptor.readExtensionScorePairs/StringTo<br>
-
-<h2> Problem reports closed</h2>
- <a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=4066">4066</a>
- Default extension in text search is often wrong (1GHFMPL)<br>
- <br>
-
-<hr size="1" width="100%">
-<h1> Eclipse Platform Build Notes<br>
- Search</h1>
- Eclipse Integration Build 20011218
-<h2> What's new in this drop</h2>
-
-<h3> API changes</h3>
-
-<h3> API additions</h3>
-
-<h3> Other highlights</h3>
- APIs added for 2.0 are now flagged with <b>@since 2.0</b>.
-
-<h2> Known deficiencies</h2>
-
-<h2> Problem reports fixed</h2>
- <a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6836">6836</a>
- Working Sets Dialog: Mnemonics, issues
-<hr size="1" width="100%">
-<h1> Eclipse Platform Build Notes<br>
- Search</h1>
- Eclipse Integration Build 20011211
-<h2> What's new in this drop</h2>
-
-<h3> API changes</h3>
-
-<h3> API additions</h3>
-
-<h3> Other highlights</h3>
-
-<h2> Known deficiencies</h2>
-
-<h2> Problem reports fixed</h2>
- <a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5868">5868</a>
- Define working set does too much work in the UI thread <br>
- <a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5620">5620</a>
- Search: control keys for navigating the list of search results
-
-<hr size="1" width="100%">
-<h1> Eclipse Platform Build Notes<br>
- Search</h1>
- Eclipse Integration Build 20011206
-<h2> What's new in this drop</h2>
-
-<h3> API changes</h3>
-
-<h3> API additions</h3>
-
-<h3> Other highlights</h3>
-
-<h2> Known deficiencies</h2>
-
-<h2> Problem reports fixed</h2>
- <a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6119">6119</a>
- cannot delete a working set <br>
- <a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6264">6264</a>
- Search results don't have initial selection
-<hr size="1" width="100%">
-<h1> Eclipse Platform Build Notes<br>
- Search</h1>
- Eclipse Integration Build 20011204
-<h2> What's new in this drop</h2>
-
-<h3> API changes</h3>
-
-<h3> API additions</h3>
-
-<h3> Other highlights</h3>
-
-<h2> Known deficiencies</h2>
-
-<h2> Problem reports fixed</h2>
- <a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3954">3954</a>
- Search dialog does not need parentheses around label (1GF86BN)
-<br>
- <a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6435">6435</a>
- Search again should move search to top of MRU list
-<hr size="1" width="100%">
-<h1> Eclipse Platform Build Notes<br>
- Search</h1>
- Note: Previous build notes have been included in <i>Eclipse Platform
- Build Notes - Java Development Tooling UI.</i><br>
-
-</body></html>
\ No newline at end of file
diff --git a/org.eclipse.search/plugin.properties b/org.eclipse.search/plugin.properties
deleted file mode 100644
index 79ca87b..0000000
--- a/org.eclipse.search/plugin.properties
+++ /dev/null
@@ -1,50 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2003 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-pluginName= Search Support
-providerName= Eclipse.org
-
-searchMarker= Search Marker
-
-searchPages= Search Pages
-searchResultSorters= Search Result Sorters
-searchResultViewPages= Search Result View Pages
-
-search= Search
-
-searchMenu.label= Se&arch
-openFileSearchPageAction.label= &File...
-
-openSearchDialogAction.label= Se&arch...
-openSearchDialogAction.tooltip= Search
-
-fileSearch= File Search
-searchResultViewName= Search
-newSearchResultViewName= New Search
-
-ResourcenameSorter.label= &Name
-ResourcenameSorter.tooltip= Sort by Resource Name
-ResourcePathSorter.label= &Path
-ResourcePathSorter.tooltip= Sort by Resource Path
-
-SearchPreferencePage.label= Search
-WorkInProgressPreferencePage.label= Work in Progress
-
-ActionDefinition.openSearchDialog.name= Open Search Dialog
-ActionDefinition.openSearchDialog.description= Open the Search dialog
-
-ActionDefinition.openFileSearchPage.name= File Search
-ActionDefinition.openFileSearchPage.description= Open the Search dialog\'s file search page
-
-SearchMarkerPreference.label= Search Results
-
-searchCategory.name= Search
-searchCategory.description= Search command category
diff --git a/org.eclipse.search/plugin.xml b/org.eclipse.search/plugin.xml
deleted file mode 100644
index 74558e2..0000000
--- a/org.eclipse.search/plugin.xml
+++ /dev/null
@@ -1,242 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
-
-<!-- ======================================================================= -->
-<!-- Search Plugin -->
-<!-- ======================================================================= -->
-<plugin
- name="%pluginName"
-
- id="org.eclipse.search"
- version="3.0.0"
- provider-name="%providerName"
- class="org.eclipse.search.internal.ui.SearchPlugin">
-
- <requires>
- <import plugin="org.eclipse.core.resources"/>
- <import plugin="org.eclipse.core.filebuffers"/>
- <import plugin="org.eclipse.ui"/>
- <import plugin="org.eclipse.ui.ide"/>
- <import plugin="org.eclipse.ui.workbench.texteditor"/>
- <import plugin="org.eclipse.jface.text"/>
- <import plugin="org.eclipse.ui.editors"/>
- <import plugin="org.eclipse.core.runtime.compatibility"/>
- </requires>
-
- <runtime>
- <library name="search.jar" >
- <export name = "*"/>
- <packages prefixes="org.eclipse.search.ui,org.eclipse.search.internal,org.eclipse.search2.internal"/>
- </library>
- </runtime>
-
-
- <!-- Search extension point definitions -->
-
- <extension-point name="%searchPages" id="searchPages" schema="schema/searchPages.exsd"/>
- <extension-point name="%searchResultSorters" id="searchResultSorters" schema="schema/searchResultSorters.exsd"/>
- <extension-point name="%searchResultViewPages" id="searchResultViewPages" schema="schema/searchResultViewPages.exsd"/>
-
-
- <!-- Extensions -->
-
- <extension point="org.eclipse.core.resources.markers" id="searchmarker" name="%searchMarker">
- <super type="org.eclipse.core.resources.textmarker"/>
- <attribute name="line"/>
- <attribute name="potentialMatch"/>
- </extension>
-
- <extension point="org.eclipse.ui.editors.annotationTypes">
- <type
- name="org.eclipse.search.results"
- markerType="org.eclipse.search.searchmarker">
- </type>
- </extension>
-
- <extension
- point="org.eclipse.ui.ide.markerImageProviders">
- <imageprovider
- id="org.eclipse.ui.searchMarkerProvider"
- markertype="org.eclipse.search.searchmarker"
- icon="icons/full/obj16/searchm_obj.gif">
- </imageprovider>
- </extension>
-
- <!-- commands and their bindings -->
- <extension point="org.eclipse.ui.commands">
- <category
- name="%searchCategory.name"
- description="%searchCategory.description"
- id="org.eclipse.search.ui.category.search"
- />
-
- <command
- category="org.eclipse.search.ui.category.search"
- id="org.eclipse.search.ui.openSearchDialog"
- name= "%ActionDefinition.openSearchDialog.name"
- description="%ActionDefinition.openSearchDialog.description"
- />
- <keyBinding
- string="Ctrl+H"
- scope="org.eclipse.ui.globalScope"
- command="org.eclipse.search.ui.openSearchDialog"
- configuration="org.eclipse.ui.defaultAcceleratorConfiguration"
- />
-
- <command
- category="org.eclipse.search.ui.category.search"
- id="org.eclipse.search.ui.openFileSearchPage"
- name= "%ActionDefinition.openFileSearchPage.name"
- description="%ActionDefinition.openFileSearchPage.description"
- />
- <keyBinding
- string=""
- scope="org.eclipse.ui.globalScope"
- command="org.eclipse.search.ui.openFileSearchPage"
- configuration="org.eclipse.ui.defaultAcceleratorConfiguration"
- />
- </extension>
-
- <!-- action sets -->
- <extension point="org.eclipse.ui.actionSets">
- <actionSet
- id="org.eclipse.search.searchActionSet"
- label="%search"
- visible="true">
-
- <!-- =================================================================== -->
- <!-- Search Menu -->
- <!-- =================================================================== -->
-
- <menu
- id="org.eclipse.search.menu"
- label="%searchMenu.label"
- path="navigate">
- <groupMarker name="internalDialogGroup"/> <!-- not to be used by clients -->
- <groupMarker name="dialogGroup"/> <!-- to be used by clients -->
- <separator name="contextMenuActionsGroup"/>
- </menu>
-
- <!-- dialog group -->
- <action id="org.eclipse.search.OpenFileSearchPage"
- definitionId="org.eclipse.search.ui.openFileSearchPage"
- menubarPath="org.eclipse.search.menu/internalDialogGroup"
- label="%openFileSearchPageAction.label"
- icon="icons/full/obj16/tsearch_obj.gif"
- helpContextId="file_search_action_context"
- class="org.eclipse.search.internal.ui.OpenFileSearchPageAction"/>
-
- <action id="org.eclipse.search.OpenSearchDialog"
- definitionId="org.eclipse.search.ui.openSearchDialog"
- toolbarPath="Normal/Search"
- menubarPath="org.eclipse.search.menu/internalDialogGroup"
- label="%openSearchDialogAction.label"
- tooltip="%openSearchDialogAction.tooltip"
- icon="icons/full/ctool16/search.gif"
- helpContextId="open_search_dialog_action_context"
- class="org.eclipse.search.internal.ui.OpenSearchDialogAction"/>
- </actionSet>
- </extension>
-
- <extension point="org.eclipse.ui.views">
- <view
- id="org.eclipse.search.SearchResultView"
- name="%searchResultViewName"
- category="org.eclipse.ui"
- class="org.eclipse.search.internal.ui.SearchResultView"
- icon="icons/full/cview16/searchres.gif">
- </view>
- <view
- name="%newSearchResultViewName"
- icon="icons/full/cview16/searchres.gif"
- category="org.eclipse.ui"
- class="org.eclipse.search2.internal.ui.SearchView"
- id="org.eclipse.search.ui.views.SearchView">
- </view>
- </extension>
-
-<!-- Default search results view -->
- <extension
- id="FileSearchPage"
- point="org.eclipse.search.searchResultViewPages">
- <viewPage
- id="org.eclipse.search.text.FileSearchResultPage"
- targetClass="org.eclipse.search.internal.ui.text.FileSearchResult"
- class="org.eclipse.search.internal.ui.text.FileSearchPage">
- </viewPage>
- </extension>
-
- <extension point="org.eclipse.search.searchPages">
- <page
- id="org.eclipse.search.internal.ui.text.TextSearchPage"
- label="%fileSearch"
- icon="icons/full/obj16/tsearch_obj.gif"
- sizeHint="250,160"
- tabPosition="1"
- extensions="*:1"
- showScopeSection="true"
- canSearchEnclosingProjects="true"
- class="org.eclipse.search.internal.ui.text.TextSearchPage">
- </page>
- </extension>
-
- <extension point="org.eclipse.search.searchResultSorters">
- <sorter
- id="org.eclipse.search.internal.ui.ResourcenameSorter"
- pageId="org.eclipse.search.internal.ui.text.TextSearchPage"
- label="%ResourcenameSorter.label"
- tooltip="%ResourcenameSorter.tooltip"
- icon="icons/full/clcl16/search_sortmatch.gif"
- class="org.eclipse.search.internal.ui.text.ResourcenameSorter">
- </sorter>
- <sorter
- id="org.eclipse.search.internal.ui.ResourcePathSorter"
- pageId="org.eclipse.search.internal.ui.text.TextSearchPage"
- label="%ResourcePathSorter.label"
- tooltip="%ResourcePathSorter.tooltip"
- icon="icons/full/clcl16/search_sortmatch.gif"
- class="org.eclipse.search.internal.ui.text.ResourcePathSorter">
- </sorter>
- </extension>
-
- <extension
- point="org.eclipse.ui.preferencePages">
- <page name="%SearchPreferencePage.label"
- id="org.eclipse.search.preferences.SearchPreferencePage"
- class="org.eclipse.search.internal.ui.SearchPreferencePage"
- category="org.eclipse.ui.preferencePages.Workbench">
- </page>
- <page name="%WorkInProgressPreferencePage.label"
- id="org.eclipse.search.preferences.WorkInProgressPreferencePage"
- class="org.eclipse.search.internal.ui.WorkInProgressPreferencePage"
- category="org.eclipse.search.preferences.SearchPreferencePage">
- </page>
- </extension>
-
- <extension
- point="org.eclipse.ui.editors.markerAnnotationSpecification">
- <specification
- annotationType="org.eclipse.search.results"
- label="%SearchMarkerPreference.label"
- icon="icons/full/obj16/searchm_obj.gif"
- textPreferenceKey="searchResultIndication"
- textPreferenceValue="true"
- highlightPreferenceKey="searchResultHighlighting"
- highlightPreferenceValue="false"
- overviewRulerPreferenceKey="searchResultIndicationInOverviewRuler"
- overviewRulerPreferenceValue="true"
- verticalRulerPreferenceKey="searchResultIndicationInVerticalRuler"
- verticalRulerPreferenceValue="true"
- colorPreferenceKey="searchResultIndicationColor"
- colorPreferenceValue="192,192,192"
- presentationLayer="3"
- showInNextPrevDropdownToolbarActionKey="showSearchResultInNextPrevDropdownToolbarAction"
- showInNextPrevDropdownToolbarAction="true"
- isGoToNextNavigationTargetKey="isSearchResultGoToNextNavigationTarget"
- isGoToNextNavigationTarget="false"
- isGoToPreviousNavigationTargetKey="isSearchResultGoToPreviousNavigationTarget"
- isGoToPreviousNavigationTarget="false">
- </specification>
- </extension>
-
-</plugin>
\ No newline at end of file
diff --git a/org.eclipse.search/schema/searchPages.exsd b/org.eclipse.search/schema/searchPages.exsd
deleted file mode 100644
index 71f901c..0000000
--- a/org.eclipse.search/schema/searchPages.exsd
+++ /dev/null
@@ -1,234 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.search">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.eclipse.search" id="searchPages" name="Search Pages"/>
- </appInfo>
- <documentation>
- This extension point allows a plug-in to register search
-pages for specialized searches. When the search action
-is performed on a resource, the search infrastructure
-locates the most specific registered search page for it.
- </documentation>
- </annotation>
-
- <element name="extension">
- <complexType>
- <sequence>
- <element ref="page" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
- a fully qualified identifier of the target extension point
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
- an optional identifier of the extension instance
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
- an optional name of the extension instance
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="page">
- <annotation>
- <appInfo>
- <meta.element labelAttribute="label" icon="icon"/>
- </appInfo>
- </annotation>
- <complexType>
- <attribute name="id" type="string" use="required">
- <annotation>
- <documentation>
- a unique name that will be used to identify this
-search page
- </documentation>
- </annotation>
- </attribute>
- <attribute name="label" type="string" use="required">
- <annotation>
- <documentation>
- a translatable label that will be used in the search
-page tab
- </documentation>
- </annotation>
- </attribute>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
- a name of the class which implements <samp>org.eclipse.search.ui.ISearchPage</samp>. We recommend subclassing
-<samp>org.eclipse.jface.dialogs.DialogPage</samp>.
- </documentation>
- <appInfo>
- <meta.attribute kind="java" basedOn="org.eclipse.jface.dialogs.DialogPage:org.eclipse.search.ui.ISearchPage"/>
- </appInfo>
- </annotation>
- </attribute>
- <attribute name="icon" type="string">
- <annotation>
- <documentation>
- a relative name of the image that will be used
-for all resources that match the specified extensions.
-If omitted, the search page's tab will only contain a label.
- </documentation>
- <appInfo>
- <meta.attribute kind="resource"/>
- </appInfo>
- </annotation>
- </attribute>
- <attribute name="sizeHint" type="string">
- <annotation>
- <documentation>
- a hint for the initial size of the page. This is a string
-containing the width and height separated by
-comma (e.g. "50, 60"). In the case this hint is
-omitted the page will be no larger than the other pages.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="tabPosition" type="string">
- <annotation>
- <documentation>
- an integer defining where the page is placed in the page
-book. The value does not define the absolute position
-but the position relative to the other pages. The ordering
-of pages is as follows:
-<ol>
-<li>
-if neither page defines the tab position then they are
-ordered alphabetically according to their labels
-</li>
-<li>
-if both pages have the tab position specified then the
-page with the lower value comes first. If the values
-are equal then the pages are treated as if the values
-would not exist (see 1.)
-</li>
-<li>
-if only one page has the value specified then this
-page comes first
-</ol>
- </documentation>
- </annotation>
- </attribute>
- <attribute name="extensions" type="string">
- <annotation>
- <documentation>
- a comma separated list with file extensions on which
-the search page can operate. Each extension must
-also include a weight (0 meaning lowest weight)
-which enables the search infrastructure to find the
-best fitting page. The weight is separated from
-the extension by a colon. If a search page can
-search all possible resources then "*" can be used.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="searchViewHelpContextId" type="string">
- <annotation>
- <documentation>
- an optional help context ID of the Search view displaying results of this page. If this attribute is missing then the default search help context ID (<samp>org.eclipse.search.search_view_context</samp>) is used.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="showScopeSection" type="boolean">
- <annotation>
- <documentation>
- If this attribute is missing or set to "false", then the scope section is not shown in the Search dialog.
-To see the scope section, this attribute has to be set to "true".
-Plug-ins which add their own Search page and want to see the scope section have to add this to their plugin.xml.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="enabled" type="boolean">
- <annotation>
- <documentation>
- If this attribute is missing or set to "false", then the page is not initially shown in the Search dialog.
-The page can be activated by the user via the "Customize..." button on the Search dialog.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="canSearchEnclosingProjects" type="boolean">
- <annotation>
- <documentation>
- If this attribute is missing or set to "false", the "Enclosing Projects" search scope is not shown in the search dialog's scope part.
-If the attribute "showScopeSection" is missing or set to "false", this attribute will be ignored.
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- The following is an example of a search page extension
-definition:
-
-<p>
-<pre>
- <extension point="org.eclipse.search.searchPages">
- <page
- id="org.eclipse.search.ui.text.TextSearchPage"
- label="Text Search"
- icon="icons/full/obj16/tsearch_pref.gif"
- sizeHint="250,160"
- tabPosition="1"
- extensions="*:1"
- showScopeSection="true"
- class="org.eclipse.search.ui.text.TextSearchPage">
- </page>
- </extension>
-</pre>
-</p>
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiInfo"/>
- </appInfo>
- <documentation>
-
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="implementation"/>
- </appInfo>
- <documentation>
- The search infrastructure provides a search page
-for full-text search.
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="copyright"/>
- </appInfo>
- <documentation>
- <p>
-<a href="hglegal.htm">
- <img SRC="ngibmcpy.gif"
- ALT="Copyright (c) 2000, 2003 IBM Corporation and others. All Rights Reserved."
- BORDER=0 height=14 width=324></a>
-</p>
- </documentation>
- </annotation>
-
-</schema>
diff --git a/org.eclipse.search/schema/searchResultSorters.exsd b/org.eclipse.search/schema/searchResultSorters.exsd
deleted file mode 100644
index 8959ebe..0000000
--- a/org.eclipse.search/schema/searchResultSorters.exsd
+++ /dev/null
@@ -1,165 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.search">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.eclipse.search" id="searchResultSorters" name="Result Sorters"/>
- </appInfo>
- <documentation>
- This extension point allows a plug-in to contribute
-search result sorters to the search result view's Sort
-context menu.
- </documentation>
- </annotation>
-
- <element name="extension">
- <complexType>
- <sequence>
- <element ref="sorter" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
- a fully qualified identifier of the target extension point
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
- an optional identifier of the extension instance
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
- an optional name of the extension instance
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="sorter">
- <annotation>
- <appInfo>
- <meta.element labelAttribute="label" icon="icon"/>
- </appInfo>
- </annotation>
- <complexType>
- <attribute name="id" type="string" use="required">
- <annotation>
- <documentation>
- a unique name that will be used to identify this search result sorter.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="pageId" type="string" use="required">
- <annotation>
- <documentation>
- the ID of a registered search page for which the
-sorter will be activated. "*" activates the sorter
-for all pages.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="label" type="string" use="required">
- <annotation>
- <documentation>
- a translatable label that will be used as the
-menu item's label.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="tooltip" type="string">
- <annotation>
- <documentation>
- a translatable text that will be used as the menu
-item's tool tip . If omitted, the menu item will
-have no tool tip.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="icon" type="string">
- <annotation>
- <documentation>
- a relative name of the image that will be shown in
-the context menu along with the label. If omitted,
-the menu entry will only contain a label.
- </documentation>
- <appInfo>
- <meta.attribute kind="resource"/>
- </appInfo>
- </annotation>
- </attribute>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
- a name of the class that extends <samp>org.eclipse.jface.viewers.ViewerSorter</samp>
- </documentation>
- <appInfo>
- <meta.attribute kind="java" basedOn="org.eclipse.jface.viewers.ViewerSorter"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- The following is an example of a search page extension definition:
-<p>
-<pre>
- <extension point="org.eclipse.search.searchResultSorters">
- <sorter
- id="org.eclipse.search.internal.ui.FileNameSorter"
- pageId="*"
- label="%FileNameSorter.label"
- tooltip="%FilenNameSorter.tooltip"
- icon="icons/full/ecl16/search_sort.gif"
- class="org.eclipse.search.internal.ui.FileNameSorter">
- </sorter>
- </extension>
-</pre>
-</p>
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiInfo"/>
- </appInfo>
- <documentation>
-
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="implementation"/>
- </appInfo>
- <documentation>
- The search infrastructure provides a sorter that sorts
-the matches by the resource name.
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="copyright"/>
- </appInfo>
- <documentation>
- <p>
-<a href="hglegal.htm">
- <img SRC="ngibmcpy.gif"
- ALT="Copyright (c) 2000, 2003 IBM Corporation and others. All Rights Reserved."
- BORDER=0 height=14 width=324></a>
-</p>
- </documentation>
- </annotation>
-
-</schema>
diff --git a/org.eclipse.search/schema/searchResultViewPages.exsd b/org.eclipse.search/schema/searchResultViewPages.exsd
deleted file mode 100644
index 4637786..0000000
--- a/org.eclipse.search/schema/searchResultViewPages.exsd
+++ /dev/null
@@ -1,112 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.search.ui">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.eclipse.search.ui" id="searchResultViewPages" name="Search Result View Pages"/>
- </appInfo>
- <documentation>
- [Enter description of this extension point.]
- </documentation>
- </annotation>
-
- <element name="extension">
- <complexType>
- <sequence>
- <element ref="viewPage"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="viewPage">
- <complexType>
- <attribute name="targetClass" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute kind="java"/>
- </appInfo>
- </annotation>
- </attribute>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute kind="java"/>
- </appInfo>
- </annotation>
- </attribute>
- <attribute name="id" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="since"/>
- </appInfo>
- <documentation>
- [Enter the first release in which this extension point appears.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- [Enter extension point usage example here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiInfo"/>
- </appInfo>
- <documentation>
- [Enter API information here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="implementation"/>
- </appInfo>
- <documentation>
- [Enter information about supplied implementation of this extension point.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="copyright"/>
- </appInfo>
- <documentation>
-
- </documentation>
- </annotation>
-
-</schema>
diff --git a/org.eclipse.search/scripts/exportplugin.xml b/org.eclipse.search/scripts/exportplugin.xml
deleted file mode 100644
index fab6295..0000000
--- a/org.eclipse.search/scripts/exportplugin.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<project name="org.eclipse.search" default="export" basedir="..">
- <target name="init">
- <tstamp/>
- <property name="destdir" value="../../plugin-export" />
- <property name="plugin" value="org.eclipse.search" />
- <property name="version" value="_3.0.0" />
- <property name="dest" value="${destdir}/${plugin}${version}" />
- </target>
-
- <target name="build" depends="init">
- <eclipse.incrementalBuild project="${plugin}" kind="incr"/>
- </target>
-
- <target name="export" depends="build">
- <mkdir dir="${destdir}" />
- <delete dir="${dest}" />
- <mkdir dir="${dest}" />
- <jar
- jarfile="${dest}/search.jar"
- basedir="bin"
- />
- <copy file="plugin.xml" todir="${dest}"/>
- <copy file="plugin.properties" todir="${dest}"/>
- <copy todir="${dest}/icons">
- <fileset dir="icons" />
- </copy>
- <zip zipfile="${dest}/searchsrc.zip">
- <fileset dir="search" />
- <fileset dir="new search" />
- </zip>
- </target>
-</project>
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/core/ISearchScope.java b/org.eclipse.search/search/org/eclipse/search/internal/core/ISearchScope.java
deleted file mode 100644
index 1400e4a..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/core/ISearchScope.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.core;
-
-import org.eclipse.core.resources.IResourceProxy;
-
-/**
- * Defines a scope to which search results are limited.
- */
-public interface ISearchScope {
-
- /**
- * Checks whether the given element is enclosed by
- * this scope or not.
- *
- * @param element the resource proxy to be checked
- * @return <code>true</code> if the resource is inside the search scope
- *
- */
- public boolean encloses(IResourceProxy element);
-
- /**
- * Returns a human readable description of this scope
- *
- * @return the description of this scope as <code>String</code>
- *
- */
- public String getDescription();
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/core/SearchScope.java b/org.eclipse.search/search/org/eclipse/search/internal/core/SearchScope.java
deleted file mode 100644
index 315abd9..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/core/SearchScope.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.core;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceProxy;
-import org.eclipse.core.runtime.IPath;
-
-import org.eclipse.jface.util.Assert;
-
-/**
- * A default implementation of <code>ISearchScope</code>.
- */
-public class SearchScope implements ISearchScope {
-
- private List fElements;
- private String fDescription;
-
- public SearchScope(String description) {
- Assert.isNotNull(description);
- fDescription= description;
- fElements= new ArrayList(5);
- }
-
- public SearchScope(String description, IResource[] resources) {
- Assert.isNotNull(description);
- int resourceCount= resources.length;
- fDescription= description;
- fElements= new ArrayList(resourceCount + 5);
- for (int i= 0; i < resourceCount; i++)
- fElements.add(resources[i]);
- }
-
- public void setDescription(String description) {
- Assert.isNotNull(description);
- fDescription= description;
- }
-
- /*
- * @see ISearchScope#add(IResource)
- */
- public void add(IResource element) {
- fElements.add(element);
- }
-
- /*
- * Implements method from ISearchScope
- */
- public boolean encloses(IResourceProxy proxy) {
- IPath elementPath= proxy.requestFullPath();
- Iterator iter= elements();
- while (iter.hasNext()) {
- IResource resource= (IResource)iter.next();
- if (resource.getFullPath().isPrefixOf(elementPath))
- return true;
- }
- return false;
- }
-
- /*
- * Implements method from ISearchScope
- */
- public String getDescription() {
- return fDescription;
- }
-
- /**
- * Returns the search scope elements
- */
- protected Iterator elements() {
- return fElements.iterator();
- }
-
- /**
- * Implements method from ISearchScope
- *
- * @deprecated as of 2.1 use @link #encloses(IResourceProxy)
- */
- public boolean encloses(IResource element) {
- IPath elementPath= element.getFullPath();
- Iterator iter= elements();
- while (iter.hasNext()) {
- IResource resource= (IResource)iter.next();
- if (resource.getFullPath().isPrefixOf(elementPath))
- return true;
- }
- return false;
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/core/text/AmountOfWorkCalculator.java b/org.eclipse.search/search/org/eclipse/search/internal/core/text/AmountOfWorkCalculator.java
deleted file mode 100644
index 5a20009..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/core/text/AmountOfWorkCalculator.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.core.text;
-
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceProxy;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.MultiStatus;
-
-import org.eclipse.search.internal.core.ISearchScope;
-
-/**
- * The visitor that does the actual work.
- */
-public class AmountOfWorkCalculator extends TypedResourceVisitor {
- private ISearchScope fScope;
- private int fResult;
-
- AmountOfWorkCalculator(MultiStatus status) {
- super(status);
- }
-
- protected boolean visitFile(IResourceProxy proxy) throws CoreException {
- if (fScope.encloses(proxy) && !proxy.isDerived())
- fResult++;
- return true;
- }
-
- public int process(Collection projects, ISearchScope scope) {
- fResult= 0;
- fScope= scope;
-
- Iterator i= projects.iterator();
- while(i.hasNext()) {
- IProject project= (IProject)i.next();
- int save= fResult;
- try {
- project.accept(this, IResource.NONE);
- } catch (CoreException ex) {
- addToStatus(ex);
- }
- // Project doesn't contain any files that are in scope
- if (save == fResult)
- i.remove();
- }
-
- return fResult;
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/core/text/FileMatchCollector.java b/org.eclipse.search/search/org/eclipse/search/internal/core/text/FileMatchCollector.java
deleted file mode 100644
index 2b85f80..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/core/text/FileMatchCollector.java
+++ /dev/null
@@ -1,38 +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.search.internal.core.text;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.resources.IResourceProxy;
-import org.eclipse.core.runtime.CoreException;
-
-/**
- * @author Thomas Mäder
- *
- */
-public class FileMatchCollector implements IMatchCollector {
- private ITextSearchResultCollector fCollector;
- private IResourceProxy fProxy;
-
- public FileMatchCollector(ITextSearchResultCollector collector, IResourceProxy proxy) {
- fCollector= collector;
- fProxy= proxy;
- }
-
- public void accept(String line, int start, int length, int lineNumber) throws InvocationTargetException {
- try {
- fCollector.accept(fProxy, line, start, length, lineNumber);
- } catch (CoreException e) {
- throw new InvocationTargetException(e);
- }
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/core/text/IMatchCollector.java b/org.eclipse.search/search/org/eclipse/search/internal/core/text/IMatchCollector.java
deleted file mode 100644
index 936305f..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/core/text/IMatchCollector.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.search.internal.core.text;
-
-import java.lang.reflect.InvocationTargetException;
-
-/**
- * @author Thomas Mäder
- *
- */
-public interface IMatchCollector {
- void accept(String line, int start, int length, int lineNumber) throws InvocationTargetException;
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/core/text/ITextSearchResultCollector.java b/org.eclipse.search/search/org/eclipse/search/internal/core/text/ITextSearchResultCollector.java
deleted file mode 100644
index e2caed1..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/core/text/ITextSearchResultCollector.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.core.text;
-
-import org.eclipse.core.resources.IResourceProxy;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-public interface ITextSearchResultCollector {
-
- /**
- * Returns the progress monitor used to setup and report progress.
- */
- public IProgressMonitor getProgressMonitor();
-
- /**
- * Called before the actual search starts.
- */
- public void aboutToStart() throws CoreException;
-
- /**
- * Accepts the given search result.
- * @param resource proxy the resource proxy in which the match has been found.
- * @param line the line containing the match
- * @param int start position from the beginning of the file. Start position
- * is zero based.
- * @param length the length of the match.
- * @param lineNumber the line number of the match.
- */
- public void accept(IResourceProxy proxy, String line, int start, int length, int lineNumber) throws CoreException;
-
- /**
- * Called when the search has ended.
- */
- public void done() throws CoreException;
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/core/text/MatchLocator.java b/org.eclipse.search/search/org/eclipse/search/internal/core/text/MatchLocator.java
deleted file mode 100644
index e87a843..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/core/text/MatchLocator.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.core.text;
-
-import java.io.IOException;
-import java.io.Reader;
-import java.lang.reflect.InvocationTargetException;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-
-import org.eclipse.search.internal.ui.SearchMessages;
-
-/**
- * A class finding matches withing a file.
- * @since 3.0
- */
-public class MatchLocator {
-
- protected static final int fgLF= '\n';
- protected static final int fgCR= '\r';
-
- private Matcher fMatcher;
- protected int fPushbackChar;
- protected boolean fPushback;
- private String fPattern;
- private boolean fIsRegEx;
-
- public MatchLocator(String pattern, String options) {
- fPattern= pattern;
- Pattern regExPattern;
-
- fIsRegEx= options.indexOf('r') != -1;
- if (!isRegExSearch())
- pattern= asRegEx(pattern);
-
- if (options.indexOf('i') != -1)
- regExPattern= Pattern.compile(pattern, Pattern.CASE_INSENSITIVE);
- else
- regExPattern= Pattern.compile(pattern);
-
- fMatcher= regExPattern.matcher(""); //$NON-NLS-1$
-
- }
-
- public boolean isEmtpy() {
- return getPattern().length() == 0;
- }
-
- public String getPattern() {
- return fPattern;
- }
-
- public void locateMatches(IProgressMonitor monitor, Reader reader, IMatchCollector collector) throws IOException, InvocationTargetException {
- int lineCounter= 1;
- int charCounter=0;
- boolean eof= false;
- try {
- while (!eof) {
- StringBuffer sb= new StringBuffer(200);
- int eolStrLength= readLine(reader, sb);
- int lineLength= sb.length();
- int start= 0;
- eof= eolStrLength == -1;
- String line= sb.toString();
- while (start < lineLength) {
- fMatcher.reset(line);
- if (fMatcher.find(start)) {
- start= charCounter + fMatcher.start();
- int length= fMatcher.end() - fMatcher.start();
- collector.accept(line.trim(), start, length, lineCounter);
- start= fMatcher.end();
- }
- else // no match in this line
- start= lineLength;
- }
- charCounter+= lineLength + eolStrLength;
- lineCounter++;
- if (monitor.isCanceled())
- throw new OperationCanceledException(SearchMessages.getString("TextSearchVisitor.canceled")); //$NON-NLS-1$
- }
- } finally {
- if (reader != null)
- reader.close();
- }
- }
-
- /*
- * Converts '*' and '?' to regEx variables.
- */
- private String asRegEx(String pattern) {
-
- StringBuffer out= new StringBuffer(pattern.length());
-
- boolean escaped= false;
- boolean quoting= false;
-
- int i= 0;
- while (i < pattern.length()) {
- char ch= pattern.charAt(i++);
-
- if (ch == '*' && !escaped) {
- if (quoting) {
- out.append("\\E"); //$NON-NLS-1$
- quoting= false;
- }
- out.append(".*"); //$NON-NLS-1$
- escaped= false;
- continue;
- } else if (ch == '?' && !escaped) {
- if (quoting) {
- out.append("\\E"); //$NON-NLS-1$
- quoting= false;
- }
- out.append("."); //$NON-NLS-1$
- escaped= false;
- continue;
- } else if (ch == '\\' && !escaped) {
- escaped= true;
- continue;
-
- } else if (ch == '\\' && escaped) {
- escaped= false;
- if (quoting) {
- out.append("\\E"); //$NON-NLS-1$
- quoting= false;
- }
- out.append("\\\\"); //$NON-NLS-1$
- continue;
- }
-
- if (!quoting) {
- out.append("\\Q"); //$NON-NLS-1$
- quoting= true;
- }
- if (escaped && ch != '*' && ch != '?' && ch != '\\')
- out.append('\\');
- out.append(ch);
- escaped= ch == '\\';
-
- }
- if (quoting)
- out.append("\\E"); //$NON-NLS-1$
-
- return out.toString();
- }
-
- protected int readLine(Reader reader, StringBuffer sb) throws IOException {
- int ch= -1;
- if (fPushback) {
- ch= fPushbackChar;
- fPushback= false;
- }
- else
- ch= reader.read();
- while (ch >= 0) {
- if (ch == fgLF)
- return 1;
- if (ch == fgCR) {
- ch= reader.read();
- if (ch == fgLF)
- return 2;
- else {
- fPushbackChar= ch;
- fPushback= true;
- return 1;
- }
- }
- sb.append((char)ch);
- ch= reader.read();
- }
- return -1;
- }
-
- public boolean isRegExSearch() {
- return fIsRegEx;
- }
-
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchEngine.java b/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchEngine.java
deleted file mode 100644
index 55a3a5f..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchEngine.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.core.text;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-
-import org.eclipse.jface.util.Assert;
-
-import org.eclipse.search.ui.SearchUI;
-
-import org.eclipse.search.internal.core.ISearchScope;
-import org.eclipse.search.internal.ui.SearchMessages;
-
-public class TextSearchEngine {
-
- /**
- * Search for the given pattern.
- */
- public IStatus search(IWorkspace workspace, ISearchScope scope, ITextSearchResultCollector collector, MatchLocator matchLocator) {
- Assert.isNotNull(workspace);
- Assert.isNotNull(scope);
- Assert.isNotNull(collector);
- Assert.isNotNull(matchLocator);
- IProgressMonitor monitor= collector.getProgressMonitor();
-
- IProject[] projects= workspace.getRoot().getProjects();
- Collection openProjects= new ArrayList(10);
- for (int i= 0; i < projects.length; i++) {
- IProject project= projects[i];
- if (project.isOpen())
- openProjects.add(project);
- }
- String message= SearchMessages.getString("TextSearchEngine.statusMessage"); //$NON-NLS-1$
- MultiStatus status= new MultiStatus(SearchUI.PLUGIN_ID, IStatus.OK, message, null);
- if (!openProjects.isEmpty()) {
- int amountOfWork= (new AmountOfWorkCalculator(status)).process(openProjects, scope);
- try {
- monitor.beginTask("", amountOfWork); //$NON-NLS-1$
- if (amountOfWork > 0) {
- Integer[] args= new Integer[] {new Integer(1), new Integer(amountOfWork)};
- monitor.setTaskName(SearchMessages.getFormattedString("TextSearchEngine.scanning", args)); //$NON-NLS-1$
- }
- collector.aboutToStart();
- TextSearchVisitor visitor= new TextSearchVisitor(matchLocator, scope, collector, status, amountOfWork);
- visitor.process(openProjects);
- } catch (CoreException ex) {
- status.add(ex.getStatus());
- } finally {
- monitor.done();
- try {
- collector.done();
- } catch (CoreException ex) {
- status.add(ex.getStatus());
- }
- }
- }
- return status;
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchScope.java b/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchScope.java
deleted file mode 100644
index 5b2646f..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchScope.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.core.text;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceProxy;
-import org.eclipse.core.runtime.IAdaptable;
-
-import org.eclipse.ui.IWorkingSet;
-
-import org.eclipse.search.internal.core.SearchScope;
-import org.eclipse.search.internal.ui.SearchMessages;
-
-/**
- * A special text search scope that take file extensions into account.
- */
-public class TextSearchScope extends SearchScope {
-
- private static class WorkspaceScope extends TextSearchScope {
-
- private WorkspaceScope() {
- super(SearchMessages.getString("WorkspaceScope")); //$NON-NLS-1$
- }
-
- public void add(IResource element) {
- // do nothing
- }
-
- /**
- * @see ISearchScope#encloses(Object)
- */
- public boolean encloses(IResourceProxy proxy) {
- if (proxy.getType() == IResource.FILE && skipFile(proxy))
- return false;
- return true;
- }
- }
-
- private Set fExtensions= new HashSet(3);
-
- /**
- * Returns a new Workbench scope.
- */
- public static TextSearchScope newWorkspaceScope() {
- return new WorkspaceScope();
- }
-
- public TextSearchScope(String description) {
- super(description);
- }
-
- public TextSearchScope(String description, IResource[] resources) {
- super(description, resources);
- }
-
- public TextSearchScope(String description, IAdaptable[] elements) {
- super(description, convertToResources(elements));
-
- }
-
- public TextSearchScope(String description, IWorkingSet[] workingSets) {
- super(description, convertToResources(getElements(workingSets)));
- }
-
- private static IResource[] convertToResources(IAdaptable[] elements) {
- int length= elements.length;
- Set resources= new HashSet(length);
- for (int i= 0; i < length; i++) {
- IResource resource= (IResource)elements[i].getAdapter(IResource.class);
- if (resource != null)
- resources.add(resource);
- }
- return (IResource[])resources.toArray(new IResource[resources.size()]);
- }
-
- private static IAdaptable[] getElements(IWorkingSet[] workingSets) {
- int length= workingSets.length;
- Set elements= new HashSet(length);
- for (int i= 0; i < length; i++) {
- elements.addAll(Arrays.asList(workingSets[i].getElements()));
- }
- return (IAdaptable[])elements.toArray(new IAdaptable[elements.size()]);
- }
-
- /**
- * Adds an extension to the scope.
- */
- public void addExtension(String extension) {
- Pattern pattern= Pattern.compile(asRegEx(extension), Pattern.CASE_INSENSITIVE);
- fExtensions.add(pattern.matcher("")); //$NON-NLS-1$
- }
-
- /*
- * Converts '*' and '?' to regEx variables.
- */
- private String asRegEx(String pattern) {
-
- StringBuffer out= new StringBuffer(pattern.length());
-
- boolean escaped= false;
- boolean quoting= false;
-
- int i= 0;
- while (i < pattern.length()) {
- char ch= pattern.charAt(i++);
-
- if (ch == '*' && !escaped) {
- if (quoting) {
- out.append("\\E"); //$NON-NLS-1$
- quoting= false;
- }
- out.append(".*"); //$NON-NLS-1$
- escaped= false;
- continue;
- } else if (ch == '?' && !escaped) {
- if (quoting) {
- out.append("\\E"); //$NON-NLS-1$
- quoting= false;
- }
- out.append("."); //$NON-NLS-1$
- escaped= false;
- continue;
- } else if (ch == '\\' && !escaped) {
- escaped= true;
- continue;
-
- } else if (ch == '\\' && escaped) {
- escaped= false;
- if (quoting) {
- out.append("\\E"); //$NON-NLS-1$
- quoting= false;
- }
- out.append("\\\\"); //$NON-NLS-1$
- continue;
- }
-
- if (!quoting) {
- out.append("\\Q"); //$NON-NLS-1$
- quoting= true;
- }
- if (escaped && ch != '*' && ch != '?' && ch != '\\')
- out.append('\\');
- out.append(ch);
- escaped= ch == '\\';
-
- }
- if (quoting)
- out.append("\\E"); //$NON-NLS-1$
-
- return out.toString();
- }
-
- /**
- * Adds all string patterns contained in <code>extensions</code> to this
- * scope. The allowed pattern characters are <code>*</code> for any character
- * and <code>?</code> for one character.
- */
- public void addExtensions(Set extensions) {
- if (extensions == null)
- return;
- Iterator iter= extensions.iterator();
- while (iter.hasNext()) {
- Object obj= iter.next();
- if (obj instanceof String)
- addExtension((String)obj);
- }
- }
-
- /*
- * Implements method from ISearchScope
- */
- public boolean encloses(IResourceProxy proxy) {
- if (proxy.getType() == IResource.FILE && skipFile(proxy))
- return false;
- return super.encloses(proxy);
- }
-
- boolean skipFile(IResourceProxy proxy) {
- if (proxy != null) {
- Iterator iter= fExtensions.iterator();
- while (iter.hasNext()) {
- if (((Matcher)iter.next()).reset(proxy.getName()).matches())
- return false;
- }
- }
- return true;
- }
-
- /**
- * Implements method from ISearchScope
- *
- * @deprecated As of 2.1, replaced by {@link #encloses(IResourceProxy)}
- */
- public boolean encloses(IResource element) {
- if (element.getType() == IResource.FILE && skipFile((IFile)element))
- return false;
- return super.encloses(element);
- }
-
- boolean skipFile(IFile file) {
- if (file != null) {
- Iterator iter= fExtensions.iterator();
- while (iter.hasNext()) {
- if (((Matcher)iter.next()).reset(file.getName()).matches())
- return false;
- }
- }
- return true;
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchVisitor.java b/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchVisitor.java
deleted file mode 100644
index 5d7b1f2..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchVisitor.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.core.text;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.StringReader;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceProxy;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorReference;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.texteditor.ITextEditor;
-
-import org.eclipse.search.ui.SearchUI;
-
-import org.eclipse.search.internal.core.ISearchScope;
-import org.eclipse.search.internal.ui.SearchMessages;
-import org.eclipse.search.internal.ui.SearchPlugin;
-
-/**
- * The visitor that does the actual work.
- */
-public class TextSearchVisitor extends TypedResourceVisitor {
- protected static final int fgLF= '\n';
- protected static final int fgCR= '\r';
-
- private ISearchScope fScope;
- private ITextSearchResultCollector fCollector;
- private IEditorPart[] fEditors;
- private MatchLocator fLocator;
-
- private IProgressMonitor fProgressMonitor;
- private Integer[] fMessageFormatArgs;
-
- private int fNumberOfScannedFiles;
- private int fNumberOfFilesToScan;
- private long fLastUpdateTime;
-
- public TextSearchVisitor(MatchLocator locator, ISearchScope scope, ITextSearchResultCollector collector, MultiStatus status, int fileCount) {
- super(status);
- fScope= scope;
- fCollector= collector;
-
- fProgressMonitor= collector.getProgressMonitor();
-
- fLocator= locator;
-
- fNumberOfScannedFiles= 0;
- fNumberOfFilesToScan= fileCount;
- fMessageFormatArgs= new Integer[] { new Integer(0), new Integer(fileCount) };
- }
-
- public void process(Collection projects) {
- Iterator i= projects.iterator();
- while(i.hasNext()) {
- IProject project= (IProject)i.next();
- try {
- project.accept(this, IResource.NONE);
- } catch (CoreException ex) {
- addToStatus(ex);
- }
- }
- }
-
- /**
- * Returns an array of all editors that have an unsaved content. If the identical content is
- * presented in more than one editor, only one of those editor parts is part of the result.
- *
- * @return an array of all editor parts.
- */
- public static IEditorPart[] getEditors() {
- Set inputs= new HashSet();
- List result= new ArrayList(0);
- IWorkbench workbench= SearchPlugin.getDefault().getWorkbench();
- IWorkbenchWindow[] windows= workbench.getWorkbenchWindows();
- for (int i= 0; i < windows.length; i++) {
- IWorkbenchPage[] pages= windows[i].getPages();
- for (int x= 0; x < pages.length; x++) {
- IEditorReference[] editorRefs= pages[x].getEditorReferences();
- for (int z= 0; z < editorRefs.length; z++) {
- IEditorPart ep= editorRefs[z].getEditor(false);
- if (ep != null) {
- IEditorInput input= ep.getEditorInput();
- if (!inputs.contains(input)) {
- inputs.add(input);
- result.add(ep);
- }
- }
- }
- }
- }
- return (IEditorPart[])result.toArray(new IEditorPart[result.size()]);
- }
-
-
- protected boolean visitFile(IResourceProxy proxy) throws CoreException {
- if (! fScope.encloses(proxy))
- return false;
-
- // Exclude to derived resources
- if (proxy.isDerived())
- return false;
-
- if (fLocator.isEmtpy()) {
- fCollector.accept(proxy, "", -1, 0, -1); //$NON-NLS-1$
- updateProgressMonitor();
- return true;
- }
- IFile file= (IFile)proxy.requestResource();
- try {
- BufferedReader reader= null;
- ITextEditor editor= findEditorFor(file);
- if (editor != null) {
- String s= editor.getDocumentProvider().getDocument(editor.getEditorInput()).get();
- reader= new BufferedReader(new StringReader(s));
- } else {
- InputStream stream= file.getContents(false);
- reader= new BufferedReader(new InputStreamReader(stream, file.getCharset()));
- }
- try {
- fLocator.locateMatches(fProgressMonitor, reader, new FileMatchCollector(fCollector, proxy));
- } catch (InvocationTargetException e1) {
- throw ((CoreException)e1.getCause());
- }
- } catch (IOException e) {
- String message= SearchMessages.getFormattedString("TextSearchVisitor.error", file.getFullPath()); //$NON-NLS-1$
- throw new CoreException(new Status(IStatus.ERROR, SearchUI.PLUGIN_ID, Platform.PLUGIN_ERROR, message, e));
- }
- finally {
- updateProgressMonitor();
- }
- return true;
- }
-
- private void updateProgressMonitor() {
- fNumberOfScannedFiles++;
- if (fNumberOfScannedFiles < fNumberOfFilesToScan) {
- if (System.currentTimeMillis() - fLastUpdateTime > 1000) {
- fMessageFormatArgs[0]= new Integer(fNumberOfScannedFiles+1);
- fProgressMonitor.setTaskName(SearchMessages.getFormattedString("TextSearchVisitor.scanning", fMessageFormatArgs)); //$NON-NLS-1$
- fLastUpdateTime= System.currentTimeMillis();
- }
- }
- fProgressMonitor.worked(1);
- if (fProgressMonitor.isCanceled())
- throw new OperationCanceledException(SearchMessages.getString("TextSearchVisitor.canceled")); //$NON-NLS-1$
- }
-
- private ITextEditor findEditorFor(IFile file) {
- int i= 0;
- while (i < fEditors.length) {
- IEditorPart editor= fEditors[i];
- IEditorInput input= editor.getEditorInput();
- if (input instanceof IFileEditorInput && editor instanceof ITextEditor)
- if (((IFileEditorInput)input).getFile().equals(file))
- return (ITextEditor)editor;
- i++;
- }
- return null;
- }
-
- /*
- * @see IResourceProxyVisitor#visit(IResourceProxy)
- */
- public boolean visit(IResourceProxy proxy) {
- fEditors= getEditors();
- return super.visit(proxy);
- }
-}
-
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/core/text/TypedResourceVisitor.java b/org.eclipse.search/search/org/eclipse/search/internal/core/text/TypedResourceVisitor.java
deleted file mode 100644
index 6188516..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/core/text/TypedResourceVisitor.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.core.text;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceProxy;
-import org.eclipse.core.resources.IResourceProxyVisitor;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.MultiStatus;
-
-import org.eclipse.jface.util.Assert;
-
-public class TypedResourceVisitor implements IResourceProxyVisitor {
-
- private MultiStatus fStatus;
-
- TypedResourceVisitor(MultiStatus status) {
- Assert.isNotNull(status);
- fStatus= status;
- }
-
- protected boolean visitFile(IResourceProxy proxy) throws CoreException {
- return true;
- }
-
- protected boolean visitProject(IResourceProxy proxy) throws CoreException {
- return true;
- }
-
- protected boolean visitFolder(IResourceProxy proxy) throws CoreException {
- return true;
- }
-
- protected void addToStatus(CoreException ex) {
- fStatus.add(ex.getStatus());
- }
-
- /*
- * @see org.eclipse.core.resources.IResourceProxyVisitor#visit(org.eclipse.core.resources.IResourceProxy)
- */
- public boolean visit(IResourceProxy proxy) {
- try {
- switch(proxy.getType()) {
- case IResource.FILE:
- return visitFile(proxy);
- case IResource.FOLDER:
- return visitFolder(proxy);
- case IResource.PROJECT:
- return visitProject(proxy);
- default:
- Assert.isTrue(false, "unknown resource type"); //$NON-NLS-1$
- }
- return false;
- } catch (CoreException ex) {
- addToStatus(ex);
- return false;
- }
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/CopyToClipboardAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/CopyToClipboardAction.java
deleted file mode 100644
index 0108d45..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/CopyToClipboardAction.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import java.util.Collections;
-import java.util.Iterator;
-
-import org.eclipse.swt.SWTError;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.TextTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredViewer;
-
-public class CopyToClipboardAction extends Action {
-
- private StructuredViewer fViewer;
-
- public CopyToClipboardAction(StructuredViewer viewer) {
- Assert.isNotNull(viewer);
- fViewer= viewer;
- setText(SearchMessages.getString("CopyToClipboardAction.label")); //$NON-NLS-1$
- setToolTipText(SearchMessages.getString("CopyToClipboardAction.tooltip")); //$NON-NLS-1$
- }
-
- /*
- * Implements method from IAction
- */
- public void run() {
- Shell shell= SearchPlugin.getActiveWorkbenchShell();
- if (shell == null)
- return;
-
- ILabelProvider labelProvider= (ILabelProvider)fViewer.getLabelProvider();
- String lineDelim= System.getProperty("line.separator"); //$NON-NLS-1$
- StringBuffer buf= new StringBuffer();
- Iterator iter= getSelection();
- while (iter.hasNext()) {
- if (buf.length() > 0) {
- buf.append(lineDelim);
- }
- buf.append(labelProvider.getText(iter.next()));
- }
-
- if (buf.length() > 0) {
- Clipboard clipboard= new Clipboard(shell.getDisplay());
- try {
- copyToClipbard(clipboard, buf.toString(), shell);
- } finally {
- clipboard.dispose();
- }
- }
- }
-
- private Iterator getSelection() {
- ISelection s= fViewer.getSelection();
- if (s instanceof IStructuredSelection)
- return ((IStructuredSelection)s).iterator();
- return Collections.EMPTY_LIST.iterator();
- }
-
- private void copyToClipbard(Clipboard clipboard, String str, Shell shell) {
- try {
- clipboard.setContents(new String[] { str }, new Transfer[] { TextTransfer.getInstance() });
- } catch (SWTError ex) {
- if (ex.code != DND.ERROR_CANNOT_SET_CLIPBOARD)
- throw ex;
- String title= SearchMessages.getString("CopyToClipboardAction.error.title"); //$NON-NLS-1$
- String message= SearchMessages.getString("CopyToClipboardAction.error.message"); //$NON-NLS-1$
- if (MessageDialog.openQuestion(shell, title, message))
- copyToClipbard(clipboard, str, shell);
- }
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/GotoMarkerAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/GotoMarkerAction.java
deleted file mode 100644
index 3050af6..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/GotoMarkerAction.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import org.eclipse.jface.action.Action;
-
-class GotoMarkerAction extends Action {
-
- private SearchResultViewer fViewer;
-
- public GotoMarkerAction(SearchResultViewer viewer) {
- super(SearchMessages.getString("SearchResultView.gotoMarker.text")); //$NON-NLS-1$
- SearchPluginImages.setImageDescriptors(this, SearchPluginImages.T_LCL, SearchPluginImages.IMG_LCL_SEARCH_GOTO);
- setToolTipText(SearchMessages.getString("SearchResultView.gotoMarker.tooltip")); //$NON-NLS-1$
- fViewer= viewer;
- }
-
- public void run() {
- fViewer.showResult();
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/ISearchHelpContextIds.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/ISearchHelpContextIds.java
deleted file mode 100644
index 9fde0e9..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/ISearchHelpContextIds.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import org.eclipse.search.ui.SearchUI;
-
-public interface ISearchHelpContextIds {
-
- public static final String PREFIX= SearchUI.PLUGIN_ID + "."; //$NON-NLS-1$
-
- public static final String SEARCH_DIALOG= PREFIX + "search_dialog_context"; //$NON-NLS-1$
-
- public static final String TEXT_SEARCH_PAGE= PREFIX + "text_search_page_context"; //$NON-NLS-1$
- public static final String TYPE_FILTERING_DIALOG= PREFIX + "type_filtering_dialog_context"; //$NON-NLS-1$
-
- public static final String SEARCH_VIEW= PREFIX + "search_view_context"; //$NON-NLS-1$
-
- public static final String SEARCH_PREFERENCE_PAGE= PREFIX + "search_preference_page_context"; //$NON-NLS-1$
-
- public static final String SELECT_ALL_ACTION = PREFIX + "select_all_action_context"; //$NON-NLS-1$
-
- public static final String SEARCH_ACTION = PREFIX + "search_action_context"; //$NON-NLS-1$
-
- public static final String FILE_SEARCH_ACTION= PREFIX + "file_search_action_context"; //$NON-NLS-1$
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/OpenFileSearchPageAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/OpenFileSearchPageAction.java
deleted file mode 100644
index 1c4f4ee..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/OpenFileSearchPageAction.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-
-import org.eclipse.search.ui.SearchUI;
-
-/**
- * Opens the Search Dialog.
- */
-public class OpenFileSearchPageAction implements IWorkbenchWindowActionDelegate {
-
- private static final String TEXT_SEARCH_PAGE_ID= "org.eclipse.search.internal.ui.text.TextSearchPage"; //$NON-NLS-1$
-
- private IWorkbenchWindow fWindow;
-
- public OpenFileSearchPageAction() {
- }
-
- public void init(IWorkbenchWindow window) {
- fWindow= window;
- }
-
- public void run(IAction action) {
- if (fWindow == null || fWindow.getActivePage() == null) {
- SearchPlugin.beep();
- logErrorMessage("Could not open the search dialog - for some reason the window handle was null"); //$NON-NLS-1$
- return;
- }
- SearchUI.openSearchDialog(fWindow, TEXT_SEARCH_PAGE_ID); //$NON-NLS-1$
- }
-
- public void selectionChanged(IAction action, ISelection selection) {
- // do nothing since the action isn't selection dependent.
- }
-
- public void dispose() {
- fWindow= null;
- }
-
- public static void logErrorMessage(String message) {
- IStatus status= new Status(IStatus.ERROR, SearchUI.PLUGIN_ID, IStatus.ERROR, message, null);
- SearchPlugin.log(status);
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/OpenSearchDialogAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/OpenSearchDialogAction.java
deleted file mode 100644
index ce38d4d..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/OpenSearchDialogAction.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-
-/**
- * Opens the Search Dialog.
- */
-public class OpenSearchDialogAction extends Action implements IWorkbenchWindowActionDelegate {
-
- private IWorkbenchWindow fWindow;
- private String fPageId;
-
- public OpenSearchDialogAction() {
- super(SearchMessages.getString("OpenSearchDialogAction.label")); //$NON-NLS-1$
- SearchPluginImages.setImageDescriptors(this, SearchPluginImages.T_TOOL, SearchPluginImages.IMG_TOOL_SEARCH);
- setToolTipText(SearchMessages.getString("OpenSearchDialogAction.tooltip")); //$NON-NLS-1$
- }
-
- public OpenSearchDialogAction(IWorkbenchWindow window, String pageId) {
- this();
- fPageId= pageId;
- fWindow= window;
- }
-
- public void init(IWorkbenchWindow window) {
- fWindow= window;
- }
-
- public void run(IAction action) {
- run();
- }
-
- public void run() {
- if (getWindow().getActivePage() == null) {
- SearchPlugin.beep();
- return;
- }
- SearchDialog dialog= new SearchDialog(
- getWindow().getShell(),
- SearchPlugin.getWorkspace(),
- getSelection(),
- getEditorPart(),
- fPageId);
- dialog.open();
- }
-
- public void selectionChanged(IAction action, ISelection selection) {
- // do nothing since the action isn't selection dependent.
- }
-
- private ISelection getSelection() {
- return getWindow().getSelectionService().getSelection();
- }
-
- private IEditorPart getEditorPart() {
- return getWindow().getActivePage().getActiveEditor();
- }
-
- private IWorkbenchWindow getWindow() {
- if (fWindow == null)
- fWindow= SearchPlugin.getActiveWorkbenchWindow();
- return fWindow;
- }
-
- public void dispose() {
- fWindow= null;
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/RemoveAllResultsAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/RemoveAllResultsAction.java
deleted file mode 100644
index 08ffc5b..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/RemoveAllResultsAction.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import org.eclipse.jface.action.Action;
-
-class RemoveAllResultsAction extends Action {
-
- public RemoveAllResultsAction() {
- super(SearchMessages.getString("SearchResultView.removeAllResults.text")); //$NON-NLS-1$
- SearchPluginImages.setImageDescriptors(this, SearchPluginImages.T_LCL, SearchPluginImages.IMG_LCL_SEARCH_REM_ALL);
- setToolTipText(SearchMessages.getString("SearchResultView.removeAllResults.tooltip")); //$NON-NLS-1$
- }
-
- public void run() {
- SearchManager.getDefault().removeAllResults();
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/RemoveAllSearchesAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/RemoveAllSearchesAction.java
deleted file mode 100644
index 178ccba..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/RemoveAllSearchesAction.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import org.eclipse.jface.action.Action;
-
-class RemoveAllSearchesAction extends Action {
-
- public RemoveAllSearchesAction() {
- super(SearchMessages.getString("SearchResultView.removeAllSearches.text")); //$NON-NLS-1$
- SearchPluginImages.setImageDescriptors(this, SearchPluginImages.T_LCL, SearchPluginImages.IMG_LCL_SEARCH_REM_ALL);
- setToolTipText(SearchMessages.getString("SearchResultView.removeAllSearches.tooltip")); //$NON-NLS-1$
- }
-
- public void run() {
- SearchManager.getDefault().removeAllSearches();
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/RemoveMatchAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/RemoveMatchAction.java
deleted file mode 100644
index 98abd6a..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/RemoveMatchAction.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.runtime.CoreException;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-
-import org.eclipse.search.ui.ISearchResultViewEntry;
-
-import org.eclipse.search.internal.ui.util.ExceptionHandler;
-
-class RemoveMatchAction extends Action {
-
- private ISelectionProvider fSelectionProvider;
-
- public RemoveMatchAction(ISelectionProvider provider) {
- super(SearchMessages.getString("SearchResultView.removeMatch.text")); //$NON-NLS-1$
- setToolTipText(SearchMessages.getString("SearchResultView.removeMatch.tooltip")); //$NON-NLS-1$
- fSelectionProvider= provider;
- }
-
- public void run() {
- IMarker[] markers= getMarkers(fSelectionProvider.getSelection());
- if (markers != null)
- try {
- SearchPlugin.getWorkspace().deleteMarkers(markers);
- } catch (CoreException ex) {
- ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.deleteMarkers.title"), SearchMessages.getString("Search.Error.deleteMarkers.message")); //$NON-NLS-2$ //$NON-NLS-1$
- }
- }
-
- private IMarker[] getMarkers(ISelection s) {
- if (! (s instanceof IStructuredSelection) || s.isEmpty())
- return null;
-
- IStructuredSelection selection= (IStructuredSelection)s;
- int size= selection.size();
- if (size != 1)
- return null;
- if (selection.getFirstElement() instanceof ISearchResultViewEntry) {
- IMarker marker= ((ISearchResultViewEntry)selection.getFirstElement()).getSelectedMarker();
- if (marker != null)
- return new IMarker[] {marker};
- }
- return null;
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/RemovePotentialMatchesAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/RemovePotentialMatchesAction.java
deleted file mode 100644
index 5ff5b30..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/RemovePotentialMatchesAction.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.runtime.CoreException;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-
-import org.eclipse.ui.IWorkbenchSite;
-
-import org.eclipse.search.ui.SearchUI;
-
-import org.eclipse.search.internal.ui.util.ExceptionHandler;
-
-class RemovePotentialMatchesAction extends Action {
-
- private IWorkbenchSite fSite;
-
- public RemovePotentialMatchesAction(IWorkbenchSite site) {
- fSite= site;
-
- if (usePluralLabel()) {
- setText(SearchMessages.getString("RemovePotentialMatchesAction.removePotentialMatches.text")); //$NON-NLS-1$
- setToolTipText(SearchMessages.getString("RemovePotentialMatchesAction.removePotentialMatches.tooltip")); //$NON-NLS-1$
- }
- else {
- setText(SearchMessages.getString("RemovePotentialMatchesAction.removePotentialMatch.text")); //$NON-NLS-1$
- setToolTipText(SearchMessages.getString("RemovePotentialMatchesAction.removePotentialMatch.tooltip")); //$NON-NLS-1$
- }
- }
-
- public void run() {
- IMarker[] markers= getMarkers();
- if (markers != null)
- try {
- SearchPlugin.getWorkspace().deleteMarkers(markers);
- } catch (CoreException ex) {
- ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.deleteMarkers.title"), SearchMessages.getString("Search.Error.deleteMarkers.message")); //$NON-NLS-2$ //$NON-NLS-1$
- }
- else {
- String title= SearchMessages.getString("RemovePotentialMatchesAction.dialog.title"); //$NON-NLS-1$
- String message= SearchMessages.getString("RemovePotentialMatchesAction.dialog.message"); //$NON-NLS-1$
- MessageDialog.openInformation(fSite.getShell(), title, message);
- }
-
- // action only makes sense once
- setEnabled(false);
- }
-
- private IMarker[] getMarkers() {
-
- ISelection s= fSite.getSelectionProvider().getSelection();
- if (! (s instanceof IStructuredSelection))
- return null;
- IStructuredSelection selection= (IStructuredSelection)s;
-
- int size= selection.size();
- if (size <= 0)
- return null;
-
- ArrayList markers= new ArrayList(size * 3);
- Iterator iter= selection.iterator();
- for(int i= 0; iter.hasNext(); i++) {
- SearchResultViewEntry entry= (SearchResultViewEntry)iter.next();
- Iterator entryIter= entry.getMarkers().iterator();
- while (entryIter.hasNext()) {
- IMarker marker= (IMarker)entryIter.next();
- if (marker.getAttribute(SearchUI.POTENTIAL_MATCH, false))
- markers.add(marker);
- }
- }
- return (IMarker[])markers.toArray(new IMarker[markers.size()]);
- }
-
- private boolean usePluralLabel() {
- ISelection s= fSite.getSelectionProvider().getSelection();
-
- if (! (s instanceof IStructuredSelection) || s.isEmpty())
- return false;
-
- IStructuredSelection selection= (IStructuredSelection)s;
- int size= selection.size();
- if (size <= 0)
- return false;
-
- int markerCount= 0;
- Iterator iter= selection.iterator();
- for(int i= 0; iter.hasNext(); i++) {
- SearchResultViewEntry entry= (SearchResultViewEntry)iter.next();
- Iterator entryIter= entry.getMarkers().iterator();
- while (entryIter.hasNext()) {
- IMarker marker= (IMarker)entryIter.next();
- if (marker.getAttribute(SearchUI.POTENTIAL_MATCH, false)) {
- markerCount++;
- }
- if (markerCount > 1)
- return true;
- }
- }
- return false;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/RemoveResultAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/RemoveResultAction.java
deleted file mode 100644
index 4922292..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/RemoveResultAction.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.runtime.CoreException;
-
-import org.eclipse.swt.custom.BusyIndicator;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-
-import org.eclipse.search.ui.ISearchResultViewEntry;
-
-import org.eclipse.search.internal.ui.util.ExceptionHandler;
-
-class RemoveResultAction extends Action {
-
- private ISelectionProvider fSelectionProvider;
-
- public RemoveResultAction(ISelectionProvider provider, boolean stringsDependOnMatchCount) {
- fSelectionProvider= provider;
- if (!stringsDependOnMatchCount || usePluralLabel()) {
- setText(SearchMessages.getString("SearchResultView.removeEntries.text")); //$NON-NLS-1$
- setToolTipText(SearchMessages.getString("SearchResultView.removeEntries.tooltip")); //$NON-NLS-1$
- }
- else {
- setText(SearchMessages.getString("SearchResultView.removeEntry.text")); //$NON-NLS-1$
- setToolTipText(SearchMessages.getString("SearchResultView.removeEntry.tooltip")); //$NON-NLS-1$
- }
- SearchPluginImages.setImageDescriptors(this, SearchPluginImages.T_LCL, SearchPluginImages.IMG_LCL_SEARCH_REM);
- }
-
- public void run() {
- final IMarker[] markers= getMarkers(fSelectionProvider.getSelection());
- if (markers != null) {
- BusyIndicator.showWhile(SearchPlugin.getActiveWorkbenchShell().getDisplay(), new Runnable() {
- public void run() {
- try {
- SearchPlugin.getWorkspace().deleteMarkers(markers);
- } catch (CoreException ex) {
- ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.deleteMarkers.title"), SearchMessages.getString("Search.Error.deleteMarkers.message")); //$NON-NLS-2$ //$NON-NLS-1$
- }
- }
- });
- }
- }
-
- private IMarker[] getMarkers(ISelection s) {
- if (! (s instanceof IStructuredSelection) || s.isEmpty())
- return null;
-
- IStructuredSelection selection= (IStructuredSelection)s;
- int size= selection.size();
- if (size <= 0)
- return null;
- ArrayList markers= new ArrayList(size * 3);
- int markerCount= 0;
- Iterator iter= selection.iterator();
- for(int i= 0; iter.hasNext(); i++) {
- SearchResultViewEntry entry= (SearchResultViewEntry)iter.next();
- markerCount += entry.getMatchCount();
- markers.addAll(entry.getMarkers());
- }
- return (IMarker[])markers.toArray(new IMarker[markerCount]);
- }
-
- private boolean usePluralLabel() {
- ISelection s= fSelectionProvider.getSelection();
- if (s == null || s.isEmpty() || !(s instanceof IStructuredSelection))
- return false;
- IStructuredSelection selection= (IStructuredSelection)s;
-
- if (selection.size() != 1)
- return true;
-
- Object firstElement= selection.getFirstElement();
- if (firstElement instanceof ISearchResultViewEntry)
- return ((ISearchResultViewEntry)firstElement).getMatchCount() > 1;
- else
- return false;
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/ResourceToItemsMapper.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/ResourceToItemsMapper.java
deleted file mode 100644
index 3019eb3..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/ResourceToItemsMapper.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Stack;
-
-import org.eclipse.core.resources.IResource;
-
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Item;
-
-import org.eclipse.jface.viewers.ContentViewer;
-import org.eclipse.jface.viewers.ILabelProvider;
-
-import org.eclipse.search.ui.ISearchResultViewEntry;
-
-/**
- * Helper class for updating error markers and other decorators that work on resources.
- * Items are mapped to their element's underlying resource.
- * Method <code>resourceChanged</code> updates all items that are affected from the changed
- * elements.
- */
-class ResourceToItemsMapper {
-
- private static final int NUMBER_LIST_REUSE= 10;
-
- // map from resource to item
- private HashMap fResourceToItem;
- private Stack fReuseLists;
-
- private ContentViewer fContentViewer;
-
- public ResourceToItemsMapper(ContentViewer viewer) {
- fResourceToItem= new HashMap();
- fReuseLists= new Stack();
-
- fContentViewer= viewer;
- }
-
- /**
- * Must be called from the UI thread.
- */
- public void resourceChanged(IResource changedResource) {
- Object obj= fResourceToItem.get(changedResource);
- if (obj == null) {
- // not mapped
- } else if (obj instanceof Item) {
- updateItem((Item) obj);
- } else { // List of Items
- List list= (List) obj;
- for (int k= 0; k < list.size(); k++) {
- updateItem((Item) list.get(k));
- }
- }
- }
-
- private void updateItem(Item item) {
- if (!item.isDisposed()) { // defensive code
- ILabelProvider lprovider= (ILabelProvider) fContentViewer.getLabelProvider();
-
- Object data= item.getData();
-
- String oldText= item.getText();
- String text= lprovider.getText(data);
- if (text != null && !text.equals(oldText)) {
- item.setText(text);
- }
-
- Image oldImage= item.getImage();
- Image image= lprovider.getImage(data);
- if (image != null && !image.equals(oldImage)) {
- item.setImage(image);
- }
- }
- }
-
- /**
- * Adds a new item to the map.
- * @param element Element to map
- * @param item The item used for the element
- */
- public void addToMap(Object element, Item item) {
- IResource resource= ((ISearchResultViewEntry)element).getResource();
- if (resource != null) {
- Object existingMapping= fResourceToItem.get(resource);
- if (existingMapping == null) {
- fResourceToItem.put(resource, item);
- } else if (existingMapping instanceof Item) {
- if (existingMapping != item) {
- List list= getNewList();
- list.add(existingMapping);
- list.add(item);
- fResourceToItem.put(resource, list);
- }
- } else { // List
- List list= (List) existingMapping;
- if (!list.contains(item)) {
- list.add(item);
- }
- }
- }
- }
-
- /**
- * Removes an element from the map.
- */
- public void removeFromMap(Object element, Item item) {
- IResource resource= ((ISearchResultViewEntry)element).getResource();
- if (resource != null) {
- Object existingMapping= fResourceToItem.get(resource);
- if (existingMapping == null) {
- return;
- } else if (existingMapping instanceof Item) {
- fResourceToItem.remove(resource);
- } else { // List
- List list= (List) existingMapping;
- list.remove(item);
- if (list.isEmpty()) {
- fResourceToItem.remove(list);
- releaseList(list);
- }
- }
- }
- }
-
- private List getNewList() {
- if (!fReuseLists.isEmpty()) {
- return (List) fReuseLists.pop();
- }
- return new ArrayList(2);
- }
-
- private void releaseList(List list) {
- if (fReuseLists.size() < NUMBER_LIST_REUSE) {
- fReuseLists.push(list);
- }
- }
-
- /**
- * Clears the map.
- */
- public void clearMap() {
- fResourceToItem.clear();
- }
-
- /**
- * Clears the map.
- */
- public boolean isEmpty() {
- return fResourceToItem.isEmpty();
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/ScopePart.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/ScopePart.java
deleted file mode 100644
index 187cebc..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/ScopePart.java
+++ /dev/null
@@ -1,424 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.window.Window;
-import org.eclipse.search.internal.ui.util.PixelConverter;
-import org.eclipse.search.internal.ui.util.SWTUtil;
-import org.eclipse.search.ui.ISearchPageContainer;
-import org.eclipse.search.ui.SearchUI;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkingSet;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.IWorkingSetSelectionDialog;
-
-public class ScopePart {
-
- // Settings store
- private static final String DIALOG_SETTINGS_KEY= "SearchDialog.ScopePart"; //$NON-NLS-1$
- private static final String STORE_SCOPE= "scope"; //$NON-NLS-1$
- private static final String STORE_LRU_WORKING_SET_NAME= "lastUsedWorkingSetName"; //$NON-NLS-1$
- private static final String STORE_LRU_WORKING_SET_NAMES= "lastUsedWorkingSetNames"; //$NON-NLS-1$
- private static IDialogSettings fgSettingsStore;
-
- static {
- fgSettingsStore= SearchPlugin.getDefault().getDialogSettings().getSection(DIALOG_SETTINGS_KEY);
- if (fgSettingsStore == null)
- fgSettingsStore= SearchPlugin.getDefault().getDialogSettings().addNewSection(DIALOG_SETTINGS_KEY);
- }
-
- private Group fPart;
-
- // Scope radio buttons
- private Button fUseWorkspace;
- private Button fUseSelection;
- private Button fUseProject;
- private Button fUseWorkingSet;
-
- private int fScope;
- private boolean fCanSearchEnclosingProjects;
- private Text fWorkingSetText;
- private IWorkingSet[] fWorkingSets;
-
- // Reference to its search page container (can be null)
- private ISearchPageContainer fSearchPageContainer;
-
- /**
- * Returns a new scope part with workspace as initial scope.
- * The part is not yet created.
- */
- public ScopePart(ISearchPageContainer searchPageContainer, boolean searchEnclosingProjects) {
- int initialScope= getStoredScope();
- Assert.isLegal(initialScope >= 0 && initialScope <= 3);
- fScope= initialScope;
- fCanSearchEnclosingProjects= searchEnclosingProjects;
- if (!fCanSearchEnclosingProjects && fScope == ISearchPageContainer.SELECTED_PROJECTS_SCOPE)
- fScope= ISearchPageContainer.WORKSPACE_SCOPE;
- fSearchPageContainer= searchPageContainer;
- restoreState();
- }
-
- private static int getStoredScope() {
- int scope;
- try {
- scope= fgSettingsStore.getInt(STORE_SCOPE);
- } catch (NumberFormatException ex) {
- scope= ISearchPageContainer.WORKSPACE_SCOPE;
- }
- if (scope != ISearchPageContainer.WORKING_SET_SCOPE
- && scope != ISearchPageContainer.SELECTION_SCOPE
- && scope != ISearchPageContainer.SELECTED_PROJECTS_SCOPE
- && scope != ISearchPageContainer.WORKSPACE_SCOPE)
- scope= ISearchPageContainer.WORKSPACE_SCOPE;
- return scope;
- }
-
-
- private void restoreState() {
- String[] lruWorkingSetNames= fgSettingsStore.getArray(STORE_LRU_WORKING_SET_NAMES);
- if (lruWorkingSetNames != null) {
- Set existingWorkingSets= new HashSet(lruWorkingSetNames.length);
- for (int i= 0; i < lruWorkingSetNames.length; i++) {
- String name= lruWorkingSetNames[i];
- IWorkingSet workingSet= PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(name);
- if (workingSet != null)
- existingWorkingSets.add(workingSet);
- }
- if (!existingWorkingSets.isEmpty())
- fWorkingSets= (IWorkingSet[]) existingWorkingSets.toArray(new IWorkingSet[existingWorkingSets.size()]);
- } else {
- // Backward compatibility
- String workingSetName= fgSettingsStore.get(STORE_LRU_WORKING_SET_NAME);
- if (workingSetName != null) {
- IWorkingSet workingSet= PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(workingSetName);
- if (workingSet != null) {
- fWorkingSets= new IWorkingSet[] { workingSet };
- saveState();
- }
- }
- }
- }
-
-
- /**
- * Returns the scope selected in this part
- *
- * @return the selected scope
- */
- public int getSelectedScope() {
- return fScope;
- }
-
- /**
- * Sets the selected scope.
- * This method must only be called on a created part.
- *
- * @param scope the scope to be selected in this part
- */
- public void setSelectedScope(int scope) {
- Assert.isLegal(scope >= 0 && scope <= 3);
- Assert.isNotNull(fUseWorkspace);
- Assert.isNotNull(fUseSelection);
- Assert.isNotNull(fUseWorkingSet);
- Assert.isNotNull(fUseProject);
- fScope= scope;
- if (fScope == ISearchPageContainer.SELECTED_PROJECTS_SCOPE) {
- if (!fCanSearchEnclosingProjects) {
- SearchPlugin.log(new Status(IStatus.WARNING, SearchUI.PLUGIN_ID, IStatus.WARNING, "Enclosing projects scope set on search page that does not support it", null)); //$NON-NLS-1$
- fScope= ISearchPageContainer.WORKSPACE_SCOPE;
- } else if (!fUseProject.isEnabled()) {
- fScope= ISearchPageContainer.WORKSPACE_SCOPE;
- }
- } else if (fScope == ISearchPageContainer.SELECTION_SCOPE) {
- if (!fUseSelection.isEnabled()) {
- fScope= ISearchPageContainer.WORKSPACE_SCOPE;
- }
- }
- switch (fScope) {
- case ISearchPageContainer.WORKSPACE_SCOPE :
- fUseWorkspace.setSelection(true);
- fUseSelection.setSelection(false);
- fUseProject.setSelection(false);
- fUseWorkingSet.setSelection(false);
- break;
- case ISearchPageContainer.SELECTION_SCOPE :
- fUseWorkspace.setSelection(false);
- fUseSelection.setSelection(true);
- fUseProject.setSelection(false);
- fUseWorkingSet.setSelection(false);
- break;
- case ISearchPageContainer.WORKING_SET_SCOPE :
- fUseWorkspace.setSelection(false);
- fUseSelection.setSelection(false);
- fUseProject.setSelection(false);
- fUseWorkingSet.setSelection(true);
- break;
- case ISearchPageContainer.SELECTED_PROJECTS_SCOPE :
- fUseWorkspace.setSelection(false);
- fUseSelection.setSelection(false);
- fUseProject.setSelection(true);
- fUseWorkingSet.setSelection(false);
- break;
- }
-
- updateSearchPageContainerActionPerformedEnablement();
- fgSettingsStore.put(STORE_SCOPE, fScope);
-
- }
-
- private void updateSearchPageContainerActionPerformedEnablement() {
- boolean newState= fScope != ISearchPageContainer.WORKING_SET_SCOPE || fWorkingSets != null;
- if (fSearchPageContainer instanceof SearchDialog)
- ((SearchDialog) fSearchPageContainer).setPerformActionEnabledFromScopePart(newState);
- else if (fSearchPageContainer != null)
- fSearchPageContainer.setPerformActionEnabled(newState);
- }
-
- /**
- * Returns the selected working set of this part.
- *
- * @return the selected working set or null
- * - if the scope is not WORKING_SET_SCOPE
- * - if there is no working set selected
- */
- public IWorkingSet[] getSelectedWorkingSets() {
- if (getSelectedScope() == ISearchPageContainer.WORKING_SET_SCOPE)
- return fWorkingSets;
- else
- return null;
- }
-
- /**
- * Sets the selected working set for this part.
- * This method must only be called on a created part.
- *
- * @param workingSet the working set to be selected
- */
- public void setSelectedWorkingSets(IWorkingSet[] workingSets) {
- Assert.isNotNull(workingSets);
- setSelectedScope(ISearchPageContainer.WORKING_SET_SCOPE);
- fWorkingSets= null;
- Set existingWorkingSets= new HashSet(workingSets.length);
- for (int i= 0; i < workingSets.length; i++) {
- String name= workingSets[i].getName();
- IWorkingSet workingSet= PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(name);
- if (workingSet != null)
- existingWorkingSets.add(workingSet);
- }
- if (!existingWorkingSets.isEmpty())
- fWorkingSets= (IWorkingSet[]) existingWorkingSets.toArray(new IWorkingSet[existingWorkingSets.size()]);
-
- saveState();
-
- if (fWorkingSetText != null)
- fWorkingSetText.setText(toString(fWorkingSets));
- }
-
- /**
- * Saves the last recently used working sets,
- * if any.
- */
- private void saveState() {
- if (fWorkingSets != null && fWorkingSets.length > 0) {
- String[] existingWorkingSetNames= new String[fWorkingSets.length];
- for (int i= 0; i < existingWorkingSetNames.length; i++)
- existingWorkingSetNames[i]= fWorkingSets[i].getName();
- fgSettingsStore.put(STORE_LRU_WORKING_SET_NAMES, existingWorkingSetNames);
- }
- }
-
- /**
- * Creates this scope part.
- *
- * @param parent a widget which will be the parent of the new instance (cannot be null)
- */
- public Composite createPart(Composite parent) {
- fPart= new Group(parent, SWT.NONE);
- fPart.setText(SearchMessages.getString("ScopePart.group.text")); //$NON-NLS-1$
-
- GridLayout layout= new GridLayout();
- layout.numColumns= 4;
- fPart.setLayout(layout);
- fPart.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- fUseWorkspace= new Button(fPart, SWT.RADIO);
- fUseWorkspace.setData(new Integer(ISearchPageContainer.WORKSPACE_SCOPE));
- fUseWorkspace.setText(SearchMessages.getString("ScopePart.workspaceScope.text")); //$NON-NLS-1$
-
- fUseSelection= new Button(fPart, SWT.RADIO);
- fUseSelection.setData(new Integer(ISearchPageContainer.SELECTION_SCOPE));
- fUseSelection.setText(SearchMessages.getString("ScopePart.selectedResourcesScope.text")); //$NON-NLS-1$
- ISelection selection= fSearchPageContainer.getSelection();
- fUseSelection.setEnabled((selection instanceof IStructuredSelection &&
- !fSearchPageContainer.getSelection().isEmpty()));
-
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- gd.horizontalIndent= 8;
- fUseSelection.setLayoutData(gd);
-
- fUseProject= new Button(fPart, SWT.RADIO);
- fUseProject.setData(new Integer(ISearchPageContainer.SELECTED_PROJECTS_SCOPE));
- fUseProject.setText(SearchMessages.getString("ScopePart.enclosingProjectsScope.text")); //$NON-NLS-1$
- fUseProject.setEnabled((selection instanceof IStructuredSelection &&
- !fSearchPageContainer.getSelection().isEmpty()) ||
- hasFocusEditor());
-
- gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- gd.horizontalSpan= 2;
- gd.horizontalIndent= 8;
- fUseProject.setLayoutData(gd);
- if (!fCanSearchEnclosingProjects)
- fUseProject.setVisible(false);
-
- fUseWorkingSet= new Button(fPart, SWT.RADIO);
- fUseWorkingSet.setData(new Integer(ISearchPageContainer.WORKING_SET_SCOPE));
- fUseWorkingSet.setText(SearchMessages.getString("ScopePart.workingSetScope.text")); //$NON-NLS-1$
- fWorkingSetText= new Text(fPart, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY);
- Button chooseWorkingSet= new Button(fPart, SWT.PUSH);
- chooseWorkingSet.setLayoutData(new GridData());
- chooseWorkingSet.setText(SearchMessages.getString("ScopePart.workingSetChooseButton.text")); //$NON-NLS-1$
- SWTUtil.setButtonDimensionHint(chooseWorkingSet);
- chooseWorkingSet.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- if (handleChooseWorkingSet()) {
- setSelectedScope(ISearchPageContainer.WORKING_SET_SCOPE);
- }
- }
- });
- gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalIndent= 8;
- gd.horizontalSpan= 2;
- gd.widthHint= new PixelConverter(fWorkingSetText).convertWidthInCharsToPixels(30);
- fWorkingSetText.setLayoutData(gd);
-
- // Add scope change listeners
- SelectionAdapter scopeChangedLister= new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- handleScopeChanged(e);
- }
- };
- fUseWorkspace.addSelectionListener(scopeChangedLister);
- fUseSelection.addSelectionListener(scopeChangedLister);
- fUseProject.addSelectionListener(scopeChangedLister);
- fUseWorkingSet.addSelectionListener(scopeChangedLister);
-
- // Set initial scope
- setSelectedScope(fScope);
-
- // Set initial working set
- if (fWorkingSets != null)
- fWorkingSetText.setText(toString(fWorkingSets));
-
- return fPart;
- }
-
- /**
- * @return Whether an editor has the focus
- */
- private boolean hasFocusEditor() {
- IWorkbenchPage activePage= SearchPlugin.getActivePage();
- if (activePage == null)
- return false;
- if (activePage.getActivePart() instanceof IEditorPart)
- return true;
- return false;
- }
-
- private void handleScopeChanged(SelectionEvent e) {
- Object source= e.getSource();
- if (source instanceof Button) {
- Button button= (Button) source;
- if (button.getSelection())
- setSelectedScope(((Integer) button.getData()).intValue());
- }
- }
-
- private boolean handleChooseWorkingSet() {
- IWorkingSetSelectionDialog dialog=
- PlatformUI.getWorkbench().getWorkingSetManager().createWorkingSetSelectionDialog(
- fUseSelection.getShell(),
- true);
-
- if (fWorkingSets != null)
- dialog.setSelection(fWorkingSets);
- if (dialog.open() == Window.OK) {
- Object[] result= dialog.getSelection();
- if (result.length > 0) {
- setSelectedWorkingSets((IWorkingSet[]) result);
- return true;
- }
- fWorkingSetText.setText(""); //$NON-NLS-1$
- fWorkingSets= null;
- if (fScope == ISearchPageContainer.WORKING_SET_SCOPE)
- setSelectedScope(ISearchPageContainer.WORKSPACE_SCOPE);
- return false;
- } else {
- if (fWorkingSets != null) {
- // test if selected working set has been removed
- int i= 0;
- while (i < fWorkingSets.length) {
- if (PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(fWorkingSets[i].getName())
- == null)
- break;
- i++;
- }
- if (i < fWorkingSets.length) {
- fWorkingSetText.setText(""); //$NON-NLS-1$
- fWorkingSets= null;
- updateSearchPageContainerActionPerformedEnablement();
- }
- }
- }
- return false;
- }
-
- void setVisible(boolean state) {
- fPart.setVisible(state);
- }
-
- public static String toString(IWorkingSet[] workingSets) {
- String result= ""; //$NON-NLS-1$
- if (workingSets != null && workingSets.length > 0) {
- Arrays.sort(workingSets, new WorkingSetComparator());
- boolean firstFound= false;
- for (int i= 0; i < workingSets.length; i++) {
- String workingSetName= workingSets[i].getName();
- if (firstFound)
- result= SearchMessages.getFormattedString("ScopePart.workingSetConcatenation", new String[] { result, workingSetName }); //$NON-NLS-1$
- else {
- result= workingSetName;
- firstFound= true;
- }
- }
- }
- return result;
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/Search.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/Search.java
deleted file mode 100644
index 9a78101..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/Search.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IWorkspaceDescription;
-
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ISelection;
-
-import org.eclipse.search.ui.IActionGroupFactory;
-import org.eclipse.search.ui.IContextMenuContributor;
-import org.eclipse.search.ui.IGroupByKeyComputer;
-import org.eclipse.search.ui.ISearchResultViewEntry;
-
-import org.eclipse.search.internal.ui.util.ExceptionHandler;
-
-public class Search extends Object {
- private String fPageId;
- private String fSingularLabel;
- private String fPluralLabelPattern;
- private ImageDescriptor fImageDescriptor;
- private ILabelProvider fLabelProvider;
- private ISelection fSelection;
- private ArrayList fResults;
- private IAction fGotoMarkerAction;
- private IContextMenuContributor fContextMenuContributor;
- private IActionGroupFactory fActionGroupFactory;
- private IGroupByKeyComputer fGroupByKeyComputer;
- private IRunnableWithProgress fOperation;
-
-
- public Search(String pageId, String singularLabel, String pluralLabelPattern, ILabelProvider labelProvider, ImageDescriptor imageDescriptor, IAction gotoMarkerAction, IActionGroupFactory groupFactory, IGroupByKeyComputer groupByKeyComputer, IRunnableWithProgress operation) {
- fPageId= pageId;
- fSingularLabel= singularLabel;
- fPluralLabelPattern= pluralLabelPattern;
- fImageDescriptor= imageDescriptor;
- fLabelProvider= labelProvider;
- fGotoMarkerAction= gotoMarkerAction;
- fActionGroupFactory= groupFactory;
- fGroupByKeyComputer= groupByKeyComputer;
- fOperation= operation;
-
- if (fPluralLabelPattern == null)
- fPluralLabelPattern= ""; //$NON-NLS-1$
- }
-
- public Search(String pageId, String singularLabel, String pluralLabelPattern, ILabelProvider labelProvider, ImageDescriptor imageDescriptor, IAction gotoMarkerAction, IContextMenuContributor contextMenuContributor, IGroupByKeyComputer groupByKeyComputer, IRunnableWithProgress operation) {
- fPageId= pageId;
- fSingularLabel= singularLabel;
- fPluralLabelPattern= pluralLabelPattern;
- fImageDescriptor= imageDescriptor;
- fLabelProvider= labelProvider;
- fGotoMarkerAction= gotoMarkerAction;
- fContextMenuContributor= contextMenuContributor;
- fGroupByKeyComputer= groupByKeyComputer;
- fOperation= operation;
-
- if (fPluralLabelPattern == null)
- fPluralLabelPattern= ""; //$NON-NLS-1$
- }
-
- /**
- * Returns the full description of the search.
- * The description set by the client where
- * {0} will be replaced by the match count.
- */
- String getFullDescription() {
- if (fSingularLabel != null && getItemCount() == 1)
- return fSingularLabel;
-
- // try to replace "{0}" with the match count
- int i= fPluralLabelPattern.lastIndexOf("{0}"); //$NON-NLS-1$
- if (i < 0)
- return fPluralLabelPattern;
- else
- return fPluralLabelPattern.substring(0, i) + getItemCount()+ fPluralLabelPattern.substring(Math.min(i + 3, fPluralLabelPattern.length()));
- }
-
- /**
- * Returns a short description of the search.
- * Cuts off after 30 characters and adds ...
- * The description set by the client where
- * {0} will be replaced by the match count.
- */
- String getShortDescription() {
- String text= getFullDescription();
- int separatorPos= text.indexOf(" - "); //$NON-NLS-1$
- if (separatorPos < 1)
- return text.substring(0, Math.min(50, text.length())) + "..."; // use first 50 characters //$NON-NLS-1$
- if (separatorPos < 30)
- return text; // don't cut
- if (text.charAt(0) == '"') //$NON-NLS-1$
- return text.substring(0, Math.min(30, text.length())) + "...\" - " + text.substring(Math.min(separatorPos + 3, text.length())); //$NON-NLS-1$
- else
- return text.substring(0, Math.min(30, text.length())) + "... - " + text.substring(Math.min(separatorPos + 3, text.length())); //$NON-NLS-1$
- }
- /** Image used when search is displayed in a list */
- ImageDescriptor getImageDescriptor() {
- return fImageDescriptor;
- }
-
- int getItemCount() {
- int count= 0;
- Iterator iter= getResults().iterator();
- while (iter.hasNext())
- count += ((ISearchResultViewEntry)iter.next()).getMatchCount();
- return count;
- }
-
- List getResults() {
- if (fResults == null)
- return new ArrayList();
- return fResults;
- }
-
- ILabelProvider getLabelProvider() {
- return fLabelProvider;
- }
-
- void searchAgain() {
- if (fOperation == null)
- return;
- Shell shell= SearchPlugin.getActiveWorkbenchShell();
- IWorkspaceDescription workspaceDesc= SearchPlugin.getWorkspace().getDescription();
- boolean isAutoBuilding= workspaceDesc.isAutoBuilding();
- if (isAutoBuilding)
- // disable auto-build during search operation
- SearchPlugin.setAutoBuilding(false);
- try {
- new ProgressMonitorDialog(shell).run(true, true, fOperation);
- } catch (InvocationTargetException ex) {
- ExceptionHandler.handle(ex, shell, SearchMessages.getString("Search.Error.search.title"), SearchMessages.getString("Search.Error.search.message")); //$NON-NLS-2$ //$NON-NLS-1$
- } catch(InterruptedException e) {
- } finally {
- if (isAutoBuilding)
- // enable auto-building again
- SearchPlugin.setAutoBuilding(true);
- }
- }
-
- boolean isSameSearch(Search search) {
- return search != null && search.getOperation() == fOperation && fOperation != null;
- }
-
- void backupMarkers() {
- Iterator iter= getResults().iterator();
- while (iter.hasNext()) {
- ((SearchResultViewEntry)iter.next()).backupMarkers();
- }
- }
-
- String getPageId() {
- return fPageId;
- }
-
- IGroupByKeyComputer getGroupByKeyComputer() {
- return fGroupByKeyComputer;
- }
-
- public IRunnableWithProgress getOperation() {
- return fOperation;
- }
-
- IAction getGotoMarkerAction() {
- return fGotoMarkerAction;
- }
-
- IContextMenuContributor getContextMenuContributor() {
- return fContextMenuContributor;
- }
-
- IActionGroupFactory getActionGroupFactory() {
- return fActionGroupFactory;
- }
-
- public void removeResults() {
- fResults= null;
- }
-
- void setResults(ArrayList results) {
- Assert.isNotNull(results);
- fResults= results;
- }
-
- ISelection getSelection() {
- return fSelection;
- }
-
- void setSelection(ISelection selection) {
- fSelection= selection;
- }
-}
-
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchAgainAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchAgainAction.java
deleted file mode 100644
index 304d838..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchAgainAction.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import org.eclipse.jface.action.Action;
-
-class SearchAgainAction extends Action {
-
- public SearchAgainAction() {
- super(SearchMessages.getString("SearchResultView.searchAgain.text")); //$NON-NLS-1$
- setToolTipText(SearchMessages.getString("SearchResultView.searchAgain.tooltip")); //$NON-NLS-1$
- }
-
- public void run() {
- Search selected= SearchManager.getDefault().getCurrentSearch();
- if (selected != null)
- selected.searchAgain();
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchDialog.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchDialog.java
deleted file mode 100644
index eae98ba..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchDialog.java
+++ /dev/null
@@ -1,576 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IWorkspace;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Layout;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.TabFolder;
-import org.eclipse.swt.widgets.TabItem;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.CheckboxTableViewer;
-import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.window.Window;
-
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.IWorkingSet;
-import org.eclipse.ui.dialogs.ListSelectionDialog;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-import org.eclipse.search.ui.IReplacePage;
-import org.eclipse.search.ui.ISearchPage;
-import org.eclipse.search.ui.ISearchPageContainer;
-import org.eclipse.search.ui.ISearchPageScoreComputer;
-
-import org.eclipse.search.internal.ui.util.ExtendedDialogWindow;
-import org.eclipse.search.internal.ui.util.ListContentProvider;
-import org.eclipse.search.internal.ui.util.SWTUtil;
-
-class SearchDialog extends ExtendedDialogWindow implements ISearchPageContainer {
-
- private class TabFolderLayout extends Layout {
- protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) {
- if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT)
- return new Point(wHint, hHint);
-
- int x= 0;
- int y= 0;
- Control[] children= composite.getChildren();
- for (int i= 0; i < children.length; i++) {
- Point size= children[i].computeSize(SWT.DEFAULT, SWT.DEFAULT, flushCache);
- x= Math.max(x, size.x);
- y= Math.max(y, size.y);
- }
-
- Point minSize= getMinSize();
- x= Math.max(x, minSize.x);
- y= Math.max(y, minSize.y);
-
- if (wHint != SWT.DEFAULT)
- x= wHint;
- if (hHint != SWT.DEFAULT)
- y= hHint;
- return new Point(x, y);
- }
- protected void layout(Composite composite, boolean flushCache) {
- Rectangle rect= composite.getClientArea();
-
- Control[] children= composite.getChildren();
- for (int i= 0; i < children.length; i++) {
- children[i].setBounds(rect);
- }
- }
- }
-
-
- private static final int SEARCH_ID= IDialogConstants.CLIENT_ID+1;
- private static final int REPLACE_ID= SEARCH_ID+1;
-
- private IWorkspace fWorkspace;
- private ISearchPage fCurrentPage;
- private String fInitialPageId;
- private int fCurrentIndex;
- private ISelection fSelection;
- private IEditorPart fEditorPart;
- private List fDescriptors;
- private Point fMinSize;
- private ScopePart[] fScopeParts;
- private boolean fPageStateIgnoringScopePart;
- private Button fCustomizeButton;
- private Button fReplaceButton;
-
- public SearchDialog(Shell shell, IWorkspace workspace, ISelection selection, IEditorPart editor, String pageId) {
- super(shell);
- Assert.isNotNull(workspace);
- fWorkspace= workspace;
- fSelection= selection;
- fEditorPart= editor;
- fDescriptors= SearchPlugin.getDefault().getEnabledSearchPageDescriptors(pageId);
- fInitialPageId= pageId;
- }
-
- /* (non-Javadoc)
- * Method declared in Window.
- */
- protected void configureShell(Shell shell) {
- super.configureShell(shell);
- shell.setText(SearchMessages.getString("SearchDialog.title")); //$NON-NLS-1$
- shell.setImage(SearchPluginImages.get(SearchPluginImages.IMG_TOOL_SEARCH));
- WorkbenchHelp.setHelp(shell, ISearchHelpContextIds.SEARCH_DIALOG);
- }
-
- public IWorkspace getWorkspace() {
- return fWorkspace;
- }
-
- public ISelection getSelection() {
- return fSelection;
- }
-
- public IEditorPart getEditorPart() {
- return fEditorPart;
- }
-
- //---- Page Handling -------------------------------------------------------
-
- /*
- * Overrides method from Window
- */
- public void create() {
- super.create();
- if (fCurrentPage != null)
- fCurrentPage.setVisible(true);
- }
-
- private void handleCustomizePressed() {
- List input= SearchPlugin.getDefault().getSearchPageDescriptors();
- final ArrayList createdImages= new ArrayList(input.size());
- ILabelProvider labelProvider= new LabelProvider() {
- public String getText(Object element) {
- if (element instanceof SearchPageDescriptor) {
- String label= ((SearchPageDescriptor)element).getLabel();
- int i= label.indexOf('&');
- while (i >= 0) {
- if (i < label.length())
- label= label.substring(0, i) + label.substring(i+1);
- else
- label.substring(0, i);
- i= label.indexOf('&');
- }
- return label;
- } else
- return null;
- }
- public Image getImage(Object element) {
- if (element instanceof SearchPageDescriptor) {
- ImageDescriptor imageDesc= ((SearchPageDescriptor)element).getImage();
- if (imageDesc == null)
- return null;
- Image image= imageDesc.createImage();
- if (image != null)
- createdImages.add(image);
- return image;
- } else
- return null;
- }
- };
-
- String message= SearchMessages.getString("SearchPageSelectionDialog.message"); //$NON-NLS-1$
-
- ListSelectionDialog dialog= new ListSelectionDialog(getShell(), input, new ListContentProvider(), labelProvider, message) {
- public void create() {
- super.create();
- final CheckboxTableViewer viewer= getViewer();
- final Button okButton= this.getOkButton();
- viewer.addCheckStateListener(new ICheckStateListener() {
- public void checkStateChanged(CheckStateChangedEvent event) {
- okButton.setEnabled(viewer.getCheckedElements().length > 0);
- }
- });
- SelectionListener listener = new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- okButton.setEnabled(viewer.getCheckedElements().length > 0);
- }
- };
- this.getButton(IDialogConstants.SELECT_ALL_ID).addSelectionListener(listener);
- this.getButton(IDialogConstants.DESELECT_ALL_ID).addSelectionListener(listener);
- }
- };
- dialog.setTitle(SearchMessages.getString("SearchPageSelectionDialog.title")); //$NON-NLS-1$
- dialog.setInitialSelections(SearchPlugin.getDefault().getEnabledSearchPageDescriptors(fInitialPageId).toArray());
- if (dialog.open() == Window.OK) {
- SearchPageDescriptor.setEnabled(dialog.getResult());
- Display display= getShell().getDisplay();
- close();
- if (display != null && !display.isDisposed()) {
- display.asyncExec(
- new Runnable() {
- public void run() {
- new OpenSearchDialogAction().run();
- }
- });
- }
- }
- destroyImages(createdImages);
- }
-
- private void destroyImages(List images) {
- Iterator iter= images.iterator();
- while (iter.hasNext()) {
- Image image= (Image)iter.next();
- if (image != null && !image.isDisposed())
- image.dispose();
- }
- }
-
- protected Control createPageArea(Composite parent) {
- int numPages= fDescriptors.size();
- fScopeParts= new ScopePart[numPages];
-
- if (numPages == 0) {
- Label label= new Label(parent, SWT.CENTER | SWT.WRAP);
- label.setText(SearchMessages.getString("SearchDialog.noSearchExtension")); //$NON-NLS-1$
- return label;
- }
-
- fCurrentIndex= getPreferredPageIndex();
-
- BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {
- public void run() {
- fCurrentPage= getDescriptorAt(fCurrentIndex).createObject();
- }
- });
-
- fCurrentPage.setContainer(this);
-
- if (numPages == 1)
- return getControl(fCurrentPage, parent, 0);
- else {
- Composite border= new Composite(parent, SWT.NONE);
- FillLayout layout= new FillLayout();
- layout.marginWidth= 7;
- layout.marginHeight= 7;
- border.setLayout(layout);
-
- TabFolder folder= new TabFolder(border, SWT.NONE);
- folder.setLayout(new TabFolderLayout());
-
- for (int i= 0; i < numPages; i++) {
- SearchPageDescriptor descriptor= (SearchPageDescriptor)fDescriptors.get(i);
-
- final TabItem item= new TabItem(folder, SWT.NONE);
- item.setText(descriptor.getLabel());
- item.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- item.setData(null);
- if (item.getImage() != null)
- item.getImage().dispose();
- }
- });
- ImageDescriptor imageDesc= descriptor.getImage();
- if (imageDesc != null)
- item.setImage(imageDesc.createImage());
- item.setData(descriptor);
- if (i == fCurrentIndex) {
- item.setControl(getControl(fCurrentPage, folder, i));
- item.setData(fCurrentPage);
- }
- }
-
- folder.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
- turnToPage(event);
- }
- });
-
- folder.setSelection(fCurrentIndex);
-
- return border;
- }
- }
-
- protected void createButtonsForButtonBar(Composite parent) {
- fReplaceButton= createActionButton(parent, REPLACE_ID, SearchMessages.getString("SearchDialog.replaceAction"), true); //$NON-NLS-1$
- fReplaceButton.setVisible(fCurrentPage instanceof IReplacePage);
- createActionButton(parent, SEARCH_ID, SearchMessages.getString("SearchDialog.searchAction"), true); //$NON-NLS-1$
- super.createButtonsForButtonBar(parent);
- }
-
- protected Control createButtonBar(Composite parent) {
- Composite composite= new Composite(parent, SWT.NULL);
- GridLayout layout= new GridLayout();
- layout.numColumns= 3;
- layout.marginHeight= 0;
- layout.marginWidth= 0;
-
- composite.setLayout(layout);
- composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- fCustomizeButton= new Button(composite, SWT.NONE);
- fCustomizeButton.setText(SearchMessages.getString("SearchDialog.customize")); //$NON-NLS-1$
- GridData gd= new GridData();
- gd.horizontalIndent= 2 * new GridLayout().marginWidth;
- fCustomizeButton.setLayoutData(gd);
- SWTUtil.setButtonDimensionHint(fCustomizeButton);
- fCustomizeButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- handleCustomizePressed();
- }
- });
-
- Label filler= new Label(composite, SWT.NONE);
- filler.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
-
- Control result= super.createButtonBar(composite);
- getButton(SEARCH_ID).setEnabled(fDescriptors.size() > 0);
- applyDialogFont(composite);
- return result;
- }
-
- protected boolean performAction(int actionID) {
- if (fCurrentPage == null)
- return true;
-
- boolean isAutoBuilding= SearchPlugin.getWorkspace().isAutoBuilding();
- if (isAutoBuilding)
- // disable auto-build during search operation
- SearchPlugin.setAutoBuilding(false);
- try {
- fCustomizeButton.setEnabled(false);
- if (actionID == SEARCH_ID)
- return fCurrentPage.performAction();
- else
- // safe cast, replace button is only visible when the curren page is
- // a replace page.
- return ((IReplacePage)fCurrentPage).performReplace();
- } finally {
- fCustomizeButton.setEnabled(true);
- if (isAutoBuilding)
- // enable auto-building again
- SearchPlugin.setAutoBuilding(true);
- }
- }
-
- private SearchPageDescriptor getDescriptorAt(int index) {
- return (SearchPageDescriptor)fDescriptors.get(index);
- }
-
- private Point getMinSize() {
- if (fMinSize != null)
- return fMinSize;
-
- int x= 0;
- int y= 0;
- int length= fDescriptors.size();
- for (int i= 0; i < length; i++) {
- Point size= getDescriptorAt(i).getPreferredSize();
- if (size.x != SWT.DEFAULT)
- x= Math.max(x, size.x);
- if (size.y != SWT.DEFAULT)
- y= Math.max(y, size.y);
- }
-
- fMinSize= new Point(x, y);
- return fMinSize;
- }
-
- private void turnToPage(SelectionEvent event) {
- final TabItem item= (TabItem)event.item;
- TabFolder folder= item.getParent();
- Control oldControl= folder.getItem(fCurrentIndex).getControl();
- Point oldSize= oldControl.getSize();
- if (item.getControl() == null) {
- final SearchPageDescriptor descriptor= (SearchPageDescriptor)item.getData();
-
- BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {
- public void run() {
- item.setData(descriptor.createObject());
- }
- });
-
- ISearchPage page= (ISearchPage)item.getData();
- page.setContainer(this);
-
- Control newControl= getControl(page, (Composite)event.widget, item.getParent().getSelectionIndex());
- item.setControl(newControl);
- }
- if (item.getData() instanceof ISearchPage) {
- fCurrentPage= (ISearchPage)item.getData();
- fReplaceButton.setVisible(fCurrentPage instanceof IReplacePage);
- fCurrentIndex= item.getParent().getSelectionIndex();
- fCurrentPage.setVisible(true);
- }
- Control newControl= item.getControl();
- resizeDialogIfNeeded(oldSize, newControl.computeSize(SWT.DEFAULT, SWT.DEFAULT, true));
- }
-
- private int getPreferredPageIndex() {
- Object element= null;
- if (fSelection instanceof IStructuredSelection)
- element= ((IStructuredSelection)fSelection).getFirstElement();
- if (element == null && fEditorPart != null) {
- element= fEditorPart.getEditorInput();
- if (element instanceof IFileEditorInput)
- element= ((IFileEditorInput)element).getFile();
- }
- int result= 0;
- int level= ISearchPageScoreComputer.LOWEST;
- int size= fDescriptors.size();
- for (int i= 0; i < size; i++) {
- SearchPageDescriptor descriptor= (SearchPageDescriptor)fDescriptors.get(i);
- if (fInitialPageId != null && fInitialPageId.equals(descriptor.getId()))
- return i;
-
- int newLevel= descriptor.computeScore(element);
- if ( newLevel > level) {
- level= newLevel;
- result= i;
- }
- }
- return result;
- }
-
- /*
- * Implements method from ISearchPageContainer
- */
- public IRunnableContext getRunnableContext() {
- return this;
- }
-
- /*
- * Implements method from ISearchPageContainer
- */
- public int getSelectedScope() {
- if (fScopeParts[fCurrentIndex] == null)
- // safe code - should not happen
- return ISearchPageContainer.WORKSPACE_SCOPE;
- else
- return fScopeParts[fCurrentIndex].getSelectedScope();
- }
-
- /*
- * Implements method from ISearchPageContainer
- */
- public IWorkingSet[] getSelectedWorkingSets() {
- if (fScopeParts[fCurrentIndex] == null)
- // safe code - should not happen
- return null;
- else
- return fScopeParts[fCurrentIndex].getSelectedWorkingSets();
- }
-
- /*
- * Implements method from ISearchPageContainer
- */
- public void setSelectedScope(int scope) {
- if (fScopeParts[fCurrentIndex] != null)
- fScopeParts[fCurrentIndex].setSelectedScope(scope);
- }
-
- /*
- * Implements method from ISearchPageContainer
- */
- public boolean hasValidScope() {
- return getSelectedScope() != WORKING_SET_SCOPE || getSelectedWorkingSets() != null;
- }
-
- /*
- * Implements method from ISearchPageContainer
- */
- public void setSelectedWorkingSets(IWorkingSet[] workingSets) {
- if (fScopeParts[fCurrentIndex] != null)
- fScopeParts[fCurrentIndex].setSelectedWorkingSets(workingSets);
- }
-
- /*
- * Overrides method from ExtendedDialogWindow
- */
- public void setPerformActionEnabled(boolean state) {
- super.setPerformActionEnabled(state);
- fPageStateIgnoringScopePart= state;
- setPerformActionEnabledFromScopePart(hasValidScope());
- }
-
- /**
- * Set the enable state of the perform action button.
- * <p>
- * Note: This is a special method to be called only from the ScopePart
- * </p>
- */
- public void setPerformActionEnabledFromScopePart(boolean state) {
- if (fPageStateIgnoringScopePart)
- super.setPerformActionEnabled(state);
- }
-
- private Control getControl(ISearchPage page, Composite parent, int index) {
- Control control= page.getControl();
- if (control != null)
- return control;
- // Page wrapper
- Composite pageWrapper= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.marginWidth= 0;
- layout.marginHeight= 0;
- pageWrapper.setLayout(layout);
-
- Dialog.applyDialogFont(pageWrapper);
- // The page itself
- page.createControl(pageWrapper);
-
- // Search scope
- SearchPageDescriptor descriptor= getDescriptorAt(index);
- boolean showScope= descriptor.showScopeSection();
- if (showScope) {
- Composite c= new Composite(pageWrapper, SWT.NONE);
- layout= new GridLayout();
- c.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- c.setLayout(layout);
- fScopeParts[index]= new ScopePart(this, descriptor.canSearchInProjects());
- Control part= fScopeParts[index].createPart(c);
- applyDialogFont(part);
- fScopeParts[index].setVisible(true);
- }
- return pageWrapper;
- }
-
- private void resizeDialogIfNeeded(Point oldSize, Point newSize) {
- if (oldSize == null || newSize == null)
- return;
- Shell shell= getShell();
- Point shellSize= shell.getSize();
- if (mustResize(oldSize, newSize)) {
- if (newSize.x > oldSize.x)
- shellSize.x+= (newSize.x-oldSize.x);
- if (newSize.y > oldSize.y)
- shellSize.y+= (newSize.y-oldSize.y);
- shell.setSize(shellSize);
- shell.layout(true);
- }
- }
-
- private boolean mustResize(Point currentSize, Point newSize) {
- return currentSize.x < newSize.x || currentSize.y < newSize.y;
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchDropDownAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchDropDownAction.java
deleted file mode 100644
index bb6db83..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchDropDownAction.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import java.util.Iterator;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IMenuCreator;
-
-class SearchDropDownAction extends Action implements IMenuCreator {
-
-
- public static final int RESULTS_IN_DROP_DOWN= 10;
-
- private Menu fMenu;
-
- public SearchDropDownAction() {
- setText(SearchMessages.getString("SearchResultView.previousSearches.text")); //$NON-NLS-1$
- setToolTipText(SearchMessages.getString("SearchResultView.previousSearches.tooltip")); //$NON-NLS-1$
- SearchPluginImages.setImageDescriptors(this, SearchPluginImages.T_LCL, SearchPluginImages.IMG_LCL_SEARCH_HISTORY);
- setMenuCreator(this);
- }
-
- public void dispose() {
- if (fMenu != null) {
- fMenu.dispose();
- fMenu= null;
- }
- }
-
- public Menu getMenu(Menu parent) {
- return null;
- }
-
- public Menu getMenu(Control parent) {
- if (fMenu != null)
- fMenu.dispose();
-
- fMenu= new Menu(parent);
- boolean checkedOne= false;
- Iterator iter= SearchManager.getDefault().getPreviousSearches().iterator();
- Search selected= SearchManager.getDefault().getCurrentSearch();
- int i= 0;
- while (iter.hasNext() && i++ < RESULTS_IN_DROP_DOWN) {
- Search search= (Search)iter.next();
- ShowSearchAction action= new ShowSearchAction(search);
- action.setChecked(search.equals(selected));
- if (search.equals(selected))
- checkedOne= true;
- addActionToMenu(fMenu, action);
- }
- new MenuItem(fMenu, SWT.SEPARATOR);
- if (iter.hasNext()) {
- Action others= new ShowSearchesAction();
- others.setChecked(!checkedOne);
- addActionToMenu(fMenu, others);
- }
- addActionToMenu(fMenu, new RemoveAllSearchesAction());
- return fMenu;
- }
-
- protected void addActionToMenu(Menu parent, Action action) {
- ActionContributionItem item= new ActionContributionItem(action);
- item.fill(parent, -1);
- }
-
- public void run() {
- new ShowSearchesAction().run(true);
- }
-
- /**
- * Get's rid of the menu, because the menu hangs on to
- * the searches, etc.
- */
- void clear() {
- dispose();
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchManager.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchManager.java
deleted file mode 100644
index 6e31023..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchManager.java
+++ /dev/null
@@ -1,507 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.Map;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IMarkerDelta;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.viewers.Viewer;
-
-import org.eclipse.ui.actions.WorkspaceModifyOperation;
-
-import org.eclipse.search.ui.IGroupByKeyComputer;
-import org.eclipse.search.ui.SearchUI;
-
-import org.eclipse.search.internal.ui.util.ExceptionHandler;
-
-/**
- * Manage search results
- */
-public class SearchManager implements IResourceChangeListener {
-
- static final SearchManager fgDefault= new SearchManager();
-
- Search fCurrentSearch= null;
-
- private SearchManager() {
- SearchPlugin.getWorkspace().addResourceChangeListener(this);
- }
-
- private HashSet fListeners= new HashSet();
- private LinkedList fPreviousSearches= new LinkedList();
- private boolean fIsRemoveAll= false;
-
- public static SearchManager getDefault() {
- return fgDefault;
- }
-
- /**
- * Returns the list with previous searches (ISearch).
- */
- LinkedList getPreviousSearches() {
- return fPreviousSearches;
- }
- /**
- * Returns the list with current (last) results
- */
- ArrayList getCurrentResults() {
- if (fCurrentSearch == null)
- return new ArrayList(0);
- else
- return (ArrayList)fCurrentSearch.getResults();
- }
-
- public Search getCurrentSearch() {
- return fCurrentSearch;
- }
-
- void removeAllSearches() {
- SearchPlugin.getWorkspace().removeResourceChangeListener(this);
- WorkspaceModifyOperation op= new WorkspaceModifyOperation(null) {
- protected void execute(IProgressMonitor monitor) throws CoreException {
- monitor.beginTask(SearchMessages.getString("SearchManager.updating"), 100); //$NON-NLS-1$
- SearchPlugin.getWorkspace().getRoot().deleteMarkers(SearchUI.SEARCH_MARKER, true, IResource.DEPTH_INFINITE);
- monitor.worked(100);
- monitor.done();
- }
- };
- boolean isAutoBuilding= SearchPlugin.getWorkspace().isAutoBuilding();
- if (isAutoBuilding)
- // disable auto-build during search operation
- SearchPlugin.setAutoBuilding(false);
- try {
- ProgressMonitorDialog dialog= new ProgressMonitorDialog(getShell());
- dialog.run(true, true, op);
- } catch (InvocationTargetException ex) {
- ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.deleteMarkers.title"), SearchMessages.getString("Search.Error.deleteMarkers.message")); //$NON-NLS-2$ //$NON-NLS-1$
- } catch (InterruptedException e) {
- // Do nothing. Operation has been canceled.
- } finally {
- SearchPlugin.getWorkspace().addResourceChangeListener(this);
- if (isAutoBuilding)
- // enable auto-building again
- SearchPlugin.setAutoBuilding(true);
- }
-
- // clear searches
- fPreviousSearches= new LinkedList();
- fCurrentSearch= null;
-
- // update viewers
- Iterator iter= fListeners.iterator();
- while (iter.hasNext()) {
- SearchResultViewer viewer= (SearchResultViewer)iter.next();
- handleAllSearchesRemoved(viewer);
- }
- }
-
- private void handleAllSearchesRemoved(SearchResultViewer viewer) {
- viewer.handleAllSearchesRemoved();
- }
-
- void setCurrentSearch(final Search search) {
- if (fCurrentSearch == search)
- return;
-
- SearchPlugin.getWorkspace().removeResourceChangeListener(this);
- WorkspaceModifyOperation op= new WorkspaceModifyOperation(null) {
- protected void execute(IProgressMonitor monitor) throws CoreException {
- internalSetCurrentSearch(search, monitor);
- }
- };
- boolean isAutoBuilding= SearchPlugin.getWorkspace().isAutoBuilding();
- if (isAutoBuilding)
- // disable auto-build during search operation
- SearchPlugin.setAutoBuilding(false);
- try {
- ProgressMonitorDialog dialog= new ProgressMonitorDialog(getShell());
- dialog.run(true, true, op);
- } catch (InvocationTargetException ex) {
- ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.switchSearch.title"), SearchMessages.getString("Search.Error.switchSearch.message")); //$NON-NLS-2$ //$NON-NLS-1$
- } catch (InterruptedException e) {
- // Do nothing. Operation has been canceled.
- } finally {
- SearchPlugin.getWorkspace().addResourceChangeListener(this);
- if (isAutoBuilding)
- // enable auto-building again
- SearchPlugin.setAutoBuilding(true);
- }
-
- getPreviousSearches().remove(search);
- getPreviousSearches().addFirst(search);
- }
-
- void internalSetCurrentSearch(final Search search, IProgressMonitor monitor) {
- if (fCurrentSearch != null)
- fCurrentSearch.backupMarkers();
-
- final Search previousSearch= fCurrentSearch;
- fCurrentSearch= search;
- monitor.beginTask(SearchMessages.getString("SearchManager.updating"), getCurrentResults().size() + 20); //$NON-NLS-1$
-
- // remove current search markers
- try {
- SearchPlugin.getWorkspace().getRoot().deleteMarkers(SearchUI.SEARCH_MARKER, true, IResource.DEPTH_INFINITE);
- } catch (CoreException ex) {
- ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.deleteMarkers.title"), SearchMessages.getString("Search.Error.deleteMarkers.message")); //$NON-NLS-2$ //$NON-NLS-1$
- }
- monitor.worked(10);
-
- // add search markers
- Iterator iter= getCurrentResults().iterator();
- ArrayList emptyEntries= new ArrayList(10);
- boolean filesChanged= false;
- boolean filesDeleted= false;
- IGroupByKeyComputer groupByKeyComputer= getCurrentSearch().getGroupByKeyComputer();
- while (iter.hasNext()) {
- monitor.worked(1);
- SearchResultViewEntry entry= (SearchResultViewEntry)iter.next();
- Iterator attrPerMarkerIter= entry.getAttributesPerMarker().iterator();
- entry.clearMarkerList();
- if (entry.getResource() == null || !entry.getResource().exists()) {
- emptyEntries.add(entry);
- filesDeleted= true;
- continue;
- }
- while (attrPerMarkerIter.hasNext()) {
- IMarker newMarker= null;
- try {
- newMarker= entry.getResource().createMarker(entry.getMarkerType());
- } catch (CoreException ex) {
- ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.createMarker.title"), SearchMessages.getString("Search.Error.createMarker.message")); //$NON-NLS-2$ //$NON-NLS-1$
- continue;
- }
- try {
- newMarker.setAttributes((Map)attrPerMarkerIter.next());
- if (groupByKeyComputer !=null && groupByKeyComputer.computeGroupByKey(newMarker) == null) {
- filesDeleted= true;
- newMarker.delete();
- continue;
- }
- } catch (CoreException ex) {
- ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.markerAttributeAccess.title"), SearchMessages.getString("Search.Error.markerAttributeAccess.message")); //$NON-NLS-2$ //$NON-NLS-1$
- }
- entry.add(newMarker);
- }
- if (entry.getMatchCount() == 0)
- emptyEntries.add(entry);
- else if (!filesChanged && entry.getResource().getModificationStamp() != entry.getModificationStamp())
- filesChanged= true;
- }
- getCurrentResults().removeAll(emptyEntries);
- monitor.worked(10);
-
- String warningMessage= null;
- Display display= getDisplay();
-
- if (filesChanged)
- warningMessage= SearchMessages.getString("SearchManager.resourceChanged"); //$NON-NLS-1$
- if (filesDeleted) {
- if (warningMessage == null)
- warningMessage= ""; //$NON-NLS-1$
- else
- warningMessage += "\n"; //$NON-NLS-1$
- warningMessage += SearchMessages.getString("SearchManager.resourceDeleted"); //$NON-NLS-1$
- }
- if (warningMessage != null) {
- if (display != null && !display.isDisposed()) {
- final String warningTitle= SearchMessages.getString("SearchManager.resourceChangedWarning"); //$NON-NLS-1$
- final String warningMsg= warningMessage;
- display.syncExec(new Runnable() {
- public void run() {
- MessageDialog.openWarning(getShell(), warningTitle, warningMsg);
- }
- });
- }
- }
-
- // update viewers
- iter= fListeners.iterator();
- if (display != null && !display.isDisposed()) {
- final Viewer visibleViewer= ((SearchResultView)SearchPlugin.getSearchResultView()).getViewer();
- while (iter.hasNext()) {
- final SearchResultViewer viewer= (SearchResultViewer)iter.next();
- display.syncExec(new Runnable() {
- public void run() {
- if (previousSearch != null && viewer == visibleViewer)
- previousSearch.setSelection(viewer.getSelection());
- viewer.setInput(null);
- viewer.setPageId(search.getPageId());
- viewer.setGotoMarkerAction(search.getGotoMarkerAction());
- viewer.setContextMenuTarget(search.getContextMenuContributor());
- viewer.setActionGroupFactory(null);
- viewer.setInput(getCurrentResults());
- viewer.setActionGroupFactory(search.getActionGroupFactory());
- viewer.setSelection(fCurrentSearch.getSelection(), true);
- }
- });
- }
- }
- monitor.done();
- }
-
- /**
- * Returns the number of matches
- */
- int getCurrentItemCount() {
- if (fCurrentSearch != null)
- return fCurrentSearch.getItemCount();
- else
- return 0;
- }
-
- void removeAllResults() {
- fIsRemoveAll= true;
- try {
- SearchPlugin.getWorkspace().getRoot().deleteMarkers(SearchUI.SEARCH_MARKER, true, IResource.DEPTH_INFINITE);
- } catch (CoreException ex) {
- ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.deleteMarkers.title"), SearchMessages.getString("Search.Error.deleteMarkers.message")); //$NON-NLS-2$ //$NON-NLS-1$
- fIsRemoveAll= false;
- }
- }
-
- void addNewSearch(final Search newSearch) {
-
- SearchPlugin.getWorkspace().removeResourceChangeListener(this);
-
- // Clear the viewers
- Iterator iter= fListeners.iterator();
- Display display= getDisplay();
- if (display != null && !display.isDisposed()) {
- final Viewer visibleViewer= ((SearchResultView)SearchPlugin.getSearchResultView()).getViewer();
- while (iter.hasNext()) {
- final SearchResultViewer viewer= (SearchResultViewer)iter.next();
- display.syncExec(new Runnable() {
- public void run() {
- if (fCurrentSearch != null && viewer == visibleViewer)
- fCurrentSearch.setSelection(viewer.getSelection());
- setNewSearch(viewer, newSearch);
- }
- });
- }
- }
-
- if (fCurrentSearch != null) {
- if (fCurrentSearch.isSameSearch(newSearch))
- getPreviousSearches().remove(fCurrentSearch);
- else
- fCurrentSearch.backupMarkers();
- }
- fCurrentSearch= newSearch;
- getPreviousSearches().addFirst(fCurrentSearch);
-
- // Remove the markers
- try {
- SearchPlugin.getWorkspace().getRoot().deleteMarkers(SearchUI.SEARCH_MARKER, true, IResource.DEPTH_INFINITE);
- } catch (CoreException ex) {
- ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.deleteMarkers.title"), SearchMessages.getString("Search.Error.deleteMarkers.message")); //$NON-NLS-2$ //$NON-NLS-1$
- }
- }
-
- void searchFinished(ArrayList results) {
- Assert.isNotNull(results);
- getCurrentSearch().setResults(results);
-
- Display display= getDisplay();
- if (display == null || display.isDisposed())
- return;
-
- if (Thread.currentThread() == display.getThread())
- handleNewSearchResult();
- else {
- display.syncExec(new Runnable() {
- public void run() {
- handleNewSearchResult();
- }
- });
- }
- SearchPlugin.getWorkspace().addResourceChangeListener(this);
- }
-
- //--- Change event handling -------------------------------------------------
-
- void addSearchChangeListener(SearchResultViewer viewer) {
- fListeners.add(viewer);
- }
-
- void removeSearchChangeListener(SearchResultViewer viewer) {
- Assert.isNotNull(viewer);
- fListeners.remove(viewer);
- }
-
- private final void handleSearchMarkersChanged(IMarkerDelta[] markerDeltas) {
- if (fIsRemoveAll) {
- handleRemoveAll();
- fIsRemoveAll= false;
- return;
- }
-
- Iterator iter= fListeners.iterator();
- while (iter.hasNext())
- ((SearchResultViewer)iter.next()).getControl().setRedraw(false);
-
- for (int i=0; i < markerDeltas.length; i++) {
- handleSearchMarkerChanged(markerDeltas[i]);
- }
-
- iter= fListeners.iterator();
- while (iter.hasNext())
- ((SearchResultViewer)iter.next()).getControl().setRedraw(true);
-
- }
-
- private void handleSearchMarkerChanged(IMarkerDelta markerDelta) {
- int kind= markerDelta.getKind();
- // don't listen for adds will be done by ISearchResultView.addMatch(...)
- if (((kind & IResourceDelta.REMOVED) != 0))
- handleRemoveMatch(markerDelta.getMarker());
- else if ((kind & IResourceDelta.CHANGED) != 0)
- handleUpdateMatch(markerDelta.getMarker());
- }
-
- private void handleRemoveAll() {
- if (fCurrentSearch != null)
- fCurrentSearch.removeResults();
- Iterator iter= fListeners.iterator();
- while (iter.hasNext())
- ((SearchResultViewer)iter.next()).handleRemoveAll();
- }
-
- private void handleNewSearchResult() {
- Iterator iter= fListeners.iterator();
- while (iter.hasNext()) {
- SearchResultViewer viewer= (SearchResultViewer)iter.next();
- viewer.setInput(getCurrentResults());
- }
- }
-
- private void setNewSearch(SearchResultViewer viewer, Search search) {
- viewer.setInput(null);
- viewer.clearTitle();
- viewer.setPageId(search.getPageId());
- viewer.setGotoMarkerAction(search.getGotoMarkerAction());
- viewer.setContextMenuTarget(search.getContextMenuContributor());
- viewer.setActionGroupFactory(search.getActionGroupFactory());
- }
-
- private void handleRemoveMatch(IMarker marker) {
- SearchResultViewEntry entry= findEntry(marker);
- if (entry != null) {
- entry.remove(marker);
- if (entry.getMatchCount() == 0) {
- getCurrentResults().remove(entry);
- Iterator iter= fListeners.iterator();
- while (iter.hasNext())
- ((SearchResultViewer)iter.next()).handleRemoveMatch(entry);
- }
- else {
- Iterator iter= fListeners.iterator();
- while (iter.hasNext())
- ((SearchResultViewer)iter.next()).handleUpdateMatch(entry, true);
- }
- }
- }
-
- private void handleUpdateMatch(IMarker marker) {
- SearchResultViewEntry entry= findEntry(marker);
- if (entry != null) {
- Iterator iter= fListeners.iterator();
- while (iter.hasNext())
- ((SearchResultViewer)iter.next()).handleUpdateMatch(entry, false);
- }
- }
-
- private SearchResultViewEntry findEntry(IMarker marker) {
- Iterator entries= getCurrentResults().iterator();
- while (entries.hasNext()) {
- SearchResultViewEntry entry= (SearchResultViewEntry)entries.next();
- if (entry.contains(marker))
- return entry;
- }
- return null;
- }
-
- /**
- * Received a resource event. Since the delta could be created in a
- * separate thread this methods post the event into the viewer's
- * display thread.
- */
- public final void resourceChanged(final IResourceChangeEvent event) {
- if (event == null)
- return;
-
- final IMarkerDelta[] markerDeltas= event.findMarkerDeltas(SearchUI.SEARCH_MARKER, true);
- if (markerDeltas == null || markerDeltas.length < 1)
- return;
-
- Display display= getDisplay();
- if (display == null || display.isDisposed())
- return;
-
- Runnable runnable= new Runnable() {
- public void run() {
- if (getCurrentSearch() != null) {
- handleSearchMarkersChanged(markerDeltas);
- // update title and actions
- Iterator iter= fListeners.iterator();
- while (iter.hasNext()) {
- SearchResultViewer viewer= (SearchResultViewer)iter.next();
- viewer.enableActions();
- viewer.updateTitle();
- }
- }
- }
- };
- display.syncExec(runnable);
- }
- /**
- * Find and return a valid display
- */
- private Display getDisplay() {
- Iterator iter= fListeners.iterator();
- while (iter.hasNext()) {
- Control control= ((Viewer)iter.next()).getControl();
- if (control != null && !control.isDisposed()) {
- Display display= control.getDisplay();
- if (display != null && !display.isDisposed())
- return display;
- }
- }
- return null;
- }
- /**
- * Find and return a valid shell
- */
- private Shell getShell() {
- return SearchPlugin.getActiveWorkbenchShell();
- }
-}
-
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchMessages.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchMessages.java
deleted file mode 100644
index 2f9d75e..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchMessages.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-public class SearchMessages {
-
- private static final String RESOURCE_BUNDLE= SearchMessages.class.getName();
-
- private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
-
- private SearchMessages() {
- }
-
- public static String getString(String key) {
- try {
- return fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- }
-
- /**
- * Gets a string from the resource bundle and formats it with the argument
- *
- * @param key the string used to get the bundle value, must not be null
- */
- 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 });
- }
-
- /**
- * Gets a string from the resource bundle and formats it with the argument
- *
- * @param key the string used to get the bundle value, must not be null
- */
- public static String getFormattedString(String key, Object[] args) {
- String format= null;
- try {
- format= fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- return MessageFormat.format(format, args);
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchMessages.properties b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchMessages.properties
deleted file mode 100644
index 8c52877..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchMessages.properties
+++ /dev/null
@@ -1,230 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2003 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-SearchDialog.title= Search
-SearchDialog.searchAction= &Search
-SearchDialog.replaceAction= R&eplace...
-SearchDialog.customize= Customi&ze...
-SearchDialog.noSearchExtension= No Search Extensions plugged into workbench or all search pages disabled.
-
-SearchPageSelectionDialog.title= Search Page Selection
-SearchPageSelectionDialog.message= S&elect from the pages shown in the dialog:
-
-SearchManager.resourceChangedWarning= Changed Resources
-SearchManager.resourceChanged= Some resources have changed. The positions of matches may have changed.
-SearchManager.resourceDeleted= Some resources no longer exist. Corresponding matches have been removed from the search results.
-SearchManager.updating= Updating...
-
-SearchResultView.title= Search
-SearchResultView.titleWithDescription= Search ({0})
-SearchResultView.matches= matches
-SearchResultView.removed_resource= <removed resource>
-SearchResultView.removeAllResults.text= Remove &All Matches
-SearchResultView.removeAllResults.tooltip= Remove All Matches
-SearchResultView.removeAllSearches.text= &Clear History
-SearchResultView.removeAllSearches.tooltip= Clear the search result history
-SearchResultView.searchAgain.text= &Search Again
-SearchResultView.searchAgain.tooltip= Search Again
-SearchResultView.previousSearches.text= Previous Search Results
-SearchResultView.previousSearches.tooltip= Previous Search Results
-SearchResultView.removeEntry.text= &Remove Selected Match
-SearchResultView.removeEntry.tooltip= Remove Selected Match
-SearchResultView.removeEntries.text= &Remove Selected Matches
-SearchResultView.removeEntries.tooltip= Remove Selected Matches
-SearchResultView.removeMatch.text= Remove Current &Match
-SearchResultView.removeMatch.tooltip= Remove Current Match
-SearchResultView.gotoMarker.text= &Go to File
-SearchResultView.gotoMarker.tooltip= Go to File
-SearchResultView.showNext.text= Next Match
-SearchResultView.showNext.tooltip= Show Next Match
-SearchResultView.showPrev.text= Previous Match
-SearchResultView.showPrev.tooltip= Show Previous Match
-
-SearchDialogClosingDialog.title= Search Dialog Closing
-SearchDialogClosingDialog.message= Dialog can not be closed due to an active operation. You must cancel the operation before you can close the dialog.
-
-SearchPlugin.internal_error= Internal Error
-
-Search.Error.search.title= Search Error
-Search.Error.search.message= An error occurred during the search operation
-
-Search.Error.setDescription.title= Search Error
-Search.Error.setDescription.message= Can not save workspace description
-
-Search.Error.openEditor.title= Search Error
-Search.Error.openEditor.message= Could not open the editor
-
-Search.Error.openResultView.title= Search Error
-Search.Error.openResultView.message= Could not open the search results view
-
-Search.Error.deleteMarkers.title= Search Error
-Search.Error.deleteMarkers.message= An error occurred during deletion of search markers
-
-Search.Error.findMarkers.title= Search Error
-Search.Error.findMarkers.message= An error occurred while gathering the search markers
-
-Search.Error.createMarker.title= Search Error
-Search.Error.createMarker.message= Could not create the search marker
-
-Search.Error.markerAttributeAccess.title= Search Error
-Search.Error.markerAttributeAccess.message= An error occurred while accessing a marker attribute
-
-Search.Error.switchSearch.title= Search Error
-Search.Error.switchSearch.message= An error occurred while switching to a previous search result
-
-Search.Error.createSearchPage.title= Search Error
-Search.Error.createSearchPage.message= An error occurred while creating a search page
-
-Search.Error.createSorter.title= Search Error
-Search.Error.createSorter.message= An error occurred while creating a sorter
-
-Search.Error.incorrectIconLocation.message= Invalid icon location
-
-Search.Problems.title= Text Search Problems
-
-SearchResultCollector.match= 1 match
-SearchResultCollector.matches= {0} matches
-SearchResultCollector.done= Search done: {0}.
-
-SearchPage.containingText.text= C&ontaining text:
-SearchPage.containingText.hint= (* = any string, ? = any character, \\ = escape for literals: * ? \\)
-SearchPage.browse= &Choose...
-SearchPage.fileNamePatterns.text= File name &patterns:
-SearchPage.fileNamePatterns.hint= The patterns are separated by comma (* = any string, ? = any character)
-SearchPage.caseSensitive= Case sens&itive
-SearchPage.regularExpression= &Regular expression
-SearchPage.regularExpressionSyntaxProblem.title= Search: Invalid Regular Expression
-
-TextSearchEngine.scanning= Scanning file {0} of {1}...
-TextSearchEngine.statusMessage= Problems encountered during text search.
-
-TextSearchVisitor.scanning= Scanning file {0} of {1}...
-TextSearchVisitor.error= Error reading file during search: {0}
-TextSearchVisitor.canceled= Operation Canceled
-
-SortDropDownAction.label= S&ort By
-SortDropDownAction.tooltip= Sort By
-
-ShowOtherSearchesAction.label= &Other...
-ShowOtherSearchesAction.tooltip= Open Other Searches Dialog
-
-OtherSearchesDialog.title= Other Searches
-OtherSearchesDialog.message= &Select one of the searches
-
-PreviousSearchesDialog.title= Previous Searches
-PreviousSearchesDialog.message= &Select one of the searches
-
-# The first argument will be replaced by the pattern, the second by the scope
-TextSearchOperation.singularLabelPostfix= "{0}" - 1 Occurrence in {1}
-
-# The argument will be replaced by the scope
-FileSearchOperation.singularLabelPostfix= 1 File in {0}
-
-# The first argument will be replaced by the pattern, the second by the count and the last by the scope
-TextSearchOperation.pluralLabelPatternPostfix= "{0}" - {1} Occurrences in {2}
-
-# The first argument will be replaced by the count and the second by the scope
-FileSearchOperation.pluralLabelPatternPostfix= {0} Files in {1}
-
-OpenSearchDialogAction.label= Search
-OpenSearchDialogAction.tooltip= Search
-
-FileTypeEditor.typeDelimiter= ,
-
-FileLabelProvider.dashSeparated= {0} - {1}
-FileLabelProvider.removed_resource.label=<removed resource>
-
-FileSearchPage.sort_name.label=Name
-FileSearchPage.sort_path.label=Path
-FileSearchPage.error.marker=Could not create marker
-FileSearchPage.sort_by.label=Sort By
-
-TypesFiltering.title= Select Types
-TypesFiltering.message= S&elect the types to scan.
-TypesFiltering.otherExtensions= &Other Patterns:
-TypesFiltering.selectAll= &Select All
-TypesFiltering.deselectAll= &Deselect All
-
-WorkspaceScope= Workspace
-WorkingSetScope= Working Set - {0}
-SelectionScope= Selection
-EnclosingProjectsScope= Projects {0}, ...
-EnclosingProjectScope= Project {0}
-
-ScopePart.group.text= Scope
-ScopePart.selectedResourcesScope.text= Selecte&d Resources
-ScopePart.enclosingProjectsScope.text= Enclosing Pro&jects
-ScopePart.workingSetChooseButton.text= C&hoose...
-ScopePart.workingSetScope.text= Wor&king Set:
-ScopePart.workspaceScope.text= &Workspace
-
-# Concatenate two working set names e.g. "Source, Lib"
-ScopePart.workingSetConcatenation= {0}, {1}
-
-CopyToClipboardAction.label= Copy to Clip&board
-CopyToClipboardAction.tooltip= Copy to Clipboard
-CopyToClipboardAction.error.title= Problem Copying to Clipboard
-CopyToClipboardAction.error.message= There was a problem when accessing the system clipboard. Retry?
-
-ExceptionDialog.seeErrorLogMessage= See error log for more details
-
-SearchPreferencePage.emphasizePotentialMatches= &Emphasize inexact matches
-SearchPreferencePage.potentialMatchFgColor= &Foreground color for inexact matches:
-SearchPreferencePage.reuseEditor= &Reuse editors to show matches
-SearchPreferencePage.bringToFront= &Bring Search view to front after search
-SearchPreferencePage.defaultPerspective= Default &perspective for the Search view:
-SearchPreferencePage.defaultPerspective.none= None
-SearchPreferencePage.ignorePotentialMatches= &Ignore inexact matches
-
-ReplaceAction.label_all= Re&place...
-ReplaceAction.label_selected= Rep&lace Selected...
-ReplaceAction.error.only_on_text_search= Replace is only available on text search.
-ReplaceAction.dialog.title= Replace
-
-ReplaceDialog.replace_label= Replace:
-ReplaceDialog.with_label= &With:
-ReplaceDialog.replace= &Replace
-ReplaceDialog.replaceAllInFile= Replace All in &File
-ReplaceDialog.replaceAll= Replace &All
-ReplaceDialog.skip= &Skip
-ReplaceDialog.skipFile= S&kip File
-ReplaceDialog.dialog.title= Replace
-ReplaceDialog.error.unable_to_open_text_editor= It is not possible to open the built-in text editor for file ''{0}''.
-ReplaceDialog.error.unable_to_replace= An error occurred while replacing in file ''{0}''.
-ReplaceDialog.progress.message= File: {0} ({1} of {2})
-
-SelectAllAction.label= Select A&ll
-SelectAllAction.tooltip= Select All
-
-RemovePotentialMatchesAction.removePotentialMatch.text= Remove Inexact Match
-RemovePotentialMatchesAction.removePotentialMatch.tooltip= Remove inexact match
-RemovePotentialMatchesAction.removePotentialMatches.text= Remove Inexact Matches
-RemovePotentialMatchesAction.removePotentialMatches.tooltip= Remove all inexact matches
-RemovePotentialMatchesAction.dialog.title= Remove Inexact Matches
-RemovePotentialMatchesAction.dialog.message= The current search result does not contain inexact matches.
-
-OpenWithMenu.label= Open Wit&h
-
-ReadOnlyDialog.skipFile= Skip File
-ReadOnlyDialog.skipAll= Skip All
-ReadOnlyDialog.message= The file {0} is read-only
-ReplaceDialog.task.replace= Replacing Match
-ReplaceDialog.task.replaceInFile= Replacing Matches in File {0}
-ReplaceDialog.task.replace.replaceAll= Replacing Matches
-ReplaceAction.label= Replace
-ReplaceAction.research.error= An error occurred while updating the matches
-SearchAgainConfirmationDialog.outofsync.message= Some resources are out of sync with the file system or may contain stale matches. Do you want to refresh those files and search again?
-SearchAgainConfirmationDialog.outofsync.label= Files out of sync:
-SearchAgainConfirmationDialog.stale.message= Some resources may contain stale matches. Do you want to search again?
-SearchAgainConfirmationDialog.stale.label= Files with stale matches:
-SearchAgainConfirmationDialog.title= Replace
-ReplaceDialog.isRegex.label= Regular Expression
-WorkInProgressPreferencePage.newsearch.label=Use new search view
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPageDescriptor.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPageDescriptor.java
deleted file mode 100644
index 8361043..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPageDescriptor.java
+++ /dev/null
@@ -1,342 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IConfigurationElement;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.resource.StringConverter;
-
-import org.eclipse.search.ui.ISearchPage;
-import org.eclipse.search.ui.ISearchPageScoreComputer;
-import org.eclipse.search.ui.ISearchResultViewEntry;
-
-import org.eclipse.search.internal.ui.util.ExceptionHandler;
-
-/**
- * Proxy that represents a search page.
- */
-class SearchPageDescriptor implements Comparable {
-
- public final static String PAGE_TAG= "page"; //$NON-NLS-1$
- private final static String ID_ATTRIBUTE= "id"; //$NON-NLS-1$
- private final static String ICON_ATTRIBUTE= "icon"; //$NON-NLS-1$
- private final static String CLASS_ATTRIBUTE= "class"; //$NON-NLS-1$
- private final static String LABEL_ATTRIBUTE= "label"; //$NON-NLS-1$
- private final static String SIZE_ATTRIBUTE= "sizeHint"; //$NON-NLS-1$
- private final static String TAB_POSITION_ATTRIBUTE= "tabPosition"; //$NON-NLS-1$
- private final static String EXTENSIONS_ATTRIBUTE= "extensions"; //$NON-NLS-1$
- private final static String SHOW_SCOPE_SECTION_ATTRIBUTE= "showScopeSection"; //$NON-NLS-1$
- private final static String CAN_SEARCH_ENCLOSING_PROJECTS= "canSearchEnclosingProjects"; //$NON-NLS-1$
- private final static String ENABLED_ATTRIBUTE= "enabled"; //$NON-NLS-1$
- private final static String SEARCH_VIEW_HELP_CONTEXT_ID_ATTRIBUTE= "searchViewHelpContextId"; //$NON-NLS-1$
-
- public final static Point UNKNOWN_SIZE= new Point(SWT.DEFAULT, SWT.DEFAULT);
-
- // dialog store id constants
- private final static String SECTION_ID= "Search"; //$NON-NLS-1$
- private final static String STORE_ENABLED_PAGE_IDS= SECTION_ID + ".enabledPageIds"; //$NON-NLS-1$
- private final static String STORE_PROCESSED_PAGE_IDS= SECTION_ID + ".processedPageIds"; //$NON-NLS-1$
-
- private static List fgEnabledPageIds;
-
- private static class ExtensionScorePair {
- public String extension;
- public int score;
- public ExtensionScorePair(String extension, int score) {
- this.extension= extension;
- this.score= score;
- }
- }
-
- private IConfigurationElement fElement;
- private List fExtensionScorePairs;
- private int fWildcardScore= ISearchPageScoreComputer.UNKNOWN;
-
- /**
- * Creates a new search page node with the given configuration element.
- */
- public SearchPageDescriptor(IConfigurationElement element) {
- fElement= element;
- }
-
- /**
- * Creates a new search page from this node.
- */
- public ISearchPage createObject() {
- ISearchPage result= null;
- try {
- result= (ISearchPage)fElement.createExecutableExtension(CLASS_ATTRIBUTE);
- } catch (CoreException ex) {
- ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.createSearchPage.title"), SearchMessages.getString("Search.Error.createSearchPage.message")); //$NON-NLS-2$ //$NON-NLS-1$
- } catch (ClassCastException ex) {
- ExceptionHandler.displayMessageDialog(ex, SearchMessages.getString("Search.Error.createSearchPage.title"), SearchMessages.getString("Search.Error.createSearchPage.message")); //$NON-NLS-2$ //$NON-NLS-1$
- return null;
- }
- if (result != null) {
- result.setTitle(getLabel());
- }
- return result;
- }
-
- //---- XML Attribute accessors ---------------------------------------------
-
- /**
- * Returns the page's id.
- */
- public String getId() {
- return fElement.getAttribute(ID_ATTRIBUTE);
- }
-
- /**
- * Returns the page's image
- */
- public ImageDescriptor getImage() {
- String imageName= fElement.getAttribute(ICON_ATTRIBUTE);
- if (imageName == null)
- return null;
- URL url;
- try {
- url= new URL(fElement.getDeclaringExtension().getDeclaringPluginDescriptor().getInstallURL(), imageName);
- } catch (java.net.MalformedURLException ex) {
- ExceptionHandler.log(ex, SearchMessages.getString("Search.Error.createSearchPage.message")); //$NON-NLS-1$
- return null;
- }
- return ImageDescriptor.createFromURL(url);
- }
-
- /**
- * Returns the page's label.
- */
- public String getLabel() {
- return fElement.getAttribute(LABEL_ATTRIBUTE);
- }
-
- /**
- * Returns <code>true</code> if the scope section needs
- * to be shown in the dialog.
- */
- public boolean showScopeSection() {
- return Boolean.valueOf(fElement.getAttribute(SHOW_SCOPE_SECTION_ATTRIBUTE)).booleanValue();
- }
-
- /**
- * Returns <code>true</code> if the page is initially
- * shown in the Search dialog.
- *
- * This attribute is optional and defaults to <code>true</code>.
- */
- public boolean isInitiallyEnabled() {
- String strVal= fElement.getAttribute(ENABLED_ATTRIBUTE);
- return strVal == null || Boolean.valueOf(strVal).booleanValue();
- }
-
- /**
- * Returns <code>true</code> if the page can handle
- * searches in enclosing projects. The value should be ignored if <code>showScopeSection()</code>
- * returns <code>false</code>.
- *
- * This attribute is optional and defaults to <code>false</code>.
- */
- public boolean canSearchInProjects() {
- return Boolean.valueOf(fElement.getAttribute(CAN_SEARCH_ENCLOSING_PROJECTS)).booleanValue();
- }
-
- /**
- * Returns the page's preferred size
- */
- public Point getPreferredSize() {
- return StringConverter.asPoint(
- fElement.getAttribute(SIZE_ATTRIBUTE), UNKNOWN_SIZE);
- }
-
- /**
- * Returns the page's tab position relative to the other tabs.
- * @return the tab position or <code>Integer.MAX_VALUE</code> if not defined in
- * the plugins.xml file
- */
- public int getTabPosition() {
- int position= Integer.MAX_VALUE / 2;
- String str= fElement.getAttribute(TAB_POSITION_ATTRIBUTE);
- if (str != null)
- try {
- position= Integer.parseInt(str);
- } catch (NumberFormatException ex) {
- ExceptionHandler.log(ex, SearchMessages.getString("Search.Error.createSearchPage.message")); //$NON-NLS-1$
- // position is Integer.MAX_VALUE;
- }
- return position;
- }
-
- boolean isEnabled() {
- return getEnabledPageIds().contains(getId());
- }
-
- /**
- * Returns the help context for help shown in search view.
- *
- * @return the help context id or <code>null</code> if not defined
- */
- public String getSearchViewHelpContextId() {
- return fElement.getAttribute(SEARCH_VIEW_HELP_CONTEXT_ID_ATTRIBUTE);
- }
-
- static void setEnabled(Object[] enabledDescriptors) {
- fgEnabledPageIds= new ArrayList(5);
- for (int i= 0; i < enabledDescriptors.length; i++) {
- if (enabledDescriptors[i] instanceof SearchPageDescriptor)
- fgEnabledPageIds.add(((SearchPageDescriptor)enabledDescriptors[i]).getId());
- }
- storeEnabledPageIds();
- }
-
- private static List getEnabledPageIds() {
- if (fgEnabledPageIds == null) {
- List descriptors= SearchPlugin.getDefault().getSearchPageDescriptors();
-
- String[] enabledPageIds= getDialogSettings().getArray(STORE_ENABLED_PAGE_IDS);
- if (enabledPageIds == null)
- fgEnabledPageIds= new ArrayList(descriptors.size());
- else
- fgEnabledPageIds= new ArrayList(Arrays.asList(enabledPageIds));
-
-
- List processedPageIds;
- String[] processedPageIdsArr= getDialogSettings().getArray(STORE_PROCESSED_PAGE_IDS);
- if (processedPageIdsArr == null)
- processedPageIds= new ArrayList(descriptors.size());
- else
- processedPageIds= new ArrayList(Arrays.asList(processedPageIdsArr));
-
- // Enable pages based on contribution
- Iterator iter= descriptors.iterator();
- while (iter.hasNext()) {
- SearchPageDescriptor desc= (SearchPageDescriptor)iter.next();
- if (processedPageIds.contains(desc.getId()))
- continue;
-
- processedPageIds.add(desc.getId());
- if (desc.isInitiallyEnabled())
- fgEnabledPageIds.add(desc.getId());
- }
-
- getDialogSettings().put(STORE_PROCESSED_PAGE_IDS, (String[])processedPageIds.toArray(new String[processedPageIds.size()]));
- storeEnabledPageIds();
- }
- return fgEnabledPageIds;
- }
-
- private static void storeEnabledPageIds() {
- getDialogSettings().put(STORE_ENABLED_PAGE_IDS, (String[])fgEnabledPageIds.toArray(new String[fgEnabledPageIds.size()]));
- SearchPlugin.getDefault().savePluginPreferences();
- }
-
- private static IDialogSettings getDialogSettings() {
- IDialogSettings settings= SearchPlugin.getDefault().getDialogSettings();
- IDialogSettings section= settings.getSection(SECTION_ID);
- if (section == null)
- // create new section
- section= settings.addNewSection(SECTION_ID);
- return section;
- }
-
- /*
- * Implements a method from IComparable
- */
- public int compareTo(Object o) {
- int myPos= getTabPosition();
- int objsPos= ((SearchPageDescriptor)o).getTabPosition();
- if (myPos == Integer.MAX_VALUE && objsPos == Integer.MAX_VALUE || myPos == objsPos)
- return getLabel().compareTo(((SearchPageDescriptor)o).getLabel());
- else
- return myPos - objsPos;
- }
-
- //---- Suitability tests ---------------------------------------------------
-
- /**
- * Returns the score for this page with the given input element.
- */
- public int computeScore(Object element) {
- if (element instanceof IAdaptable) {
- IResource resource= (IResource)((IAdaptable)element).getAdapter(IResource.class);
- if (resource != null && resource.getType() == IResource.FILE) {
- String extension= ((IFile)resource).getFileExtension();
- if (extension != null)
- return getScoreForFileExtension(extension);
- } else {
- ISearchPageScoreComputer tester=
- (ISearchPageScoreComputer)((IAdaptable)element).getAdapter(ISearchPageScoreComputer.class);
- if (tester != null)
- return tester.computeScore(getId(), element);
- }
- } else if (element instanceof ISearchResultViewEntry) {
- ISearchResultViewEntry entry= (ISearchResultViewEntry)element;
- return computeScore(entry.getSelectedMarker());
- }
- if (fWildcardScore != ISearchPageScoreComputer.UNKNOWN)
- return fWildcardScore;
-
- return ISearchPageScoreComputer.LOWEST;
- }
-
- private int getScoreForFileExtension(String extension) {
- if (fExtensionScorePairs == null)
- readExtensionScorePairs();
-
- int size= fExtensionScorePairs.size();
- for (int i= 0; i < size; i++) {
- ExtensionScorePair p= (ExtensionScorePair)fExtensionScorePairs.get(i);
- if (extension.equals(p.extension))
- return p.score;
- }
- if (fWildcardScore != ISearchPageScoreComputer.UNKNOWN)
- return fWildcardScore;
-
- return ISearchPageScoreComputer.LOWEST;
- }
-
- private void readExtensionScorePairs() {
- fExtensionScorePairs= new ArrayList(3);
- String content= fElement.getAttribute(EXTENSIONS_ATTRIBUTE);
- if (content == null)
- return;
- StringTokenizer tokenizer= new StringTokenizer(content, ","); //$NON-NLS-1$
- while (tokenizer.hasMoreElements()) {
- String token= tokenizer.nextToken().trim();
- int pos= token.indexOf(':');
- if (pos != -1) {
- String extension= token.substring(0, pos);
- int score= StringConverter.asInt(token.substring(pos+1), ISearchPageScoreComputer.UNKNOWN);
- if (extension.equals("*")) { //$NON-NLS-1$
- fWildcardScore= score;
- } else {
- fExtensionScorePairs.add(new ExtensionScorePair(extension, score));
- }
- }
- }
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPlugin.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPlugin.java
deleted file mode 100644
index a09883e..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPlugin.java
+++ /dev/null
@@ -1,384 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceDescription;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdapterManager;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.core.runtime.IPluginRegistry;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.jface.action.GroupMarker;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.util.Assert;
-
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.WorkbenchException;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-
-import org.eclipse.search.ui.IContextMenuConstants;
-import org.eclipse.search.ui.ISearchResultView;
-import org.eclipse.search.ui.ISearchResultViewEntry;
-import org.eclipse.search.ui.SearchUI;
-
-import org.eclipse.search.internal.ui.util.ExceptionHandler;
-
-import org.eclipse.search2.internal.ui.InternalSearchUI;
-
-/**
- * The plug-in runtime class for Search plug-in
- */
-public class SearchPlugin extends AbstractUIPlugin {
-
- public static final String SEARCH_PAGE_EXTENSION_POINT= "searchPages"; //$NON-NLS-1$
- public static final String SORTER_EXTENSION_POINT= "searchResultSorters"; //$NON-NLS-1$
-
- /** Status code describing an internal error */
- public static final int INTERNAL_ERROR= 1;
-
- private static SearchPlugin fgSearchPlugin;
-
- private List fPageDescriptors;
- private List fSorterDescriptors;
-
- private SearchResultViewEntryAdapterFactory fSearchResultViewEntryAdapterFactory;
-
- public SearchPlugin(IPluginDescriptor descriptor) {
- super(descriptor);
- Assert.isTrue(fgSearchPlugin == null);
- fgSearchPlugin= this;
- }
-
- /**
- * Returns the search plugin instance.
- */
- public static SearchPlugin getDefault() {
- return fgSearchPlugin;
- }
-
- /*
- * Overrides AbstractUIPlugin#initializeDefaultPreferences
- */
- protected void initializeDefaultPreferences(IPreferenceStore store) {
- SearchPreferencePage.initDefaults(store);
- WorkInProgressPreferencePage.initDefaults(store);
- }
-
- /**
- * Returns the active workbench window.
- * <code>null</code> if the active window is not a workbench window
- */
- public static IWorkbenchWindow getActiveWorkbenchWindow() {
- IWorkbenchWindow window= fgSearchPlugin.getWorkbench().getActiveWorkbenchWindow();
- if (window == null) {
- final WindowRef windowRef= new WindowRef();
- Display.getDefault().syncExec(new Runnable() {
- public void run() {
- setActiveWorkbenchWindow(windowRef);
- }
- });
- return windowRef.window;
- }
- else
- return window;
- }
-
- private static class WindowRef {
- public IWorkbenchWindow window;
- }
-
- private static void setActiveWorkbenchWindow(WindowRef windowRef) {
- windowRef.window= null;
- Display display= Display.getCurrent();
- if (display == null)
- return;
- Control shell= display.getActiveShell();
- while (shell != null) {
- Object data= shell.getData();
- if (data instanceof IWorkbenchWindow) {
- windowRef.window= (IWorkbenchWindow)data;
- return;
- }
- shell= shell.getParent();
- }
- Shell shells[]= display.getShells();
- for (int i= 0; i < shells.length; i++) {
- Object data= shells[i].getData();
- if (data instanceof IWorkbenchWindow) {
- windowRef.window= (IWorkbenchWindow)data;
- return;
- }
- }
- }
-
- /**
- * Returns the shell of the active workbench window.
- */
- public static Shell getActiveWorkbenchShell() {
- IWorkbenchWindow window= getActiveWorkbenchWindow();
- if (window != null)
- return window.getShell();
- return null;
- }
-
- /**
- * Beeps using the display of the active workbench window.
- */
- public static void beep() {
- getActiveWorkbenchShell().getDisplay().beep();
- }
-
- /**
- * Returns the active workbench window's currrent page.
- */
- public static IWorkbenchPage getActivePage() {
- return getActiveWorkbenchWindow().getActivePage();
- }
-
- /**
- * Returns the workbench from which this plugin has been loaded.
- */
- public static IWorkspace getWorkspace() {
- return ResourcesPlugin.getWorkspace();
- }
-
- /**
- * Activates the search result view in the active page.
- * This call has no effect, if the search result view is
- * already activated.
- *
- * @return <code>true</code> if the search result view could be activated
- */
- public static boolean activateSearchResultView() {
-
- String defaultPerspectiveId= SearchUI.getDefaultPerspectiveId();
- if (defaultPerspectiveId != null) {
- IWorkbenchWindow window= window= getActiveWorkbenchWindow();
- if (window != null && window.getShell() != null && !window.getShell().isDisposed()) {
- try {
- PlatformUI.getWorkbench().showPerspective(defaultPerspectiveId, window);
- } catch (WorkbenchException ex) {
- // show view in current perspective
- }
- }
- }
-
- try {
- IViewPart viewPart= getActivePage().findView(SearchUI.SEARCH_RESULT_VIEW_ID);
- if (viewPart == null || SearchPreferencePage.isViewBroughtToFront()) {
- return (getActivePage().showView(SearchUI.SEARCH_RESULT_VIEW_ID) != null);
- }
- return true;
- } catch (PartInitException ex) {
- ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.openResultView.title"), SearchMessages.getString("Search.Error.openResultView.message")); //$NON-NLS-2$ //$NON-NLS-1$
- return false;
- }
- }
-
- /**
- * Returns the search result view of the active workbench window. Returns <code>
- * null</code> if the active workbench window doesn't have any search result
- * view.
- */
- public static ISearchResultView getSearchResultView() {
- IViewPart part= getActivePage().findView(SearchUI.SEARCH_RESULT_VIEW_ID);
- if (part instanceof ISearchResultView)
- return (ISearchResultView) part;
- return null;
- }
-
- static void setAutoBuilding(boolean state) {
- IWorkspaceDescription workspaceDesc= getWorkspace().getDescription();
- workspaceDesc.setAutoBuilding(state);
- try {
- getWorkspace().setDescription(workspaceDesc);
- }
- catch (CoreException ex) {
- ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.setDescription.title"), SearchMessages.getString("Search.Error.setDescription.message")); //$NON-NLS-2$ //$NON-NLS-1$
- }
- }
-
-
- public void startup() throws CoreException {
- super.startup();
- registerAdapters();
- }
-
- /**
- * Shuts down this plug-in.
- */
- public void shutdown() throws CoreException {
- InternalSearchUI.getInstance().shutdown();
- unregisterAdapters();
- getWorkspace().removeResourceChangeListener(SearchManager.getDefault());
- super.shutdown();
- fgSearchPlugin = null;
- }
-
- /**
- * Returns all search pages contributed to the workbench.
- */
- public List getSearchPageDescriptors() {
- if (fPageDescriptors == null) {
- IPluginRegistry registry= Platform.getPluginRegistry();
- IConfigurationElement[] elements= registry.getConfigurationElementsFor(SearchUI.PLUGIN_ID, SEARCH_PAGE_EXTENSION_POINT);
- fPageDescriptors= createSearchPageDescriptors(elements);
- }
- return fPageDescriptors;
- }
-
- /**
- * Returns all search pages contributed to the workbench.
- */
- public List getEnabledSearchPageDescriptors(String pageId) {
- Iterator iter= getSearchPageDescriptors().iterator();
- List enabledDescriptors= new ArrayList(5);
- while (iter.hasNext()) {
- SearchPageDescriptor desc= (SearchPageDescriptor)iter.next();
- if (desc.isEnabled() || desc.getId().equals(pageId))
- enabledDescriptors.add(desc);
- }
- return enabledDescriptors;
- }
-
- /**
- * Returns the help context ID for the Search view
- * as provided by the current search page extension.
- *
- * @since 3.0
- */
- public String getSearchViewHelpContextId() {
- Search currentSearch= SearchManager.getDefault().getCurrentSearch();
- if (currentSearch != null) {
- String pageId= currentSearch.getPageId();
- Iterator iter= getSearchPageDescriptors().iterator();
- while (iter.hasNext()) {
- SearchPageDescriptor desc= (SearchPageDescriptor)iter.next();
- if (desc.getId().equals(pageId)) {
- String helpId= desc.getSearchViewHelpContextId();
- if (helpId == null)
- return ISearchHelpContextIds.SEARCH_VIEW;
- else
- return desc.getSearchViewHelpContextId();
- }
- }
- }
- return ISearchHelpContextIds.SEARCH_VIEW;
- }
-
- /**
- * Creates all necessary search page nodes.
- */
- private List createSearchPageDescriptors(IConfigurationElement[] elements) {
- List result= new ArrayList(5);
- for (int i= 0; i < elements.length; i++) {
- IConfigurationElement element= elements[i];
- if (SearchPageDescriptor.PAGE_TAG.equals(element.getName())) {
- SearchPageDescriptor desc= new SearchPageDescriptor(element);
- result.add(desc);
- }
- }
- Collections.sort(result);
- return result;
- }
-
- /**
- * Returns all sorters contributed to the workbench.
- */
- public List getSorterDescriptors() {
- if (fSorterDescriptors == null) {
- IPluginRegistry registry= Platform.getPluginRegistry();
- IConfigurationElement[] elements= registry.getConfigurationElementsFor(SearchUI.PLUGIN_ID, SORTER_EXTENSION_POINT);
- fSorterDescriptors= createSorterDescriptors(elements);
- }
- return fSorterDescriptors;
- }
-
- /**
- * Creates all necessary sorter description nodes.
- */
- private List createSorterDescriptors(IConfigurationElement[] elements) {
- List result= new ArrayList(5);
- for (int i= 0; i < elements.length; i++) {
- IConfigurationElement element= elements[i];
- if (SorterDescriptor.SORTER_TAG.equals(element.getName()))
- result.add(new SorterDescriptor(element));
- }
- return result;
- }
-
- /**
- * Log status to platform log
- */
- public static void log(IStatus status) {
- getDefault().getLog().log(status);
- }
-
- public static void log(Throwable e) {
- log(new Status(IStatus.ERROR, SearchUI.PLUGIN_ID, INTERNAL_ERROR, SearchMessages.getString("SearchPlugin.internal_error"), e)); //$NON-NLS-1$
- }
-
- public static String getID() {
- return getDefault().getDescriptor().getUniqueIdentifier();
- }
-
- /**
- * Creates the Search plugin standard groups in a context menu.
- */
- public static void createStandardGroups(IMenuManager menu) {
- if (!menu.isEmpty())
- return;
- menu.add(new Separator(IContextMenuConstants.GROUP_NEW));
- menu.add(new GroupMarker(IContextMenuConstants.GROUP_GOTO));
- menu.add(new GroupMarker(IContextMenuConstants.GROUP_OPEN));
- menu.add(new Separator(IContextMenuConstants.GROUP_SHOW));
- menu.add(new Separator(IContextMenuConstants.GROUP_BUILD));
- menu.add(new Separator(IContextMenuConstants.GROUP_REORGANIZE));
- menu.add(new Separator(IContextMenuConstants.GROUP_REMOVE_MATCHES));
- menu.add(new GroupMarker(IContextMenuConstants.GROUP_GENERATE));
- menu.add(new Separator(IContextMenuConstants.GROUP_SEARCH));
- menu.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS));
- menu.add(new Separator(IContextMenuConstants.GROUP_VIEWER_SETUP));
- menu.add(new Separator(IContextMenuConstants.GROUP_PROPERTIES));
- }
-
- private void registerAdapters() {
- IAdapterManager manager= Platform.getAdapterManager();
- fSearchResultViewEntryAdapterFactory= new SearchResultViewEntryAdapterFactory();
- manager.registerAdapters(fSearchResultViewEntryAdapterFactory, ISearchResultViewEntry.class);
- }
-
- private void unregisterAdapters() {
- IAdapterManager manager= Platform.getAdapterManager();
- manager.unregisterAdapters(fSearchResultViewEntryAdapterFactory);
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPluginImages.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPluginImages.java
deleted file mode 100644
index a967460..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPluginImages.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.eclipse.swt.graphics.Image;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.resource.ImageRegistry;
-
-import org.eclipse.search.internal.ui.util.ExceptionHandler;
-
-/**
- * Bundle of all images used by the Search UI plugin.
- */
-public class SearchPluginImages {
-
- private static URL fgIconLocation;
-
- static {
- String pathSuffix= "icons/full/"; //$NON-NLS-1$
- try {
- fgIconLocation= new URL(SearchPlugin.getDefault().getDescriptor().getInstallURL(), pathSuffix);
- } catch (MalformedURLException ex) {
- ExceptionHandler.log(ex, SearchMessages.getString("Search.Error.incorrectIconLocation.message")); //$NON-NLS-1$
- }
- }
-
- // The plugin registry
- private final static ImageRegistry PLUGIN_REGISTRY= SearchPlugin.getDefault().getImageRegistry();
-
- public static final String T_OBJ= "obj16/"; //$NON-NLS-1$
- public static final String T_WIZBAN= "wizban/"; //$NON-NLS-1$
- public static final String T_LCL= "lcl16/"; //$NON-NLS-1$
- public static final String T_TOOL= "tool16/"; //$NON-NLS-1$
- public static final String T_VIEW= "view16/"; //$NON-NLS-1$
-
- private static final String NAME_PREFIX= "org.eclipse.search.ui."; //$NON-NLS-1$
- private static final int NAME_PREFIX_LENGTH= NAME_PREFIX.length();
-
- // Define image names
- public static final String IMG_TOOL_SEARCH= NAME_PREFIX + "search.gif"; //$NON-NLS-1$
-
- public static final String IMG_LCL_SEARCH_REM= NAME_PREFIX + "search_rem.gif"; //$NON-NLS-1$
- public static final String IMG_LCL_SEARCH_REM_ALL= NAME_PREFIX + "search_remall.gif"; //$NON-NLS-1$
- public static final String IMG_LCL_SEARCH_NEXT= NAME_PREFIX + "search_next.gif"; //$NON-NLS-1$
- public static final String IMG_LCL_SEARCH_PREV= NAME_PREFIX + "search_prev.gif"; //$NON-NLS-1$
- public static final String IMG_LCL_SEARCH_GOTO= NAME_PREFIX + "search_goto.gif"; //$NON-NLS-1$
- public static final String IMG_LCL_SEARCH_SORT= NAME_PREFIX + "search_sortmatch.gif"; //$NON-NLS-1$
- public static final String IMG_LCL_SEARCH_HISTORY= NAME_PREFIX + "search_history.gif"; //$NON-NLS-1$
- public static final String IMG_LCL_SEARCH_FLAT_LAYOUT= NAME_PREFIX + "flatLayout.gif"; //$NON-NLS-1$
- public static final String IMG_LCL_SEARCH_HIERARCHICAL_LAYOUT= NAME_PREFIX + "hierarchicalLayout.gif"; //$NON-NLS-1$
- public static final String IMG_LCL_SEARCH_CANCEL= NAME_PREFIX + "stop.gif"; //$NON-NLS-1$
-
- public static final String IMG_VIEW_SEARCHRES= NAME_PREFIX + "searchres.gif"; //$NON-NLS-1$
-
- public static final String IMG_OBJ_TSEARCH= NAME_PREFIX + "tsearch_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_TSEARCH_DPDN= NAME_PREFIX + "tsearch_dpdn_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_SEARCHMARKER= NAME_PREFIX + "searchm_obj.gif"; //$NON-NLS-1$
-
-
-
- // Define images
- public static final ImageDescriptor DESC_OBJ_TSEARCH= createManaged(T_OBJ, IMG_OBJ_TSEARCH);
- public static final ImageDescriptor DESC_OBJ_TSEARCH_DPDN= createManaged(T_OBJ, IMG_OBJ_TSEARCH_DPDN);
- public static final ImageDescriptor DESC_OBJ_SEARCHMARKER= createManaged(T_OBJ, IMG_OBJ_SEARCHMARKER);
-
- public static Image get(String key) {
- return PLUGIN_REGISTRY.get(key);
- }
-
- private static ImageDescriptor createManaged(String prefix, String name) {
- ImageDescriptor result= ImageDescriptor.createFromURL(makeIconFileURL(prefix, name.substring(NAME_PREFIX_LENGTH)));
- PLUGIN_REGISTRY.put(name, result);
- return result;
- }
-
- private static ImageDescriptor create(String prefix, String name) {
- return ImageDescriptor.createFromURL(makeIconFileURL(prefix, name));
- }
-
- private static URL makeIconFileURL(String prefix, String name) {
- StringBuffer buffer= new StringBuffer(prefix);
- buffer.append(name);
- try {
- return new URL(fgIconLocation, buffer.toString());
- } catch (MalformedURLException ex) {
- ExceptionHandler.log(ex, SearchMessages.getString("Search.Error.incorrectIconLocation.message")); //$NON-NLS-1$
- return null;
- }
- }
-
- /**
- * Sets all available image descriptors for the given action.
- */
- public static void setImageDescriptors(IAction action, String type, String relPath) {
- relPath= relPath.substring(NAME_PREFIX_LENGTH);
- action.setDisabledImageDescriptor(create("d" + type, relPath)); //$NON-NLS-1$
- action.setHoverImageDescriptor(create("c" + type, relPath)); //$NON-NLS-1$
- action.setImageDescriptor(create("e" + type, relPath)); //$NON-NLS-1$
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPreferencePage.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPreferencePage.java
deleted file mode 100644
index f07ae46..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPreferencePage.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import java.text.Collator;
-import java.util.Arrays;
-import java.util.Comparator;
-
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Composite;
-
-import org.eclipse.jface.preference.BooleanFieldEditor;
-import org.eclipse.jface.preference.ColorFieldEditor;
-import org.eclipse.jface.preference.FieldEditorPreferencePage;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.jface.util.PropertyChangeEvent;
-
-import org.eclipse.ui.IPerspectiveDescriptor;
-import org.eclipse.ui.IPerspectiveRegistry;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-import org.eclipse.search.internal.ui.util.ComboFieldEditor;
-
-/*
- * The page for setting the Search preferences.
- */
-public class SearchPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
-
- public static final String IGNORE_POTENTIAL_MATCHES= "org.eclipse.search.potentialMatch.ignore"; //$NON-NLS-1$
- public static final String EMPHASIZE_POTENTIAL_MATCHES= "org.eclipse.search.potentialMatch.emphasize"; //$NON-NLS-1$
- public static final String POTENTIAL_MATCH_FG_COLOR= "org.eclipse.search.potentialMatch.fgColor"; //$NON-NLS-1$
- public static final String REUSE_EDITOR= "org.eclipse.search.reuseEditor"; //$NON-NLS-1$
- public static final String DEFAULT_PERSPECTIVE= "org.eclipse.search.defaultPerspective"; //$NON-NLS-1$
- private static final String NO_DEFAULT_PERSPECTIVE= "org.eclipse.search.defaultPerspective.none"; //$NON-NLS-1$
- public static final String BRING_VIEW_TO_FRONT= "org.eclipse.search.bringToFront"; //$NON-NLS-1$
-
- private ColorFieldEditor fColorEditor;
- private BooleanFieldEditor fEmphasizedCheckbox;
- private BooleanFieldEditor fIgnorePotentialMatchesCheckbox;
-
-
- private static class PerspectiveDescriptorComparator implements Comparator {
- /*
- * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
- */
- public int compare(Object o1, Object o2) {
- if (o1 instanceof IPerspectiveDescriptor && o2 instanceof IPerspectiveDescriptor) {
- String id1= ((IPerspectiveDescriptor)o1).getLabel();
- String id2= ((IPerspectiveDescriptor)o2).getLabel();
- return Collator.getInstance().compare(id1, id2);
- }
- return 0;
- }
- }
-
-
-
- public SearchPreferencePage() {
- super(GRID);
- setPreferenceStore(SearchPlugin.getDefault().getPreferenceStore());
- }
-
- public static void initDefaults(IPreferenceStore store) {
- RGB gray= new RGB(85, 85, 85);
- store.setDefault(EMPHASIZE_POTENTIAL_MATCHES, true);
- store.setDefault(IGNORE_POTENTIAL_MATCHES, false);
- PreferenceConverter.setDefault(store, POTENTIAL_MATCH_FG_COLOR, gray);
- store.setDefault(REUSE_EDITOR, false);
- store.setDefault(BRING_VIEW_TO_FRONT, true);
- store.setDefault(DEFAULT_PERSPECTIVE, NO_DEFAULT_PERSPECTIVE);
- }
-
- public static boolean isEditorReused() {
- IPreferenceStore store= SearchPlugin.getDefault().getPreferenceStore();
- return store.getBoolean(REUSE_EDITOR);
- }
-
- public static boolean isViewBroughtToFront() {
- IPreferenceStore store= SearchPlugin.getDefault().getPreferenceStore();
- return store.getBoolean(BRING_VIEW_TO_FRONT);
-
- }
-
- public static String getDefaultPerspectiveId() {
- handleDeletedPerspectives();
- IPreferenceStore store= SearchPlugin.getDefault().getPreferenceStore();
- String id= store.getString(DEFAULT_PERSPECTIVE);
- if (id == null || id.length() == 0 || id.equals(NO_DEFAULT_PERSPECTIVE))
- return null;
- else if (PlatformUI.getWorkbench().getPerspectiveRegistry().findPerspectiveWithId(id) == null) {
- store.putValue(DEFAULT_PERSPECTIVE, id);
- return null;
- }
- return id;
- }
-
- public static boolean arePotentialMatchesIgnored() {
- IPreferenceStore store= SearchPlugin.getDefault().getPreferenceStore();
- return store.getBoolean(IGNORE_POTENTIAL_MATCHES);
- }
-
- public static boolean arePotentialMatchesEmphasized() {
- IPreferenceStore store= SearchPlugin.getDefault().getPreferenceStore();
- return store.getBoolean(EMPHASIZE_POTENTIAL_MATCHES);
- }
-
- public static RGB getPotentialMatchForegroundColor() {
- IPreferenceStore store= SearchPlugin.getDefault().getPreferenceStore();
- return PreferenceConverter.getColor(store, POTENTIAL_MATCH_FG_COLOR);
- }
-
- public void createControl(Composite parent) {
- super.createControl(parent);
- WorkbenchHelp.setHelp(getControl(), ISearchHelpContextIds.SEARCH_PREFERENCE_PAGE);
- }
-
- protected void createFieldEditors() {
- BooleanFieldEditor boolEditor= new BooleanFieldEditor(
- REUSE_EDITOR,
- SearchMessages.getString("SearchPreferencePage.reuseEditor"), //$NON-NLS-1$
- getFieldEditorParent()
- );
- addField(boolEditor);
-
- boolEditor= new BooleanFieldEditor(
- BRING_VIEW_TO_FRONT,
- SearchMessages.getString("SearchPreferencePage.bringToFront"), //$NON-NLS-1$
- getFieldEditorParent()
- );
- addField(boolEditor);
-
- fIgnorePotentialMatchesCheckbox= new BooleanFieldEditor(
- IGNORE_POTENTIAL_MATCHES,
- SearchMessages.getString("SearchPreferencePage.ignorePotentialMatches"), //$NON-NLS-1$
- getFieldEditorParent());
- addField(fIgnorePotentialMatchesCheckbox);
-
- fEmphasizedCheckbox= new BooleanFieldEditor(
- EMPHASIZE_POTENTIAL_MATCHES,
- SearchMessages.getString("SearchPreferencePage.emphasizePotentialMatches"), //$NON-NLS-1$
- getFieldEditorParent());
- addField(fEmphasizedCheckbox);
-
- fColorEditor= new ColorFieldEditor(
- POTENTIAL_MATCH_FG_COLOR,
- SearchMessages.getString("SearchPreferencePage.potentialMatchFgColor"), //$NON-NLS-1$
- getFieldEditorParent()
- );
- addField(fColorEditor);
-
- fEmphasizedCheckbox.setEnabled(!arePotentialMatchesIgnored(), getFieldEditorParent());
- fColorEditor.setEnabled(!arePotentialMatchesIgnored() && arePotentialMatchesEmphasized(), getFieldEditorParent());
-
- handleDeletedPerspectives();
- String[][] perspectiveNamesAndIds = getPerspectiveNamesAndIds();
- ComboFieldEditor comboEditor= new ComboFieldEditor(
- DEFAULT_PERSPECTIVE,
- SearchMessages.getString("SearchPreferencePage.defaultPerspective"), //$NON-NLS-1$
- perspectiveNamesAndIds,
- getFieldEditorParent());
- addField(comboEditor);
- }
-
- public void setVisible(boolean state) {
- handleDeletedPerspectives();
- super.setVisible(state);
- }
-
- public void propertyChange(PropertyChangeEvent event) {
- boolean arePotentialMatchesIgnored= fIgnorePotentialMatchesCheckbox.getBooleanValue();
- fEmphasizedCheckbox.setEnabled(!arePotentialMatchesIgnored, getFieldEditorParent());
- fColorEditor.setEnabled(!arePotentialMatchesIgnored && fEmphasizedCheckbox.getBooleanValue(), getFieldEditorParent());
- }
-
- public void init(IWorkbench workbench) {
- }
-
- protected void performDefaults() {
- super.performDefaults();
- boolean arePotentialMatchesIgnored= fIgnorePotentialMatchesCheckbox.getBooleanValue();
- fEmphasizedCheckbox.setEnabled(!arePotentialMatchesIgnored, getFieldEditorParent());
- fColorEditor.setEnabled(!arePotentialMatchesIgnored && fEmphasizedCheckbox.getBooleanValue(), getFieldEditorParent());
- }
-
- /**
- * Return a 2-dimensional array of perspective names and ids.
- */
- private String[][] getPerspectiveNamesAndIds() {
-
- IPerspectiveRegistry registry= PlatformUI.getWorkbench().getPerspectiveRegistry();
- IPerspectiveDescriptor[] perspectiveDescriptors= registry.getPerspectives();
-
- Arrays.sort(perspectiveDescriptors, new PerspectiveDescriptorComparator());
-
- String[][] table = new String[perspectiveDescriptors.length + 1][2];
- table[0][0] = SearchMessages.getString("SearchPreferencePage.defaultPerspective.none"); //$NON-NLS-1$;
- table[0][1] = NO_DEFAULT_PERSPECTIVE;
- for (int i = 0; i < perspectiveDescriptors.length; i++) {
- table[i + 1][0] = perspectiveDescriptors[i].getLabel();
- table[i + 1][1] = perspectiveDescriptors[i].getId();
- }
- return table;
- }
-
- private static void handleDeletedPerspectives() {
- IPreferenceStore store= SearchPlugin.getDefault().getPreferenceStore();
- String id= store.getString(DEFAULT_PERSPECTIVE);
- if (PlatformUI.getWorkbench().getPerspectiveRegistry().findPerspectiveWithId(id) == null) {
- store.putValue(DEFAULT_PERSPECTIVE, NO_DEFAULT_PERSPECTIVE);
- }
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultContentProvider.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultContentProvider.java
deleted file mode 100644
index 86f69cf..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultContentProvider.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import java.util.ArrayList;
-
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-
-class SearchResultContentProvider implements IStructuredContentProvider {
-
- private static final Object[] fgEmptyArray= new Object[0];
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- // Do nothing since the viewer listens to resource deltas
- }
-
- public void dispose() {
- }
-
- public boolean isDeleted(Object element) {
- return false;
- }
-
- public Object[] getElements(Object element) {
- if (element instanceof ArrayList)
- return ((ArrayList)element).toArray();
- else
- return fgEmptyArray;
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultLabelProvider.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultLabelProvider.java
deleted file mode 100644
index c55d2ef..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultLabelProvider.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import org.eclipse.swt.graphics.Image;
-
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.LabelProvider;
-
-import org.eclipse.ui.PlatformUI;
-
-import org.eclipse.search.ui.ISearchResultViewEntry;
-
-class SearchResultLabelProvider extends LabelProvider {
-
- private static final String MATCHES_POSTFIX= " " + SearchMessages.getString("SearchResultView.matches") + ")"; //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$
-
- private ILabelProvider fLabelProvider;
-
-
- SearchResultLabelProvider(ILabelProvider provider) {
- fLabelProvider= provider;
- }
-
- public String getText(Object element) {
- StringBuffer buf= new StringBuffer(getLabelProvider().getText(element));
- int count= ((ISearchResultViewEntry)element).getMatchCount();
- if (count > 1) {
- buf.append(" ("); //$NON-NLS-1$
- buf.append(count);
- buf.append(MATCHES_POSTFIX);
- }
- return buf.toString();
- }
-
- public Image getImage(Object element) {
- return fLabelProvider.getImage(element);
- }
-
- // Don't dispose since label providers are reused.
- public void dispose() {
- }
-
- ILabelProvider getLabelProvider() {
- return fLabelProvider;
- }
-
- public void addListener(ILabelProviderListener listener) {
- super.addListener(listener);
- fLabelProvider.addListener(listener);
- PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator().addListener(listener);
- }
-
- public boolean isLabelProperty(Object element, String property) {
- return fLabelProvider.isLabelProperty(element, property);
- }
-
- public void removeListener(ILabelProviderListener listener) {
- super.removeListener(listener);
- fLabelProvider.removeListener(listener);
- PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator().removeListener(listener);
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultView.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultView.java
deleted file mode 100644
index 8fc92a4..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultView.java
+++ /dev/null
@@ -1,325 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.IBaseLabelProvider;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ISelection;
-
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IViewSite;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.ui.part.CellEditorActionHandler;
-import org.eclipse.ui.part.ViewPart;
-
-import org.eclipse.search.ui.IActionGroupFactory;
-import org.eclipse.search.ui.IContextMenuContributor;
-import org.eclipse.search.ui.IGroupByKeyComputer;
-import org.eclipse.search.ui.ISearchResultView;
-
-
-public class SearchResultView extends ViewPart implements ISearchResultView {
-
-
- private static Map fgLabelProviders= new HashMap(5);
-
- private SearchResultViewer fViewer;
- private Map fResponse;
- private IMemento fMemento;
- private IPropertyChangeListener fPropertyChangeListener;
- private CellEditorActionHandler fCellEditorActionHandler;
- private SelectAllAction fSelectAllAction;
-
- /*
- * Implements method from IViewPart.
- */
- public void init(IViewSite site, IMemento memento) throws PartInitException {
- super.init(site, memento);
- fMemento= memento;
- }
-
- /*
- * Implements method from IViewPart.
- */
- public void saveState(IMemento memento) {
- if (fViewer == null) {
- // part has not been created
- if (fMemento != null) //Keep the old state;
- memento.putMemento(fMemento);
- return;
- }
- fViewer.saveState(memento);
- }
-
- /**
- * Creates the search list inner viewer.
- */
- public void createPartControl(Composite parent) {
- Assert.isTrue(fViewer == null);
- fViewer= new SearchResultViewer(this, parent);
- if (fMemento != null)
- fViewer.restoreState(fMemento);
- fMemento= null;
- SearchManager.getDefault().addSearchChangeListener(fViewer);
- fViewer.init();
-
- // Add selectAll action handlers.
- fCellEditorActionHandler = new CellEditorActionHandler(getViewSite().getActionBars());
- fSelectAllAction= new SelectAllAction(fViewer);
- fCellEditorActionHandler.setSelectAllAction(fSelectAllAction);
-
- fillActionBars(getViewSite().getActionBars());
-
- fPropertyChangeListener= new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- if (SearchPreferencePage.POTENTIAL_MATCH_FG_COLOR.equals(event.getProperty()) || SearchPreferencePage.EMPHASIZE_POTENTIAL_MATCHES.equals(event.getProperty()))
- if (fViewer != null)
- fViewer.updatedPotentialMatchFgColor();
- }
- };
-
- SearchPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(fPropertyChangeListener);
-
- WorkbenchHelp.setHelp(fViewer.getControl(), SearchPlugin.getDefault().getSearchViewHelpContextId());
- }
-
- /**
- * Returns the search result viewer.
- */
- public SearchResultViewer getViewer() {
- return fViewer;
- }
-
- //---- IWorkbenchPart ------------------------------------------------------
-
-
- public void setFocus() {
- fViewer.getControl().setFocus();
- }
-
- public void dispose() {
- if (fViewer != null) {
- SearchManager.getDefault().removeSearchChangeListener(fViewer);
- fViewer= null;
- }
- if (fPropertyChangeListener != null)
- SearchPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPropertyChangeListener);
- if (fCellEditorActionHandler != null) {
- fCellEditorActionHandler.dispose();
- fCellEditorActionHandler= null;
- }
- super.dispose();
- }
-
- protected void setTitle(String title) {
- super.setTitle(title);
- }
-
- protected void setTitleToolTip(String text) {
- super.setTitleToolTip(text);
- }
-
- //---- Adding Action to Toolbar -------------------------------------------
-
- private void fillActionBars(IActionBars actionBars) {
- IToolBarManager toolBar= actionBars.getToolBarManager();
- fillToolBar(toolBar);
- actionBars.updateActionBars();
-
- // Add selectAll action handlers.
- actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), fSelectAllAction);
- }
-
- private void fillToolBar(IToolBarManager tbm) {
- fViewer.fillToolBar(tbm);
- }
-
- ILabelProvider getLabelProvider(String pageId) {
- if (pageId != null)
- return (ILabelProvider)fgLabelProviders.get(pageId);
- return null;
- }
-
- public ILabelProvider getLabelProvider() {
- if (fViewer == null)
- return null;
- IBaseLabelProvider labelProvider= fViewer.getLabelProvider();
- if (labelProvider == null)
- return null;
-
- return ((SearchResultLabelProvider)labelProvider).getLabelProvider();
- }
-
- private void setGotoMarkerAction(final IAction gotoMarkerAction) {
- // Make sure we are doing it in the right thread.
- getDisplay().syncExec(new Runnable() {
- public void run() {
- getViewer().setGotoMarkerAction(gotoMarkerAction);
- }
- });
- }
-
-
- Display getDisplay() {
- return fViewer.getControl().getDisplay();
- }
-
-
- //---- ISearchResultView --------------------------------------------------
-
-
- /*
- * Implements method from ISearchResultView
- */
- public ISelection getSelection() {
- return fViewer.getSelection();
- }
-
- /*
- * Implements method from ISearchResultView
- */
- public void searchStarted(
- IActionGroupFactory groupFactory,
- String singularLabel,
- String pluralLabelPattern,
- ImageDescriptor imageDescriptor,
- String pageId,
- ILabelProvider labelProvider,
- IAction gotoAction,
- IGroupByKeyComputer groupByKeyComputer,
- IRunnableWithProgress operation) {
-
-
- Assert.isNotNull(pageId);
- Assert.isNotNull(pluralLabelPattern);
- Assert.isNotNull(gotoAction);
-
- fResponse= new HashMap(500);
- setGotoMarkerAction(gotoAction);
-
- ILabelProvider oldLabelProvider= (ILabelProvider)fgLabelProviders.get(pageId);
- if (oldLabelProvider != null)
- oldLabelProvider.dispose();
- fgLabelProviders.put(pageId, labelProvider);
-
- SearchManager.getDefault().addNewSearch(
- new Search(
- pageId,
- singularLabel,
- pluralLabelPattern,
- null,
- imageDescriptor,
- fViewer.getGotoMarkerAction(),
- groupFactory,
- groupByKeyComputer,
- operation));
- }
-
- /**
- * Implements method from ISearchResultView
- * @deprecated As of build > 20011107, replaced by the new version with additonal parameter
- */
- public void searchStarted(
- String pageId,
- String label,
- ImageDescriptor imageDescriptor,
- IContextMenuContributor contributor,
- ILabelProvider labelProvider,
- IAction gotoAction,
- IGroupByKeyComputer groupByKeyComputer,
- IRunnableWithProgress operation) {
-
- searchStarted(pageId, null, label, imageDescriptor, contributor, labelProvider, gotoAction, groupByKeyComputer, operation);
- }
-
- /**
- * Implements method from ISearchResultView
- * @deprecated As of build > 20020514
- */
- public void searchStarted(
- String pageId,
- String singularLabel,
- String pluralLabelPattern,
- ImageDescriptor imageDescriptor,
- IContextMenuContributor contributor,
- ILabelProvider labelProvider,
- IAction gotoAction,
- IGroupByKeyComputer groupByKeyComputer,
- IRunnableWithProgress operation) {
-
-
- Assert.isNotNull(pageId);
- Assert.isNotNull(pluralLabelPattern);
- Assert.isNotNull(gotoAction);
-
- fResponse= new HashMap(500);
- setGotoMarkerAction(gotoAction);
-
- ILabelProvider oldLabelProvider= (ILabelProvider)fgLabelProviders.get(pageId);
- if (oldLabelProvider != null)
- oldLabelProvider.dispose();
- fgLabelProviders.put(pageId, labelProvider);
-
- SearchManager.getDefault().addNewSearch(
- new Search(
- pageId,
- singularLabel,
- pluralLabelPattern,
- null,
- imageDescriptor,
- fViewer.getGotoMarkerAction(),
- contributor,
- groupByKeyComputer,
- operation));
- }
-
- /*
- * Implements method from ISearchResultView
- */
- public void addMatch(String description, Object groupByKey, IResource resource, IMarker marker) {
- SearchResultViewEntry entry= (SearchResultViewEntry)fResponse.get(groupByKey);
- if (entry == null) {
- entry= new SearchResultViewEntry(groupByKey, resource);
- fResponse.put(groupByKey, entry);
- }
- entry.add(marker);
- }
-
-
- /*
- * Implements method from ISearchResultView
- */
- public void searchFinished() {
- SearchManager.getDefault().searchFinished(new ArrayList(fResponse.values()));
- fResponse= null;
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewEntry.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewEntry.java
deleted file mode 100644
index 9d536a3..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewEntry.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.PlatformObject;
-
-import org.eclipse.search.ui.ISearchResultViewEntry;
-import org.eclipse.search.ui.SearchUI;
-
-/**
- * Represents an entry in the search result view
- */
-public class SearchResultViewEntry extends PlatformObject implements ISearchResultViewEntry {
-
- private Object fGroupByKey= null;
- private IResource fResource= null;
- private IMarker fMarker= null;
- private ArrayList fMarkers= null;
- private ArrayList fAttributes;
- private int fSelectedMarkerIndex;
- private long fModificationStamp= IResource.NULL_STAMP;
- private String fMarkerType;
-
- public SearchResultViewEntry(Object groupByKey, IResource resource) {
- fGroupByKey= groupByKey;
- fResource= resource;
- if (fResource != null)
- fModificationStamp= fResource.getModificationStamp();
- }
-
- //---- Accessors ------------------------------------------------
- public Object getGroupByKey() {
- return fGroupByKey;
- }
-
- void setGroupByKey(Object groupByKey) {
- fGroupByKey= groupByKey;
- }
-
- public IResource getResource() {
- return fResource;
- }
-
- public int getMatchCount() {
- if (fMarkers != null)
- return fMarkers.size();
- if (fMarkers == null && fMarker != null)
- return 1;
- return 0;
- }
-
- boolean isPotentialMatch() {
- if (fMarker != null)
- return fMarker.getAttribute(SearchUI.POTENTIAL_MATCH, false);
- return false;
- }
-
- List getAttributesPerMarker() {
- if (fAttributes == null)
- return new ArrayList(0);
- return fAttributes;
- }
-
- public long getModificationStamp() {
- return fModificationStamp;
- }
-
- void clearMarkerList() {
- fMarker= null;
- if (fMarkers != null)
- fMarkers.clear();
- }
-
- void add(IMarker marker) {
- if (marker != null && fMarkerType == null) {
- try {
- fMarkerType= marker.getType();
- } catch (CoreException ex) {
- // will default to org.eclipse.search.searchmarker
- }
- }
-
- if (fMarker == null) {
- fMarker= marker;
- if (fMarkers != null)
- fMarkers.add(marker);
- return;
- }
- if (fMarkers == null) {
- fMarkers= new ArrayList(10);
- addByStartpos(fMarkers, fMarker);
- }
- addByStartpos(fMarkers, marker);
- }
-
- void setSelectedMarkerIndex(int index) {
- fSelectedMarkerIndex= index;
- }
-
- public IMarker getSelectedMarker() {
- fSelectedMarkerIndex= Math.min(fSelectedMarkerIndex, getMatchCount() - 1);
- if (fMarkers == null && fMarker == null)
- return null;
- if (fMarkers != null && fSelectedMarkerIndex >= 0)
- return (IMarker)fMarkers.get(fSelectedMarkerIndex);
- return fMarker;
- }
-
- public List getMarkers() {
- if (fMarkers == null && fMarker == null)
- return new ArrayList(0);
- else if (fMarkers == null && fMarker != null) {
- List markers= new ArrayList(1);
- markers.add(fMarker);
- return markers;
- }
- return fMarkers;
- }
-
- String getMarkerType() {
- if (fMarkerType == null)
- return SearchUI.SEARCH_MARKER;
- else
- return fMarkerType;
- }
-
- boolean contains(IMarker marker) {
- if (fMarkers == null && fMarker == null)
- return false;
- if (fMarkers == null)
- return fMarker.equals(marker);
- else
- return fMarkers.contains(marker);
- }
-
- void remove(IMarker marker) {
- if (marker == null)
- return;
-
- if (fMarkers == null) {
- if (fMarker != null && fMarker.equals(marker))
- fMarker= null;
- }
- else {
- fMarkers.remove(marker);
- if (fMarkers.size() == 1) {
- fMarker= (IMarker)fMarkers.get(0);
- fMarkers= null;
- }
- }
- }
-
- void backupMarkers() {
- if (fResource != null)
- fModificationStamp= fResource.getModificationStamp();
- List markers= getMarkers();
- fAttributes= new ArrayList(markers.size());
- Iterator iter= markers.iterator();
- while (iter.hasNext()) {
- IMarker marker= (IMarker)iter.next();
- Map attributes= null;
- try {
- attributes= marker.getAttributes();
- } catch (CoreException ex) {
- // don't backup corrupt marker
- continue;
- }
- fAttributes.add(attributes);
- }
- }
-
- private void addByStartpos(ArrayList markers, IMarker marker) {
- int startPos= marker.getAttribute(IMarker.CHAR_START, -1);
- int i= 0;
- int markerCount= markers.size();
- while (i < markerCount && startPos >= ((IMarker)markers.get(i)).getAttribute(IMarker.CHAR_START, -1))
- i++;
- markers.add(i, marker);
- if (i == 0)
- fMarker= marker;
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewEntryAdapterFactory.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewEntryAdapterFactory.java
deleted file mode 100644
index 7acaaf1..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewEntryAdapterFactory.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.search.internal.ui;
-
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IAdapterFactory;
-
-import org.eclipse.search.ui.ISearchResultViewEntry;
-
-/**
- * Implements basic UI support for Java elements.
- * Implements handle to persistent support for Java elements.
- */
-public class SearchResultViewEntryAdapterFactory implements IAdapterFactory {
-
- private static Class[] PROPERTIES= new Class[] {
- IResource.class,
- };
-
-
- public Class[] getAdapterList() {
- return PROPERTIES;
- }
-
- public Object getAdapter(Object element, Class key) {
-
- ISearchResultViewEntry entry= (ISearchResultViewEntry)element;
-
- if (IResource.class.equals(key)) {
- IResource resource= entry.getResource();
- /*
- * This is a trick to filter out dummy markers that
- * have been attached to a project because there is no
- * corresponding resource in the workspace.
- */
- int type= resource.getType();
- if (type != IResource.PROJECT && type != IResource.ROOT)
- return resource;
- }
- return null;
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewer.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewer.java
deleted file mode 100644
index d9e07df..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewer.java
+++ /dev/null
@@ -1,728 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IPath;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Item;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.swt.widgets.Widget;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.viewers.IBaseLabelProvider;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.IOpenListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.LabelProviderChangedEvent;
-import org.eclipse.jface.viewers.OpenEvent;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TableViewer;
-
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.actions.ActionContext;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.actions.ActionGroup;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-import org.eclipse.search.ui.IActionGroupFactory;
-import org.eclipse.search.ui.IContextMenuConstants;
-import org.eclipse.search.ui.IContextMenuContributor;
-import org.eclipse.search.ui.ISearchResultViewEntry;
-import org.eclipse.search.ui.SearchUI;
-
-import org.eclipse.search.internal.ui.util.FileLabelProvider;
-
-
-/**
- * A special viewer to present search results. The viewer implements an
- * optimized adding and removing strategy. Furthermore it manages
- * contributions for search result types. For example the viewer's context
- * menu differs if the search result has been generated by a text or
- * a java search.
- */
-public class SearchResultViewer extends TableViewer {
-
- private SearchResultView fOuterPart;
- private ShowNextResultAction fShowNextResultAction;
- private ShowPreviousResultAction fShowPreviousResultAction;
- private GotoMarkerAction fGotoMarkerActionProxy;
- private SearchAgainAction fSearchAgainAction;
- private RemoveResultAction fRemoveSelectedMatchesAction;
- private RemoveAllResultsAction fRemoveAllResultsAction;
- private SortDropDownAction fSortDropDownAction;
- private SearchDropDownAction fSearchDropDownAction;
- private CopyToClipboardAction fCopyToClipboardAction;
- private int fMarkerToShow;
- private boolean fHandleSelectionChangedEvents= true;
- private ISelection fLastSelection;
- private boolean fCurrentMatchRemoved= false;
- private Color fPotentialMatchFgColor;
- private ActionGroup fActionGroup;
- private IContextMenuContributor fContextMenuContributor;
- private IAction fGotoMarkerAction;
-
- private ResourceToItemsMapper fResourceToItemsMapper;
- private String fCurrentPageId= null;
-
- public SearchResultViewer(SearchResultView outerPart, Composite parent) {
- super(new Table(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION));
-
- fResourceToItemsMapper= new ResourceToItemsMapper(this);
-
- fOuterPart= outerPart;
- Assert.isNotNull(fOuterPart);
-
- if (SearchPreferencePage.arePotentialMatchesEmphasized())
- fPotentialMatchFgColor= new Color(SearchPlugin.getActiveWorkbenchShell().getDisplay(), SearchPreferencePage.getPotentialMatchForegroundColor());
-
- setUseHashlookup(true);
- setContentProvider(new SearchResultContentProvider());
-
- ILabelProvider labelProvider= new SearchResultLabelProvider(new FileLabelProvider(FileLabelProvider.SHOW_LABEL));
- setLabelProvider(labelProvider);
-
- Search currentSearch= SearchManager.getDefault().getCurrentSearch();
- boolean hasSearch= currentSearch != null;
- boolean hasSearchOperation= hasSearch && currentSearch.getOperation() != null;
-
- fShowNextResultAction= new ShowNextResultAction(this);
- fShowNextResultAction.setEnabled(false);
- fShowPreviousResultAction= new ShowPreviousResultAction(this);
- fShowPreviousResultAction.setEnabled(false);
- fGotoMarkerActionProxy= new GotoMarkerAction(this);
- fGotoMarkerActionProxy.setEnabled(false);
- fRemoveSelectedMatchesAction= new RemoveResultAction(this, false);
- fRemoveSelectedMatchesAction.setEnabled(false);
- fRemoveAllResultsAction= new RemoveAllResultsAction();
- fRemoveAllResultsAction.setEnabled(false);
- fSearchAgainAction= new SearchAgainAction();
- fSearchAgainAction.setEnabled(hasSearchOperation);
- fSortDropDownAction = new SortDropDownAction(this);
- fSortDropDownAction.setEnabled(getItemCount() > 0);
- fSearchDropDownAction= new SearchDropDownAction();
- fSearchDropDownAction.setEnabled(hasSearch);
- fCopyToClipboardAction= new CopyToClipboardAction(this);
-
- addSelectionChangedListener(
- new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- if (fLastSelection == null || !fLastSelection.equals(event.getSelection())) {
- fLastSelection= event.getSelection();
- handleSelectionChanged();
- }
- }
- }
- );
-
- addOpenListener(new IOpenListener() {
- public void open(OpenEvent event) {
- showResult();
- }
- });
-
- MenuManager menuMgr= new MenuManager("#PopUp"); //$NON-NLS-1$
- menuMgr.setRemoveAllWhenShown(true);
- menuMgr.addMenuListener(
- new IMenuListener() {
- public void menuAboutToShow(IMenuManager mgr) {
- SearchPlugin.createStandardGroups(mgr);
- fillContextMenu(mgr);
- }
- });
- Menu menu= menuMgr.createContextMenu(getTable());
- getTable().setMenu(menu);
-
- // Register menu
- fOuterPart.getSite().registerContextMenu(menuMgr, this);
-
- IActionBars actionBars= fOuterPart.getViewSite().getActionBars();
- if (actionBars != null) {
- actionBars.setGlobalActionHandler(ActionFactory.NEXT.getId(), fShowNextResultAction);
- actionBars.setGlobalActionHandler(ActionFactory.PREVIOUS.getId(), fShowPreviousResultAction);
- }
-
- fOuterPart.getSite().setSelectionProvider(this);
- }
-
- void init() {
- Search search= SearchManager.getDefault().getCurrentSearch();
- if (search != null) {
- setGotoMarkerAction(search.getGotoMarkerAction());
- setContextMenuTarget(search.getContextMenuContributor());
- setActionGroupFactory(null);
- setActionGroupFactory(search.getActionGroupFactory());
- setPageId(search.getPageId());
- setInput(search.getResults());
- }
- }
-
- /**
- * @see StructuredViewer#doUpdateItem(Widget, Object, boolean)
- */
- protected void doUpdateItem(Widget item, Object element, boolean fullMap) {
- super.doUpdateItem(item, element, fullMap);
- if (((SearchResultViewEntry)element).isPotentialMatch()) {
- TableItem ti = (TableItem) item;
- ti.setForeground(fPotentialMatchFgColor);
- }
- }
-
- private void handleSelectionChanged() {
- int selectionCount= getSelectedEntriesCount();
- boolean hasSingleSelection= selectionCount == 1;
- boolean hasElements= getItemCount() > 0;
- fShowNextResultAction.setEnabled(hasSingleSelection || (hasElements && selectionCount == 0));
- fShowPreviousResultAction.setEnabled(hasSingleSelection || (hasElements && selectionCount == 0));
- fGotoMarkerActionProxy.setEnabled(hasSingleSelection);
- fRemoveSelectedMatchesAction.setEnabled(selectionCount > 0);
-
- if (fHandleSelectionChangedEvents) {
- fMarkerToShow= -1;
- fCurrentMatchRemoved= false;
- } else
- fHandleSelectionChangedEvents= true;
-
- updateStatusLine();
- }
-
- void updateStatusLine() {
- boolean hasSingleSelection= getSelectedEntriesCount() == 1;
- String location= ""; //$NON-NLS-1$
- if (hasSingleSelection) {
- ISearchResultViewEntry entry= (ISearchResultViewEntry)getTable().getItem(getTable().getSelectionIndex()).getData();
- IPath path= entry.getResource().getFullPath();
- if (path != null)
- location= path.makeRelative().toString();
- }
- setStatusLineMessage(location);
- }
-
- void enableActions() {
- /*
- * Note: The check before each set operation reduces flickering
- */
- boolean state= getItemCount() > 0;
- if (state != fShowNextResultAction.isEnabled())
- fShowNextResultAction.setEnabled(state);
- if (state != fShowPreviousResultAction.isEnabled())
- fShowPreviousResultAction.setEnabled(state);
- if (state != fSortDropDownAction.isEnabled())
- fSortDropDownAction.setEnabled(state);
- if (state != fRemoveAllResultsAction.isEnabled())
- fRemoveAllResultsAction.setEnabled(state);
-
- Search currentSearch= SearchManager.getDefault().getCurrentSearch();
- state= currentSearch != null;
- boolean operationState= state && currentSearch.getOperation() != null;
- if (state != fSearchDropDownAction.isEnabled())
- fSearchDropDownAction.setEnabled(state);
- if (operationState != fSearchAgainAction.isEnabled())
- fSearchAgainAction.setEnabled(operationState);
-
- state= !getSelection().isEmpty();
- if (state != fGotoMarkerActionProxy.isEnabled())
- fGotoMarkerActionProxy.setEnabled(state);
- if (state != fRemoveSelectedMatchesAction.isEnabled())
- fRemoveSelectedMatchesAction.setEnabled(state);
- }
-
-
- protected void inputChanged(Object input, Object oldInput) {
- fLastSelection= null;
- getTable().removeAll();
- super.inputChanged(input, oldInput);
- fMarkerToShow= -1;
- fCurrentMatchRemoved= false;
- updateTitle();
- enableActions();
- if (getItemCount() > 0)
- selectResult(0);
-
- WorkbenchHelp.setHelp(getControl(), SearchPlugin.getDefault().getSearchViewHelpContextId());
- }
-
- protected int getSelectedEntriesCount() {
- ISelection s= getSelection();
- if (s == null || s.isEmpty() || !(s instanceof IStructuredSelection))
- return 0;
- IStructuredSelection selection= (IStructuredSelection)s;
- return selection.size();
- }
-
- //--- Contribution management -----------------------------------------------
-
-
- protected boolean enableRemoveMatchMenuItem() {
- if (getSelectedEntriesCount() != 1)
- return false;
- Table table= getTable();
- int index= table.getSelectionIndex();
- SearchResultViewEntry entry= null;
- if (index > -1)
- entry= (SearchResultViewEntry)table.getItem(index).getData();
- return (entry != null && entry.getMatchCount() > 1);
-
- }
-
- void fillContextMenu(IMenuManager menu) {
- ISelection selection= getSelection();
-
- if (fActionGroup != null) {
- ActionContext context= new ActionContext(selection);
- context.setInput(getInput());
- fActionGroup.setContext(context);
- fActionGroup.fillContextMenu(menu);
- fActionGroup.setContext(null);
- }
-
- if (fContextMenuContributor != null)
- fContextMenuContributor.fill(menu, this);
-
- if (!selection.isEmpty()) {
- menu.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, fCopyToClipboardAction);
- menu.appendToGroup(IContextMenuConstants.GROUP_GOTO, fGotoMarkerActionProxy);
- if (enableRemoveMatchMenuItem())
- menu.appendToGroup(IContextMenuConstants.GROUP_REMOVE_MATCHES, new RemoveMatchAction(this));
- menu.appendToGroup(IContextMenuConstants.GROUP_REMOVE_MATCHES, new RemoveResultAction(this, true));
-
- if (isPotentialMatchSelected())
- menu.appendToGroup(IContextMenuConstants.GROUP_REMOVE_MATCHES, new RemovePotentialMatchesAction(fOuterPart.getViewSite()));
- }
-
- // If we have elements
- if (getItemCount() > 0)
- menu.appendToGroup(IContextMenuConstants.GROUP_REMOVE_MATCHES, new RemoveAllResultsAction());
-
- menu.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, fSearchAgainAction);
- if (getItemCount() > 0) {
- fSortDropDownAction= fSortDropDownAction.renew();
- if (fSortDropDownAction.getSorterCount() > 1)
- menu.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, fSortDropDownAction);
- }
- }
-
- private boolean isPotentialMatchSelected() {
- if (getSelectedEntriesCount() == 0)
- return false;
-
- Iterator iter= Collections.EMPTY_LIST.iterator();
- ISelection selection= getSelection();
- if (selection instanceof IStructuredSelection)
- iter= ((IStructuredSelection)selection).iterator();
-
- while (iter.hasNext()) {
- Object entry= iter.next();
- if (entry instanceof ISearchResultViewEntry) {
- IMarker marker= ((ISearchResultViewEntry)entry).getSelectedMarker();
- if (marker != null && marker.getAttribute(SearchUI.POTENTIAL_MATCH, false))
- return true;
- }
- }
-
- return false;
- }
-
- IAction getGotoMarkerAction() {
- // null as return value is covered (no action will take place)
- return fGotoMarkerAction;
- }
-
- void setGotoMarkerAction(IAction gotoMarkerAction) {
- fGotoMarkerAction= gotoMarkerAction;
- }
-
-
- void setContextMenuTarget(IContextMenuContributor contributor) {
- fContextMenuContributor= contributor;
- }
-
- void setActionGroupFactory(IActionGroupFactory groupFactory) {
- IActionBars actionBars= fOuterPart.getViewSite().getActionBars();
- if (fActionGroup != null) {
- fActionGroup.dispose();
- fActionGroup= null;
- }
-
- if (groupFactory != null) {
- fActionGroup= groupFactory.createActionGroup(fOuterPart);
- if (actionBars != null)
- fActionGroup.fillActionBars(actionBars);
- }
- if (actionBars != null)
- actionBars.updateActionBars();
- }
-
- void setPageId(String pageId) {
- if (fCurrentPageId != null && fCurrentPageId.equals(pageId))
- return;
-
- fCurrentPageId= pageId;
- ILabelProvider labelProvider= fOuterPart.getLabelProvider(pageId);
- if (labelProvider != null)
- internalSetLabelProvider(labelProvider);
- fSortDropDownAction.setPageId(pageId);
- }
-
- void fillToolBar(IToolBarManager tbm) {
- tbm.add(fShowNextResultAction);
- tbm.add(fShowPreviousResultAction);
-// tbm.add(fGotoMarkerAction); see bug 15275
- tbm.add(fRemoveSelectedMatchesAction);
- tbm.add(fRemoveAllResultsAction);
- tbm.add(new Separator());
- tbm.add(new OpenSearchDialogAction());
- tbm.add(fSearchDropDownAction);
-
- // need to hook F5 to table
- getTable().addKeyListener(new KeyAdapter() {
- public void keyReleased(KeyEvent e) {
- if (e.keyCode == SWT.F5) {
- fSearchAgainAction.run();
- return; // performance
- }
- if (e.character == SWT.DEL) {
- new RemoveResultAction(SearchResultViewer.this, true).run();
- return; // performance
- }
- }
- });
- }
-
- int getItemCount() {
- return SearchManager.getDefault().getCurrentItemCount();
- }
-
- void internalSetLabelProvider(ILabelProvider provider) {
- setLabelProvider(new SearchResultLabelProvider(provider));
- }
-
- /**
- * Makes the first marker of the current result entry
- * visible in an editor. If no result
- * is visible, this method does nothing.
- */
- public void showResult() {
- Table table= getTable();
- if (!canDoShowResult(table))
- return;
-
-
- int index= table.getSelectionIndex();
- if (index < 0)
- return;
- SearchResultViewEntry entry= (SearchResultViewEntry)getTable().getItem(index).getData();
-
-
- fMarkerToShow= 0;
- fCurrentMatchRemoved= false;
- entry.setSelectedMarkerIndex(0);
- openCurrentSelection();
- }
-
-
- /**
- * Makes the next result (marker) visible in an editor. If no result
- * is visible, this method makes the first result visible.
- */
- public void showNextResult() {
- Table table= getTable();
- if (!canDoShowResult(table))
- return;
-
- int index= table.getSelectionIndex();
- SearchResultViewEntry entry= null;
- if (index > -1)
- entry= (SearchResultViewEntry)table.getItem(index).getData();
-
- if (fCurrentMatchRemoved)
- fCurrentMatchRemoved= false;
- else
- fMarkerToShow++;
- if (entry == null || fMarkerToShow >= entry.getMatchCount()) {
- // move selection
- if (index == -1) {
- index= 0;
- } else {
- index++;
- if (index >= table.getItemCount())
- index= 0;
- }
- fMarkerToShow= 0;
- entry= (SearchResultViewEntry)getTable().getItem(index).getData();
- selectResult(index);
- }
- entry.setSelectedMarkerIndex(fMarkerToShow);
- openCurrentSelection();
- updateStatusLine();
- }
-
-
- /**
- * Makes the previous result (marker) visible. If there isn't any
- * visible result, this method makes the last result visible.
- */
- public void showPreviousResult() {
- fCurrentMatchRemoved= false;
- Table table= getTable();
- if (!canDoShowResult(table))
- return;
-
- int index= table.getSelectionIndex();
- SearchResultViewEntry entry;
-
-
- fMarkerToShow--;
- if (fMarkerToShow >= 0)
- entry= (SearchResultViewEntry)getTable().getItem(getTable().getSelectionIndex()).getData();
- else {
- // move selection
- int count= table.getItemCount();
- if (index == -1) {
- index= count - 1;
- } else {
- index--;
- if (index < 0)
- index= count - 1;
- }
- entry= (SearchResultViewEntry)getTable().getItem(index).getData();
- fMarkerToShow= entry.getMatchCount() - 1;
- selectResult(index);
- }
- entry.setSelectedMarkerIndex(fMarkerToShow);
- openCurrentSelection();
- updateStatusLine();
- }
-
- private boolean canDoShowResult(Table table) {
- if (table == null || getItemCount() == 0)
- return false;
- return true;
- }
-
- private void selectResult(int index) {
- fHandleSelectionChangedEvents= false;
- Object element= getElementAt(index);
- if (element != null)
- setSelection(new StructuredSelection(getElementAt(index)), true);
- else
- setSelection(StructuredSelection.EMPTY);
- }
-
- private void openCurrentSelection() {
- IAction action= getGotoMarkerAction();
- if (action != null)
- action.run();
- }
-
- /**
- * Updates the foreground color for potential matches.
- */
- void updatedPotentialMatchFgColor() {
- if (fPotentialMatchFgColor != null)
- fPotentialMatchFgColor.dispose();
- fPotentialMatchFgColor= null;
- if (SearchPreferencePage.arePotentialMatchesEmphasized())
- fPotentialMatchFgColor= new Color(SearchPlugin.getActiveWorkbenchShell().getDisplay(), SearchPreferencePage.getPotentialMatchForegroundColor());
- refresh();
- }
-
- /**
- * Update the title
- */
- protected void updateTitle() {
- boolean hasCurrentSearch= SearchManager.getDefault().getCurrentSearch() != null;
- String title;
- if (hasCurrentSearch) {
- String description= SearchManager.getDefault().getCurrentSearch().getFullDescription();
- title= SearchMessages.getFormattedString("SearchResultView.titleWithDescription", description); //$NON-NLS-1$
- } else
- title= SearchMessages.getString("SearchResultView.title"); //$NON-NLS-1$
- if (title == null || !title.equals(fOuterPart.getTitle()))
- fOuterPart.setTitle(title);
- }
-
- /**
- * Clear the title
- */
- protected void clearTitle() {
- String title= SearchMessages.getString("SearchResultView.title"); //$NON-NLS-1$
- if (!title.equals(fOuterPart.getTitle()))
- fOuterPart.setTitle(title);
- }
-
- /**
- * Sets the message text to be displayed on the status line.
- * The image on the status line is cleared.
- */
- private void setStatusLineMessage(String message) {
- fOuterPart.getViewSite().getActionBars().getStatusLineManager().setMessage(message);
- }
-
-
- protected void handleDispose(DisposeEvent event) {
- fLastSelection= null;
- Menu menu= getTable().getMenu();
- if (menu != null)
- menu.dispose();
- if (fPotentialMatchFgColor != null)
- fPotentialMatchFgColor.dispose();
- if (fActionGroup != null) {
- fActionGroup.dispose();
- fActionGroup= null;
- }
- super.handleDispose(event);
- }
-
- //--- Change event handling -------------------------------------------------
-
- /**
- * Handle a single add.
- */
- protected void handleAddMatch(ISearchResultViewEntry entry) {
- insert(entry, -1);
- }
-
- /**
- * Handle a single remove.
- */
- protected void handleRemoveMatch(ISearchResultViewEntry entry) {
- Widget item= findItem(entry);
- if (entry.getMatchCount() == 0)
- remove(entry);
- else
- updateItem(item, entry);
- updateStatusLine();
- }
-
- /**
- * Handle remove all.
- */
- protected void handleRemoveAll() {
- setContextMenuTarget(null);
- setActionGroupFactory(null);
- setInput(null);
- }
-
- /**
- * Handle an update of an entry.
- */
- protected void handleUpdateMatch(ISearchResultViewEntry entry, boolean matchRemoved) {
- Widget item= findItem(entry);
- updateItem(item, entry);
- if (matchRemoved && getSelectionFromWidget().contains(entry))
- fCurrentMatchRemoved= true;
- }
-
- //--- Persistency -------------------------------------------------
-
- void restoreState(IMemento memento) {
- fSortDropDownAction.restoreState(memento);
- }
-
- void saveState(IMemento memento) {
- fSortDropDownAction.saveState(memento);
- }
-
- /*
- * @see ContentViewer#handleLabelProviderChanged(LabelProviderChangedEvent)
- */
- protected void handleLabelProviderChanged(LabelProviderChangedEvent event) {
- Object[] changed= event.getElements();
- if (changed != null && !fResourceToItemsMapper.isEmpty()) {
- ArrayList others= new ArrayList(changed.length);
- for (int i= 0; i < changed.length; i++) {
- Object curr= changed[i];
- if (curr instanceof IResource)
- fResourceToItemsMapper.resourceChanged((IResource) curr);
- else if (curr instanceof IAdaptable) {
- IResource resource= (IResource)((IAdaptable)curr).getAdapter(IResource.class);
- if (resource != null)
- fResourceToItemsMapper.resourceChanged(resource);
- } else
- others.add(curr);
- }
- if (others.isEmpty()) {
- return;
- }
- event= new LabelProviderChangedEvent((IBaseLabelProvider) event.getSource(), others.toArray());
- }
- super.handleLabelProviderChanged(event);
- }
-
- /*
- * @see StructuredViewer#mapElement(Object, Widget)
- */
- protected void mapElement(Object element, Widget item) {
- super.mapElement(element, item);
- if (item instanceof Item) {
- fResourceToItemsMapper.addToMap(element, (Item)item);
- }
- }
-
- /*
- * @see StructuredViewer#unmapElement(Object, Widget)
- */
- protected void unmapElement(Object element, Widget item) {
- if (item instanceof Item) {
- fResourceToItemsMapper.removeFromMap(element, (Item)item);
- }
- super.unmapElement(element, item);
- }
-
- /*
- * @see StructuredViewer#unmapAllElements()
- */
- protected void unmapAllElements() {
- fResourceToItemsMapper.clearMap();
- super.unmapAllElements();
- }
-
- protected void internalRefresh(Object element, boolean updateLabels) {
- // see bug 44891
- getTable().setRedraw(false);
- super.internalRefresh(element, updateLabels);
- getTable().setRedraw(true);
- }
-
- void handleAllSearchesRemoved() {
- setContextMenuTarget(null);
- setActionGroupFactory(null);
- setInput(null);
- fSearchDropDownAction.clear();
- }
-
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SelectAllAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SelectAllAction.java
deleted file mode 100644
index 6ee7c50..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SelectAllAction.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import org.eclipse.jface.action.Action;
-
-import org.eclipse.ui.help.WorkbenchHelp;
-
-/**
- * This action selects all entries currently showing in view.
- */
-class SelectAllAction extends Action {
-
- private SearchResultViewer fViewer;
-
- /**
- * Creates the action.
- */
- SelectAllAction(SearchResultViewer viewer) {
- super("selectAll"); //$NON-NLS-1$
- setText(SearchMessages.getString("SelectAllAction.label")); //$NON-NLS-1$
- setToolTipText(SearchMessages.getString("SelectAllAction.tooltip")); //$NON-NLS-1$
- WorkbenchHelp.setHelp(this, ISearchHelpContextIds.SELECT_ALL_ACTION);
- fViewer= viewer;
- }
-
- /**
- * Selects all resources in the view.
- */
- public void run() {
- fViewer.getTable().selectAll();
- // force viewer selection change
- fViewer.setSelection(fViewer.getSelection());
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/ShowNextResultAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/ShowNextResultAction.java
deleted file mode 100644
index 9745056..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/ShowNextResultAction.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import org.eclipse.jface.action.Action;
-
-class ShowNextResultAction extends Action {
-
- private SearchResultViewer fViewer;
-
- public ShowNextResultAction(SearchResultViewer viewer) {
- super(SearchMessages.getString("SearchResultView.showNext.text")); //$NON-NLS-1$
- SearchPluginImages.setImageDescriptors(this, SearchPluginImages.T_LCL, SearchPluginImages.IMG_LCL_SEARCH_NEXT);
- setToolTipText(SearchMessages.getString("SearchResultView.showNext.tooltip")); //$NON-NLS-1$
- fViewer= viewer;
- setActionDefinitionId("org.eclipse.ui.navigate.next"); //$NON-NLS-1$
- }
-
- public void run() {
- fViewer.showNextResult();
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/ShowPreviousResultAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/ShowPreviousResultAction.java
deleted file mode 100644
index 806144d..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/ShowPreviousResultAction.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import org.eclipse.jface.action.Action;
-
-class ShowPreviousResultAction extends Action {
-
- private SearchResultViewer fViewer;
-
- public ShowPreviousResultAction(SearchResultViewer viewer) {
- super(SearchMessages.getString("SearchResultView.showPrev.text")); //$NON-NLS-1$
- SearchPluginImages.setImageDescriptors(this, SearchPluginImages.T_LCL, SearchPluginImages.IMG_LCL_SEARCH_PREV);
- setToolTipText(SearchMessages.getString("SearchResultView.showPrev.tooltip")); //$NON-NLS-1$
- setActionDefinitionId("org.eclipse.ui.navigate.previous"); //$NON-NLS-1$
- fViewer= viewer;
- }
-
- public void run() {
- fViewer.showPreviousResult();
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/ShowSearchAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/ShowSearchAction.java
deleted file mode 100644
index 969e085..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/ShowSearchAction.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import org.eclipse.jface.action.Action;
-
-class ShowSearchAction extends Action {
- private Search fSearch;
-
- /**
- * Create a new instance of this class
- */
- public ShowSearchAction(Search search) {
- fSearch= search;
- String desc= search.getShortDescription();
- setText(desc);
- setToolTipText(desc);
- setImageDescriptor(search.getImageDescriptor());
- }
- /**
- * Invoke the resource wizard selection wizard
- *
- * @param browser org.eclipse.jface.parts.Window
- */
- public void run() {
- if (fSearch != SearchManager.getDefault().getCurrentSearch())
- SearchManager.getDefault().setCurrentSearch(fSearch);
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/ShowSearchesAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/ShowSearchesAction.java
deleted file mode 100644
index 26baeae..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/ShowSearchesAction.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.swt.graphics.Image;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.window.Window;
-
-import org.eclipse.search.internal.ui.util.ListDialog;
-
-/**
- * Invoke the resource creation wizard selection Wizard.
- * This action will retarget to the active view.
- */
-class ShowSearchesAction extends Action {
-
- private static final class SearchesLabelProvider extends LabelProvider {
-
- private ArrayList fImages= new ArrayList();
-
- public String getText(Object element) {
- if (!(element instanceof ShowSearchAction))
- return ""; //$NON-NLS-1$
- return ((ShowSearchAction)element).getText();
- }
- public Image getImage(Object element) {
- if (!(element instanceof ShowSearchAction))
- return null;
-
- ImageDescriptor imageDescriptor= ((ShowSearchAction)element).getImageDescriptor();
- if (imageDescriptor == null)
- return null;
-
- Image image= imageDescriptor.createImage();
- fImages.add(image);
-
- return image;
- }
-
- public void dispose() {
- Iterator iter= fImages.iterator();
- while (iter.hasNext())
- ((Image)iter.next()).dispose();
-
- fImages= null;
- }
- }
-
- /**
- * Create a new instance of this class
- */
- public ShowSearchesAction() {
- super(SearchMessages.getString("ShowOtherSearchesAction.label")); //$NON-NLS-1$
- setToolTipText(SearchMessages.getString("ShowOtherSearchesAction.tooltip")); //$NON-NLS-1$
- }
- /*
- * Overrides method from Action
- */
- public void run() {
- run(false);
- }
-
- public void run(boolean showAll) {
- Iterator iter= SearchManager.getDefault().getPreviousSearches().iterator();
- int cutOffSize;
- if (showAll)
- cutOffSize= 0;
- else
- cutOffSize= SearchDropDownAction.RESULTS_IN_DROP_DOWN;
- int size= SearchManager.getDefault().getPreviousSearches().size() - cutOffSize;
- Search selectedSearch= SearchManager.getDefault().getCurrentSearch();
- Action selectedAction = null;
- ArrayList input= new ArrayList(size);
- int i= 0;
- while (iter.hasNext()) {
- Search search= (Search)iter.next();
- if (i++ < cutOffSize)
- continue;
- Action action= new ShowSearchAction(search);
- input.add(action);
- if (selectedSearch == search)
- selectedAction= action;
- }
-
- // Open a list dialog.
- String title;
- String message;
- if (showAll) {
- title= SearchMessages.getString("PreviousSearchesDialog.title"); //$NON-NLS-1$
- message= SearchMessages.getString("PreviousSearchesDialog.message"); //$NON-NLS-1$
- }
- else {
- title= SearchMessages.getString("OtherSearchesDialog.title"); //$NON-NLS-1$
- message= SearchMessages.getString("OtherSearchesDialog.message"); //$NON-NLS-1$
- }
-
- LabelProvider labelProvider=new SearchesLabelProvider();
-
- ListDialog dlg= new ListDialog(SearchPlugin.getActiveWorkbenchShell(),input, title, message, new SearchResultContentProvider(), labelProvider);
- if (selectedAction != null) {
- Object[] selected= new Object[1];
- selected[0]= selectedAction;
- dlg.setInitialSelections(selected);
- }
- if (dlg.open() == Window.OK) {
- List result= Arrays.asList(dlg.getResult());
- if (result != null && result.size() == 1) {
- ((ShowSearchAction)result.get(0)).run();
- }
- }
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SortDropDownAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SortDropDownAction.java
deleted file mode 100644
index 4df1ab0..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SortDropDownAction.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Menu;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IMenuCreator;
-import org.eclipse.jface.viewers.ViewerSorter;
-
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.model.WorkbenchViewerSorter;
-
-/**
- * Drop down action that holds the currently registered sort actions.
- */
-class SortDropDownAction extends Action implements IMenuCreator {
-
- // Persistance tags.
- private static final String TAG_SORTERS= "sorters"; //$NON-NLS-1$
- private static final String TAG_DEFAULT_SORTERS= "defaultSorters"; //$NON-NLS-1$
- private static final String TAG_ELEMENT= "element"; //$NON-NLS-1$
- private static final String TAG_PAGE_ID= "pageId"; //$NON-NLS-1$
- private static final String TAG_SORTER_ID= "sorterId"; //$NON-NLS-1$
-
- private static Map fgLastCheckedForType= new HashMap(5);
-
- private SearchResultViewer fViewer;
- private String fPageId;
- private Menu fMenu;
- private Map fLastCheckedForType;
-
- public SortDropDownAction(SearchResultViewer viewer) {
- super(SearchMessages.getString("SortDropDownAction.label")); //$NON-NLS-1$
- SearchPluginImages.setImageDescriptors(this, SearchPluginImages.T_LCL, SearchPluginImages.IMG_LCL_SEARCH_SORT);
- fViewer= viewer;
- setToolTipText(SearchMessages.getString("SortDropDownAction.tooltip")); //$NON-NLS-1$
- setMenuCreator(this);
- fLastCheckedForType= new HashMap(5);
- }
-
- public void dispose() {
- if (fMenu != null && !fMenu.isDisposed())
- fMenu.dispose();
- fMenu= null;
- }
-
- public Menu getMenu(Control parent) {
- return null;
- }
-
- void setPageId(String pageId) {
- fPageId= pageId;
- SorterDescriptor sorterDesc= (SorterDescriptor)fLastCheckedForType.get(pageId);
- if (sorterDesc == null)
- sorterDesc= (SorterDescriptor)fgLastCheckedForType.get(pageId);
- if (sorterDesc == null)
- sorterDesc= findSorter(fPageId);
- if (sorterDesc != null) {
- setChecked(sorterDesc);
- fViewer.setSorter(sorterDesc.createObject());
- } else {
- // Use default sort workbench viewer sorter
- fViewer.setSorter(new WorkbenchViewerSorter());
- }
- }
-
- public Menu getMenu(final Menu parent) {
- dispose(); // ensure old menu gets disposed
-
- fMenu= new Menu(parent);
-
- Iterator iter= SearchPlugin.getDefault().getSorterDescriptors().iterator();
- while (iter.hasNext()) {
- Object value= fLastCheckedForType.get(fPageId);
- final String checkedId;
- if (value instanceof SorterDescriptor)
- checkedId= ((SorterDescriptor)value).getId();
- else
- checkedId= ""; //$NON-NLS-1$
-
- final SorterDescriptor sorterDesc= (SorterDescriptor) iter.next();
- if (!sorterDesc.getPageId().equals(fPageId) && !sorterDesc.getPageId().equals("*")) //$NON-NLS-1$
- continue;
- final ViewerSorter sorter= sorterDesc.createObject();
- if (sorter != null) {
- final Action action= new Action() {
- public void run() {
- if (!checkedId.equals(sorterDesc.getId())) {
- SortDropDownAction.this.setChecked(sorterDesc);
- BusyIndicator.showWhile(parent.getDisplay(), new Runnable() {
- public void run() {
- fViewer.setSorter(sorter);
- }
- });
- }
- }
- };
- action.setText(sorterDesc.getLabel());
- action.setImageDescriptor(sorterDesc.getImage());
- action.setToolTipText(sorterDesc.getToolTipText());
- action.setChecked(checkedId.equals(sorterDesc.getId()));
- addActionToMenu(fMenu, action);
- }
- }
- return fMenu;
- }
-
- protected void addActionToMenu(Menu parent, Action action) {
- ActionContributionItem item= new ActionContributionItem(action);
- item.fill(parent, -1);
- }
-
- public void run() {
- // nothing to do
- }
-
- private SorterDescriptor findSorter(String pageId) {
- Iterator iter= SearchPlugin.getDefault().getSorterDescriptors().iterator();
- while (iter.hasNext()) {
- SorterDescriptor sorterDesc= (SorterDescriptor)iter.next();
- if (sorterDesc.getPageId().equals(pageId) || sorterDesc.getPageId().equals("*")) //$NON-NLS-1$
- return sorterDesc;
- }
- return null;
- }
-
- private SorterDescriptor getSorter(String sorterId) {
- Iterator iter= SearchPlugin.getDefault().getSorterDescriptors().iterator();
- while (iter.hasNext()) {
- SorterDescriptor sorterDesc= (SorterDescriptor)iter.next();
- if (sorterDesc.getId().equals(sorterId))
- return sorterDesc;
- }
- return null;
- }
-
- private void setChecked(SorterDescriptor sorterDesc) {
- fLastCheckedForType.put(fPageId, sorterDesc);
- fgLastCheckedForType.put(fPageId, sorterDesc);
- }
-
- /**
- * Disposes this action's menu and returns a new unused instance.
- */
- SortDropDownAction renew() {
- SortDropDownAction action= new SortDropDownAction(fViewer);
- action.fLastCheckedForType= fLastCheckedForType;
- action.fPageId= fPageId;
- dispose();
- return action;
- }
-
- //--- Persistency -------------------------------------------------
-
- void restoreState(IMemento memento) {
- if (fLastCheckedForType.isEmpty())
- restoreState(memento, fLastCheckedForType, TAG_SORTERS);
- if (fgLastCheckedForType.isEmpty())
- restoreState(memento, fgLastCheckedForType, TAG_DEFAULT_SORTERS);
- }
-
- private void restoreState(IMemento memento, Map map, String mapName) {
- memento= memento.getChild(mapName);
- if (memento == null)
- return;
- IMemento[] mementoElements= memento.getChildren(TAG_ELEMENT);
- for (int i= 0; i < mementoElements.length; i++) {
- String pageId= mementoElements[i].getString(TAG_PAGE_ID);
- String sorterId= mementoElements[i].getString(TAG_SORTER_ID);
- SorterDescriptor sorterDesc= getSorter(sorterId);
- if (sorterDesc != null)
- map.put(pageId, sorterDesc);
- }
- }
-
- void saveState(IMemento memento) {
- saveState(memento, fgLastCheckedForType, TAG_DEFAULT_SORTERS);
- saveState(memento, fLastCheckedForType, TAG_SORTERS);
- }
-
- private void saveState(IMemento memento, Map map, String mapName) {
- Iterator iter= map.entrySet().iterator();
- memento= memento.createChild(mapName);
- while (iter.hasNext()) {
- IMemento mementoElement= memento.createChild(TAG_ELEMENT);
- Map.Entry entry= (Map.Entry)iter.next();
- mementoElement.putString(TAG_PAGE_ID, (String)entry.getKey());
- mementoElement.putString(TAG_SORTER_ID, ((SorterDescriptor)entry.getValue()).getId());
- }
- }
-
- int getSorterCount() {
- int count= 0;
- Iterator iter= SearchPlugin.getDefault().getSorterDescriptors().iterator();
- while (iter.hasNext()) {
- SorterDescriptor sorterDesc= (SorterDescriptor)iter.next();
- if (sorterDesc.getPageId().equals(fPageId) || sorterDesc.getPageId().equals("*")) //$NON-NLS-1$
- count++;
- }
- return count;
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SorterDescriptor.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SorterDescriptor.java
deleted file mode 100644
index d1e572f..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SorterDescriptor.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import java.net.URL;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ViewerSorter;
-
-import org.eclipse.search.internal.ui.util.ExceptionHandler;
-
-/**
- * Proxy that represents a sorter.
- */
-class SorterDescriptor {
-
- public final static String SORTER_TAG= "sorter"; //$NON-NLS-1$
- private final static String ID_ATTRIBUTE= "id"; //$NON-NLS-1$
- private final static String PAGE_ID_ATTRIBUTE= "pageId"; //$NON-NLS-1$
- private final static String ICON_ATTRIBUTE= "icon"; //$NON-NLS-1$
- private final static String CLASS_ATTRIBUTE= "class"; //$NON-NLS-1$
- private final static String LABEL_ATTRIBUTE= "label"; //$NON-NLS-1$
- private final static String TOOLTIP_ATTRIBUTE= "tooltip"; //$NON-NLS-1$
-
- private IConfigurationElement fElement;
-
- /**
- * Creates a new sorter node with the given configuration element.
- */
- public SorterDescriptor(IConfigurationElement element) {
- fElement= element;
- }
-
- /**
- * Creates a new sorter from this node.
- */
- public ViewerSorter createObject() {
- try {
- return (ViewerSorter)fElement.createExecutableExtension(CLASS_ATTRIBUTE);
- } catch (CoreException ex) {
- ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.createSorter.title"), SearchMessages.getString("Search.Error.createSorter.message")); //$NON-NLS-2$ //$NON-NLS-1$
- return null;
- } catch (ClassCastException ex) {
- ExceptionHandler.displayMessageDialog(ex, SearchMessages.getString("Search.Error.createSorter.title"), SearchMessages.getString("Search.Error.createSorter.message")); //$NON-NLS-2$ //$NON-NLS-1$
- return null;
- }
- }
-
- //---- XML Attribute accessors ---------------------------------------------
-
- /**
- * Returns the sorter's id.
- */
- public String getId() {
- return fElement.getAttribute(ID_ATTRIBUTE);
- }
-
- /**
- * Returns the sorter's image
- */
- public ImageDescriptor getImage() {
- String imageName= fElement.getAttribute(ICON_ATTRIBUTE);
- if (imageName == null)
- return null;
- URL url;
- try {
- url= new URL(fElement.getDeclaringExtension().getDeclaringPluginDescriptor().getInstallURL(), imageName);
- } catch (java.net.MalformedURLException ex) {
- ExceptionHandler.log(ex, SearchMessages.getString("Search.Error.createSorter.message")); //$NON-NLS-1$
- return null;
- }
- return ImageDescriptor.createFromURL(url);
- }
-
- /**
- * Returns the sorter's label.
- */
- public String getLabel() {
- return fElement.getAttribute(LABEL_ATTRIBUTE);
- }
-
- /**
- * Returns the sorter's preferred size
- */
- public String getToolTipText() {
- return fElement.getAttribute(TOOLTIP_ATTRIBUTE);
- }
-
- /**
- * Returns the sorter's preferred size
- */
- public String getPageId() {
- return fElement.getAttribute(PAGE_ID_ATTRIBUTE);
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/WorkInProgressPreferencePage.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/WorkInProgressPreferencePage.java
deleted file mode 100644
index 5ca7f30..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/WorkInProgressPreferencePage.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.search.internal.ui;
-
-import org.eclipse.jface.preference.BooleanFieldEditor;
-import org.eclipse.jface.preference.FieldEditorPreferencePage;
-import org.eclipse.jface.preference.IPreferenceStore;
-
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-
-public class WorkInProgressPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
-
- public WorkInProgressPreferencePage() {
- super(GRID);
- setPreferenceStore(SearchPlugin.getDefault().getPreferenceStore());
- }
- public static final String SEARCH_IN_BACKGROUND= "org.eclipse.search.newsearch"; //$NON-NLS-1$
- /* (non-Javadoc)
- * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
- */
- protected void createFieldEditors() {
- BooleanFieldEditor boolEditor= new BooleanFieldEditor(
- SEARCH_IN_BACKGROUND,
- SearchMessages.getString("WorkInProgressPreferencePage.newsearch.label"), //$NON-NLS-1$
- getFieldEditorParent()
- );
- addField(boolEditor);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
- */
- public void init(IWorkbench workbench) {
- // do nothing
- }
- public static boolean useNewSearch() {
- IPreferenceStore store= SearchPlugin.getDefault().getPreferenceStore();
- return store.getBoolean(SEARCH_IN_BACKGROUND);
- }
-
- public static void initDefaults(IPreferenceStore store) {
- store.setDefault(SEARCH_IN_BACKGROUND, true);
- }
-
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/WorkingSetComparator.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/WorkingSetComparator.java
deleted file mode 100644
index f660f3c..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/WorkingSetComparator.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import java.text.Collator;
-import java.util.Comparator;
-
-import org.eclipse.ui.IWorkingSet;
-
-class WorkingSetComparator implements Comparator {
-
- private Collator fCollator= Collator.getInstance();
-
- /*
- * @see Comparator#compare(Object, Object)
- */
- public int compare(Object o1, Object o2) {
- String name1= null;
- String name2= null;
-
- if (o1 instanceof IWorkingSet)
- name1= ((IWorkingSet)o1).getName();
-
- if (o2 instanceof IWorkingSet)
- name2= ((IWorkingSet)o2).getName();
-
- return fCollator.compare(name1, name2);
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/DelegatingLabelProvider.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/DelegatingLabelProvider.java
deleted file mode 100644
index 68e5a48..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/DelegatingLabelProvider.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui.text;
-
-import org.eclipse.swt.graphics.Image;
-
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-
-import org.eclipse.search.ui.text.AbstractTextSearchViewPage;
-
-public class DelegatingLabelProvider extends LabelProvider {
-
- private ILabelProvider fLabelProvider;
- private AbstractTextSearchViewPage fPage;
-
- public DelegatingLabelProvider(AbstractTextSearchViewPage page, ILabelProvider inner) {
- fPage= page;
- fLabelProvider= inner;
- }
-
- public ILabelProvider getLabelProvider() {
- return fLabelProvider;
- }
-
- public Image getImage(Object element) {
- return fLabelProvider.getImage(element);
- }
-
- public String getText(Object element) {
- int matchCount= fPage.getInput().getMatchCount(element);
- String text= fLabelProvider.getText(element);
- if (matchCount == 0)
- return text;
- if (matchCount == 1)
- return fLabelProvider.getText(element)+ " (" + 1 + " match)"; //$NON-NLS-1$ //$NON-NLS-2$
- return text + " (" + matchCount + " matches)"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void dispose() {
- fLabelProvider.dispose();
- super.dispose();
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileContentProvider.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileContentProvider.java
deleted file mode 100644
index abe1bce..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileContentProvider.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui.text;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-
-import org.eclipse.search.ui.text.AbstractTextSearchResult;
-public abstract class FileContentProvider implements IStructuredContentProvider {
- protected final Object[] EMPTY_ARR= new Object[0];
- protected AbstractTextSearchResult fResult;
- public void dispose() {
- // nothing to do
- }
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- if (newInput instanceof FileSearchResult) {
- initialize((FileSearchResult) newInput);
- }
- }
- protected void initialize(AbstractTextSearchResult result) {
- fResult= result;
- }
-
- public abstract void elementsChanged(Object[] updatedElements);
- public abstract void clear();
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileLabelProvider.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileLabelProvider.java
deleted file mode 100644
index 83713c5..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileLabelProvider.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui.text;
-
-import java.text.MessageFormat;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IPath;
-
-import org.eclipse.swt.graphics.Image;
-
-import org.eclipse.jface.viewers.ILabelDecorator;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.LabelProvider;
-
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.model.WorkbenchLabelProvider;
-
-import org.eclipse.search.internal.ui.SearchMessages;
-
-
-public class FileLabelProvider extends LabelProvider {
-
- public static final int SHOW_LABEL= 1;
- public static final int SHOW_LABEL_PATH= 2;
- public static final int SHOW_PATH_LABEL= 3;
- public static final int SHOW_PATH= 4;
-
- private static final String fgSeparatorFormat= "{0} - {1}"; //$NON-NLS-1$
-
- private WorkbenchLabelProvider fLabelProvider;
- private ILabelDecorator fDecorator;
-
- private int fOrder;
- private String[] fArgs= new String[2];
-
- public FileLabelProvider(int orderFlag) {
- fDecorator= PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator();
- fLabelProvider= new WorkbenchLabelProvider();
- fOrder= orderFlag;
- }
-
- public void setOrder(int orderFlag) {
- fOrder= orderFlag;
- }
-
- public int getOrder() {
- return fOrder;
- }
-
- public String getText(Object element) {
- if (!(element instanceof IResource))
- return null; //$NON-NLS-1$
-
- IResource resource= (IResource)element;
- String text= null;
-
- if (!resource.exists())
- text= SearchMessages.getString("FileLabelProvider.removed_resource.label"); //$NON-NLS-1$
-
- else {
- IPath path= resource.getFullPath().removeLastSegments(1);
- if (path.getDevice() == null)
- path= path.makeRelative();
- if (fOrder == SHOW_LABEL || fOrder == SHOW_LABEL_PATH) {
- text= fLabelProvider.getText(resource);
- if (path != null && fOrder == SHOW_LABEL_PATH) {
- fArgs[0]= text;
- fArgs[1]= path.toString();
- text= MessageFormat.format(fgSeparatorFormat, fArgs);
- }
- } else {
- if (path != null)
- text= path.toString();
- else
- text= ""; //$NON-NLS-1$
- if (fOrder == SHOW_PATH_LABEL) {
- fArgs[0]= text;
- fArgs[1]= fLabelProvider.getText(resource);
- text= MessageFormat.format(fgSeparatorFormat, fArgs);
- }
- }
- }
-
- // Do the decoration
- if (fDecorator != null) {
- String decoratedText= fDecorator.decorateText(text, resource);
- if (decoratedText != null)
- return decoratedText;
- }
- return text;
- }
-
- public Image getImage(Object element) {
- if (!(element instanceof IResource))
- return null; //$NON-NLS-1$
-
- IResource resource= (IResource)element;
- Image image= fLabelProvider.getImage(resource);
- if (fDecorator != null) {
- Image decoratedImage= fDecorator.decorateImage(image, resource);
- if (decoratedImage != null)
- return decoratedImage;
- }
- return image;
- }
-
- public void dispose() {
- super.dispose();
- fLabelProvider.dispose();
- }
-
- public boolean isLabelProperty(Object element, String property) {
- return fLabelProvider.isLabelProperty(element, property);
- }
-
- public void removeListener(ILabelProviderListener listener) {
- super.removeListener(listener);
- fLabelProvider.removeListener(listener);
- }
-
- public void addListener(ILabelProviderListener listener) {
- super.addListener(listener);
- fLabelProvider.addListener(listener);
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileMatch.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileMatch.java
deleted file mode 100644
index d1f28e1..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileMatch.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.search.internal.ui.text;
-
-import org.eclipse.core.resources.IFile;
-
-import org.eclipse.search.ui.text.Match;
-
-public class FileMatch extends Match {
- private long fCreationTimeStamp;
-
- public FileMatch(IFile element, int offset, int length) {
- super(element, offset, length);
- fCreationTimeStamp= element.getModificationStamp();
- }
-
- public IFile getFile() {
- return (IFile) getElement();
- }
-
- public long getCreationTimeStamp() {
- return fCreationTimeStamp;
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchDescription.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchDescription.java
deleted file mode 100644
index 9be1d44..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchDescription.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui.text;
-
-/**
- * @author Thomas Mäder
- *
- */
-public class FileSearchDescription {
- private String fSearchString;
- private String fScopeDescription;
-
- public FileSearchDescription(String searchString, String scopeDescription) {
- super();
- fSearchString= searchString;
- fScopeDescription= scopeDescription;
- }
-
- public String getScopeDescription() {
- return fScopeDescription;
- }
-
- public String getSearchString() {
- return fSearchString;
- }
-
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchPage.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchPage.java
deleted file mode 100644
index 27af90d..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchPage.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui.text;
-
-import java.util.HashMap;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.runtime.CoreException;
-
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TreeViewer;
-
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.actions.ActionContext;
-import org.eclipse.ui.actions.ActionGroup;
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.ui.texteditor.ITextEditor;
-
-import org.eclipse.search.ui.IContextMenuConstants;
-import org.eclipse.search.ui.ISearchResultViewPart;
-import org.eclipse.search.ui.SearchUI;
-import org.eclipse.search.ui.text.AbstractTextSearchViewPage;
-import org.eclipse.search.ui.text.Match;
-
-import org.eclipse.search.internal.ui.SearchMessages;
-import org.eclipse.search.internal.ui.SearchPlugin;
-
-
-/**
- * @author Thomas Mäder
- *
- */
-public class FileSearchPage extends AbstractTextSearchViewPage {
- private ActionGroup fActionGroup;
- private FileContentProvider fContentProvider;
- private SortAction fCurrentSortAction;
- private SortAction fSortByNameAction;
- private SortAction fSortByPathAction;
-
-
- public FileSearchPage() {
- fSortByNameAction= new SortAction(SearchMessages.getString("FileSearchPage.sort_name.label"), this, FileLabelProvider.SHOW_LABEL_PATH); //$NON-NLS-1$
- fSortByPathAction= new SortAction(SearchMessages.getString("FileSearchPage.sort_path.label"), this, FileLabelProvider.SHOW_PATH_LABEL); //$NON-NLS-1$
- fCurrentSortAction= fSortByNameAction;
- }
-
- public StructuredViewer getViewer() {
- return super.getViewer();
- }
-
- protected void configureTableViewer(TableViewer viewer) {
- viewer.setLabelProvider(new DelegatingLabelProvider(this, new FileLabelProvider(FileLabelProvider.SHOW_LABEL)));
- viewer.setContentProvider(new FileTableContentProvider(viewer));
- setSortOrder(fCurrentSortAction);
- fContentProvider= (FileContentProvider) viewer.getContentProvider();
- }
-
- protected void configureTreeViewer(TreeViewer viewer) {
- viewer.setLabelProvider(new DelegatingLabelProvider(this, new FileLabelProvider(FileLabelProvider.SHOW_LABEL)));
- viewer.setContentProvider(new FileTreeContentProvider(viewer));
- fContentProvider= (FileContentProvider) viewer.getContentProvider();
- }
-
- protected void showMatch(Match match, int offset, int length) throws PartInitException {
- IFile file= (IFile) match.getElement();
- IWorkbenchPage page= SearchPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
- IEditorPart editor= IDE.openEditor(page, file, false);
- if (editor instanceof ITextEditor) {
- ITextEditor textEditor= (ITextEditor) editor;
- textEditor.selectAndReveal(offset, length);
- } else if (editor != null){
- showWithMarker(editor, file, offset, length);
- }
- }
- private void showWithMarker(IEditorPart editor, IFile file, int offset, int length) throws PartInitException {
- try {
- IMarker marker= file.createMarker(SearchUI.SEARCH_MARKER);
- HashMap attributes= new HashMap(4);
- attributes.put(IMarker.CHAR_START, new Integer(offset));
- attributes.put(IMarker.CHAR_END, new Integer(offset + length));
- marker.setAttributes(attributes);
- IDE.gotoMarker(editor, marker);
- marker.delete();
- } catch (CoreException e) {
- throw new PartInitException(SearchMessages.getString("FileSearchPage.error.marker"), e); //$NON-NLS-1$
- }
- }
-
- protected void fillContextMenu(IMenuManager mgr) {
- super.fillContextMenu(mgr);
- addSortActions(mgr);
- fActionGroup.setContext(new ActionContext(getSite().getSelectionProvider().getSelection()));
- fActionGroup.fillContextMenu(mgr);
- FileSearchQuery query= (FileSearchQuery) getInput().getQuery();
- if (!"".equals(query.getSearchString())) { //$NON-NLS-1$
- ReplaceAction2 replaceAction= new ReplaceAction2(this, (IStructuredSelection) getViewer().getSelection());
- if (replaceAction.isEnabled())
- mgr.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, replaceAction);
-
- ReplaceAction2 replaceAll= new ReplaceAction2(this);
- if (replaceAll.isEnabled())
- mgr.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, replaceAll);
- }
- }
-
- private void addSortActions(IMenuManager mgr) {
- if (getLayout() != FLAG_LAYOUT_FLAT)
- return;
- MenuManager sortMenu= new MenuManager(SearchMessages.getString("FileSearchPage.sort_by.label")); //$NON-NLS-1$
- sortMenu.add(fSortByNameAction);
- sortMenu.add(fSortByPathAction);
-
- fSortByNameAction.setChecked(fCurrentSortAction == fSortByNameAction);
- fSortByPathAction.setChecked(fCurrentSortAction == fSortByPathAction);
-
- mgr.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, sortMenu);
- }
-
- public void setViewPart(ISearchResultViewPart part) {
- super.setViewPart(part);
- fActionGroup= new NewTextSearchActionGroup(part);
- }
-
- public void dispose() {
- fActionGroup.dispose();
- super.dispose();
- }
-
- protected void elementsChanged(Object[] objects) {
- if (fContentProvider != null)
- fContentProvider.elementsChanged(objects);
- }
-
- protected void clear() {
- if (fContentProvider != null)
- fContentProvider.clear();
- }
-
- public void setSortOrder(SortAction action) {
- fCurrentSortAction= action;
- StructuredViewer viewer= getViewer();
- DelegatingLabelProvider lpWrapper= (DelegatingLabelProvider) viewer.getLabelProvider();
- ((FileLabelProvider)lpWrapper.getLabelProvider()).setOrder(action.getSortOrder());
- if (action.getSortOrder() == FileLabelProvider.SHOW_LABEL_PATH) {
- viewer.setSorter(new NameSorter());
- } else {
- viewer.setSorter(new PathSorter());
- }
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchQuery.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchQuery.java
deleted file mode 100644
index 19f3bc2..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchQuery.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui.text;
-
-import java.text.MessageFormat;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceProxy;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-
-import org.eclipse.search.ui.ISearchQuery;
-import org.eclipse.search.ui.ISearchResult;
-import org.eclipse.search.ui.text.AbstractTextSearchResult;
-
-import org.eclipse.search.internal.core.SearchScope;
-import org.eclipse.search.internal.core.text.ITextSearchResultCollector;
-import org.eclipse.search.internal.core.text.MatchLocator;
-import org.eclipse.search.internal.core.text.TextSearchEngine;
-import org.eclipse.search.internal.core.text.TextSearchScope;
-import org.eclipse.search.internal.ui.SearchPlugin;
-
-
-public class FileSearchQuery implements ISearchQuery {
- private String fSearchString;
- private String fSearchOptions;
- private TextSearchScope fScope;
- private FileSearchResult fResult;
-
- public FileSearchQuery(TextSearchScope scope, String options, String searchString) {
-
- fScope= scope;
- fSearchOptions= options;
- fSearchString= searchString;
- }
-
- public boolean canRunInBackground() {
- return true;
- }
-
- public IStatus run(final IProgressMonitor pm) {
- final AbstractTextSearchResult textResult= (AbstractTextSearchResult) getSearchResult();
- textResult.removeAll();
- ITextSearchResultCollector collector= new ITextSearchResultCollector() {
- public IProgressMonitor getProgressMonitor() {
- return pm;
- }
-
- public void aboutToStart() {
- // do nothing
- }
-
- public void accept(IResourceProxy proxy, String line, int start, int length, int lineNumber) {
- IResource resource= proxy.requestResource();
- if (start < 0)
- start= 0;
- if (length < 0)
- length= 0;
- textResult.addMatch(new FileMatch((IFile) resource, start, length));
- }
-
- public void done() {
- // do nothing
- }
- };
- return new TextSearchEngine().search(SearchPlugin.getWorkspace(), fScope, collector, new MatchLocator(fSearchString, fSearchOptions));
- }
-
- public String getLabel() {
- return "Searching for occurrences of \""+fSearchString+"\"";
- }
-
- public String getSearchString() {
- return fSearchString;
- }
-
- String getSingularLabel() {
- String[] args= new String[] { fSearchString, fScope.getDescription() };
- String format= "\"{0}\" - 1 match in {1}"; //$NON-NLS-1$
- return MessageFormat.format(format, args);
- }
-
- String getPluralPattern() {
- String[] args= new String[] { fSearchString, "{0}", fScope.getDescription() }; //$NON-NLS-1$
- String format= "\"{0}\" - {1} matches in {2}"; //$NON-NLS-1$
- return MessageFormat.format(format, args);
- }
-
- /**
- * @return
- */
- public IStatus searchInFile(final AbstractTextSearchResult result, final IProgressMonitor monitor, IFile file) {
- ITextSearchResultCollector collector= new ITextSearchResultCollector() {
- public IProgressMonitor getProgressMonitor() {
- return monitor;
- }
-
- public void aboutToStart() {
- // do nothing
- }
-
- public void accept(IResourceProxy proxy, String line, int start, int length, int lineNumber) {
- IResource resource= proxy.requestResource();
- if (start < 0)
- start= 0;
- if (length < 0)
- length= 0;
- result.addMatch(new FileMatch((IFile) resource, start, length));
- }
-
- public void done() {
- // do nothing
- }
- };
- SearchScope scope= new SearchScope("", new IResource[] { file }); //$NON-NLS-1$
- new TextSearchEngine().search(SearchPlugin.getWorkspace(), scope, collector, new MatchLocator(fSearchString, fSearchOptions));
- return Status.OK_STATUS; //$NON-NLS-1$
- }
-
- public boolean canRerun() {
- return true;
- }
-
- public ISearchResult getSearchResult() {
- if (fResult == null)
- fResult= new FileSearchResult(this);
- return fResult;
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchResult.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchResult.java
deleted file mode 100644
index b29d99b..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchResult.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui.text;
-
-import java.text.MessageFormat;
-
-import org.eclipse.core.resources.IFile;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.part.FileEditorInput;
-
-import org.eclipse.search.ui.ISearchQuery;
-import org.eclipse.search.ui.text.AbstractTextSearchResult;
-import org.eclipse.search.ui.text.Match;
-
-import org.eclipse.search.internal.ui.SearchPluginImages;
-
-
-/**
- * @author Thomas Mäder
- *
- */
-public class FileSearchResult extends AbstractTextSearchResult {
- private final Match[] EMPTY_ARR= new Match[0];
-
- private FileSearchQuery fQuery;
- /**
- * @param description
- */
- public FileSearchResult(FileSearchQuery job) {
- fQuery= job;
- }
- public ImageDescriptor getImageDescriptor() {
- return SearchPluginImages.DESC_OBJ_TSEARCH_DPDN;
- }
- public String getLabel() {
- if (getMatchCount() == 1)
- return fQuery.getSingularLabel();
- else return MessageFormat.format(fQuery.getPluralPattern(), new Object[] { new Integer(getMatchCount()) });
- }
- public String getTooltip() {
- return getLabel();
- }
-
- public Match[] findContainedMatches(IFile file) {
- return getMatches(file);
- }
-
- public IFile getFile(Object element) {
- if (element instanceof IFile)
- return (IFile)element;
- return null;
- }
-
- public boolean isShownInEditor(Match match, IEditorPart editor) {
- IEditorInput ei= editor.getEditorInput();
- if (ei instanceof IFileEditorInput) {
- FileEditorInput fi= (FileEditorInput) ei;
- return match.getElement().equals(fi.getFile());
- }
- return false;
- }
-
- public Match[] findContainedMatches(IEditorPart editor) {
- IEditorInput ei= editor.getEditorInput();
- if (ei instanceof IFileEditorInput) {
- FileEditorInput fi= (FileEditorInput) ei;
- return getMatches(fi.getFile());
- }
- return EMPTY_ARR;
- }
-
- public ISearchQuery getQuery() {
- return fQuery;
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileTableContentProvider.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileTableContentProvider.java
deleted file mode 100644
index 0753f54..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileTableContentProvider.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui.text;
-
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-
-public class FileTableContentProvider extends FileContentProvider implements IStructuredContentProvider {
- private TableViewer fTableViewer;
-
- /**
- * @param viewer
- */
- public FileTableContentProvider(TableViewer viewer) {
- fTableViewer= viewer;
- }
- public Object[] getElements(Object inputElement) {
- if (inputElement instanceof FileSearchResult)
- return ((FileSearchResult)inputElement).getElements();
- return EMPTY_ARR;
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- if (newInput instanceof FileSearchResult) {
- fResult= (FileSearchResult) newInput;
- }
- }
-
- public void elementsChanged(Object[] updatedElements) {
- for (int i= 0; i < updatedElements.length; i++) {
- if (fResult.getMatchCount(updatedElements[i]) > 0)
- fTableViewer.add(updatedElements[i]);
- else
- fTableViewer.remove(updatedElements[i]);
- }
- }
-
- public void clear() {
- fTableViewer.refresh();
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileTreeContentProvider.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileTreeContentProvider.java
deleted file mode 100644
index 6a66f53..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileTreeContentProvider.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui.text;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-
-import org.eclipse.jface.viewers.AbstractTreeViewer;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-
-import org.eclipse.search.ui.text.AbstractTextSearchResult;
-/**
- * @author Thomas Mäder
- *
- */
-public class FileTreeContentProvider extends FileContentProvider implements ITreeContentProvider {
- private AbstractTreeViewer fTreeViewer;
- private Map fChildrenMap;
-
- FileTreeContentProvider(AbstractTreeViewer viewer) {
- fTreeViewer= viewer;
- }
-
- public Object[] getElements(Object inputElement) {
- return getChildren(inputElement);
- }
-
-
- protected synchronized void initialize(AbstractTextSearchResult result) {
- super.initialize(result);
- fChildrenMap= new HashMap();
- if (result != null) {
- Object[] elements= result.getElements();
- for (int i= 0; i < elements.length; i++) {
- insert(elements[i], false);
- }
- }
- }
-
- protected void insert(Object child, boolean refreshViewer) {
- Object parent= getParent(child);
- while (parent != null) {
- if (insertChild(parent, child)) {
- if (refreshViewer)
- fTreeViewer.add(parent, child);
- } else {
- if (refreshViewer)
- fTreeViewer.refresh(parent);
- return;
- }
- child= parent;
- parent= getParent(child);
- }
- if (insertChild(fResult, child)) {
- if (refreshViewer)
- fTreeViewer.add(fResult, child);
- }
- }
-
- /**
- * returns true if the child already was a child of parent.
- *
- * @param parent
- * @param child
- * @return
- */
- private boolean insertChild(Object parent, Object child) {
- Set children= (Set) fChildrenMap.get(parent);
- if (children == null) {
- children= new HashSet();
- fChildrenMap.put(parent, children);
- }
- return children.add(child);
- }
-
- protected void remove(Object element, boolean refreshViewer) {
- // precondition here: fResult.getMatchCount(child) <= 0
-
- if (hasChildren(element)) {
- if (refreshViewer)
- fTreeViewer.refresh(element);
- } else {
- if (fResult.getMatchCount(element) == 0) {
- fChildrenMap.remove(element);
- Object parent= getParent(element);
- if (parent != null) {
- removeFromSiblings(element, parent);
- remove(parent, refreshViewer);
- } else {
- removeFromSiblings(element, fResult);
- if (refreshViewer)
- fTreeViewer.refresh();
- }
- } else {
- if (refreshViewer) {
- fTreeViewer.refresh(element);
- }
- }
- }
- }
-
- private void removeFromSiblings(Object element, Object parent) {
- Set siblings= (Set) fChildrenMap.get(parent);
- if (siblings != null) {
- siblings.remove(element);
- }
- }
-
- public Object[] getChildren(Object parentElement) {
- Set children= (Set) fChildrenMap.get(parentElement);
- if (children == null)
- return EMPTY_ARR;
- return children.toArray();
- }
-
- public boolean hasChildren(Object element) {
- return getChildren(element).length > 0;
- }
-
- public synchronized void elementsChanged(Object[] updatedElements) {
- for (int i= 0; i < updatedElements.length; i++) {
- if (fResult.getMatchCount(updatedElements[i]) > 0)
- insert(updatedElements[i], true);
- else
- remove(updatedElements[i], true);
- }
- }
-
- public void clear() {
- initialize(fResult);
- fTreeViewer.refresh();
- }
-
- public Object getParent(Object element) {
- if (element instanceof IProject)
- return null;
- if (element instanceof IResource) {
- IResource resource = (IResource) element;
- return resource.getParent();
- }
- return null;
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/GotoMarkerAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/GotoMarkerAction.java
deleted file mode 100644
index 5c7b954..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/GotoMarkerAction.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui.text;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-
-import org.eclipse.ui.IEditorDescriptor;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorReference;
-import org.eclipse.ui.IEditorRegistry;
-import org.eclipse.ui.IReusableEditor;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.ui.part.FileEditorInput;
-
-import org.eclipse.search.ui.ISearchResultView;
-import org.eclipse.search.ui.ISearchResultViewEntry;
-import org.eclipse.search.ui.SearchUI;
-
-import org.eclipse.search.internal.ui.SearchMessages;
-import org.eclipse.search.internal.ui.SearchPlugin;
-import org.eclipse.search.internal.ui.util.ExceptionHandler;
-
-class GotoMarkerAction extends Action {
-
- private IEditorPart fEditor;
-
- public void run() {
- ISearchResultView view= SearchUI.getSearchResultView();
- ISelection selection= view.getSelection();
- Object element= null;
- if (selection instanceof IStructuredSelection)
- element= ((IStructuredSelection)selection).getFirstElement();
- if (element instanceof ISearchResultViewEntry) {
- ISearchResultViewEntry entry= (ISearchResultViewEntry)element;
- show(entry.getSelectedMarker());
- }
- }
-
- private void show(IMarker marker) {
- if (SearchUI.reuseEditor())
- showWithReuse(marker);
- else
- showWithoutReuse(marker);
- }
-
- private void showWithReuse(IMarker marker) {
- IWorkbenchPage page= SearchPlugin.getActivePage();
- IResource resource= marker.getResource();
- if (page == null || !(resource instanceof IFile))
- return;
-
- IEditorInput input= new FileEditorInput((IFile)resource);
- String editorId= null;
- IEditorDescriptor desc= IDE.getDefaultEditor((IFile)resource);
- if (desc == null)
- editorId= SearchPlugin.getDefault().getWorkbench().getEditorRegistry().findEditor(IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID).getId();
- else
- editorId= desc.getId();
-
- IEditorPart editor= page.findEditor(input);
- if (editor != null)
- page.bringToTop(editor);
- else {
- boolean isOpen= false;
- if (fEditor != null) {
- IEditorReference[] parts= page.getEditorReferences();
- int i= 0;
- while (!isOpen && i < parts.length)
- isOpen= fEditor == parts[i++].getEditor(false);
- }
-
- boolean canBeReused= isOpen && !fEditor.isDirty() && !isPinned(fEditor);
- boolean showsSameInputType= fEditor != null && fEditor.getSite().getId().equals(editorId);
-
- if (canBeReused && !showsSameInputType) {
- page.closeEditor(fEditor, false);
- fEditor= null;
- }
-
- if (canBeReused && showsSameInputType) {
- ((IReusableEditor)fEditor).setInput(input);
- page.bringToTop(fEditor);
- editor= fEditor;
- } else
- try {
- editor= page.openEditor(input, editorId, false);
- if (editor instanceof IReusableEditor)
- fEditor= editor;
- else
- fEditor= null;
- } catch (PartInitException ex) {
- ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.openEditor.title"), SearchMessages.getString("Search.Error.openEditor.message")); //$NON-NLS-2$ //$NON-NLS-1$
- return;
- }
- }
-
- if (editor != null) {
- IDE.gotoMarker(editor, marker);
- }
- }
-
- private boolean isPinned(IEditorPart editor) {
- if (editor == null)
- return false;
-
- IEditorReference[] editorRefs= editor.getEditorSite().getPage().getEditorReferences();
- int i= 0;
- while (i < editorRefs.length) {
- if (editor.equals(editorRefs[i].getEditor(false)))
- return editorRefs[i].isPinned();
- i++;
- }
- return false;
- }
-
- private void showWithoutReuse(IMarker marker) {
- IWorkbenchPage page= SearchPlugin.getActivePage();
- if (page == null)
- return;
-
- try {
- IDE.openEditor(page, marker, false);
- } catch (PartInitException ex) {
- ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.openEditor.title"), SearchMessages.getString("Search.Error.openEditor.message")); //$NON-NLS-2$ //$NON-NLS-1$
- return;
- }
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/GroupByKeyComputer.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/GroupByKeyComputer.java
deleted file mode 100644
index 61e207f..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/GroupByKeyComputer.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui.text;
-
-import org.eclipse.core.resources.IMarker;
-
-import org.eclipse.search.ui.IGroupByKeyComputer;
-
-class GroupByKeyComputer implements IGroupByKeyComputer {
-
- public Object computeGroupByKey(IMarker marker) {
- if (marker == null)
- return null;
- else
- return marker.getResource();
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/NameSorter.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/NameSorter.java
deleted file mode 100644
index ab3567d..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/NameSorter.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.search.internal.ui.text;
-
-import org.eclipse.core.resources.IResource;
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-
-public class NameSorter extends ViewerSorter {
- public int compare(Viewer viewer, Object e1, Object e2) {
- return compare((IResource)e1, (IResource)e2);
- }
-
- protected int compare(IResource resource, IResource resource2) {
- String property1= getProperty(resource);
- String property2= getProperty(resource2);
- return collator.compare(property1, property2);
- }
-
- protected String getProperty(IResource resource) {
- return resource.getName();
- }
-
- public boolean isSorterProperty(Object element, String property) {
- return true;
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/NewTextSearchActionGroup.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/NewTextSearchActionGroup.java
deleted file mode 100644
index ab169fc..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/NewTextSearchActionGroup.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui.text;
-
-import org.eclipse.core.runtime.IAdaptable;
-
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.actions.ActionGroup;
-import org.eclipse.ui.actions.OpenWithMenu;
-import org.eclipse.ui.dialogs.PropertyDialogAction;
-
-import org.eclipse.search.ui.IContextMenuConstants;
-
-import org.eclipse.search.internal.ui.SearchMessages;
-
-/**
- * Action group that adds the Text search actions to a context menu and
- * the global menu bar.
- *
- * <p>
- * This class may be instantiated; it is not intended to be subclassed.
- * </p>
- *
- * @since 2.1
- */
-class NewTextSearchActionGroup extends ActionGroup {
-
- private ISelectionProvider fSelectionProvider;
- private IWorkbenchPage fPage;
- private PropertyDialogAction fOpenPropertiesDialog;
-
- public NewTextSearchActionGroup(IViewPart part) {
- Assert.isNotNull(part);
- IWorkbenchPartSite site= part.getSite();
- fSelectionProvider= site.getSelectionProvider();
- fPage= site.getPage();
- fOpenPropertiesDialog= new PropertyDialogAction(site.getShell(), fSelectionProvider);
-
- ISelection selection= fSelectionProvider.getSelection();
-
- if (selection instanceof IStructuredSelection)
- fOpenPropertiesDialog.selectionChanged((IStructuredSelection)selection);
- else
- fOpenPropertiesDialog.selectionChanged(selection);
- }
-
- public void fillContextMenu(IMenuManager menu) {
- // view must exist if we create a context menu for it.
-
- ISelection selection= getContext().getSelection();
- if (selection instanceof IStructuredSelection) {
- addOpenWithMenu(menu, (IStructuredSelection) selection);
- if (fOpenPropertiesDialog != null && fOpenPropertiesDialog.isEnabled() && selection != null &&fOpenPropertiesDialog.isApplicableForSelection((IStructuredSelection) selection))
- menu.appendToGroup(IContextMenuConstants.GROUP_PROPERTIES, fOpenPropertiesDialog);
- }
-
- }
-
- private void addOpenWithMenu(IMenuManager menu, IStructuredSelection selection) {
- if (selection == null || selection.size() != 1)
- return;
-
- Object o= selection.getFirstElement();
-
- if (!(o instanceof IAdaptable))
- return;
-
- // Create menu
- IMenuManager submenu= new MenuManager(SearchMessages.getString("OpenWithMenu.label")); //$NON-NLS-1$
- submenu.add(new OpenWithMenu(fPage, (IAdaptable)o));
-
- // Add the submenu.
- menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, submenu);
- }
-
- /* (non-Javadoc)
- * Method declared in ActionGroup
- */
- public void fillActionBars(IActionBars actionBar) {
- super.fillActionBars(actionBar);
- setGlobalActionHandlers(actionBar);
- }
-
- private void setGlobalActionHandlers(IActionBars actionBars) {
- actionBars.setGlobalActionHandler(ActionFactory.PROPERTIES.getId(), fOpenPropertiesDialog);
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/PathSorter.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/PathSorter.java
deleted file mode 100644
index 2f5acad..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/PathSorter.java
+++ /dev/null
@@ -1,28 +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.search.internal.ui.text;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IPath;
-
-public class PathSorter extends NameSorter {
- protected int compare(IResource left, IResource right) {
- IPath path1= left.getFullPath();
- IPath path2= right.getFullPath();
- int segmentCount= Math.min(path1.segmentCount(), path2.segmentCount());
- for (int i= 0; i < segmentCount; i++) {
- int value= collator.compare(path1.segment(i), path2.segment(i));
- if (value != 0)
- return value;
- }
- return path1.segmentCount() - path2.segmentCount();
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceAction.java
deleted file mode 100644
index e51e287..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceAction.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui.text;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceProxy;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-
-import org.eclipse.core.filebuffers.FileBuffers;
-import org.eclipse.core.filebuffers.ITextFileBuffer;
-import org.eclipse.core.filebuffers.ITextFileBufferManager;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-
-import org.eclipse.ui.IWorkbenchSite;
-import org.eclipse.ui.actions.WorkspaceModifyOperation;
-
-import org.eclipse.search.ui.SearchUI;
-
-import org.eclipse.search.internal.core.text.ITextSearchResultCollector;
-import org.eclipse.search.internal.ui.Search;
-import org.eclipse.search.internal.ui.SearchManager;
-import org.eclipse.search.internal.ui.SearchMessages;
-import org.eclipse.search.internal.ui.SearchPlugin;
-import org.eclipse.search.internal.ui.SearchResultView;
-import org.eclipse.search.internal.ui.SearchResultViewEntry;
-import org.eclipse.search.internal.ui.util.ExceptionHandler;
-
-/* package */ class ReplaceAction extends Action {
-
- private IWorkbenchSite fSite;
- private List fElements;
-
- public ReplaceAction(IWorkbenchSite site, List elements) {
- Assert.isNotNull(site);
- fSite= site;
- if (elements != null)
- fElements= elements;
- else
- fElements= new ArrayList(0);
- setText(SearchMessages.getString("ReplaceAction.label_all")); //$NON-NLS-1$
- setEnabled(!fElements.isEmpty());
- }
-
- public ReplaceAction(IWorkbenchSite site, IStructuredSelection selection) {
- Assert.isNotNull(site);
- fSite= site;
- setText(SearchMessages.getString("ReplaceAction.label_selected")); //$NON-NLS-1$
- fElements= selection.toList();
- setEnabled(!fElements.isEmpty());
- }
-
- public void run() {
- Search search= SearchManager.getDefault().getCurrentSearch();
- IRunnableWithProgress operation= search.getOperation();
- if (operation instanceof TextSearchOperation) {
- if (validateResources((TextSearchOperation) operation)) {
- ReplaceDialog dialog= new ReplaceDialog(fSite.getShell(), fElements, (TextSearchOperation)operation);
- dialog.open();
- }
- } else {
- MessageDialog.openError(fSite.getShell(), getDialogTitle(), SearchMessages.getString("ReplaceAction.error.only_on_text_search")); //$NON-NLS-1$
- }
- }
-
- private boolean validateResources(final TextSearchOperation operation) {
- final List outOfDateEntries= new ArrayList();
- for (Iterator elements = fElements.iterator(); elements.hasNext();) {
- SearchResultViewEntry entry = (SearchResultViewEntry) elements.next();
- if (isOutOfDate(entry)) {
- outOfDateEntries.add(entry);
- }
- }
-
- final List outOfSyncEntries= new ArrayList();
- for (Iterator elements = fElements.iterator(); elements.hasNext();) {
- SearchResultViewEntry entry = (SearchResultViewEntry) elements.next();
- if (isOutOfSync(entry)) {
- outOfSyncEntries.add(entry);
- }
- }
-
- if (outOfDateEntries.size() > 0 || outOfSyncEntries.size() > 0) {
- if (askForResearch(outOfDateEntries, outOfSyncEntries)) {
- ProgressMonitorDialog pmd= new ProgressMonitorDialog(fSite.getShell());
- try {
- pmd.run(true, true, new WorkspaceModifyOperation(null) {
- protected void execute(IProgressMonitor monitor) throws CoreException {
- research(monitor, outOfDateEntries, operation);
- }
- });
- return true;
- } catch (InvocationTargetException e) {
- ExceptionHandler.handle(e, fSite.getShell(), SearchMessages.getString("ReplaceAction.label"), SearchMessages.getString("ReplaceAction.research.error")); //$NON-NLS-1$ //$NON-NLS-2$
- } catch (InterruptedException e) {
- // canceled
- }
- }
- return false;
- }
- return true;
- }
-
- private void research(IProgressMonitor monitor, List outOfDateEntries, TextSearchOperation operation) throws CoreException {
- IStatus status= null;
- for (Iterator elements = outOfDateEntries.iterator(); elements.hasNext();) {
- SearchResultViewEntry entry = (SearchResultViewEntry) elements.next();
- status = research(operation, monitor, entry);
- if (status != null && !status.isOK()) {
- throw new CoreException(status);
- }
- }
- }
-
- private boolean askForResearch(List outOfDateEntries, List outOfSyncEntries) {
- SearchResultView view= (SearchResultView) SearchPlugin.getSearchResultView();
- ILabelProvider labelProvider= null;
- if (view != null)
- labelProvider= view.getLabelProvider();
- SearchAgainConfirmationDialog dialog= new SearchAgainConfirmationDialog(fSite.getShell(), labelProvider, outOfSyncEntries, outOfDateEntries);
- return dialog.open() == IDialogConstants.OK_ID;
- }
-
- private String getDialogTitle() {
- return SearchMessages.getString("ReplaceAction.dialog.title"); //$NON-NLS-1$
- }
-
- private boolean isOutOfDate(SearchResultViewEntry entry) {
- IResource resource= entry.getResource();
- if (entry.getModificationStamp() != resource.getModificationStamp())
- return true;
- ITextFileBufferManager bm= FileBuffers.getTextFileBufferManager();
- ITextFileBuffer fb= bm.getTextFileBuffer(resource.getFullPath());
- if (fb != null && fb.isDirty())
- return true;
- return false;
- }
-
- private boolean isOutOfSync(SearchResultViewEntry entry) {
- return !entry.getResource().isSynchronized(IResource.DEPTH_ZERO);
- }
-
- private IStatus research(TextSearchOperation operation, final IProgressMonitor monitor, SearchResultViewEntry entry) throws CoreException {
- List markers= new ArrayList();
- markers.addAll(entry.getMarkers());
- operation.searchInFile((IFile) entry.getResource(), new ITextSearchResultCollector() {
- public IProgressMonitor getProgressMonitor() {
- return monitor;
- }
-
- public void aboutToStart() {
- // nothing to do
- }
-
- public void accept(IResourceProxy proxy, String line, int start, int length, int lineNumber) throws CoreException {
- IFile file= (IFile)proxy.requestResource();
- if (start < 0 || length < 1)
- return;
- IMarker marker= file.createMarker(SearchUI.SEARCH_MARKER);
- HashMap attributes= new HashMap(4);
- attributes.put(SearchUI.LINE, line);
- attributes.put(IMarker.CHAR_START, new Integer(start));
- attributes.put(IMarker.CHAR_END, new Integer(start + length));
- attributes.put(IMarker.LINE_NUMBER, new Integer(lineNumber));
- marker.setAttributes(attributes);
- }
-
- public void done(){
- // nothing to do
- }
- });
- IStatus status = operation.getStatus();
- if (status == null || status.isOK()) {
- for (Iterator markerIter = markers.iterator(); markerIter.hasNext();) {
- IMarker marker = (IMarker) markerIter.next();
- marker.delete();
- }
- }
- return status;
- }
-
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceAction2.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceAction2.java
deleted file mode 100644
index 16e63f0..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceAction2.java
+++ /dev/null
@@ -1,243 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui.text;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-import java.util.Set;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceProxy;
-import org.eclipse.core.resources.IResourceProxyVisitor;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-
-import org.eclipse.swt.widgets.Item;
-
-import org.eclipse.core.filebuffers.FileBuffers;
-import org.eclipse.core.filebuffers.ITextFileBuffer;
-import org.eclipse.core.filebuffers.ITextFileBufferManager;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TreeViewer;
-
-import org.eclipse.ui.IWorkbenchSite;
-import org.eclipse.ui.actions.WorkspaceModifyOperation;
-
-import org.eclipse.search.ui.text.AbstractTextSearchResult;
-import org.eclipse.search.ui.text.Match;
-
-import org.eclipse.search.internal.ui.SearchMessages;
-import org.eclipse.search.internal.ui.SearchPlugin;
-import org.eclipse.search.internal.ui.util.ExceptionHandler;
-
-/* package */ class ReplaceAction2 extends Action {
-
- private IWorkbenchSite fSite;
- private IFile[] fElements;
- private FileSearchPage fPage;
-
- private static class ItemIterator implements Iterator {
- private Item[] fArray;
- private int fNextPosition;
- ItemIterator(Item[] array) {
- fArray= array;
- fNextPosition= 0;
- }
-
- public boolean hasNext() {
- return fNextPosition < fArray.length;
- }
-
- public Object next() {
- if (!hasNext())
- throw new NoSuchElementException();
- return fArray[fNextPosition++].getData();
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
- }
-
- public ReplaceAction2(FileSearchPage page, IFile[] elements) {
- Assert.isNotNull(page);
- fSite= page.getSite();
- if (elements != null)
- fElements= elements;
- else
- fElements= new IFile[0];
- fPage= page;
-
- setText(SearchMessages.getString("ReplaceAction.label_all")); //$NON-NLS-1$
- setEnabled(!(fElements.length == 0));
- }
-
- public ReplaceAction2(FileSearchPage page) {
- Assert.isNotNull(page);
- fSite= page.getSite();
- fPage= page;
-
- Item[] items= null;
- StructuredViewer viewer= fPage.getViewer();
- if (viewer instanceof TreeViewer) {
- items= ((TreeViewer)viewer).getTree().getItems();
- } else if (viewer instanceof TableViewer) {
- items= ((TableViewer)viewer).getTable().getItems();
- }
- fElements= collectFiles(new ItemIterator(items));
-
- setText(SearchMessages.getString("ReplaceAction.label_all")); //$NON-NLS-1$
- setEnabled(!(fElements.length == 0));
- }
-
-
- public ReplaceAction2(FileSearchPage page, IStructuredSelection selection) {
- fSite= page.getSite();
- fPage= page;
- setText(SearchMessages.getString("ReplaceAction.label_selected")); //$NON-NLS-1$
- fElements= collectFiles(selection.iterator());
- setEnabled(!(fElements.length == 0));
- }
-
- private IFile[] collectFiles(Iterator resources) {
- final Set files= new HashSet();
- while (resources.hasNext()) {
- IResource resource= (IResource) resources.next();
- try {
- resource.accept(new IResourceProxyVisitor() {
- public boolean visit(IResourceProxy proxy) throws CoreException {
- if (proxy.getType() == IResource.FILE) {
- files.add(proxy.requestResource());
- return false;
- }
- return true;
- }
- }, IContainer.NONE);
- } catch (CoreException e) {
- // TODO Don't know yet how to handle this. This is called when we open the context
- // menu. A bad time to show a dialog.
- SearchPlugin.getDefault().getLog().log(e.getStatus());
- }
- }
- return (IFile[]) files.toArray(new IFile[files.size()]);
- }
-
- private AbstractTextSearchResult getResult() {
- return fPage.getInput();
- }
-
- public void run() {
- if (validateResources((FileSearchQuery) getResult().getQuery())) {
- ReplaceDialog2 dialog= new ReplaceDialog2(fSite.getShell(), fElements, fPage.getViewer(), getResult());
- dialog.open();
- }
- }
-
- private boolean validateResources(final FileSearchQuery operation) {
- final List outOfDateEntries= new ArrayList();
- for (int j= 0; j < fElements.length; j++) {
- IFile entry = fElements[j];
- Match[] markers= getResult().getMatches(entry);
- for (int i= 0; i < markers.length; i++) {
- if (isOutOfDate((FileMatch)markers[i])) {
- outOfDateEntries.add(entry);
- break;
- }
- }
- }
-
- final List outOfSyncEntries= new ArrayList();
- for (int i= 0; i < fElements.length; i++) {
- IFile entry = fElements[i];
- if (isOutOfSync(entry)) {
- outOfSyncEntries.add(entry);
- }
- }
-
- if (outOfDateEntries.size() > 0 || outOfSyncEntries.size() > 0) {
- if (askForResearch(outOfDateEntries, outOfSyncEntries)) {
- ProgressMonitorDialog pmd= new ProgressMonitorDialog(fSite.getShell());
- try {
- pmd.run(true, true, new WorkspaceModifyOperation(null) {
- protected void execute(IProgressMonitor monitor) throws CoreException {
- research(monitor, outOfDateEntries, operation);
- }
- });
- return true;
- } catch (InvocationTargetException e) {
- ExceptionHandler.handle(e, fSite.getShell(), SearchMessages.getString("ReplaceAction.label"), SearchMessages.getString("ReplaceAction.research.error")); //$NON-NLS-1$ //$NON-NLS-2$
- } catch (InterruptedException e) {
- // canceled
- }
- }
- return false;
- }
- return true;
- }
-
- private void research(IProgressMonitor monitor, List outOfDateEntries, FileSearchQuery operation) throws CoreException {
- IStatus status= null;
- for (Iterator elements = outOfDateEntries.iterator(); elements.hasNext();) {
- IFile entry = (IFile) elements.next();
- status = research(operation, monitor, entry);
- if (status != null && !status.isOK()) {
- throw new CoreException(status);
- }
- }
- }
-
- private boolean askForResearch(List outOfDateEntries, List outOfSyncEntries) {
- SearchAgainConfirmationDialog dialog= new SearchAgainConfirmationDialog(fSite.getShell(), (ILabelProvider) fPage.getViewer().getLabelProvider(), outOfSyncEntries, outOfDateEntries);
- return dialog.open() == IDialogConstants.OK_ID;
- }
-
- private boolean isOutOfDate(FileMatch match) {
-
- if (match.getCreationTimeStamp() != match.getFile().getModificationStamp())
- return true;
- ITextFileBufferManager bm= FileBuffers.getTextFileBufferManager();
- ITextFileBuffer fb= bm.getTextFileBuffer(match.getFile().getFullPath());
- if (fb != null && fb.isDirty())
- return true;
- return false;
- }
-
- private boolean isOutOfSync(IFile entry) {
- return !entry.isSynchronized(IResource.DEPTH_ZERO);
- }
-
- private IStatus research(FileSearchQuery operation, final IProgressMonitor monitor, IFile entry) {
- Match[] matches= getResult().getMatches(entry);
- IStatus status= operation.searchInFile(getResult(), monitor, entry);
- if (status == null || status.isOK()) {
- for (int i= 0; i < matches.length; i++) {
- getResult().removeMatch(matches[i]);
- }
- }
- return status;
- }
-
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceDialog.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceDialog.java
deleted file mode 100644
index f867336..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceDialog.java
+++ /dev/null
@@ -1,679 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui.text;
-
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.SubProgressMonitor;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Text;
-
-import org.eclipse.core.filebuffers.FileBuffers;
-import org.eclipse.core.filebuffers.ITextFileBuffer;
-import org.eclipse.core.filebuffers.ITextFileBufferManager;
-
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.Position;
-
-import org.eclipse.ui.IEditorDescriptor;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorReference;
-import org.eclipse.ui.IReusableEditor;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.actions.WorkspaceModifyOperation;
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.MarkerUtilities;
-
-import org.eclipse.search.ui.SearchUI;
-
-import org.eclipse.search.internal.ui.SearchMessages;
-import org.eclipse.search.internal.ui.SearchPlugin;
-import org.eclipse.search.internal.ui.SearchResultView;
-import org.eclipse.search.internal.ui.SearchResultViewEntry;
-import org.eclipse.search.internal.ui.SearchResultViewer;
-import org.eclipse.search.internal.ui.util.ExtendedDialogWindow;
-
-class ReplaceDialog extends ExtendedDialogWindow {
-
- /**
- * A class wrapping a resource marker, adding a position.
- */
- private static class ReplaceMarker {
- private Position fPosition;
- private IMarker fMarker;
-
- ReplaceMarker(IMarker marker) {
- fMarker= marker;
- }
-
- public IFile getFile() {
- return (IFile)fMarker.getResource();
- }
-
- public void deletePosition(IDocument doc) {
- if (fPosition != null) {
- MarkerUtilities.setCharStart(fMarker, fPosition.getOffset());
- MarkerUtilities.setCharEnd(fMarker, fPosition.getOffset()+fPosition.getLength());
- doc.removePosition(fPosition);
- fPosition= null;
- }
- }
-
- public void delete() throws CoreException {
- fMarker.delete();
- }
-
- public void createPosition(IDocument doc) throws BadLocationException {
- if (fPosition == null) {
- int charStart= MarkerUtilities.getCharStart(fMarker);
- fPosition= new Position(charStart, MarkerUtilities.getCharEnd(fMarker)-charStart);
- doc.addPosition(fPosition);
- }
- }
-
- public int getLength() {
- if (fPosition != null)
- return fPosition.getLength();
- return MarkerUtilities.getCharEnd(fMarker)-MarkerUtilities.getCharStart(fMarker);
- }
-
- public int getOffset() {
- if (fPosition != null)
- return fPosition.getOffset();
- return MarkerUtilities.getCharStart(fMarker);
- }
- }
-
- private abstract static class ReplaceOperation extends WorkspaceModifyOperation {
- public void execute(IProgressMonitor monitor) throws InvocationTargetException {
- try {
- doReplace(monitor);
- } catch (BadLocationException e) {
- throw new InvocationTargetException(e);
- } catch (CoreException e) {
- throw new InvocationTargetException(e);
- } catch (IOException e) {
- throw new InvocationTargetException(e);
- }
- }
-
- protected abstract void doReplace(IProgressMonitor pm) throws BadLocationException, CoreException, IOException;
- }
-
- // various widget related constants
- private static final int REPLACE= IDialogConstants.CLIENT_ID + 1;
- private static final int REPLACE_ALL_IN_FILE= IDialogConstants.CLIENT_ID + 2;
- private static final int REPLACE_ALL= IDialogConstants.CLIENT_ID + 3;
- private static final int SKIP= IDialogConstants.CLIENT_ID + 4;
- private static final int SKIP_FILE= IDialogConstants.CLIENT_ID + 5;
- private static final int SKIP_ALL= IDialogConstants.CLIENT_ID + 6;
-
- // Widgets
- private Text fTextField;
- private Button fReplaceButton;
- private Button fReplaceAllInFileButton;
- private Button fReplaceAllButton;
- private Button fSkipButton;
- private Button fSkipFileButton;
-
- private List fMarkers;
- private TextSearchOperation fOperation;
- private boolean fSkipReadonly= false;
-
- // reuse editors stuff
- private IReusableEditor fEditor;
-
- protected ReplaceDialog(Shell parentShell, List entries, TextSearchOperation operation) {
- super(parentShell);
- Assert.isNotNull(entries);
- Assert.isNotNull(operation);
- fMarkers= new ArrayList();
- initializeMarkers(entries);
- fOperation= operation;
- }
-
- private void initializeMarkers(List entries) {
- for (Iterator elements= entries.iterator(); elements.hasNext(); ) {
- SearchResultViewEntry element= (SearchResultViewEntry)elements.next();
- List markerList= element.getMarkers();
- for (Iterator markers= markerList.iterator(); markers.hasNext(); ) {
- IMarker marker= (IMarker)markers.next();
- int charStart= MarkerUtilities.getCharStart(marker);
- if (charStart >= 0 && MarkerUtilities.getCharEnd(marker) > charStart)
- fMarkers.add(new ReplaceMarker(marker));
- }
- }
- }
-
- // widget related stuff -----------------------------------------------------------
- public void create() {
- super.create();
- Shell shell= getShell();
- shell.setText(getDialogTitle());
- gotoCurrentMarker();
- enableButtons();
- }
-
- protected Control createPageArea(Composite parent) {
- Composite result= new Composite(parent, SWT.NULL);
- GridLayout layout= new GridLayout();
- result.setLayout(layout);
- layout.numColumns= 2;
-
- layout.marginHeight =
- convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- layout.marginWidth =
- convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
- layout.verticalSpacing =
- convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
- layout.horizontalSpacing =
- convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
-
- initializeDialogUnits(result);
-
- Label label= new Label(result, SWT.NONE);
- label.setText(SearchMessages.getString("ReplaceDialog.replace_label")); //$NON-NLS-1$
- Text clabel= new Text(result, SWT.BORDER);
- clabel.setEnabled(false);
- clabel.setText(fOperation.getPattern());
- GridData gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.widthHint= convertWidthInCharsToPixels(50);
- clabel.setLayoutData(gd);
-
-
- label= new Label(result, SWT.NONE);
- label.setText(SearchMessages.getString("ReplaceDialog.with_label")); //$NON-NLS-1$
- fTextField= new Text(result, SWT.BORDER);
- gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.widthHint= convertWidthInCharsToPixels(50);
- fTextField.setLayoutData(gd);
- fTextField.setFocus();
-
-
- new Label(result, SWT.NONE);
- Button replaceWithRegex= new Button(result, SWT.CHECK);
- replaceWithRegex.setText(SearchMessages.getString("ReplaceDialog.isRegex.label")); //$NON-NLS-1$
- replaceWithRegex.setEnabled(false);
- replaceWithRegex.setSelection(false);
-
- applyDialogFont(result);
- return result;
- }
-
- protected void createButtonsForButtonBar(Composite parent) {
- fReplaceButton= createButton(parent, REPLACE, SearchMessages.getString("ReplaceDialog.replace"), true); //$NON-NLS-1$
- fReplaceAllInFileButton= createButton(parent, REPLACE_ALL_IN_FILE, SearchMessages.getString("ReplaceDialog.replaceAllInFile"), false); //$NON-NLS-1$
-
- Label filler= new Label(parent, SWT.NONE);
- filler.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
-
- fReplaceAllButton= createButton(parent, REPLACE_ALL, SearchMessages.getString("ReplaceDialog.replaceAll"), false); //$NON-NLS-1$
- fSkipButton= createButton(parent, SKIP, SearchMessages.getString("ReplaceDialog.skip"), false); //$NON-NLS-1$
- fSkipFileButton= createButton(parent, SKIP_FILE, SearchMessages.getString("ReplaceDialog.skipFile"), false); //$NON-NLS-1$
-
- filler= new Label(parent, SWT.NONE);
- filler.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
- super.createButtonsForButtonBar(parent);
- ((GridLayout)parent.getLayout()).numColumns= 4;
- }
-
- protected Point getInitialLocation(Point initialSize) {
- SearchResultView view= (SearchResultView)SearchPlugin.getSearchResultView();
- if (view == null)
- return super.getInitialLocation(initialSize);
- Point result= new Point(0, 0);
- Control control= view.getViewer().getControl();
- Point size= control.getSize();
- Point location= control.toDisplay(control.getLocation());
- result.x= Math.max(0, location.x + size.x - initialSize.x);
- result.y= Math.max(0, location.y + size.y - initialSize.y);
- return result;
- }
-
- private void enableButtons() {
- fSkipButton.setEnabled(hasNextMarker());
- fSkipFileButton.setEnabled(hasNextFile());
- fReplaceButton.setEnabled(canReplace());
- fReplaceAllInFileButton.setEnabled(canReplace());
- fReplaceAllButton.setEnabled(canReplace());
- }
-
- protected void buttonPressed(int buttonId) {
- final String replaceText= fTextField.getText();
- try {
- switch (buttonId) {
- case SKIP :
- skip();
- break;
- case SKIP_FILE :
- skipFile();
- break;
- case REPLACE :
- run(false, true, new ReplaceOperation() {
- protected void doReplace(IProgressMonitor pm) throws BadLocationException, CoreException {
- replace(pm, replaceText);
- }
- });
- gotoCurrentMarker();
- break;
- case REPLACE_ALL_IN_FILE :
- run(false, true, new ReplaceOperation() {
- protected void doReplace(IProgressMonitor pm) throws BadLocationException, CoreException {
- replaceInFile(pm, replaceText);
-
- }
- });
- gotoCurrentMarker();
- break;
- case REPLACE_ALL :
- run(false, true, new ReplaceOperation() {
- protected void doReplace(IProgressMonitor pm) throws BadLocationException, CoreException {
- replaceAll(pm, replaceText);
- }
- });
- gotoCurrentMarker();
- break;
- default :
- {
- super.buttonPressed(buttonId);
- return;
- }
- }
- } catch (InvocationTargetException e) {
- SearchPlugin.log(e);
- String message= SearchMessages.getFormattedString("ReplaceDialog.error.unable_to_replace", getCurrentMarker().getFile().getName()); //$NON-NLS-1$
- MessageDialog.openError(getParentShell(), getDialogTitle(), message);
- } catch (InterruptedException e) {
- // means operation canceled
- }
- if (!hasNextMarker() && !hasNextFile() && !canReplace())
- close();
- else {
- enableButtons();
- }
- }
-
- private ReplaceMarker getCurrentMarker() {
- return (ReplaceMarker)fMarkers.get(0);
- }
-
- private void replace(IProgressMonitor pm, String replacementText) throws BadLocationException, CoreException {
- ReplaceMarker marker= getCurrentMarker();
- pm.beginTask(SearchMessages.getString("ReplaceDialog.task.replace"), 10); //$NON-NLS-1$
- replaceInFile(pm, marker.getFile(), replacementText, new ReplaceMarker[]{marker});
- }
-
- private void replaceInFile(IProgressMonitor pm, String replacementText) throws BadLocationException, CoreException {
- ReplaceMarker firstMarker= getCurrentMarker();
- ReplaceMarker[] markers= collectMarkers(firstMarker.getFile());
- pm.beginTask(SearchMessages.getFormattedString("ReplaceDialog.task.replaceInFile", firstMarker.getFile().getFullPath().toOSString()), 4); //$NON-NLS-1$
- replaceInFile(pm, firstMarker.getFile(), replacementText, markers);
- }
-
- private void replaceAll(IProgressMonitor pm, String replacementText) throws BadLocationException, CoreException {
- int resourceCount= countResources();
- pm.beginTask(SearchMessages.getString("ReplaceDialog.task.replace.replaceAll"), resourceCount); //$NON-NLS-1$
- while (fMarkers.size() > 0) {
- replaceInFile(new SubProgressMonitor(pm, 1, 0), replacementText);
- }
- pm.done();
- }
-
- private void replaceInFile(final IProgressMonitor pm, final IFile file, final String replacementText, final ReplaceMarker[] markers) throws BadLocationException, CoreException {
- if (pm.isCanceled())
- throw new OperationCanceledException();
- doReplaceInFile(pm, file, replacementText, markers);
- }
-
- private void doReplaceInFile(IProgressMonitor pm, IFile file, String replacementText, final ReplaceMarker[] markers) throws BadLocationException, CoreException {
- try {
- if (file.isReadOnly()) {
- file.getWorkspace().validateEdit(new IFile[]{file}, null);
- }
- if (file.isReadOnly()) {
- if (fSkipReadonly) {
- skipFile();
- return;
- }
- int rc= askForSkip(file);
- switch (rc) {
- case CANCEL :
- throw new OperationCanceledException();
- case SKIP_FILE :
- skipFile();
- return;
- case SKIP_ALL :
- fSkipReadonly= true;
- skipFile();
- return;
- }
- }
- ITextFileBufferManager bm= FileBuffers.getTextFileBufferManager();
- try {
- bm.connect(file.getFullPath(), new SubProgressMonitor(pm, 1));
- ITextFileBuffer fb= bm.getTextFileBuffer(file.getFullPath());
- boolean wasDirty= fb.isDirty();
- IDocument doc= fb.getDocument();
- try {
- createPositionsInFile(file, doc);
- for (int i= 0; i < markers.length; i++) {
- doc.replace(markers[i].getOffset(), markers[i].getLength(), replacementText);
- fMarkers.remove(0);
- markers[i].delete();
- }
- } finally {
- removePositonsInFile(file, doc);
- }
- if (!wasDirty)
- fb.commit(new SubProgressMonitor(pm, 1), true);
- } finally {
- bm.disconnect(file.getFullPath(), new SubProgressMonitor(pm, 1));
- }
- } finally {
- pm.done();
- }
- }
-
- private void removePositonsInFile(IFile file, IDocument doc) {
- for (Iterator markers= fMarkers.iterator(); markers.hasNext(); ) {
- ReplaceMarker marker= (ReplaceMarker)markers.next();
- if (!marker.getFile().equals(file))
- return;
- marker.deletePosition(doc);
- }
- }
-
- private void createPositionsInFile(IFile file, IDocument doc) throws BadLocationException {
- for (Iterator markers= fMarkers.iterator(); markers.hasNext(); ) {
- ReplaceMarker marker= (ReplaceMarker)markers.next();
- if (!marker.getFile().equals(file))
- return;
- marker.createPosition(doc);
- }
- }
-
- private int askForSkip(final IFile file) {
-
- String message= SearchMessages.getFormattedString("ReadOnlyDialog.message", file.getFullPath().toOSString()); //$NON-NLS-1$
- String[] buttonLabels= null;
- boolean showSkip= countResources() > 1;
- if (showSkip) {
- String skipLabel= SearchMessages.getString("ReadOnlyDialog.skipFile"); //$NON-NLS-1$
- String skipAllLabel= SearchMessages.getString("ReadOnlyDialog.skipAll"); //$NON-NLS-1$
- buttonLabels= new String[]{skipLabel, skipAllLabel, IDialogConstants.CANCEL_LABEL};
- } else {
- buttonLabels= new String[]{IDialogConstants.CANCEL_LABEL};
-
- }
-
- MessageDialog msd= new MessageDialog(getShell(), getShell().getText(), null, message, MessageDialog.ERROR, buttonLabels, 0);
- int rc= msd.open();
- switch (rc) {
- case 0 :
- return showSkip ? SKIP_FILE : CANCEL;
- case 1 :
- return SKIP_ALL;
- default :
- return CANCEL;
- }
- }
-
- private String getDialogTitle() {
- return SearchMessages.getString("ReplaceDialog.dialog.title"); //$NON-NLS-1$
- }
-
- private void skip() {
- fMarkers.remove(0);
- Assert.isTrue(fMarkers.size() > 0);
- gotoCurrentMarker();
- }
-
- private void skipFile() {
- ReplaceMarker currentMarker= getCurrentMarker();
- if (currentMarker == null)
- return;
- IResource currentFile= currentMarker.getFile();
- while (fMarkers.size() > 0 && getCurrentMarker().getFile().equals(currentFile))
- fMarkers.remove(0);
- gotoCurrentMarker();
- }
-
- private void gotoCurrentMarker() {
- if (fMarkers.size() > 0) {
- ReplaceMarker marker= getCurrentMarker();
- Control focusControl= getShell().getDisplay().getFocusControl();
- try {
- selectEntry(marker);
- ITextEditor editor= null;
- if (SearchUI.reuseEditor())
- editor= openEditorReuse(marker);
- else
- editor= openEditorNoReuse(marker);
- editor.selectAndReveal(marker.getOffset(), marker.getLength());
- if (focusControl != null && !focusControl.isDisposed())
- focusControl.setFocus();
- } catch (PartInitException e) {
- String message= SearchMessages.getFormattedString("ReplaceDialog.error.unable_to_open_text_editor", marker.getFile().getName()); //$NON-NLS-1$
- MessageDialog.openError(getParentShell(), getDialogTitle(), message);
- }
- }
- }
-
- private void selectEntry(ReplaceMarker marker) {
- SearchResultView view= (SearchResultView) SearchPlugin.getSearchResultView();
- if (view == null)
- return;
- SearchResultViewer viewer= view.getViewer();
- if (viewer == null)
- return;
- ISelection sel= viewer.getSelection();
- if (!(sel instanceof IStructuredSelection))
- return;
- IStructuredSelection ss= (IStructuredSelection) sel;
- IFile file= marker.getFile();
- if (ss.size() == 1 && file.equals(ss.getFirstElement()))
- return;
- Table table= viewer.getTable();
- if (table == null || table.isDisposed())
- return;
- int selectionIndex= table.getSelectionIndex();
- if (selectionIndex < 0)
- selectionIndex= 0;
- for (int i= 0; i < table.getItemCount(); i++) {
- int currentTableIndex= (selectionIndex+i) % table.getItemCount();
- SearchResultViewEntry entry= (SearchResultViewEntry) viewer.getElementAt(currentTableIndex);
- if (file.equals(entry.getGroupByKey())) {
- viewer.setSelection(new StructuredSelection(entry));
- return;
- }
- }
- }
-
- // opening editors ------------------------------------------
- private ITextEditor openEditorNoReuse(ReplaceMarker marker) throws PartInitException {
- IFile file= marker.getFile();
- IWorkbenchPage activePage= SearchPlugin.getActivePage();
- if (activePage == null)
- return null;
- ITextEditor textEditor= showOpenTextEditor(activePage, file);
- if (textEditor != null)
- return textEditor;
- return openNewTextEditor(file, activePage);
- }
-
- private ITextEditor openNewTextEditor(IFile file, IWorkbenchPage activePage) throws PartInitException {
- IEditorDescriptor desc= IDE.getDefaultEditor(file);
- if (desc != null) {
- String editorID= desc.getId();
- IEditorPart editor;
- if (desc.isInternal()) {
- editor= activePage.openEditor(new FileEditorInput(file), editorID);
- if (editor instanceof ITextEditor) {
- if (editor instanceof IReusableEditor)
- fEditor= (IReusableEditor) editor;
- return (ITextEditor)editor;
- } else
- activePage.closeEditor(editor, false);
- }
- }
- IEditorPart editor= activePage.openEditor(new FileEditorInput(file), "org.eclipse.ui.DefaultTextEditor"); //$NON-NLS-1$
- return (ITextEditor)editor;
- }
-
- private ITextEditor openEditorReuse(ReplaceMarker marker) throws PartInitException {
- IWorkbenchPage page= SearchPlugin.getActivePage();
- IFile file= marker.getFile();
- if (page == null)
- return null;
-
- ITextEditor textEditor= showOpenTextEditor(page, file);
- if (textEditor != null)
- return textEditor;
-
- String editorId= null;
- IEditorDescriptor desc= IDE.getDefaultEditor(file);
- if (desc != null && desc.isInternal())
- editorId= desc.getId();
-
- boolean isOpen= isEditorOpen(page, fEditor);
-
- boolean canBeReused= isOpen && !fEditor.isDirty() && !isPinned(fEditor);
- boolean showsSameInputType= fEditor != null && (editorId == null || fEditor.getSite().getId().equals(editorId));
-
- if (canBeReused) {
- if (showsSameInputType) {
- fEditor.setInput(new FileEditorInput(file));
- page.bringToTop(fEditor);
- return (ITextEditor) fEditor;
- } else {
- page.closeEditor(fEditor, false);
- fEditor= null;
- }
- }
- return openNewTextEditor(file, page);
- }
-
- private boolean isEditorOpen(IWorkbenchPage page, IEditorPart editor) {
- if (editor != null) {
- IEditorReference[] parts= page.getEditorReferences();
- int i= 0;
- for (int j = 0; j < parts.length; j++) {
- if (editor == parts[i++].getEditor(false))
- return true;
- }
- }
- return false;
- }
-
- private ITextEditor showOpenTextEditor(IWorkbenchPage page, IFile file) {
- IEditorPart editor= page.findEditor(new FileEditorInput(file));
- if (editor instanceof ITextEditor) {
- page.bringToTop(editor);
- return (ITextEditor) editor;
- }
- return null;
- }
-
- private boolean isPinned(IEditorPart editor) {
- if (editor == null)
- return false;
-
- IEditorReference[] editorRefs= editor.getEditorSite().getPage().getEditorReferences();
- int i= 0;
- while (i < editorRefs.length) {
- if (editor.equals(editorRefs[i].getEditor(false)))
- return editorRefs[i].isPinned();
- i++;
- }
- return false;
- }
-
- // resource related -------------------------------------------------------------
- /**
- * @return the number of resources referred to in fMarkers
- */
- private int countResources() {
- IResource r= null;
- int count= 0;
- for (Iterator elements= fMarkers.iterator(); elements.hasNext(); ) {
- ReplaceMarker element= (ReplaceMarker)elements.next();
- if (!element.getFile().equals(r)) {
- count++;
- r= element.getFile();
- }
- }
- return count;
- }
-
- private ReplaceMarker[] collectMarkers(IResource resource) {
- List matching= new ArrayList();
- for (int i= 0; i < fMarkers.size(); i++) {
- ReplaceMarker marker= (ReplaceMarker)fMarkers.get(i);
- if (!marker.getFile().equals(resource))
- break;
- matching.add(marker);
- }
- ReplaceMarker[] markers= new ReplaceMarker[matching.size()];
- return (ReplaceMarker[])matching.toArray(markers);
- }
-
-
- // some queries -------------------------------------------------------------
- private boolean hasNextMarker() {
- return fMarkers.size() > 1;
- }
-
- private boolean hasNextFile() {
- if (!hasNextMarker())
- return false;
- IResource currentFile= getCurrentMarker().getFile();
- for (int i= 0; i < fMarkers.size(); i++) {
- if (!((ReplaceMarker)fMarkers.get(i)).getFile().equals(currentFile))
- return true;
- }
- return false;
- }
-
- private boolean canReplace() {
- return fMarkers.size() > 0;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceDialog2.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceDialog2.java
deleted file mode 100644
index bb66174..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceDialog2.java
+++ /dev/null
@@ -1,587 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui.text;
-
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.SubProgressMonitor;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-import org.eclipse.core.filebuffers.FileBuffers;
-import org.eclipse.core.filebuffers.ITextFileBuffer;
-import org.eclipse.core.filebuffers.ITextFileBufferManager;
-
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.StructuredViewer;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.Position;
-
-import org.eclipse.ui.IEditorDescriptor;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorReference;
-import org.eclipse.ui.IReusableEditor;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.actions.WorkspaceModifyOperation;
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.ui.texteditor.ITextEditor;
-
-import org.eclipse.search.ui.SearchUI;
-import org.eclipse.search.ui.text.AbstractTextSearchResult;
-import org.eclipse.search.ui.text.Match;
-
-import org.eclipse.search.internal.ui.SearchMessages;
-import org.eclipse.search.internal.ui.SearchPlugin;
-import org.eclipse.search.internal.ui.util.ExtendedDialogWindow;
-
-import org.eclipse.search2.internal.ui.InternalSearchUI;
-import org.eclipse.search2.internal.ui.text.PositionTracker;
-
-class ReplaceDialog2 extends ExtendedDialogWindow {
-
- private abstract static class ReplaceOperation extends WorkspaceModifyOperation {
- ReplaceOperation(IResource lock) {
- super(lock);
- }
- ReplaceOperation() {
- super();
- }
- public void execute(IProgressMonitor monitor) throws InvocationTargetException {
- try {
- doReplace(monitor);
- } catch (BadLocationException e) {
- throw new InvocationTargetException(e);
- } catch (CoreException e) {
- throw new InvocationTargetException(e);
- } catch (IOException e) {
- throw new InvocationTargetException(e);
- }
- }
-
- protected abstract void doReplace(IProgressMonitor pm) throws BadLocationException, CoreException, IOException;
- }
-
- // various widget related constants
- private static final int REPLACE= IDialogConstants.CLIENT_ID + 1;
- private static final int REPLACE_ALL_IN_FILE= IDialogConstants.CLIENT_ID + 2;
- private static final int REPLACE_ALL= IDialogConstants.CLIENT_ID + 3;
- private static final int SKIP= IDialogConstants.CLIENT_ID + 4;
- private static final int SKIP_FILE= IDialogConstants.CLIENT_ID + 5;
- private static final int SKIP_ALL= IDialogConstants.CLIENT_ID + 6;
-
- // Widgets
- private Text fTextField;
- private Button fReplaceButton;
- private Button fReplaceAllInFileButton;
- private Button fReplaceAllButton;
- private Button fSkipButton;
- private Button fSkipFileButton;
-
- private List fMarkers;
- private boolean fSkipReadonly= false;
-
- // reuse editors stuff
- private IReusableEditor fEditor;
- private AbstractTextSearchResult fSearchResult;
- private StructuredViewer fViewer;
-
- protected ReplaceDialog2(Shell parentShell, IFile[] entries, StructuredViewer viewer, AbstractTextSearchResult result) {
- super(parentShell);
- Assert.isNotNull(entries);
- Assert.isNotNull(result);
- fSearchResult= result;
- fMarkers= new ArrayList();
- fViewer= viewer;
- initializeMarkers(entries);
- }
-
- private void initializeMarkers(IFile[] entries) {
- for (int j= 0; j < entries.length; j++) {
- IFile entry = entries[j];
- Match[] matches= fSearchResult.getMatches(entry);
- for (int i= 0; i < matches.length; i++) {
- fMarkers.add(matches[i]);
- }
- }
- }
-
- // widget related stuff -----------------------------------------------------------
- public void create() {
- super.create();
- Shell shell= getShell();
- shell.setText(getDialogTitle());
- gotoCurrentMarker();
- enableButtons();
- }
-
- protected Control createPageArea(Composite parent) {
- Composite result= new Composite(parent, SWT.NULL);
- GridLayout layout= new GridLayout();
- result.setLayout(layout);
- layout.numColumns= 2;
-
- layout.marginHeight =
- convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- layout.marginWidth =
- convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
- layout.verticalSpacing =
- convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
- layout.horizontalSpacing =
- convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
-
- initializeDialogUnits(result);
-
- Label label= new Label(result, SWT.NONE);
- label.setText(SearchMessages.getString("ReplaceDialog.replace_label")); //$NON-NLS-1$
- Text clabel= new Text(result, SWT.BORDER);
- clabel.setEnabled(false);
- clabel.setText(((FileSearchQuery)fSearchResult.getQuery()).getSearchString());
- GridData gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.widthHint= convertWidthInCharsToPixels(50);
- clabel.setLayoutData(gd);
-
-
- label= new Label(result, SWT.NONE);
- label.setText(SearchMessages.getString("ReplaceDialog.with_label")); //$NON-NLS-1$
- fTextField= new Text(result, SWT.BORDER);
- gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.widthHint= convertWidthInCharsToPixels(50);
- fTextField.setLayoutData(gd);
- fTextField.setFocus();
-
-
- new Label(result, SWT.NONE);
- Button replaceWithRegex= new Button(result, SWT.CHECK);
- replaceWithRegex.setText(SearchMessages.getString("ReplaceDialog.isRegex.label")); //$NON-NLS-1$
- replaceWithRegex.setEnabled(false);
- replaceWithRegex.setSelection(false);
-
- applyDialogFont(result);
- return result;
- }
-
- protected void createButtonsForButtonBar(Composite parent) {
- fReplaceButton= createButton(parent, REPLACE, SearchMessages.getString("ReplaceDialog.replace"), true); //$NON-NLS-1$
- fReplaceAllInFileButton= createButton(parent, REPLACE_ALL_IN_FILE, SearchMessages.getString("ReplaceDialog.replaceAllInFile"), false); //$NON-NLS-1$
-
- Label filler= new Label(parent, SWT.NONE);
- filler.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
-
- fReplaceAllButton= createButton(parent, REPLACE_ALL, SearchMessages.getString("ReplaceDialog.replaceAll"), false); //$NON-NLS-1$
- fSkipButton= createButton(parent, SKIP, SearchMessages.getString("ReplaceDialog.skip"), false); //$NON-NLS-1$
- fSkipFileButton= createButton(parent, SKIP_FILE, SearchMessages.getString("ReplaceDialog.skipFile"), false); //$NON-NLS-1$
-
- filler= new Label(parent, SWT.NONE);
- filler.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
- super.createButtonsForButtonBar(parent);
- ((GridLayout)parent.getLayout()).numColumns= 4;
- }
-
- private void enableButtons() {
- fSkipButton.setEnabled(hasNextMarker());
- fSkipFileButton.setEnabled(hasNextFile());
- fReplaceButton.setEnabled(canReplace());
- fReplaceAllInFileButton.setEnabled(canReplace());
- fReplaceAllButton.setEnabled(canReplace());
- }
-
- protected void buttonPressed(int buttonId) {
- final String replaceText= fTextField.getText();
- try {
- switch (buttonId) {
- case SKIP :
- skip();
- break;
- case SKIP_FILE :
- skipFile();
- break;
- case REPLACE :
- run(false, true, new ReplaceOperation((IResource) getCurrentMarker().getElement()) {
- protected void doReplace(IProgressMonitor pm) throws BadLocationException, CoreException {
- replace(pm, replaceText);
- }
- });
- gotoCurrentMarker();
- break;
- case REPLACE_ALL_IN_FILE :
- run(false, true, new ReplaceOperation((IResource) getCurrentMarker().getElement()) {
- protected void doReplace(IProgressMonitor pm) throws BadLocationException, CoreException {
- replaceInFile(pm, replaceText);
-
- }
- });
- gotoCurrentMarker();
- break;
- case REPLACE_ALL :
- run(false, true, new ReplaceOperation() {
- protected void doReplace(IProgressMonitor pm) throws BadLocationException, CoreException {
- replaceAll(pm, replaceText);
- }
- });
- gotoCurrentMarker();
- break;
- default :
- {
- super.buttonPressed(buttonId);
- return;
- }
- }
- } catch (InvocationTargetException e) {
- SearchPlugin.log(e);
- String message= SearchMessages.getFormattedString("ReplaceDialog.error.unable_to_replace", ((IFile)getCurrentMarker().getElement()).getName()); //$NON-NLS-1$
- MessageDialog.openError(getParentShell(), getDialogTitle(), message);
- } catch (InterruptedException e) {
- // means operation canceled
- }
- if (!hasNextMarker() && !hasNextFile() && !canReplace())
- close();
- else {
- enableButtons();
- }
- }
-
- private Match getCurrentMarker() {
- return (Match)fMarkers.get(0);
- }
-
- private void replace(IProgressMonitor pm, String replacementText) throws BadLocationException, CoreException {
- Match marker= getCurrentMarker();
- pm.beginTask(SearchMessages.getString("ReplaceDialog.task.replace"), 10); //$NON-NLS-1$
- replaceInFile(pm, (IFile) marker.getElement(), replacementText, new Match[]{marker});
- }
-
- private void replaceInFile(IProgressMonitor pm, String replacementText) throws BadLocationException, CoreException {
- Match firstMarker= getCurrentMarker();
- Match[] markers= collectMarkers((IFile)firstMarker.getElement());
- pm.beginTask(SearchMessages.getFormattedString("ReplaceDialog.task.replaceInFile", ((IFile)firstMarker.getElement()).getFullPath().toOSString()), 4); //$NON-NLS-1$
- replaceInFile(pm, (IFile) firstMarker.getElement(), replacementText, markers);
- }
-
- private void replaceAll(IProgressMonitor pm, String replacementText) throws BadLocationException, CoreException {
- int resourceCount= countResources();
- pm.beginTask(SearchMessages.getString("ReplaceDialog.task.replace.replaceAll"), resourceCount); //$NON-NLS-1$
- while (fMarkers.size() > 0) {
- replaceInFile(new SubProgressMonitor(pm, 1, 0), replacementText);
- }
- pm.done();
- }
-
- private void replaceInFile(final IProgressMonitor pm, final IFile file, final String replacementText, final Match[] markers) throws BadLocationException, CoreException {
- if (pm.isCanceled())
- throw new OperationCanceledException();
- doReplaceInFile(pm, file, replacementText, markers);
- }
-
- private void doReplaceInFile(IProgressMonitor pm, IFile file, String replacementText, final Match[] markers) throws BadLocationException, CoreException {
- try {
- if (file.isReadOnly()) {
- file.getWorkspace().validateEdit(new IFile[]{file}, null);
- }
- if (file.isReadOnly()) {
- if (fSkipReadonly) {
- skipFile();
- return;
- }
- int rc= askForSkip(file);
- switch (rc) {
- case CANCEL :
- throw new OperationCanceledException();
- case SKIP_FILE :
- skipFile();
- return;
- case SKIP_ALL :
- fSkipReadonly= true;
- skipFile();
- return;
- }
- }
- ITextFileBufferManager bm= FileBuffers.getTextFileBufferManager();
- try {
- bm.connect(file.getFullPath(), new SubProgressMonitor(pm, 1));
- ITextFileBuffer fb= bm.getTextFileBuffer(file.getFullPath());
- boolean wasDirty= fb.isDirty();
- IDocument doc= fb.getDocument();
- for (int i= 0; i < markers.length; i++) {
- PositionTracker tracker= InternalSearchUI.getInstance().getPositionTracker();
- int offset= markers[i].getOffset();
- int length= markers[i].getLength();
- Position currentPosition= tracker.getCurrentPosition(markers[i]);
- if (currentPosition != null) {
- offset= currentPosition.offset;
- length= currentPosition.length;
- }
- doc.replace(offset, length, replacementText);
- fMarkers.remove(0);
- fSearchResult.removeMatch(markers[i]);
- }
- if (!wasDirty)
- fb.commit(new SubProgressMonitor(pm, 1), true);
- } finally {
- bm.disconnect(file.getFullPath(), new SubProgressMonitor(pm, 1));
- }
- } finally {
- pm.done();
- }
- }
-
- private int askForSkip(final IFile file) {
-
- String message= SearchMessages.getFormattedString("ReadOnlyDialog.message", file.getFullPath().toOSString()); //$NON-NLS-1$
- String[] buttonLabels= null;
- boolean showSkip= countResources() > 1;
- if (showSkip) {
- String skipLabel= SearchMessages.getString("ReadOnlyDialog.skipFile"); //$NON-NLS-1$
- String skipAllLabel= SearchMessages.getString("ReadOnlyDialog.skipAll"); //$NON-NLS-1$
- buttonLabels= new String[]{skipLabel, skipAllLabel, IDialogConstants.CANCEL_LABEL};
- } else {
- buttonLabels= new String[]{IDialogConstants.CANCEL_LABEL};
-
- }
-
- MessageDialog msd= new MessageDialog(getShell(), getShell().getText(), null, message, MessageDialog.ERROR, buttonLabels, 0);
- int rc= msd.open();
- switch (rc) {
- case 0 :
- return showSkip ? SKIP_FILE : CANCEL;
- case 1 :
- return SKIP_ALL;
- default :
- return CANCEL;
- }
- }
-
- private String getDialogTitle() {
- return SearchMessages.getString("ReplaceDialog.dialog.title"); //$NON-NLS-1$
- }
-
- private void skip() {
- fMarkers.remove(0);
- Assert.isTrue(fMarkers.size() > 0);
- gotoCurrentMarker();
- }
-
- private void skipFile() {
- Match currentMarker= getCurrentMarker();
- if (currentMarker == null)
- return;
- IResource currentFile= (IResource) currentMarker.getElement();
- while (fMarkers.size() > 0 && getCurrentMarker().getElement().equals(currentFile))
- fMarkers.remove(0);
- gotoCurrentMarker();
- }
-
- private void gotoCurrentMarker() {
- if (fMarkers.size() > 0) {
- Match marker= getCurrentMarker();
- Control focusControl= getShell().getDisplay().getFocusControl();
- try {
- selectEntry(marker);
- ITextEditor editor= null;
- if (SearchUI.reuseEditor())
- editor= openEditorReuse(marker);
- else
- editor= openEditorNoReuse(marker);
- editor.selectAndReveal(marker.getOffset(), marker.getLength());
- if (focusControl != null && !focusControl.isDisposed())
- focusControl.setFocus();
- } catch (PartInitException e) {
- String message= SearchMessages.getFormattedString("ReplaceDialog.error.unable_to_open_text_editor", ((IFile)marker.getElement()).getName()); //$NON-NLS-1$
- MessageDialog.openError(getParentShell(), getDialogTitle(), message);
- }
- }
- }
-
- private void selectEntry(Match marker) {
- ISelection sel= fViewer.getSelection();
- if (!(sel instanceof IStructuredSelection))
- return;
- IStructuredSelection ss= (IStructuredSelection) sel;
- IFile file= (IFile) marker.getElement();
- if (ss.size() == 1 && file.equals(ss.getFirstElement()))
- return;
- fViewer.setSelection(new StructuredSelection(marker.getElement()));
- }
-
- // opening editors ------------------------------------------
- private ITextEditor openEditorNoReuse(Match marker) throws PartInitException {
- IFile file= (IFile) marker.getElement();
- IWorkbenchPage activePage= SearchPlugin.getActivePage();
- if (activePage == null)
- return null;
- ITextEditor textEditor= showOpenTextEditor(activePage, file);
- if (textEditor != null)
- return textEditor;
- return openNewTextEditor(file, activePage);
- }
-
- private ITextEditor openNewTextEditor(IFile file, IWorkbenchPage activePage) throws PartInitException {
- IEditorDescriptor desc= IDE.getDefaultEditor(file);
- if (desc != null) {
- String editorID= desc.getId();
- IEditorPart editor;
- if (desc.isInternal()) {
- editor= activePage.openEditor(new FileEditorInput(file), editorID);
- if (editor instanceof ITextEditor) {
- if (editor instanceof IReusableEditor)
- fEditor= (IReusableEditor) editor;
- return (ITextEditor)editor;
- } else
- activePage.closeEditor(editor, false);
- }
- }
- IEditorPart editor= activePage.openEditor(new FileEditorInput(file), "org.eclipse.ui.DefaultTextEditor"); //$NON-NLS-1$
- return (ITextEditor)editor;
- }
-
- private ITextEditor openEditorReuse(Match marker) throws PartInitException {
- IWorkbenchPage page= SearchPlugin.getActivePage();
- IFile file= (IFile) marker.getElement();
- if (page == null)
- return null;
-
- ITextEditor textEditor= showOpenTextEditor(page, file);
- if (textEditor != null)
- return textEditor;
-
- String editorId= null;
- IEditorDescriptor desc= IDE.getDefaultEditor(file);
- if (desc != null && desc.isInternal())
- editorId= desc.getId();
-
- boolean isOpen= isEditorOpen(page, fEditor);
-
- boolean canBeReused= isOpen && !fEditor.isDirty() && !isPinned(fEditor);
- boolean showsSameInputType= fEditor != null && (editorId == null || fEditor.getSite().getId().equals(editorId));
-
- if (canBeReused) {
- if (showsSameInputType) {
- fEditor.setInput(new FileEditorInput(file));
- page.bringToTop(fEditor);
- return (ITextEditor) fEditor;
- } else {
- page.closeEditor(fEditor, false);
- fEditor= null;
- }
- }
- return openNewTextEditor(file, page);
- }
-
- private boolean isEditorOpen(IWorkbenchPage page, IEditorPart editor) {
- if (editor != null) {
- IEditorReference[] parts= page.getEditorReferences();
- int i= 0;
- for (int j = 0; j < parts.length; j++) {
- if (editor == parts[i++].getEditor(false))
- return true;
- }
- }
- return false;
- }
-
- private ITextEditor showOpenTextEditor(IWorkbenchPage page, IFile file) {
- IEditorPart editor= page.findEditor(new FileEditorInput(file));
- if (editor instanceof ITextEditor) {
- page.bringToTop(editor);
- return (ITextEditor) editor;
- }
- return null;
- }
-
- private boolean isPinned(IEditorPart editor) {
- if (editor == null)
- return false;
-
- IEditorReference[] editorRefs= editor.getEditorSite().getPage().getEditorReferences();
- int i= 0;
- while (i < editorRefs.length) {
- if (editor.equals(editorRefs[i].getEditor(false)))
- return editorRefs[i].isPinned();
- i++;
- }
- return false;
- }
-
- // resource related -------------------------------------------------------------
- /**
- * @return the number of resources referred to in fMarkers
- */
- private int countResources() {
- IResource r= null;
- int count= 0;
- for (Iterator elements= fMarkers.iterator(); elements.hasNext(); ) {
- Match element= (Match)elements.next();
- if (!element.getElement().equals(r)) {
- count++;
- r= (IResource) element.getElement();
- }
- }
- return count;
- }
-
- private Match[] collectMarkers(IFile resource) {
- List matching= new ArrayList();
- for (int i= 0; i < fMarkers.size(); i++) {
- Match marker= (Match)fMarkers.get(i);
- if (!resource.equals(marker.getElement()))
- break;
- matching.add(marker);
- }
- Match[] markers= new Match[matching.size()];
- return (Match[])matching.toArray(markers);
- }
-
-
- // some queries -------------------------------------------------------------
- private boolean hasNextMarker() {
- return fMarkers.size() > 1;
- }
-
- private boolean hasNextFile() {
- if (!hasNextMarker())
- return false;
- IResource currentFile= (IResource) getCurrentMarker().getElement();
- for (int i= 0; i < fMarkers.size(); i++) {
- if (!((Match)fMarkers.get(i)).getElement().equals(currentFile))
- return true;
- }
- return false;
- }
-
- private boolean canReplace() {
- return fMarkers.size() > 0;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/ResourcePathSorter.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/ResourcePathSorter.java
deleted file mode 100644
index 3f3adb7..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/ResourcePathSorter.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui.text;
-
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-
-import org.eclipse.search.ui.ISearchResultView;
-import org.eclipse.search.ui.ISearchResultViewEntry;
-import org.eclipse.search.ui.SearchUI;
-
-import org.eclipse.search.internal.ui.util.FileLabelProvider;
-
-/**
- * Sorts the search result viewer by the resource path.
- */
-public class ResourcePathSorter extends ViewerSorter {
-
- /*
- * Overrides method from ViewerSorter
- */
- public int compare(Viewer viewer, Object e1, Object e2) {
- String name1= null;
- String name2= null;
-
- if (e1 instanceof ISearchResultViewEntry)
- name1= ((ISearchResultViewEntry)e1).getResource().getFullPath().toString();
- if (e2 instanceof ISearchResultViewEntry)
- name2= ((ISearchResultViewEntry)e2).getResource().getFullPath().toString();
- if (name1 == null)
- name1= ""; //$NON-NLS-1$
- if (name2 == null)
- name2= ""; //$NON-NLS-1$
- return getCollator().compare(name1, name2);
- }
-
- /*
- * Overrides method from ViewerSorter
- */
- public boolean isSorterProperty(Object element, String property) {
- return true;
- }
-
- /*
- * Overrides method from ViewerSorter
- */
- public void sort(Viewer viewer, Object[] elements) {
- // Set label provider to show "resource - path"
- ISearchResultView view= SearchUI.getSearchResultView();
- if (view != null) {
- ILabelProvider labelProvider= view.getLabelProvider();
- if (labelProvider instanceof FileLabelProvider)
- ((FileLabelProvider)labelProvider).setOrder(FileLabelProvider.SHOW_PATH_LABEL);
- }
- super.sort(viewer, elements);
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/ResourcenameSorter.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/ResourcenameSorter.java
deleted file mode 100644
index 9eff887..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/ResourcenameSorter.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui.text;
-
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-
-import org.eclipse.search.ui.ISearchResultView;
-import org.eclipse.search.ui.ISearchResultViewEntry;
-import org.eclipse.search.ui.SearchUI;
-
-import org.eclipse.search.internal.ui.util.FileLabelProvider;
-
-/**
- * Sorts the search result viewer by the resource name.
- */
-public class ResourcenameSorter extends ViewerSorter {
-
- /*
- * Overrides method from ViewerSorter
- */
- public int compare(Viewer viewer, Object e1, Object e2) {
- String name1= null;
- String name2= null;
-
- if (e1 instanceof ISearchResultViewEntry)
- name1= ((ISearchResultViewEntry)e1).getResource().getName();
- if (e2 instanceof ISearchResultViewEntry)
- name2= ((ISearchResultViewEntry)e2).getResource().getName();
- if (name1 == null)
- name1= ""; //$NON-NLS-1$
- if (name2 == null)
- name2= ""; //$NON-NLS-1$
- return getCollator().compare(name1, name2);
- }
-
- /*
- * Overrides method from ViewerSorter
- */
- public boolean isSorterProperty(Object element, String property) {
- return true;
- }
-
- /*
- * Overrides method from ViewerSorter
- */
- public void sort(Viewer viewer, Object[] elements) {
- // Set label provider to show "resource - path"
- ISearchResultView view= SearchUI.getSearchResultView();
- if (view != null) {
- ILabelProvider labelProvider= view.getLabelProvider();
- if (labelProvider instanceof FileLabelProvider)
- ((FileLabelProvider)labelProvider).setOrder(FileLabelProvider.SHOW_LABEL_PATH);
- }
- super.sort(viewer, elements);
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/SearchAgainConfirmationDialog.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/SearchAgainConfirmationDialog.java
deleted file mode 100644
index e3ef5c6..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/SearchAgainConfirmationDialog.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui.text;
-
-import java.util.List;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.TableViewer;
-
-import org.eclipse.search.internal.ui.SearchMessages;
-import org.eclipse.search.internal.ui.util.ListContentProvider;
-
-/**
- * Dialog telling the user that files are out of sync or matches
- * are stale and asks for confirmation to refresh/search again
- * @since 3.0
- */
-
-public class SearchAgainConfirmationDialog extends Dialog {
- private List fOutOfSync;
- private List fOutOfDate;
- private ILabelProvider fLabelProvider;
-
- private class ProxyLabelProvider extends LabelProvider {
-
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
- */
- public Image getImage(Object element) {
- if (fLabelProvider != null)
- return fLabelProvider.getImage(element);
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
- */
- public String getText(Object element) {
- if (fLabelProvider != null)
- return fLabelProvider.getText(element);
- return null;
- }
-
- }
-
- SearchAgainConfirmationDialog(Shell shell, ILabelProvider labelProvider, List outOfSync, List outOfDate) {
- super(shell);
- fOutOfSync= outOfSync;
- fOutOfDate= outOfDate;
- fLabelProvider= labelProvider;
- setShellStyle(getShellStyle() | SWT.RESIZE);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
- */
- protected Control createDialogArea(Composite parent) {
- Composite result= (Composite) super.createDialogArea(parent);
-
- if (fOutOfSync.size() > 0) {
- createLabel(result, SearchMessages.getString("SearchAgainConfirmationDialog.outofsync.message")); //$NON-NLS-1$
-
- createLabel(result, SearchMessages.getString("SearchAgainConfirmationDialog.outofsync.label")); //$NON-NLS-1$
- createTableViewer(fOutOfSync, result);
- } else {
- createLabel(result, SearchMessages.getString("SearchAgainConfirmationDialog.stale.message")); //$NON-NLS-1$
- }
-
- createLabel(result, SearchMessages.getString("SearchAgainConfirmationDialog.stale.label")); //$NON-NLS-1$
- createTableViewer(fOutOfDate, result);
- return result;
- }
-
- private void createLabel(Composite parent, String text) {
- Label message= new Label(parent, SWT.WRAP);
- GridData gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.widthHint= convertWidthInCharsToPixels(40);
- message.setLayoutData(gd);
- message.setText(text);
- }
-
- private TableViewer createTableViewer(List input, Composite result) {
- TableViewer viewer= new TableViewer(result);
- viewer.setContentProvider(new ListContentProvider());
- viewer.setLabelProvider(new ProxyLabelProvider());
- viewer.setInput(input);
- GridData gd= new GridData(GridData.FILL_BOTH);
- gd.widthHint= convertWidthInCharsToPixels(40);
- gd.heightHint= convertHeightInCharsToPixels(5);
- viewer.getControl().setLayoutData(gd);
- return viewer;
- }
-
- protected void configureShell(Shell shell) {
- super.configureShell(shell);
- shell.setText(SearchMessages.getString("SearchAgainConfirmationDialog.title")); //$NON-NLS-1$
- }
-
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/SortAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/SortAction.java
deleted file mode 100644
index 5483f7c..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/SortAction.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.search.internal.ui.text;
-
-import org.eclipse.jface.action.Action;
-
-
-public class SortAction extends Action {
- private int fSortOrder;
- private FileSearchPage fPage;
-
- public SortAction(String label, FileSearchPage page, int sortOrder) {
- super(label);
- fPage= page;
- fSortOrder= sortOrder;
- }
-
- public void run() {
- fPage.setSortOrder(this);
- }
-
- public int getSortOrder() {
- return fSortOrder;
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchActionGroup.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchActionGroup.java
deleted file mode 100644
index 76c4360..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchActionGroup.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui.text;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.actions.ActionGroup;
-import org.eclipse.ui.actions.OpenWithMenu;
-import org.eclipse.ui.dialogs.PropertyDialogAction;
-
-import org.eclipse.search.ui.IContextMenuConstants;
-import org.eclipse.search.ui.ISearchResultView;
-import org.eclipse.search.ui.ISearchResultViewEntry;
-import org.eclipse.search.ui.SearchUI;
-
-import org.eclipse.search.internal.ui.SearchManager;
-import org.eclipse.search.internal.ui.SearchMessages;
-import org.eclipse.search.internal.ui.SearchPlugin;
-import org.eclipse.search.internal.ui.SearchResultView;
-import org.eclipse.search.internal.ui.SearchResultViewer;
-
-/**
- * Action group that adds the Text search actions to a context menu and
- * the global menu bar.
- *
- * <p>
- * This class may be instantiated; it is not intended to be subclassed.
- * </p>
- *
- * @since 2.1
- */
-class TextSearchActionGroup extends ActionGroup {
-
- private ISelectionProvider fSelectionProvider;
- private IWorkbenchPage fPage;
- private PropertyDialogAction fOpenPropertiesDialog;
-
- public TextSearchActionGroup(IViewPart part) {
- Assert.isNotNull(part);
- IWorkbenchPartSite site= part.getSite();
- fSelectionProvider= site.getSelectionProvider();
- fPage= site.getPage();
- fOpenPropertiesDialog= new PropertyDialogAction(site.getShell(), fSelectionProvider);
-
- ISelection selection= fSelectionProvider.getSelection();
-
- if (selection instanceof IStructuredSelection)
- fOpenPropertiesDialog.selectionChanged((IStructuredSelection)selection);
- else
- fOpenPropertiesDialog.selectionChanged(selection);
- }
-
- public void fillContextMenu(IMenuManager menu) {
- if (!isTextSearch())
- return;
-
- // view must exist if we create a context menu for it.
- ISearchResultView view= SearchUI.getSearchResultView();
- IStructuredSelection selection= null;
- if (getContext().getSelection() instanceof IStructuredSelection)
- selection= (IStructuredSelection)getContext().getSelection();
- else
- selection= StructuredSelection.EMPTY;
-
- addOpenWithMenu(menu, selection);
-
- ReplaceAction replaceAll= new ReplaceAction(view.getSite(), getSearchResultEntries());
- if (replaceAll.isEnabled())
- menu.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, replaceAll);
- ReplaceAction replaceSelected= new ReplaceAction(view.getSite(), selection);
- if (replaceSelected.isEnabled())
- menu.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, replaceSelected);
-
- if (fOpenPropertiesDialog != null && fOpenPropertiesDialog.isEnabled() && selection != null &&fOpenPropertiesDialog.isApplicableForSelection(selection))
- menu.appendToGroup(IContextMenuConstants.GROUP_PROPERTIES, fOpenPropertiesDialog);
- }
-
- private List getSearchResultEntries() {
- SearchResultView view= (SearchResultView) SearchPlugin.getSearchResultView();
- // we can assume we have a view, how else would we be called?
- SearchResultViewer viewer= view.getViewer();
- Table table= viewer.getTable();
- TableItem[] items= table.getItems();
- List elements = new ArrayList(items.length);
- for (int i = 0; i < items.length; i++) {
- elements.add(items[i].getData());
- }
- return elements;
- }
-
- private boolean isTextSearch() {
- IRunnableWithProgress operation= SearchManager.getDefault().getCurrentSearch().getOperation();
- if (operation instanceof TextSearchOperation) {
- String pattern= ((TextSearchOperation)operation).getPattern();
- return pattern != null && pattern.length() > 0;
- }
- return false;
- }
-
- private void addOpenWithMenu(IMenuManager menu, IStructuredSelection selection) {
- if (selection == null || selection.size() != 1)
- return;
-
- Object o= selection.getFirstElement();
- if (!(o instanceof ISearchResultViewEntry))
- return;
-
- Object resource= ((ISearchResultViewEntry)o).getResource();
- if (!(resource instanceof IFile))
- return;
-
- // Create menu
- IMenuManager submenu= new MenuManager(SearchMessages.getString("OpenWithMenu.label")); //$NON-NLS-1$
- submenu.add(new OpenWithMenu(fPage, (IFile)resource));
-
- // Add the submenu.
- menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, submenu);
- }
-
- /* (non-Javadoc)
- * Method declared in ActionGroup
- */
- public void fillActionBars(IActionBars actionBar) {
- super.fillActionBars(actionBar);
- setGlobalActionHandlers(actionBar);
- }
-
- private void setGlobalActionHandlers(IActionBars actionBars) {
- actionBars.setGlobalActionHandler(ActionFactory.PROPERTIES.getId(), fOpenPropertiesDialog);
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchOperation.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchOperation.java
deleted file mode 100644
index 792f823..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchOperation.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui.text;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.util.Assert;
-
-import org.eclipse.ui.actions.WorkspaceModifyOperation;
-
-import org.eclipse.search.internal.core.ISearchScope;
-import org.eclipse.search.internal.core.text.ITextSearchResultCollector;
-import org.eclipse.search.internal.core.text.MatchLocator;
-import org.eclipse.search.internal.core.text.TextSearchEngine;
-import org.eclipse.search.internal.core.text.TextSearchScope;
-import org.eclipse.search.internal.ui.SearchMessages;
-import org.eclipse.search.internal.ui.SearchPluginImages;
-
-/**
- * An operation to perform a regular text search.
- */
-public class TextSearchOperation extends WorkspaceModifyOperation {
-
- public static final int NO_PRIORITY_CHANGE= -1;
-
- private IWorkspace fWorkspace;
- private MatchLocator fMatchLocator;
- private ISearchScope fScope;
- private TextSearchResultCollector fCollector;
- private IStatus fStatus;
-
- /**
- * Creates a new text search operation.
- */
- public TextSearchOperation(IWorkspace workspace, String pattern, String options,
- ISearchScope scope, TextSearchResultCollector collector) {
- super(null);
- Assert.isNotNull(collector);
- fWorkspace= workspace;
- fMatchLocator= new MatchLocator(pattern, options);
- fScope= scope;
- fCollector= collector;
- fCollector.setOperation(this);
- }
-
- /**
- * The actual algorithm.
- */
- protected void execute(IProgressMonitor monitor) {
- fCollector.setProgressMonitor(monitor);
- TextSearchEngine engine= new TextSearchEngine();
- fStatus= engine.search(fWorkspace, fScope, fCollector, fMatchLocator);
- }
-
- void searchInFile(IFile file, ITextSearchResultCollector collector) {
- TextSearchEngine engine= new TextSearchEngine();
- TextSearchScope scope= new TextSearchScope(""); //$NON-NLS-1$
- scope.add(file);
- scope.addExtension("*"); //$NON-NLS-1$
- fStatus= engine.search(fWorkspace, scope, collector, fMatchLocator);
- }
-
- String getSingularLabel() {
- String pattern= fMatchLocator.getPattern();
- if (pattern == null || pattern.length() < 1)
- return SearchMessages.getFormattedString("FileSearchOperation.singularLabelPostfix", new String[] {fScope.getDescription()}); //$NON-NLS-1$
- else
- return SearchMessages.getFormattedString("TextSearchOperation.singularLabelPostfix", new String[] {fMatchLocator.getPattern(), fScope.getDescription()}); //$NON-NLS-1$
- }
-
- String getPluralLabelPattern() {
- String pattern= fMatchLocator.getPattern();
- if (pattern == null || pattern.length() < 1)
- return SearchMessages.getFormattedString("FileSearchOperation.pluralLabelPatternPostfix", new String[] {"{0}", fScope.getDescription()}); //$NON-NLS-2$ //$NON-NLS-1$
- else
- return SearchMessages.getFormattedString("TextSearchOperation.pluralLabelPatternPostfix", new String[] {fMatchLocator.getPattern(), "{0}", fScope.getDescription()}); //$NON-NLS-2$ //$NON-NLS-1$
- }
-
- ImageDescriptor getImageDescriptor() {
- return SearchPluginImages.DESC_OBJ_TSEARCH_DPDN;
- }
-
- IStatus getStatus() {
- return fStatus;
- }
-
- String getPattern() {
- return fMatchLocator.getPattern();
- }
-
- boolean isRegexSearch() {
- return fMatchLocator.isRegExSearch();
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchPage.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchPage.java
deleted file mode 100644
index fa48351..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchPage.java
+++ /dev/null
@@ -1,777 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui.text;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.StringReader;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.regex.PatternSyntaxException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IStatus;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.DialogPage;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-
-import org.eclipse.jface.text.ITextSelection;
-
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkingSet;
-import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.ui.model.IWorkbenchAdapter;
-
-import org.eclipse.search.ui.IReplacePage;
-import org.eclipse.search.ui.ISearchPage;
-import org.eclipse.search.ui.ISearchPageContainer;
-import org.eclipse.search.ui.ISearchResultPage;
-import org.eclipse.search.ui.ISearchResultViewEntry;
-import org.eclipse.search.ui.ISearchResultViewPart;
-import org.eclipse.search.ui.NewSearchUI;
-import org.eclipse.search.ui.SearchUI;
-
-import org.eclipse.search.internal.core.text.TextSearchScope;
-import org.eclipse.search.internal.ui.ISearchHelpContextIds;
-import org.eclipse.search.internal.ui.ScopePart;
-import org.eclipse.search.internal.ui.SearchMessages;
-import org.eclipse.search.internal.ui.SearchPlugin;
-import org.eclipse.search.internal.ui.SearchResultView;
-import org.eclipse.search.internal.ui.WorkInProgressPreferencePage;
-import org.eclipse.search.internal.ui.util.ExceptionHandler;
-import org.eclipse.search.internal.ui.util.FileTypeEditor;
-import org.eclipse.search.internal.ui.util.RowLayouter;
-import org.eclipse.search.internal.ui.util.SWTUtil;
-
-public class TextSearchPage extends DialogPage implements ISearchPage, IReplacePage {
-
- public static final String EXTENSION_POINT_ID= "org.eclipse.search.internal.ui.text.TextSearchPage"; //$NON-NLS-1$
-
- // Dialog store id constants
- private final static String PAGE_NAME= "TextSearchPage"; //$NON-NLS-1$
- private final static String STORE_CASE_SENSITIVE= PAGE_NAME + "CASE_SENSITIVE"; //$NON-NLS-1$
- private final static String STORE_IS_REG_EX_SEARCH= PAGE_NAME + "REG_EX_SEARCH"; //$NON-NLS-1$
-
- private static List fgPreviousSearchPatterns= new ArrayList(20);
-
- private IDialogSettings fDialogSettings;
- private boolean fFirstTime= true;
- private boolean fIsCaseSensitive;
- private boolean fIsRegExSearch;
-
- private Combo fPattern;
- private Button fIgnoreCase;
- private Combo fExtensions;
- private Button fIsRegExCheckbox;
- private Label fHintLabel;
-
- private ISearchPageContainer fContainer;
- private FileTypeEditor fFileTypeEditor;
-
-
- private static class SearchPatternData {
- boolean ignoreCase;
- boolean isRegExSearch;
- String textPattern;
- Set fileNamePatterns;
- int scope;
- IWorkingSet[] workingSets;
-
- public SearchPatternData(String textPattern, boolean ignoreCase, boolean isRegExSearch, Set fileNamePatterns, int scope, IWorkingSet[] workingSets) {
- this.ignoreCase= ignoreCase;
- this.isRegExSearch= isRegExSearch;
- this.textPattern= textPattern;
- this.fileNamePatterns= fileNamePatterns;
- this.scope= scope;
- this.workingSets= workingSets;
- }
- }
- //---- Action Handling ------------------------------------------------
-
- public boolean performAction() {
- if (WorkInProgressPreferencePage.useNewSearch())
- return performNewSearch(false);
- else
- return performOldSearch();
- }
-
- private boolean performOldSearch() {
-
- TextSearchOperation op = createTextSearchOperation();
-
- return runOperation(op);
- }
-
- private boolean runOperation(final TextSearchOperation op) {
- try {
- getRunnableContext().run(true, true, op);
- } catch (InvocationTargetException ex) {
- if (ex.getTargetException() instanceof PatternSyntaxException)
- showRegExSyntaxError((PatternSyntaxException)ex.getTargetException());
- else
- ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.search.title"),SearchMessages.getString("Search.Error.search.message")); //$NON-NLS-2$ //$NON-NLS-1$
- return false;
- } catch (InterruptedException e) {
- return false;
- }
- IStatus status= op.getStatus();
- if (status != null && !status.isOK()) {
- String title= SearchMessages.getString("Search.Problems.title"); //$NON-NLS-1$
- ErrorDialog.openError(getShell(), title, null, status); //$NON-NLS-1$
- return false;
- }
-
- return true;
- }
-
-
- private IRunnableContext getRunnableContext() {
- IRunnableContext context= null;
- context= getContainer().getRunnableContext();
-
- Shell shell= fPattern.getShell();
- if (context == null)
- context= new ProgressMonitorDialog(shell);
- return context;
- }
-
- private TextSearchOperation createTextSearchOperation() {
-
- SearchPatternData patternData= getPatternData();
- if (patternData.fileNamePatterns == null || fExtensions.getText().length() <= 0) {
- patternData.fileNamePatterns= new HashSet(1);
- patternData.fileNamePatterns.add("*"); //$NON-NLS-1$
- }
-
- // Setup search scope
- TextSearchScope scope= null;
- switch (getContainer().getSelectedScope()) {
- case ISearchPageContainer.WORKSPACE_SCOPE:
- scope= TextSearchScope.newWorkspaceScope();
- break;
- case ISearchPageContainer.SELECTION_SCOPE:
- scope= getSelectedResourcesScope(false);
- break;
- case ISearchPageContainer.SELECTED_PROJECTS_SCOPE:
- scope= getSelectedResourcesScope(true);
- break;
- case ISearchPageContainer.WORKING_SET_SCOPE:
- IWorkingSet[] workingSets= getContainer().getSelectedWorkingSets();
- String desc= SearchMessages.getFormattedString("WorkingSetScope", ScopePart.toString(workingSets)); //$NON-NLS-1$
- scope= new TextSearchScope(desc, workingSets);
- }
- scope.addExtensions(patternData.fileNamePatterns);
-
- SearchUI.activateSearchResultView();
- TextSearchResultCollector collector= new TextSearchResultCollector();
-
- final TextSearchOperation op= new TextSearchOperation(
- SearchPlugin.getWorkspace(),
- patternData.textPattern,
- getSearchOptions(),
- scope,
- collector);
- return op;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.IReplacePage#performReplace()
- */
- public boolean performReplace() {
-
- if (WorkInProgressPreferencePage.useNewSearch()) {
- if (!performNewSearch(true))
- return false;
- Display.getCurrent().asyncExec(new Runnable() {
- public void run() {
- ISearchResultViewPart view= NewSearchUI.activateSearchResultView();
- if (view != null) {
- ISearchResultPage page= view.getActivePage();
- if (page instanceof FileSearchPage) {
- FileSearchPage filePage= (FileSearchPage) page;
- Object[] elements= filePage.getInput().getElements();
- IFile[] files= new IFile[elements.length];
- System.arraycopy(elements, 0, files, 0, files.length);
- new ReplaceAction2(filePage, files).run();
- }
- }
- }
- });
- } else {
- final TextSearchOperation op= createTextSearchOperation();
-
- if (!runOperation(op))
- return false;
-
- Display.getCurrent().asyncExec(new Runnable() {
- public void run() {
- SearchResultView view= (SearchResultView) SearchPlugin.getSearchResultView();
- new ReplaceDialog(SearchPlugin.getSearchResultView().getViewSite().getShell(), (List) view.getViewer().getInput(), op).open();
- }
- });
- }
- return true;
- }
-
- private boolean performNewSearch(boolean forground) {
- org.eclipse.search.ui.NewSearchUI.activateSearchResultView();
-
- SearchPatternData patternData= getPatternData();
- if (patternData.fileNamePatterns == null || fExtensions.getText().length() <= 0) {
- patternData.fileNamePatterns= new HashSet(1);
- patternData.fileNamePatterns.add("*"); //$NON-NLS-1$
- }
-
- // Setup search scope
- TextSearchScope scope= null;
- switch (getContainer().getSelectedScope()) {
- case ISearchPageContainer.WORKSPACE_SCOPE:
- scope= TextSearchScope.newWorkspaceScope();
- break;
- case ISearchPageContainer.SELECTION_SCOPE:
- scope= getSelectedResourcesScope(false);
- break;
- case ISearchPageContainer.SELECTED_PROJECTS_SCOPE:
- scope= getSelectedResourcesScope(true);
- break;
- case ISearchPageContainer.WORKING_SET_SCOPE:
- IWorkingSet[] workingSets= getContainer().getSelectedWorkingSets();
- String desc= SearchMessages.getFormattedString("WorkingSetScope", ScopePart.toString(workingSets)); //$NON-NLS-1$
- scope= new TextSearchScope(desc, workingSets);
- }
- scope.addExtensions(patternData.fileNamePatterns);
-
- FileSearchQuery wsJob= new FileSearchQuery(scope, getSearchOptions(), patternData.textPattern);
- if (forground) {
- IStatus status= NewSearchUI.runQueryInForeground(getRunnableContext(), wsJob);
- return status.isOK();
- } else
- NewSearchUI.runQuery(wsJob);
-
- return true;
- }
-
- private void showRegExSyntaxError(PatternSyntaxException ex) {
- String title= SearchMessages.getString("SearchPage.regularExpressionSyntaxProblem.title"); //$NON-NLS-1$
- MessageDialog.openInformation(getShell(), title, ex.getLocalizedMessage());
- }
-
- private String getPattern() {
- return fPattern.getText();
- }
-
- /**
- * Return search pattern data and update previous searches.
- * An existing entry will be updated.
- */
- private SearchPatternData getPatternData() {
- SearchPatternData match= null;
- String textPattern= fPattern.getText();
- int i= fgPreviousSearchPatterns.size() - 1;
- while (i >= 0) {
- match= (SearchPatternData)fgPreviousSearchPatterns.get(i);
- if (textPattern.equals(match.textPattern))
- break;
- i--;
- }
- if (i >= 0) {
- match.ignoreCase= ignoreCase();
- match.isRegExSearch= fIsRegExCheckbox.getSelection();
- match.textPattern= getPattern();
- match.fileNamePatterns= getExtensions();
- match.scope= getContainer().getSelectedScope();
- match.workingSets= getContainer().getSelectedWorkingSets();
- // remove - will be added last (see below)
- fgPreviousSearchPatterns.remove(match);
- } else {
- match= new SearchPatternData(
- getPattern(),
- ignoreCase(),
- fIsRegExCheckbox.getSelection(),
- getExtensions(),
- getContainer().getSelectedScope(),
- getContainer().getSelectedWorkingSets());
- }
- fgPreviousSearchPatterns.add(match);
- return match;
- }
-
- private String[] getPreviousExtensions() {
- List extensions= new ArrayList(fgPreviousSearchPatterns.size());
- for (int i= fgPreviousSearchPatterns.size() -1 ; i >= 0; i--) {
- SearchPatternData data= (SearchPatternData)fgPreviousSearchPatterns.get(i);
- String text= FileTypeEditor.typesToString(data.fileNamePatterns);
- if (!extensions.contains(text))
- extensions.add(text);
- }
- return (String[])extensions.toArray(new String[extensions.size()]);
- }
-
- private String[] getPreviousSearchPatterns() {
- int size= fgPreviousSearchPatterns.size();
- String [] patterns= new String[size];
- for (int i= 0; i < size; i++)
- patterns[i]= ((SearchPatternData) fgPreviousSearchPatterns.get(size - 1 - i)).textPattern;
- return patterns;
- }
-
- private String getSearchOptions() {
- StringBuffer result= new StringBuffer();
- if (!ignoreCase())
- result.append("i"); //$NON-NLS-1$
-
- if (fIsRegExSearch)
- result.append("r"); //$NON-NLS-1$
-
- return result.toString();
- }
-
- private Set getExtensions() {
- return fFileTypeEditor.getFileTypes();
- }
-
- private boolean ignoreCase() {
- return fIgnoreCase.getSelection();
- }
-
- /*
- * Implements method from IDialogPage
- */
- public void setVisible(boolean visible) {
- if (visible && fPattern != null) {
- if (fFirstTime) {
- fFirstTime= false;
- // Set item and text here to prevent page from resizing
- fPattern.setItems(getPreviousSearchPatterns());
- fExtensions.setItems(getPreviousExtensions());
- initializePatternControl();
- }
- fPattern.setFocus();
- getContainer().setPerformActionEnabled(getContainer().hasValidScope());
- }
- super.setVisible(visible);
- }
-
- //---- Widget creation ------------------------------------------------
-
- /**
- * Creates the page's content.
- */
- public void createControl(Composite parent) {
- initializeDialogUnits(parent);
- readConfiguration();
-
- GridData gd;
- Composite result= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout(3, false);
- layout.horizontalSpacing= 10;
- result.setLayout(layout);
- result.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- RowLayouter layouter= new RowLayouter(layout.numColumns);
- gd= new GridData();
- gd.horizontalAlignment= GridData.FILL;
- gd.verticalAlignment= GridData.VERTICAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_FILL;
-
- layouter.setDefaultGridData(gd, 0);
- layouter.setDefaultGridData(gd, 1);
- layouter.setDefaultGridData(gd, 2);
- layouter.setDefaultSpan();
-
- layouter.perform(createTextSearchComposite(result));
-
- // Vertical filler
- Label filler= new Label(result, SWT.LEFT);
- gd= new GridData(GridData.BEGINNING | GridData.VERTICAL_ALIGN_FILL);
- gd.heightHint= convertHeightInCharsToPixels(1) / 3;
- filler.setLayoutData(gd);
- layouter.perform(new Control[] {filler}, 3);
-
- layouter.perform(createFileNamePatternComposite(result));
-
- setControl(result);
- Dialog.applyDialogFont(result);
- WorkbenchHelp.setHelp(result, ISearchHelpContextIds.TEXT_SEARCH_PAGE);
- }
-
- private Control createTextSearchComposite(Composite group) {
- GridData gd;
- Label label;
-
- // Info text
- label= new Label(group, SWT.LEFT);
- label.setText(SearchMessages.getString("SearchPage.containingText.text")); //$NON-NLS-1$
- gd= new GridData(GridData.BEGINNING);
- gd.horizontalSpan= 3;
- label.setLayoutData(gd);
-
- // Pattern combo
- fPattern= new Combo(group, SWT.SINGLE | SWT.BORDER);
- // Not done here to prevent page from resizing
- // fPattern.setItems(getPreviousSearchPatterns());
- fPattern.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- getContainer().setPerformActionEnabled(true);
- }
- });
- fPattern.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- handleWidgetSelected();
- }
- });
- gd= new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
- gd.horizontalSpan= 2;
- fPattern.setLayoutData(gd);
-
- fIgnoreCase= new Button(group, SWT.CHECK);
- fIgnoreCase.setText(SearchMessages.getString("SearchPage.caseSensitive")); //$NON-NLS-1$
- gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- fIgnoreCase.setLayoutData(gd);
- fIgnoreCase.setSelection(!fIsCaseSensitive);
- fIgnoreCase.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- fIsCaseSensitive= !fIgnoreCase.getSelection();
- writeConfiguration();
- }
- });
-
- // Text line which explains the special characters
- fHintLabel= new Label(group, SWT.LEFT);
- fHintLabel.setText(SearchMessages.getString("SearchPage.containingText.hint")); //$NON-NLS-1$
- fHintLabel.setVisible(!fIsRegExSearch);
- gd= new GridData(GridData.BEGINNING);
- gd.horizontalSpan= 2;
- fHintLabel.setLayoutData(gd);
-
- // RegEx checkbox
- fIsRegExCheckbox= new Button(group, SWT.CHECK);
- fIsRegExCheckbox.setText(SearchMessages.getString("SearchPage.regularExpression")); //$NON-NLS-1$
- gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- fIsRegExCheckbox.setLayoutData(gd);
- fIsRegExCheckbox.setSelection(fIsRegExSearch);
- fIsRegExCheckbox.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- fIsRegExSearch= fIsRegExCheckbox.getSelection();
- fHintLabel.setVisible(!fIsRegExSearch);
- writeConfiguration();
- }
- });
-
- return group;
- }
-
- private void handleWidgetSelected() {
- if (fPattern.getSelectionIndex() < 0)
- return;
- int index= fgPreviousSearchPatterns.size() - 1 - fPattern.getSelectionIndex();
- SearchPatternData patternData= (SearchPatternData) fgPreviousSearchPatterns.get(index);
- if (patternData == null || !fPattern.getText().equals(patternData.textPattern))
- return;
- fIgnoreCase.setSelection(patternData.ignoreCase);
- fIsRegExCheckbox.setSelection(patternData.isRegExSearch);
- fHintLabel.setVisible(!patternData.isRegExSearch);
- fPattern.setText(patternData.textPattern);
- fFileTypeEditor.setFileTypes(patternData.fileNamePatterns);
- if (patternData.workingSets != null)
- getContainer().setSelectedWorkingSets(patternData.workingSets);
- else
- getContainer().setSelectedScope(patternData.scope);
- }
-
- private void initializePatternControl() {
- ISelection selection= getSelection();
- String text= ""; //$NON-NLS-1$
- String extension= null;
- if (selection instanceof ITextSelection) {
- ITextSelection textSelection= (ITextSelection)getSelection();
- text= textSelection.getText();
- } else {
- IResource resource= null;
- Object item= null;
- if (selection instanceof IStructuredSelection)
- item= ((IStructuredSelection)selection).getFirstElement();
- if (item instanceof IResource) {
- resource= (IResource)item;
- text= resource.getName();
- }
- else if (item instanceof ISearchResultViewEntry) {
- IMarker marker= ((ISearchResultViewEntry)item).getSelectedMarker();
- resource= marker.getResource();
- try {
- text= (String)marker.getAttribute(SearchUI.LINE);
- } catch (CoreException ex) {
- ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.markerAttributeAccess.title"), SearchMessages.getString("Search.Error.markerAttributeAccess.message")); //$NON-NLS-2$ //$NON-NLS-1$
- text= ""; //$NON-NLS-1$
- }
- } else if (item instanceof IAdaptable) {
- Object adapter= ((IAdaptable)item).getAdapter(IWorkbenchAdapter.class);
- if (adapter instanceof IWorkbenchAdapter)
- text= ((IWorkbenchAdapter)adapter).getLabel(item);
-
- adapter= ((IAdaptable)item).getAdapter(IResource.class);
- if (adapter instanceof IResource) {
- resource= (IResource)adapter;
- if (text == null) // keep text, if provided by workbench adapter
- text= resource.getName();
- }
- }
- if (resource instanceof IFile ) {
- extension= resource.getFileExtension();
- if (extension == null)
- extension= resource.getName();
- else
- extension= "*." + extension; //$NON-NLS-1$
- }
- else
- extension= "*"; //$NON-NLS-1$
- }
- fPattern.setText(insertEscapeChars(text));
-
- if (getPreviousExtensions().length > 0)
- fExtensions.setText(getPreviousExtensions()[0]);
- else {
- if (extension == null)
- extension= getExtensionFromEditor();
- if (extension != null)
- fExtensions.setText(extension);
- }
- }
-
- private String insertEscapeChars(String text) {
- if (text == null || text.equals("")) //$NON-NLS-1$
- return ""; //$NON-NLS-1$
- StringBuffer sbIn= new StringBuffer(text);
- BufferedReader reader= new BufferedReader(new StringReader(text));
- int lengthOfFirstLine= 0;
- try {
- lengthOfFirstLine= reader.readLine().length();
- } catch (IOException ex) {
- return ""; //$NON-NLS-1$
- }
- StringBuffer sbOut= new StringBuffer(lengthOfFirstLine + 5);
- int i= 0;
- while (i < lengthOfFirstLine) {
- char ch= sbIn.charAt(i);
- if (ch == '*' || ch == '?' || ch == '\\')
- sbOut.append("\\"); //$NON-NLS-1$
- sbOut.append(ch);
- i= i+1;
- }
- return sbOut.toString();
- }
-
- private String getExtensionFromEditor() {
- IEditorPart ep= SearchPlugin.getActivePage().getActiveEditor();
- if (ep != null) {
- Object elem= ep.getEditorInput();
- if (elem instanceof IFileEditorInput) {
- String extension= ((IFileEditorInput)elem).getFile().getFileExtension();
- if (extension == null)
- return ((IFileEditorInput)elem).getFile().getName();
- else
- return "*." + extension; //$NON-NLS-1$
- }
- }
- return null;
- }
-
- private Control createFileNamePatternComposite(Composite group) {
- GridData gd;
-
- // Line with label, combo and button
- Label label= new Label(group, SWT.LEFT);
- label.setText(SearchMessages.getString("SearchPage.fileNamePatterns.text")); //$NON-NLS-1$
- gd= new GridData(GridData.BEGINNING);
- gd.horizontalSpan= 3;
- label.setLayoutData(gd);
-
- fExtensions= new Combo(group, SWT.SINGLE | SWT.BORDER);
- fExtensions.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- getContainer().setPerformActionEnabled(getContainer().hasValidScope());
- }
- });
- gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan= 2;
- fExtensions.setLayoutData(gd);
-
- Button button= new Button(group, SWT.PUSH);
- button.setText(SearchMessages.getString("SearchPage.browse")); //$NON-NLS-1$
- gd= new GridData(GridData.HORIZONTAL_ALIGN_END);
- button.setLayoutData(gd);
- SWTUtil.setButtonDimensionHint(button);
- fFileTypeEditor= new FileTypeEditor(
- SearchPlugin.getDefault().getWorkbench().getEditorRegistry(),
- fExtensions, button);
-
- // Text line which explains the special characters
- label= new Label(group, SWT.LEFT);
- label.setText(SearchMessages.getString("SearchPage.fileNamePatterns.hint")); //$NON-NLS-1$
- gd= new GridData(GridData.BEGINNING);
- gd.horizontalSpan= 3;
- label.setLayoutData(gd);
-
- return group;
- }
-
- public boolean isValid() {
- return true;
- }
-
- /**
- * Sets the search page's container.
- */
- public void setContainer(ISearchPageContainer container) {
- fContainer= container;
- }
-
- /**
- * Returns the search page's container.
- */
- private ISearchPageContainer getContainer() {
- return fContainer;
- }
-
- /**
- * Returns the current active selection.
- */
- private ISelection getSelection() {
- return fContainer.getSelection();
- }
-
- private TextSearchScope getSelectedResourcesScope(boolean isProjectScope) {
- TextSearchScope scope= new TextSearchScope(SearchMessages.getString("SelectionScope")); //$NON-NLS-1$
- int elementCount= 0;
- IProject firstProject= null;
- if (getSelection() instanceof IStructuredSelection && !getSelection().isEmpty()) {
- Iterator iter= ((IStructuredSelection)getSelection()).iterator();
- while (iter.hasNext()) {
- Object selection= iter.next();
-
- //Unpack search result entry
- if (selection instanceof ISearchResultViewEntry)
- selection= ((ISearchResultViewEntry)selection).getGroupByKey();
-
- IResource resource= null;
- if (selection instanceof IResource)
- resource= (IResource)selection;
- else if (selection instanceof IAdaptable) {
- if (isProjectScope)
- resource= (IProject)((IAdaptable)selection).getAdapter(IProject.class);
- if (resource == null)
- resource= (IResource)((IAdaptable)selection).getAdapter(IResource.class);
- }
- if (resource != null) {
-
- if (isProjectScope) {
- resource= resource.getProject();
- if (resource == null || isProjectScope && scope.encloses(resource))
- continue;
- if (firstProject == null)
- firstProject= (IProject)resource;
- }
- elementCount++;
- scope.add(resource);
- }
- }
- } else if (isProjectScope) {
- IProject editorProject= getEditorProject();
- if (editorProject != null)scope.add(editorProject);
- }
- if (isProjectScope) {
- if (elementCount > 1)
- scope.setDescription(SearchMessages.getFormattedString("EnclosingProjectsScope", firstProject.getName())); //$NON-NLS-1$
- else if (elementCount == 1)
- scope.setDescription(SearchMessages.getFormattedString("EnclosingProjectScope", firstProject.getName())); //$NON-NLS-1$
- else
- scope.setDescription(SearchMessages.getFormattedString("EnclosingProjectScope", "")); //$NON-NLS-1$ //$NON-NLS-2$
- }
- return scope;
- }
-
- private IProject getEditorProject() {
- IWorkbenchPart activePart= SearchPlugin.getActivePage().getActivePart();
- if (activePart instanceof IEditorPart) {
- IEditorPart editor= (IEditorPart) activePart;
- IEditorInput input= editor.getEditorInput();
- if (input instanceof IFileEditorInput) {
- return ((IFileEditorInput)input).getFile().getProject();
- }
- }
- return null;
- }
- //--------------- Configuration handling --------------
-
- /**
- * Returns the page settings for this Text search page.
- *
- * @return the page settings to be used
- */
- private IDialogSettings getDialogSettings() {
- IDialogSettings settings= SearchPlugin.getDefault().getDialogSettings();
- fDialogSettings= settings.getSection(PAGE_NAME);
- if (fDialogSettings == null)
- fDialogSettings= settings.addNewSection(PAGE_NAME);
- return fDialogSettings;
- }
-
- /**
- * Initializes itself from the stored page settings.
- */
- private void readConfiguration() {
- IDialogSettings s= getDialogSettings();
- fIsCaseSensitive= s.getBoolean(STORE_CASE_SENSITIVE);
- fIsRegExSearch= s.getBoolean(STORE_IS_REG_EX_SEARCH);
- }
-
- /**
- * Stores it current configuration in the dialog store.
- */
- private void writeConfiguration() {
- IDialogSettings s= getDialogSettings();
- s.put(STORE_CASE_SENSITIVE, fIsCaseSensitive);
- s.put(STORE_IS_REG_EX_SEARCH, fIsRegExSearch);
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchResultCollector.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchResultCollector.java
deleted file mode 100644
index cbb14eb..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchResultCollector.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui.text;
-
-import java.text.MessageFormat;
-import java.util.HashMap;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceProxy;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-import org.eclipse.ui.actions.ActionGroup;
-
-import org.eclipse.search.ui.IActionGroupFactory;
-import org.eclipse.search.ui.ISearchResultView;
-import org.eclipse.search.ui.SearchUI;
-
-import org.eclipse.search.internal.core.text.ITextSearchResultCollector;
-import org.eclipse.search.internal.ui.SearchMessages;
-import org.eclipse.search.internal.ui.util.FileLabelProvider;
-
-public class TextSearchResultCollector implements ITextSearchResultCollector {
-
- private static final String MATCH= SearchMessages.getString("SearchResultCollector.match"); //$NON-NLS-1$
- private static final String MATCHES= SearchMessages.getString("SearchResultCollector.matches"); //$NON-NLS-1$
- private static final String DONE= SearchMessages.getString("SearchResultCollector.done"); //$NON-NLS-1$
-
- private IProgressMonitor fMonitor;
- private ISearchResultView fView;
- private TextSearchOperation fOperation;
- private int fMatchCount= 0;
- private Integer[] fMessageFormatArgs= new Integer[1];
- private long fLastUpdateTime;
-
-
- private static class TextSearchActionGroupFactory implements IActionGroupFactory {
- public ActionGroup createActionGroup(ISearchResultView part) {
- return new TextSearchActionGroup(part);
- }
- }
-
- /**
- * Returns the progress monitor used to setup and report progress.
- */
- public IProgressMonitor getProgressMonitor() {
- return fMonitor;
- }
-
- void setProgressMonitor(IProgressMonitor pm) {
- fMonitor= pm;
- }
-
- /**
- * Called before the actual search starts.
- */
- public void aboutToStart() throws CoreException {
- fView= SearchUI.getSearchResultView();
- fMatchCount= 0;
- fLastUpdateTime= 0;
- if (fView != null) {
- fView.searchStarted(
- new TextSearchActionGroupFactory(),
- fOperation.getSingularLabel(),
- fOperation.getPluralLabelPattern(),
- fOperation.getImageDescriptor(),
- TextSearchPage.EXTENSION_POINT_ID,
- new FileLabelProvider(FileLabelProvider.SHOW_LABEL_PATH),
- new GotoMarkerAction(),
- new GroupByKeyComputer(),
- fOperation);
- }
- }
-
- /**
- * Accepts the given search result.
- */
- public void accept(final IResourceProxy proxy, String line, int start, int length, final int lineNumber) throws CoreException {
- IResource resource= proxy.requestResource();
- IMarker marker= resource.createMarker(SearchUI.SEARCH_MARKER);
- HashMap attributes= new HashMap(4);
- attributes.put(SearchUI.LINE, line);
- attributes.put(IMarker.CHAR_START, new Integer(start));
- attributes.put(IMarker.CHAR_END, new Integer(start + length));
- attributes.put(IMarker.LINE_NUMBER, new Integer(lineNumber));
- marker.setAttributes(attributes);
-
- String description= resource.getFullPath().lastSegment();
- if (description == null)
- description= ""; //$NON-NLS-1$
-
- fView.addMatch(description, resource, resource, marker);
-
- fMatchCount++;
-
- if (!getProgressMonitor().isCanceled() && System.currentTimeMillis() - fLastUpdateTime > 1000) {
- getProgressMonitor().subTask(getFormattedMatchesString(fMatchCount));
- fLastUpdateTime= System.currentTimeMillis();
- }
- }
-
- /**
- * Called when the search has ended.
- */
- public void done() {
- if (!getProgressMonitor().isCanceled()) {
- String matchesString= getFormattedMatchesString(fMatchCount);
- getProgressMonitor().setTaskName(MessageFormat.format(DONE, new String[]{matchesString}));
- }
-
- if (fView != null)
- fView.searchFinished();
-
- // Cut no longer unused references because the collector might be re-used
- fView= null;
- fMonitor= null;
- }
-
- void setOperation(TextSearchOperation operation) {
- fOperation= operation;
- }
-
- private String getFormattedMatchesString(int count) {
- if (fMatchCount == 1)
- return MATCH;
- fMessageFormatArgs[0]= new Integer(count);
- return MessageFormat.format(MATCHES, fMessageFormatArgs);
-
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/util/ComboFieldEditor.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/util/ComboFieldEditor.java
deleted file mode 100644
index 877d9a3..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/util/ComboFieldEditor.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui.util;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-
-import org.eclipse.jface.preference.FieldEditor;
-import org.eclipse.jface.util.Assert;
-
-/**
- * A field editor for a combo box that allows the drop-down selection of one of a list of items.
- *
- * XXX: Note this is a copy from org.eclipse.debug.internal.ui.preferences
- * This class can be removed once bug 24928 is fixed.
- *
- * @since 2.1
- */
-public class ComboFieldEditor extends FieldEditor {
-
- /**
- * The <code>Combo</code> widget.
- */
- private Combo fCombo;
-
- /**
- * The value (not the name) of the currently selected item in the Combo widget.
- */
- private String fValue;
-
- /**
- * The names (labels) and underlying values to populate the combo widget. These should be
- * arranged as: { {name1, value1}, {name2, value2}, ...}
- */
- private String[][] fEntryNamesAndValues;
-
- public ComboFieldEditor(String name, String labelText, String[][] entryNamesAndValues, Composite parent) {
- init(name, labelText);
- Assert.isTrue(checkArray(entryNamesAndValues));
- fEntryNamesAndValues= entryNamesAndValues;
- createControl(parent);
- }
-
- /**
- * Checks whether given <code>String[][]</code> is of "type"
- * <code>String[][2]</code>.
- *
- * @return <code>true</code> if it is ok, and <code>false</code> otherwise
- */
- private boolean checkArray(String[][] table) {
- if (table == null) {
- return false;
- }
- for (int i= 0; i < table.length; i++) {
- String[] array= table[i];
- if (array == null || array.length != 2) {
- return false;
- }
- }
- return true;
- }
-
- /*
- * @see FieldEditor#adjustForNumColumns(int)
- */
- protected void adjustForNumColumns(int numColumns) {
- Control control= getLabelControl();
- if (control != null) {
- ((GridData)control.getLayoutData()).horizontalSpan= numColumns;
- }
- ((GridData)fCombo.getLayoutData()).horizontalSpan= numColumns;
- }
-
- /*
- * @see FieldEditor#doFillIntoGrid(Composite, int)
- */
- protected void doFillIntoGrid(Composite parent, int numColumns) {
- Control control= getLabelControl(parent);
- GridData gd= new GridData();
- gd.horizontalSpan= numColumns;
- control.setLayoutData(gd);
- control= getComboBoxControl(parent);
- gd= new GridData();
- gd.horizontalSpan= numColumns;
- control.setLayoutData(gd);
- }
-
- /*
- * @see FieldEditor#doLoad()
- */
- protected void doLoad() {
- updateComboForValue(getPreferenceStore().getString(getPreferenceName()));
- }
-
- /*
- * @see FieldEditor#doLoadDefault()
- */
- protected void doLoadDefault() {
- updateComboForValue(getPreferenceStore().getDefaultString(getPreferenceName()));
- }
-
- /*
- * @see FieldEditor#doStore()
- */
- protected void doStore() {
- if (fValue == null) {
- getPreferenceStore().setToDefault(getPreferenceName());
- return;
- }
-
- getPreferenceStore().setValue(getPreferenceName(), fValue);
- }
-
- /*
- * @see FieldEditor#getNumberOfControls()
- */
- public int getNumberOfControls() {
- return 2;
- }
-
- /**
- * Lazily create and return the Combo control.
- */
- public Combo getComboBoxControl(Composite parent) {
- if (fCombo == null) {
- fCombo= new Combo(parent, SWT.READ_ONLY);
- for (int i= 0; i < fEntryNamesAndValues.length; i++) {
- fCombo.add(fEntryNamesAndValues[i][0], i);
- }
- fCombo.setFont(parent.getFont());
- fCombo.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent evt) {
- String oldValue= fValue;
- String name= fCombo.getText();
- fValue= getValueForName(name);
- setPresentsDefaultValue(false);
- fireValueChanged(VALUE, oldValue, fValue);
- }
- });
- }
- return fCombo;
- }
-
- /**
- * Given the name (label) of an entry, return the corresponding value.
- */
- protected String getValueForName(String name) {
- for (int i= 0; i < fEntryNamesAndValues.length; i++) {
- String[] entry= fEntryNamesAndValues[i];
- if (name.equals(entry[0])) {
- return entry[1];
- }
- }
- return fEntryNamesAndValues[0][0];
- }
-
- /**
- * Set the name in the combo widget to match the specified value.
- */
- protected void updateComboForValue(String value) {
- fValue= value;
- for (int i= 0; i < fEntryNamesAndValues.length; i++) {
- if (value.equals(fEntryNamesAndValues[i][1])) {
- fCombo.setText(fEntryNamesAndValues[i][0]);
- return;
- }
- }
- if (fEntryNamesAndValues.length > 0) {
- fValue= fEntryNamesAndValues[0][1];
- fCombo.setText(fEntryNamesAndValues[0][0]);
- }
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/util/ExceptionHandler.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/util/ExceptionHandler.java
deleted file mode 100644
index 1cf4a32..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/util/ExceptionHandler.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui.util;
-
-import java.io.StringWriter;
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-
-import org.eclipse.search.internal.ui.SearchMessages;
-import org.eclipse.search.internal.ui.SearchPlugin;
-import org.eclipse.search.ui.SearchUI;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.MessageDialog;
-
-/**
- * The default exception handler shows an error dialog when one of its handle methods
- * is called. If the passed exception is a <code>CoreException</code> an error dialog
- * pops up showing the exception's status information. For a <code>InvocationTargetException</code>
- * a normal message dialog pops up showing the exception's message. Additionally the exception
- * is written to the platform log.
- */
-public class ExceptionHandler {
-
- private static ExceptionHandler fgInstance= new ExceptionHandler();
-
- /**
- * Logs the given exception using the platform's logging mechanism. The exception is
- * logged as an error with the error code <code>JavaStatusConstants.INTERNAL_ERROR</code>.
- */
- public static void log(Throwable t, String message) {
- SearchPlugin.log(new Status(IStatus.ERROR, SearchUI.PLUGIN_ID, IStatus.ERROR, message, t));
- }
-
- /**
- * Handles the given <code>CoreException</code>. The workbench shell is used as a parent
- * for the dialog window.
- *
- * @param e the <code>CoreException</code> to be handled
- * @param title the dialog window's window title
- * @param message message to be displayed by the dialog window
- */
- public static void handle(CoreException e, String title, String message) {
- handle(e, SearchPlugin.getActiveWorkbenchShell(), title, message);
- }
-
- /**
- * Handles the given <code>CoreException</code>.
- *
- * @param e the <code>CoreException</code> to be handled
- * @param parent the dialog window's parent shell
- * @param title the dialog window's window title
- * @param message message to be displayed by the dialog window
- */
- public static void handle(CoreException e, Shell parent, String title, String message) {
- fgInstance.perform(e, parent, title, message);
- }
-
- /**
- * Handles the given <code>InvocationTargetException</code>. The workbench shell is used
- * as a parent for the dialog window.
- *
- * @param e the <code>InvocationTargetException</code> to be handled
- * @param title the dialog window's window title
- * @param message message to be displayed by the dialog window
- */
- public static void handle(InvocationTargetException e, String title, String message) {
- handle(e, SearchPlugin.getActiveWorkbenchShell(), title, message);
- }
-
- /**
- * Handles the given <code>InvocationTargetException</code>.
- *
- * @param e the <code>InvocationTargetException</code> to be handled
- * @param parent the dialog window's parent shell
- * @param title the dialog window's window title
- * @param message message to be displayed by the dialog window
- */
- public static void handle(InvocationTargetException e, Shell parent, String title, String message) {
- fgInstance.perform(e, parent, title, message);
- }
-
- //---- Hooks for subclasses to control exception handling ------------------------------------
-
- protected void perform(CoreException e, Shell shell, String title, String message) {
- SearchPlugin.log(e);
- IStatus status= e.getStatus();
- if (status != null) {
- ErrorDialog.openError(shell, title, message, status);
- } else {
- displayMessageDialog(e, e.getMessage(), shell, title, message);
- }
- }
-
- protected void perform(InvocationTargetException e, Shell shell, String title, String message) {
- Throwable target= e.getTargetException();
- if (target instanceof CoreException) {
- perform((CoreException)target, shell, title, message);
- } else {
- SearchPlugin.log(e);
- if (e.getMessage() != null && e.getMessage().length() > 0) {
- displayMessageDialog(e, e.getMessage(), shell, title, message);
- } else {
- displayMessageDialog(e, target.getMessage(), shell, title, message);
- }
- }
- }
-
- //---- Helper methods -----------------------------------------------------------------------
-
- public static void displayMessageDialog(Throwable t, Shell shell, String title, String message) {
- fgInstance.displayMessageDialog(t, t.getMessage(), shell, title, message);
- }
-
- public static void displayMessageDialog(Throwable t, String title, String message) {
- displayMessageDialog(t, SearchPlugin.getActiveWorkbenchShell(), title, message);
- }
-
- private void displayMessageDialog(Throwable t, String exceptionMessage, Shell shell, String title, String message) {
- StringWriter msg= new StringWriter();
- if (message != null) {
- msg.write(message);
- msg.write("\n\n"); //$NON-NLS-1$
- }
- if (exceptionMessage == null || exceptionMessage.length() == 0)
- msg.write(SearchMessages.getString("ExceptionDialog.seeErrorLogMessage")); //$NON-NLS-1$
- else
- msg.write(exceptionMessage);
- MessageDialog.openError(shell, title, msg.toString());
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/util/ExtendedDialogWindow.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/util/ExtendedDialogWindow.java
deleted file mode 100644
index 1f5c705..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/util/ExtendedDialogWindow.java
+++ /dev/null
@@ -1,356 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui.util;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.dialogs.ControlEnableState;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.operation.ModalContext;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.wizard.ProgressMonitorPart;
-import org.eclipse.search.internal.ui.SearchMessages;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Cursor;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-
-
-public abstract class ExtendedDialogWindow extends Dialog implements IRunnableContext {
-
- private Control fContents;
- private Button fCancelButton;
- private Set fActionButtons;
-
- // The number of long running operation executed from the dialog.
- private long fActiveRunningOperations;
-
- // The progress monitor
- private ProgressMonitorPart fProgressMonitorPart;
- private MessageDialog fWindowClosingDialog;
- private static final String FOCUS_CONTROL= "focusControl"; //$NON-NLS-1$
- private Cursor fWaitCursor;
- private Cursor fArrowCursor;
-
-
- public ExtendedDialogWindow(Shell shell) {
- super(shell);
- fActionButtons= new HashSet();
- }
-
- //---- Hooks to reimplement in subclasses -----------------------------------
-
- /**
- * Hook called when the user has pressed the button to perform
- * the dialog's action. If the method returns <code>false</code>
- * the dialog stays open. Otherwise the dialog is going to be closed.
- */
- protected boolean performAction(int buttonId) {
- return true;
- }
-
- /**
- * Hook called when the user has pressed the button to cancel
- * the dialog. If the method returns <code>false</code> the dialog
- * stays open. Otherwise the dialog is going to be closed.
- */
- protected boolean performCancel() {
- return true;
- }
-
- //---- UI creation ----------------------------------------------------------
-
- /**
- * Create the page area.
- */
- protected abstract Control createPageArea(Composite parent);
-
- /**
- * Add buttons to the dialog's button bar.
- *
- * Subclasses may override.
- *
- * @param parent the button bar composite
- */
- protected void createButtonsForButtonBar(Composite parent) {
- fCancelButton= createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
- }
-
- protected Button createActionButton(Composite parent, int id, String label,
- boolean defaultButton) {
- Button actionButton= createButton(parent, id, label, defaultButton);
- fActionButtons.add(actionButton);
- return actionButton;
- }
-
- /**
- * Creates the layout of the extended dialog window.
- */
- protected Control createDialogArea(Composite parent) {
- Composite result= new Composite(parent, SWT.NULL);
- GridLayout layout= new GridLayout();
- layout.marginWidth= 0;
- layout.marginHeight= 0;
- layout.horizontalSpacing= 0;
- layout.verticalSpacing= 0;
- result.setLayout(layout);
- result.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- fContents= createPageArea(result);
- fContents.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- // Insert a progress monitor
- GridLayout pmlayout= new GridLayout();
- pmlayout.numColumns= 1;
- fProgressMonitorPart= new ProgressMonitorPart(result, pmlayout, SWT.DEFAULT);
- fProgressMonitorPart.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- fProgressMonitorPart.setVisible(false);
-
-
- Label separator= new Label(result, SWT.SEPARATOR | SWT.HORIZONTAL);
- separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- applyDialogFont(result);
- return result;
- }
-
- protected void buttonPressed(int buttonId) {
- switch (buttonId) {
- case IDialogConstants.CANCEL_ID:
- if (fActiveRunningOperations == 0)
- close();
- break;
- default:
- if (performAction(buttonId))
- close();
- }
- }
-
- //---- Setters and Getters --------------------------------------------------
-
- /**
- * Set the enable state of the perform action button.
- */
- public void setPerformActionEnabled(boolean state) {
- for (Iterator buttons = fActionButtons.iterator(); buttons.hasNext(); ) {
- Button element = (Button) buttons.next();
- element.setEnabled(state);
- }
- }
-
- //---- Operation stuff ------------------------------------------------------
-
- /**
- * Runs the given <code>IRunnableWithProgress</code> with the progress monitor for this
- * wizard dialog.
- * @param fork if true, it is run in a separate thread
- * @param cancelable specifies whether to enable the cancel button or not
- * @param runnable the runnable to run
- */
- public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException {
- // The operation can only be canceled if it is executed in a separate thread.
- // Otherwise the UI is blocked anyway.
- Object state= null;
- try {
- fActiveRunningOperations++;
- state= aboutToStart(fork && cancelable);
- ModalContext.run(runnable, fork, getProgressMonitor(), getShell().getDisplay());
- } finally {
- if (state != null)
- stopped(state);
- fActiveRunningOperations--;
- }
- }
-
- /**
- * Returns the progress monitor. If the wizard dialog doesn't
- * have a progress monitor <code>null</code> is returned.
- */
- protected IProgressMonitor getProgressMonitor() {
- return fProgressMonitorPart;
- }
-
- /**
- * About to start a long running operation tiggered through
- * the wizard. So show the progress monitor and disable
- * the wizard.
- * @return The saved UI state.
- */
- protected synchronized Object aboutToStart(boolean enableCancelButton) {
- HashMap savedState= null;
- Shell shell= getShell();
- if (shell != null) {
- Display d= shell.getDisplay();
-
- // Save focus control
- Control focusControl= d.getFocusControl();
- if (focusControl != null && focusControl.getShell() != shell)
- focusControl= null;
-
- // Set the busy cursor to all shells.
- fWaitCursor= new Cursor(d, SWT.CURSOR_WAIT);
- setDisplayCursor(d, fWaitCursor);
-
- // Set the arrow cursor to the cancel component.
- fArrowCursor= new Cursor(d, SWT.CURSOR_ARROW);
- fCancelButton.setCursor(fArrowCursor);
-
- // Deactivate shell
- savedState= saveUIState(enableCancelButton);
- if (focusControl != null)
- savedState.put(FOCUS_CONTROL, focusControl);
-
- // Attach the progress monitor part to the cancel button
- fProgressMonitorPart.attachToCancelComponent(fCancelButton);
- fProgressMonitorPart.setVisible(true);
- }
-
- return savedState;
- }
-
- /**
- * A long running operation triggered through the wizard
- * was stopped either by user input or by normal end.
- * @param savedState The saveState returned by <code>aboutToStart</code>.
- * @see #aboutToStart(boolean)
- */
- protected synchronized void stopped(Object savedState) {
- Assert.isTrue( savedState instanceof HashMap);
- Shell shell= getShell();
- if (shell != null) {
-
- fProgressMonitorPart.setVisible(false);
- fProgressMonitorPart.removeFromCancelComponent(fCancelButton);
-
- HashMap state= (HashMap)savedState;
- restoreUIState(state);
-
- setDisplayCursor(shell.getDisplay(), null);
- fCancelButton.setCursor(null);
- fWaitCursor.dispose();
- fWaitCursor= null;
- fArrowCursor.dispose();
- fArrowCursor= null;
- Control focusControl= (Control)state.get(FOCUS_CONTROL);
- if (focusControl != null && ! focusControl.isDisposed())
- focusControl.setFocus();
- }
- }
-
- private void setDisplayCursor(Display d, Cursor c) {
- Shell[] shells= d.getShells();
- for (int i= 0; i < shells.length; i++)
- shells[i].setCursor(c);
- }
-
- //---- UI state save and restoring ---------------------------------------------
-
- private void restoreUIState(HashMap state) {
- restoreEnableState(fCancelButton, state); //$NON-NLS-1$
- for (Iterator actionButtons = fActionButtons.iterator(); actionButtons.hasNext(); ) {
- Button button = (Button) actionButtons.next();
- restoreEnableState(button, state);
- }
- ControlEnableState pageState= (ControlEnableState)state.get("tabForm"); //$NON-NLS-1$
- pageState.restore();
- }
-
- /**
- * Restores the enable state of the given control.
- * @private
- */
- protected void restoreEnableState(Control w, HashMap h) {
- if (!w.isDisposed()) {
- Boolean b= (Boolean)h.get(w);
- if (b != null)
- w.setEnabled(b.booleanValue());
- }
- }
-
- private HashMap saveUIState(boolean keepCancelEnabled) {
- HashMap savedState= new HashMap(10);
- saveEnableStateAndSet(fCancelButton, savedState, keepCancelEnabled); //$NON-NLS-1$
- for (Iterator actionButtons = fActionButtons.iterator(); actionButtons.hasNext(); ) {
- Button button = (Button) actionButtons.next();
- saveEnableStateAndSet(button, savedState, false);
- }
- savedState.put("tabForm", ControlEnableState.disable(fContents)); //$NON-NLS-1$
-
- return savedState;
- }
-
- private void saveEnableStateAndSet(Control w, HashMap h, boolean enabled) {
- if (!w.isDisposed()) {
- h.put(w, new Boolean(w.isEnabled()));
- w.setEnabled(enabled);
- }
- }
-
- protected void handleShellCloseEvent() {
- if (okToClose())
- super.handleShellCloseEvent();
- }
-
- /**
- * The dialog is going to be closed. Check if there is a running
- * operation. If so, post an alert saying that the wizard can't
- * be closed.
- */
- public boolean okToClose() {
- if (fActiveRunningOperations > 0) {
- synchronized (this) {
- fWindowClosingDialog= createClosingDialog();
- }
- fWindowClosingDialog.open();
- synchronized (this) {
- fWindowClosingDialog= null;
- }
- return false;
- }
- return true;
- }
-
- private MessageDialog createClosingDialog() {
- MessageDialog result=
- new MessageDialog(
- getShell(),
- SearchMessages.getString("SearchDialogClosingDialog.title"), //$NON-NLS-1$
- null,
- SearchMessages.getString("SearchDialogClosingDialog.message"), //$NON-NLS-1$
- MessageDialog.QUESTION,
- new String[] {IDialogConstants.OK_LABEL},
- 0);
- return result;
- }
-
- /**
- * Returns the cancel component that is to be used to cancel
- * a long running operation.
- */
- protected Control getCancelComponent() {
- return fCancelButton;
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/util/FileLabelProvider.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/util/FileLabelProvider.java
deleted file mode 100644
index 771da15..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/util/FileLabelProvider.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui.util;
-
-import java.text.MessageFormat;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IPath;
-
-import org.eclipse.swt.graphics.Image;
-
-import org.eclipse.jface.viewers.ILabelDecorator;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.LabelProvider;
-
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.model.WorkbenchLabelProvider;
-
-import org.eclipse.search.ui.ISearchResultViewEntry;
-
-import org.eclipse.search.internal.ui.SearchMessages;
-
-
-public class FileLabelProvider extends LabelProvider {
-
- public static final int SHOW_LABEL= 1;
- public static final int SHOW_LABEL_PATH= 2;
- public static final int SHOW_PATH_LABEL= 3;
- public static final int SHOW_PATH= 4;
-
- private static final String fgSeparatorFormat= SearchMessages.getString("FileLabelProvider.dashSeparated"); //$NON-NLS-1$
-
- private WorkbenchLabelProvider fLabelProvider;
- private ILabelDecorator fDecorator;
-
- private int fOrder;
- private String[] fArgs= new String[2];
-
- public FileLabelProvider(int orderFlag) {
- fDecorator= PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator();
- fLabelProvider= new WorkbenchLabelProvider();
- fOrder= orderFlag;
- }
-
- public void setOrder(int orderFlag) {
- fOrder= orderFlag;
- }
-
- public String getText(Object element) {
- if (!(element instanceof ISearchResultViewEntry))
- return ""; //$NON-NLS-1$
-
- IResource resource= ((ISearchResultViewEntry) element).getResource();
- String text= null;
-
- if (resource == null || !resource.exists())
- text= SearchMessages.getString("SearchResultView.removed_resource"); //$NON-NLS-1$
-
- else {
- IPath path= resource.getFullPath().removeLastSegments(1);
- if (path.getDevice() == null)
- path= path.makeRelative();
- if (fOrder == SHOW_LABEL || fOrder == SHOW_LABEL_PATH) {
- text= fLabelProvider.getText(resource);
- if (path != null && fOrder == SHOW_LABEL_PATH) {
- fArgs[0]= text;
- fArgs[1]= path.toString();
- text= MessageFormat.format(fgSeparatorFormat, fArgs);
- }
- } else {
- if (path != null)
- text= path.toString();
- else
- text= ""; //$NON-NLS-1$
- if (fOrder == SHOW_PATH_LABEL) {
- fArgs[0]= text;
- fArgs[1]= fLabelProvider.getText(resource);
- text= MessageFormat.format(fgSeparatorFormat, fArgs);
- }
- }
- }
-
- // Do the decoration
- if (fDecorator != null) {
- String decoratedText= fDecorator.decorateText(text, resource);
- if (decoratedText != null)
- return decoratedText;
- }
- return text;
- }
-
- public Image getImage(Object element) {
- if (!(element instanceof ISearchResultViewEntry))
- return null; //$NON-NLS-1$
-
- IResource resource= ((ISearchResultViewEntry) element).getResource();
- Image image= fLabelProvider.getImage(resource);
- if (fDecorator != null) {
- Image decoratedImage= fDecorator.decorateImage(image, resource);
- if (decoratedImage != null)
- return decoratedImage;
- }
- return image;
- }
-
- public void dispose() {
- super.dispose();
- fLabelProvider.dispose();
- }
-
- public boolean isLabelProperty(Object element, String property) {
- return fLabelProvider.isLabelProperty(element, property);
- }
-
- public void removeListener(ILabelProviderListener listener) {
- super.removeListener(listener);
- fLabelProvider.removeListener(listener);
- }
-
- public void addListener(ILabelProviderListener listener) {
- super.addListener(listener);
- fLabelProvider.addListener(listener);
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/util/FileTypeEditor.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/util/FileTypeEditor.java
deleted file mode 100644
index 1cc0730..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/util/FileTypeEditor.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui.util;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Widget;
-
-import org.eclipse.jface.window.Window;
-
-import org.eclipse.ui.IEditorRegistry;
-
-import org.eclipse.search.internal.ui.SearchMessages;
-
-public class FileTypeEditor extends SelectionAdapter implements DisposeListener, SelectionListener {
-
- private Combo fTextField;
- private Button fBrowseButton;
-
- final static String TYPE_DELIMITER= SearchMessages.getString("FileTypeEditor.typeDelimiter"); //$NON-NLS-1$
-
- public FileTypeEditor(IEditorRegistry registry, Combo textField, Button browseButton) {
- fTextField= textField;
- fBrowseButton= browseButton;
-
- fTextField.addDisposeListener(this);
- fBrowseButton.addDisposeListener(this);
- fBrowseButton.addSelectionListener(this);
- }
-
- public void widgetDisposed(DisposeEvent event) {
- Widget widget= event.widget;
- if (widget == fTextField)
- fTextField= null;
- else if (widget == fBrowseButton)
- fBrowseButton= null;
- }
-
- public void widgetSelected(SelectionEvent event) {
- if (event.widget == fBrowseButton)
- handleBrowseButton();
- }
-
- public void widgetDoubleSelected(SelectionEvent event) {
- }
- /**
- * Answer a collection of the currently-specified resource types
- *
- * @return java.util.Vector
- */
- public Set getFileTypes() {
- Set result= new HashSet();
- StringTokenizer tokenizer= new StringTokenizer(fTextField.getText(), TYPE_DELIMITER);
-
- while (tokenizer.hasMoreTokens()) {
- String currentExtension= tokenizer.nextToken().trim();
- result.add(currentExtension);
- }
- return result;
- }
- /**
- * Populate self's import types field based upon the passed types collection
- *
- * @param types java.util.Vector
- */
- public void setFileTypes(Set types) {
- fTextField.setText(typesToString(types));
- }
- protected void handleBrowseButton() {
- TypeFilteringDialog dialog= new TypeFilteringDialog(fTextField.getShell(), getFileTypes());
- if (dialog.open() == Window.OK) {
- setFileTypes(new HashSet(Arrays.asList(dialog.getResult())));
- }
- }
-
- public static String typesToString(Set types) {
- StringBuffer result= new StringBuffer();
- Iterator typesIter= types.iterator();
- boolean first= true;
- while (typesIter.hasNext()) {
- if (!first) {
- result.append(TYPE_DELIMITER);
- result.append(" "); //$NON-NLS-1$
- } else
- first= false;
- result.append(typesIter.next());
- }
- return result.toString();
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/util/ListContentProvider.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/util/ListContentProvider.java
deleted file mode 100644
index 715c28c..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/util/ListContentProvider.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui.util;
-
-import java.util.List;
-
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-
-/**
- * A specialized content provider to show a list of editor parts.
- */
-public class ListContentProvider implements IStructuredContentProvider {
- List fContents;
-
- public ListContentProvider() {
- }
-
- public Object[] getElements(Object input) {
- if (fContents != null && fContents == input)
- return fContents.toArray();
- return new Object[0];
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- if (newInput instanceof List)
- fContents= (List)newInput;
- else
- fContents= null;
- // we use a fixed set.
- }
-
- public void dispose() {
- }
-
- public boolean isDeleted(Object o) {
- return fContents != null && !fContents.contains(o);
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/util/ListDialog.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/util/ListDialog.java
deleted file mode 100644
index bbe8b4e..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/util/ListDialog.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui.util;
-
-import java.util.List;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TableViewer;
-
-import org.eclipse.ui.dialogs.SelectionDialog;
-
-/**
- * Dialog that shows a list of items with icon and label.
- */
-public class ListDialog extends SelectionDialog {
-
- private static final int WIDTH_IN_CHARACTERS= 55;
-
- private IStructuredContentProvider fContentProvider;
- private ILabelProvider fLabelProvider;
- private Object fInput;
- private TableViewer fViewer;
- private boolean fCreateCancelButton= true;
-
- public ListDialog(Shell parent, Object input, String title, String message, IStructuredContentProvider sp, ILabelProvider lp) {
- super(parent);
- setTitle(title);
- setMessage(message);
- fInput= input;
- fContentProvider= sp;
- fLabelProvider= lp;
- }
-
- public void setCreateCancelButton(boolean value) {
- fCreateCancelButton= value;
- }
-
- /*
- * Overrides method from Dialog
- */
- protected Label createMessageArea(Composite composite) {
- Label label = new Label(composite,SWT.WRAP);
- label.setText(getMessage());
- GridData gd= new GridData(GridData.FILL_BOTH);
- gd.widthHint= convertWidthInCharsToPixels(WIDTH_IN_CHARACTERS);
- label.setLayoutData(gd);
- applyDialogFont(label);
- return label;
- }
-
- /*
- * Overrides method from Dialog
- */
- protected Control createDialogArea(Composite container) {
- Composite parent= (Composite) super.createDialogArea(container);
- createMessageArea(parent);
- fViewer= new TableViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
- fViewer.setContentProvider(fContentProvider);
-
- final Table table= fViewer.getTable();
- table.addMouseListener(new MouseAdapter() {
- public void mouseDoubleClick(MouseEvent e) {
- if (fCreateCancelButton)
- okPressed();
- }
- });
- fViewer.setLabelProvider(fLabelProvider);
- fViewer.setInput(fInput);
- List initialSelection= getInitialElementSelections();
- if (initialSelection != null)
- fViewer.setSelection(new StructuredSelection(initialSelection));
- GridData gd= new GridData(GridData.FILL_BOTH);
- gd.heightHint= convertHeightInCharsToPixels(15);
- gd.widthHint= convertWidthInCharsToPixels(WIDTH_IN_CHARACTERS);
- table.setLayoutData(gd);
- applyDialogFont(table);
- return table;
- }
-
- /*
- * Overrides method from Dialog
- */
- protected void createButtonsForButtonBar(Composite parent) {
- if (! fCreateCancelButton)
- createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
- else
- super.createButtonsForButtonBar(parent);
- }
-
- /*
- * Overrides method from Dialog
- */
- protected void okPressed() {
- // Build a list of selected children.
- ISelection selection= fViewer.getSelection();
- if (selection instanceof IStructuredSelection)
- setResult(((IStructuredSelection)fViewer.getSelection()).toList());
- super.okPressed();
- }
-}
-
-
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/util/MessageLine.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/util/MessageLine.java
deleted file mode 100644
index 8678516..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/util/MessageLine.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui.util;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CLabel;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * A message line. It distinguishs between "normal" messages and errors.
- * Setting an error message hides a currently displayed message until
- * <code>clearErrorMessage</code> is called.
- */
-public class MessageLine extends CLabel {
-
- private String fMessageText;
- private String fErrorText;
-
- private Color fDefaultColor;
- private RGB fErrorRGB;
- private Color fErrorColor;
-
- private static RGB fgErrorRGB= new RGB(200, 0, 0);
-
- /**
- * Creates a new message line as a child of the given parent.
- * Error message will be shown with in the rgb color 200,0,0.
- */
- public MessageLine(Composite parent) {
- this(parent, SWT.LEFT);
- }
-
- /**
- * Creates a new message line as a child of the parent and with the given SWT stylebits.
- * Error message will be shown with in the rgb color 200,0,0.
- */
- public MessageLine(Composite parent, int style) {
- super(parent, style);
- fDefaultColor= getForeground();
- fErrorRGB= fgErrorRGB;
- }
-
- /**
- * Creates a new message line as a child of the parent and with the given SWT stylebits.
- * Error message will be shown with in the given rgb color.
- */
- public MessageLine(Composite parent, int style, RGB errorRGB) {
- super(parent, style);
- fDefaultColor= getForeground();
- fErrorRGB= errorRGB;
- }
-
- /**
- * Clears the currently displayed error message and redisplayes
- * the message which was active before the error message was set.
- */
- public void clearErrorMessage() {
- setErrorMessage(null);
- }
-
- /**
- * Clears the currently displayed message.
- */
- public void clearMessage() {
- setMessage(null);
- }
-
- /**
- * Get the currently displayed error text.
- * @return The error message. If no error message is displayed <code>null</code> is returned.
- */
- public String getErrorMessage() {
- return fErrorText;
- }
-
- /**
- * Get the currently displayed message.
- * @return The message. If no message is displayed <code>null</code> is returned.
- */
- public String getMessage() {
- return fMessageText;
- }
-
- /**
- * Sets the default error color used by all message lines.
- * Note: a call to this method only affects newly created MessageLines not existing ones.
- */
- public static void setDefaultErrorColor(RGB color) {
- fgErrorRGB= color;
- }
-
- /**
- * Display the given error message. A currently displayed message
- * is saved and will be redisplayed when the error message is cleared.
- */
- public void setErrorMessage(String message) {
- fErrorText= message;
-
- if (message == null) {
- setMessage(fMessageText);
- } else {
- if (fErrorColor == null) {
- fErrorColor= new Color(getDisplay(), fErrorRGB);
- addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- getErrorColor().dispose();
- }
- });
- }
- setForeground(fErrorColor);
- setText(message);
- }
- }
-
- /**
- * Set the message text. If the message line currently displays an error,
- * the message is stored and will be shown after a call to clearErrorMessage
- */
- public void setMessage(String message) {
- fMessageText= message;
- if (message == null)
- message= ""; //$NON-NLS-1$
- if (fErrorText == null) {
- setForeground(fDefaultColor);
- setText(message);
- }
- }
-
- protected Color getErrorColor() {
- return fErrorColor;
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/util/PixelConverter.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/util/PixelConverter.java
deleted file mode 100644
index 4a8bee4..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/util/PixelConverter.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui.util;
-
-import org.eclipse.swt.graphics.FontMetrics;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.widgets.Control;
-
-import org.eclipse.jface.dialogs.Dialog;
-
-public class PixelConverter {
-
- private FontMetrics fFontMetrics;
-
- public PixelConverter(Control control) {
- GC gc = new GC(control);
- gc.setFont(control.getFont());
- fFontMetrics= gc.getFontMetrics();
- gc.dispose();
- }
-
- /**
- * @see org.eclipse.jface.dialogs.DialogPage#convertHeightInCharsToPixels(int)
- */
- public int convertHeightInCharsToPixels(int chars) {
- return Dialog.convertHeightInCharsToPixels(fFontMetrics, chars);
- }
-
- /**
- * @see org.eclipse.jface.dialogs.DialogPage#convertHorizontalDLUsToPixels(int)
- */
- public int convertHorizontalDLUsToPixels(int dlus) {
- return Dialog.convertHorizontalDLUsToPixels(fFontMetrics, dlus);
- }
-
- /**
- * @see org.eclipse.jface.dialogs.DialogPage#convertVerticalDLUsToPixels(int)
- */
- public int convertVerticalDLUsToPixels(int dlus) {
- return Dialog.convertVerticalDLUsToPixels(fFontMetrics, dlus);
- }
-
- /**
- * @see org.eclipse.jface.dialogs.DialogPage#convertWidthInCharsToPixels(int)
- */
- public int convertWidthInCharsToPixels(int chars) {
- return Dialog.convertWidthInCharsToPixels(fFontMetrics, chars);
- }
-
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/util/RowLayouter.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/util/RowLayouter.java
deleted file mode 100644
index a8540b9..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/util/RowLayouter.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui.util;
-
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Control;
-
-import org.eclipse.jface.util.Assert;
-
-public class RowLayouter {
-
- public int spanHorizontalAlignment= -1;
- public int spanGrabExcessHorizontalSpace= -1;
- public int spanHorizontalSpan= -1;
- public int spanHorizontalIndent= -1;
- public int spanWidthHint= -1;
-
- public int spanVerticalAlignment= -1;
- public int spanGrabExcessVerticalSpace= -1;
- public int spanVerticalSpan= -1;
- public int spanHeightHint= -1;
-
- private int fNumColumns;
- private boolean fOrder;
- private Control fLastControl;
- private GridData[] fDefaultGridDatas= new GridData[4];
-
- public RowLayouter(int numColumns) {
- this(numColumns, false);
- }
-
- public RowLayouter(int numColumns, boolean order) {
- fNumColumns= numColumns;
- fOrder= order;
- }
-
- public void setDefaultSpan() {
- spanHorizontalAlignment= GridData.FILL;
- spanGrabExcessHorizontalSpace= 1;
- }
-
- public void perform(Control c1) {
- perform(new Control[] {c1}, 0);
- }
-
- public void perform(Control c1, Control c2, int span) {
- perform(new Control[] {c1, c2}, span);
- }
-
- public void perform(Control c1, Control c2, Control c3, int span) {
- perform(new Control[] {c1, c2, c3}, span);
- }
-
- public void perform(Control[] controls, int spanColumn) {
- int numColumns= numColumns();
- Assert.isTrue(controls.length <= numColumns);
- order(controls);
- int gridIndex= 0;
- for (int i= 0; i < controls.length; i++) {
- Control control= controls[i];
- GridData gd= (GridData)control.getLayoutData();
- if (gd == null)
- gd= getGridData(gridIndex);
-
- if (i == spanColumn) {
- int span= numColumns - (controls.length - 1);
- gridIndex+= span;
- if (gd == null)
- gd= new GridData();
- applyDelta(gd);
- gd.horizontalSpan= span;
- } else {
- gridIndex++;
- }
- control.setLayoutData(gd);
- }
- }
-
- private void applyDelta(GridData gd) {
- if (spanHorizontalAlignment != -1)
- gd.horizontalAlignment= spanHorizontalAlignment;
-
- if (spanGrabExcessHorizontalSpace != -1) {
- if (spanGrabExcessHorizontalSpace == 0)
- gd.grabExcessHorizontalSpace= false;
- else
- gd.grabExcessHorizontalSpace= true;
- }
-
-
- if (spanHorizontalSpan != -1)
- gd.horizontalSpan= spanHorizontalSpan;
-
- if (spanHorizontalIndent != -1)
- gd.horizontalIndent= spanHorizontalIndent;
-
- if (spanWidthHint != -1)
- gd.widthHint= spanWidthHint;
-
- if (spanVerticalAlignment != -1)
- gd.verticalAlignment= spanVerticalAlignment;
-
- if (spanGrabExcessVerticalSpace != -1) {
- if (spanGrabExcessVerticalSpace == 0)
- gd.grabExcessVerticalSpace= false;
- else
- gd.grabExcessVerticalSpace= true;
- }
-
- if (spanVerticalSpan != -1)
- gd.verticalSpan= spanVerticalSpan;
-
- if (spanHeightHint != -1)
- gd.heightHint= spanHeightHint;
- }
- public void setDefaultGridData(GridData gd, int index) {
- if (index >= fDefaultGridDatas.length) {
- GridData[] newDatas= new GridData[index + 4];
- System.arraycopy(fDefaultGridDatas, 0, newDatas, 0, fDefaultGridDatas.length);
- fDefaultGridDatas= newDatas;
- }
- fDefaultGridDatas[index]= gd;
- }
-
- public GridData getGridData(int index) {
- if (index > fDefaultGridDatas.length)
- return null;
-
- return cloneGridData(fDefaultGridDatas[index]);
- }
-
- public int numColumns() {
- return fNumColumns;
- }
-
- protected void order(Control[] controls) {
- if (!fOrder)
- return;
-
- for (int i= 0; i < controls.length; i++) {
- Control control= controls[i];
- control.moveBelow(fLastControl);
- fLastControl= control;
- }
- }
-
- protected GridData cloneGridData(GridData gd) {
- if (gd == null)
- return null;
-
- GridData result= new GridData();
- result.horizontalAlignment= gd.horizontalAlignment;
- result.grabExcessHorizontalSpace= gd.grabExcessHorizontalSpace;
- result.horizontalSpan= gd.horizontalSpan;
- result.horizontalIndent= gd.horizontalIndent;
- result.widthHint= gd.widthHint;
-
- result.verticalAlignment= gd.verticalAlignment;
- result.grabExcessVerticalSpace= gd.grabExcessVerticalSpace;
- result.verticalSpan= gd.verticalSpan;
- result.heightHint= gd.heightHint;
- return result;
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/util/SWTUtil.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/util/SWTUtil.java
deleted file mode 100644
index 83cd7e5..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/util/SWTUtil.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui.util;
-
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.dnd.DragSource;
-import org.eclipse.swt.dnd.DropTarget;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Caret;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.ScrollBar;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Widget;
-
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.util.Assert;
-
-/**
- * Utility class to simplify access to some SWT resources.
- */
-public class SWTUtil {
-
- /**
- * Returns the standard display to be used. The method first checks, if
- * the thread calling this method has an associated disaply. If so, this
- * display is returned. Otherwise the method returns the default display.
- */
- public static Display getStandardDisplay() {
- Display display;
- display= Display.getCurrent();
- if (display == null)
- display= Display.getDefault();
- return display;
- }
-
- /**
- * Returns the shell for the given widget. If the widget doesn't represent
- * a SWT object that manage a shell, <code>null</code> is returned.
- *
- * @return the shell for the given widget
- */
- public static Shell getShell(Widget widget) {
- if (widget instanceof Control)
- return ((Control)widget).getShell();
- if (widget instanceof Caret)
- return ((Caret)widget).getParent().getShell();
- if (widget instanceof DragSource)
- return ((DragSource)widget).getControl().getShell();
- if (widget instanceof DropTarget)
- return ((DropTarget)widget).getControl().getShell();
- if (widget instanceof Menu)
- return ((Menu)widget).getParent().getShell();
- if (widget instanceof ScrollBar)
- return ((ScrollBar)widget).getParent().getShell();
-
- return null;
- }
-
-
- /**
- * Returns a width hint for a button control.
- */
- public static int getButtonWidthHint(Button button) {
- if (button.getFont().equals(JFaceResources.getDefaultFont()))
- button.setFont(JFaceResources.getDialogFont());
- PixelConverter converter= new PixelConverter(button);
- int widthHint= converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
- return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
- }
-
- /**
- * Returns a height hint for a button control.
- */
- public static int getButtonHeightHint(Button button) {
- if (button.getFont().equals(JFaceResources.getDefaultFont()))
- button.setFont(JFaceResources.getDialogFont());
- PixelConverter converter= new PixelConverter(button);
- return converter.convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
- }
-
-
- /**
- * Sets width and height hint for the button control.
- * <b>Note:</b> This is a NOP if the button's layout data is not
- * an instance of <code>GridData</code>.
- *
- * @param the button for which to set the dimension hint
- */
- public static void setButtonDimensionHint(Button button) {
- Assert.isNotNull(button);
- Object gd= button.getLayoutData();
- if (gd instanceof GridData) {
- ((GridData)gd).heightHint= getButtonHeightHint(button);
- ((GridData)gd).widthHint= getButtonWidthHint(button);
- }
- }
-
- public static int getTableHeightHint(Table table, int rows) {
- if (table.getFont().equals(JFaceResources.getDefaultFont()))
- table.setFont(JFaceResources.getDialogFont());
- int result= table.getItemHeight() * rows + table.getHeaderHeight();
- if (table.getLinesVisible())
- result+= table.getGridLineWidth() * (rows - 1);
- return result;
- }
-
-
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/util/TypeFilteringDialog.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/util/TypeFilteringDialog.java
deleted file mode 100644
index 485d595..0000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/util/TypeFilteringDialog.java
+++ /dev/null
@@ -1,291 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui.util;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.StringTokenizer;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.viewers.CheckboxTableViewer;
-
-import org.eclipse.ui.IFileEditorMapping;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.FileEditorMappingContentProvider;
-import org.eclipse.ui.dialogs.FileEditorMappingLabelProvider;
-import org.eclipse.ui.dialogs.SelectionDialog;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-import org.eclipse.search.internal.ui.ISearchHelpContextIds;
-import org.eclipse.search.internal.ui.SearchMessages;
-
-/**
- * The TypeFilteringDialog is a SelectionDialog that allows the user to select a file editor.
- * XXX: Workbench should offer this dialog (public API), see: bug 2763: TypeFilteringDialog should be public API
- */
-public class TypeFilteringDialog extends SelectionDialog {
-
- private Collection fInitialSelections;
-
- // the visual selection widget group
- private CheckboxTableViewer fListViewer;
-
- // sizing constants
- private final static int SIZING_SELECTION_WIDGET_HEIGHT= 250;
- private final static int SIZING_SELECTION_WIDGET_WIDTH= 300;
-
- private Text fUserDefinedText;
-
- private IFileEditorMapping[] fCurrentInput;
- /**
- * Creates a type selection dialog using the supplied entries. Set the initial selections to those
- * whose extensions match the preselections.
- */
- public TypeFilteringDialog(Shell parentShell, Collection preselections) {
- super(parentShell);
- setTitle(SearchMessages.getString("TypesFiltering.title")); //$NON-NLS-1$
- fInitialSelections= preselections;
- setMessage(SearchMessages.getString("TypesFiltering.message")); //$NON-NLS-1$
- }
-
- /**
- * Add the selection and deselection buttons to the dialog.
- * @param composite org.eclipse.swt.widgets.Composite
- */
- private void addSelectionButtons(Composite composite) {
-
- Composite buttonComposite= new Composite(composite, SWT.RIGHT);
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- buttonComposite.setLayout(layout);
- GridData data =
- new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.GRAB_HORIZONTAL);
- data.grabExcessHorizontalSpace= true;
- composite.setData(data);
-
- Button selectButton =
- createButton(
- buttonComposite,
- IDialogConstants.SELECT_ALL_ID,
- SearchMessages.getString("TypesFiltering.selectAll"), //$NON-NLS-1$
- false);
-
- SelectionListener listener= new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- getListViewer().setAllChecked(true);
- }
- };
- selectButton.addSelectionListener(listener);
-
- Button deselectButton =
- createButton(
- buttonComposite,
- IDialogConstants.DESELECT_ALL_ID,
- SearchMessages.getString("TypesFiltering.deselectAll"), //$NON-NLS-1$
- false);
-
- listener= new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- getListViewer().setAllChecked(false);
-
- }
- };
- deselectButton.addSelectionListener(listener);
-
- }
-
- /**
- * Add the currently-specified extensions.
- */
- private void addUserDefinedEntries(List result) {
-
- StringTokenizer tokenizer =
- new StringTokenizer(fUserDefinedText.getText(), FileTypeEditor.TYPE_DELIMITER);
-
- //Allow the *. and . prefix and strip out the extension
- while (tokenizer.hasMoreTokens()) {
- String currentExtension= tokenizer.nextToken().trim();
- if (!currentExtension.equals("")) //$NON-NLS-1$
- result.add(currentExtension);
- }
- }
-
- /**
- * Visually checks the previously-specified elements in this dialog's list
- * viewer.
- */
- private void checkInitialSelections() {
-
- IFileEditorMapping editorMappings[] =
- PlatformUI.getWorkbench().getEditorRegistry().getFileEditorMappings();
- ArrayList selectedMappings= new ArrayList();
-
- for (int i= 0; i < editorMappings.length; i++) {
- IFileEditorMapping mapping= editorMappings[i];
- if (fInitialSelections.contains(mapping.getLabel())) {
- fListViewer.setChecked(mapping, true);
- selectedMappings.add(mapping.getLabel());
- }
- }
-
- //Now add in the ones not selected to the user defined list
- Iterator initialIterator= fInitialSelections.iterator();
- StringBuffer entries= new StringBuffer();
- boolean first= true;
- while (initialIterator.hasNext()) {
- String nextExtension= (String)initialIterator.next();
- if (!selectedMappings.contains(nextExtension)) {
- if (!first) {
- entries.append(FileTypeEditor.TYPE_DELIMITER);
- entries.append(" "); //$NON-NLS-1$
- }
- first= false;
- entries.append(nextExtension);
- }
- }
- fUserDefinedText.setText(entries.toString());
- }
-
- /* (non-Javadoc)
- * Method declared in Window.
- */
- protected void configureShell(Shell shell) {
- super.configureShell(shell);
- WorkbenchHelp.setHelp(shell, ISearchHelpContextIds.TYPE_FILTERING_DIALOG);
- }
-
- /* (non-Javadoc)
- * Method declared on Dialog.
- */
- protected Control createDialogArea(Composite parent) {
- // page group
- Composite composite= (Composite)super.createDialogArea(parent);
-
- createMessageArea(composite);
-
- fListViewer= CheckboxTableViewer.newCheckList(composite, SWT.BORDER);
- GridData data= new GridData(GridData.FILL_BOTH);
- data.heightHint= SIZING_SELECTION_WIDGET_HEIGHT;
- data.widthHint= SIZING_SELECTION_WIDGET_WIDTH;
- fListViewer.getTable().setLayoutData(data);
-
- fListViewer.setLabelProvider(FileEditorMappingLabelProvider.INSTANCE);
- fListViewer.setContentProvider(FileEditorMappingContentProvider.INSTANCE);
-
- addSelectionButtons(composite);
-
- createUserEntryGroup(composite);
-
- initializeViewer();
-
- // initialize page
- if (fInitialSelections != null && !fInitialSelections.isEmpty())
- checkInitialSelections();
-
- applyDialogFont(composite);
- return composite;
- }
-
- /**
- * Create the group that shows the user defined entries for the dialog.
- * @param parent the parent this is being created in.
- */
- private void createUserEntryGroup(Composite parent) {
-
- // destination specification group
- Composite userDefinedGroup= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- userDefinedGroup.setLayout(layout);
- userDefinedGroup.setLayoutData(
- new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
-
- new Label(userDefinedGroup, SWT.NONE).setText(
- SearchMessages.getString("TypesFiltering.otherExtensions")); //$NON-NLS-1$
-
- // user defined entry field
- fUserDefinedText= new Text(userDefinedGroup, SWT.SINGLE | SWT.BORDER);
- GridData data =
- new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
- fUserDefinedText.setLayoutData(data);
- }
-
- /**
- * Return the input to the dialog.
- */
- private IFileEditorMapping[] getInput() {
-
- //Filter the mappings to be just those with a wildcard extension
- if (fCurrentInput == null) {
- List wildcardEditors= new ArrayList();
- IFileEditorMapping[] allMappings =
- PlatformUI.getWorkbench().getEditorRegistry().getFileEditorMappings();
- for (int i= 0; i < allMappings.length; i++) {
- if (allMappings[i].getName().equals("*")) //$NON-NLS-1$
- wildcardEditors.add(allMappings[i]);
- }
- fCurrentInput= new IFileEditorMapping[wildcardEditors.size()];
- wildcardEditors.toArray(fCurrentInput);
- }
-
- return fCurrentInput;
- }
-
- /**
- * Initializes this dialog's viewer after it has been laid out.
- */
- private void initializeViewer() {
- fListViewer.setInput(getInput());
- }
-
- /**
- * The <code>ListSelectionDialog</code> implementation of this
- * <code>Dialog</code> method builds a list of the selected elements for later
- * retrieval by the client and closes this dialog.
- */
- protected void okPressed() {
-
- // Get the input children.
- IFileEditorMapping[] children= getInput();
-
- List list= new ArrayList();
-
- // Build a list of selected children.
- for (int i= 0; i < children.length; ++i) {
- IFileEditorMapping element= children[i];
- if (fListViewer.getChecked(element))
- list.add(element.getLabel());
- }
-
- addUserDefinedEntries(list);
- setResult(list);
- super.okPressed();
- }
-
- protected CheckboxTableViewer getListViewer() {
- return fListViewer;
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/ui/IActionGroupFactory.java b/org.eclipse.search/search/org/eclipse/search/ui/IActionGroupFactory.java
deleted file mode 100644
index f22876e..0000000
--- a/org.eclipse.search/search/org/eclipse/search/ui/IActionGroupFactory.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.ui;
-
-import org.eclipse.ui.actions.ActionGroup;
-
-/**
- * Allows to specify an <code>ActionGroup</code> factory
- * which will be used by the Search view to create an
- * <code>ActionGroup</code> which is used to build the
- * actions bars and the context menu.
- * <p>
- * Note: Local tool bar contributions are not supported in 2.0.
- * </p>
- *
- * Clients can implement this interface and pass an
- * instance to the search result view.
- *
- * @see org.eclipse.ui.actions.ActionGroup
- * @see ISearchResultView#searchStarted
- * @since 2.0
- */
-public interface IActionGroupFactory {
-
- /**
- * Creates an <code>ActionGroup</code> for a Search view.
- *
- * @param searchView the search result view for which the group is made
- * @see org.eclipse.ui.actions.ActionGroup
- */
- ActionGroup createActionGroup(ISearchResultView searchView);
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/ui/IContextMenuConstants.java b/org.eclipse.search/search/org/eclipse/search/ui/IContextMenuConstants.java
deleted file mode 100644
index ca20099..0000000
--- a/org.eclipse.search/search/org/eclipse/search/ui/IContextMenuConstants.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.ui;
-
-import org.eclipse.ui.IWorkbenchActionConstants;
-
-/**
- * Constants for menu groups used in context menus for Search views and editors.
- * <p>
- * This interface declares constants only; it is not intended to be implemented.
- * </p>
- *
- * @since 2.0
- */
-public interface IContextMenuConstants {
-
- /**
- * Pop-up menu: name of group for goto actions (value <code>"group.open"</code>).
- * <p>
- * Examples for open actions are:
- * <ul>
- * <li>Go Into</li>
- * <li>Go To</li>
- * </ul>
- * </p>
- */
- public static final String GROUP_GOTO= "group.goto"; //$NON-NLS-1$
-
- /**
- * Pop-up menu: name of group for open actions (value <code>"group.open"</code>).
- * <p>
- * Examples for open actions are:
- * <ul>
- * <li>Open To</li>
- * <li>Open With</li>
- * </ul>
- * </p>
- */
- public static final String GROUP_OPEN= "group.open"; //$NON-NLS-1$
-
- /**
- * Pop-up menu: name of group for show actions (value <code>"group.show"</code>).
- * <p>
- * Examples for show actions are:
- * <ul>
- * <li>Show in Navigator</li>
- * <li>Show in Type Hierarchy</li>
- * </ul>
- * </p>
- */
- public static final String GROUP_SHOW= "group.show"; //$NON-NLS-1$
-
- /**
- * Pop-up menu: name of group for new actions (value <code>"group.new"</code>).
- * <p>
- * Examples for new actions are:
- * <ul>
- * <li>Create new class</li>
- * <li>Create new interface</li>
- * </ul>
- * </p>
- */
- public static final String GROUP_NEW= "group.new"; //$NON-NLS-1$
-
- /**
- * Pop-up menu: name of group for build actions (value <code>"group.build"</code>).
- */
- public static final String GROUP_BUILD= "group.build"; //$NON-NLS-1$
-
- /**
- * Pop-up menu: name of group for reorganize actions (value <code>"group.reorganize"</code>).
- */
- public static final String GROUP_REORGANIZE= IWorkbenchActionConstants.GROUP_REORGANIZE;
-
- /**
- * Pop-up menu: name of group for code generation or refactoring actions (
- * value <code>"group.generate"</code>).
- */
- public static final String GROUP_GENERATE= "group.generate"; //$NON-NLS-1$
-
- /**
- * Pop-up menu: name of group for search actions (value <code>"group.search"</code>).
- */
- public static final String GROUP_SEARCH= "group.search"; //$NON-NLS-1$
-
- /**
- * Pop-up menu: name of group for additional actions (value <code>"group.additions"</code>).
- */
- public static final String GROUP_ADDITIONS= "additions"; //$NON-NLS-1$
-
- /**
- * Pop-up menu: name of group for viewer setup actions (value <code>"group.viewerSetup"</code>).
- */
- public static final String GROUP_VIEWER_SETUP= "group.viewerSetup"; //$NON-NLS-1$
-
- /**
- * Pop-up menu: name of group for properties actions (value <code>"group.properties"</code>).
- */
- public static final String GROUP_PROPERTIES= "group.properties"; //$NON-NLS-1$
-
- /**
- * Pop-up menu: name of group for remove match actions (value <code>"group.removeMatches"</code>).
- * @since 2.1
- */
- public static final String GROUP_REMOVE_MATCHES= "group.removeMatches"; //$NON-NLS-1$
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/ui/IContextMenuContributor.java b/org.eclipse.search/search/org/eclipse/search/ui/IContextMenuContributor.java
deleted file mode 100644
index 96741e1..0000000
--- a/org.eclipse.search/search/org/eclipse/search/ui/IContextMenuContributor.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.ui;
-
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.viewers.IInputSelectionProvider;
-
-/**
- * Specify how clients can add menu items
- * to the context menu of the search result view.
- * A class that contributes context menu items
- * must implement this interface and pass an
- * instance of itself to the search result view.
- *
- * @see ISearchResultView#searchStarted
- */
-public interface IContextMenuContributor {
-
- /**
- * Contributes menu items to the given context menu appropriate for the
- * given selection.
- *
- * @param menu the menu to which the items are added
- * @param inputProvider the selection and input provider
- */
- public void fill(IMenuManager menu, IInputSelectionProvider inputProvider);
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/ui/IGroupByKeyComputer.java b/org.eclipse.search/search/org/eclipse/search/ui/IGroupByKeyComputer.java
deleted file mode 100644
index 776ff35..0000000
--- a/org.eclipse.search/search/org/eclipse/search/ui/IGroupByKeyComputer.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.ui;
-
-import org.eclipse.core.resources.IMarker;
-
-/**
- * Computes the key by which the markers in the search result view
- * are grouped.
- */
-public interface IGroupByKeyComputer {
-
- /**
- * Computes and returns key by which the given marker is grouped.
- *
- * @param marker the marker for which the key must be computed
- * @return an object that will be used as the key for that marker,
- * <code>null</code> if the marker seems to be invalid
- */
- public Object computeGroupByKey(IMarker marker);
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/ui/IReplacePage.java b/org.eclipse.search/search/org/eclipse/search/ui/IReplacePage.java
deleted file mode 100644
index 11abd3d..0000000
--- a/org.eclipse.search/search/org/eclipse/search/ui/IReplacePage.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.ui;
-
-/**
- * An extension interface to <code>ISearchPage</code>. If clients implement
- * <code>IReplacePage</code> in addition to <code>ISearchPage</code>, a
- * "Replace" button will be shown in the search dialog.
- *
- * @since 3.0
- */
-public interface IReplacePage {
-
- /**
- * Performs the replace action for this page.
- * The search dialog calls this method when the Replace
- * button is pressed.
- *
- * @return <code>true</code> if the dialog can be closed after execution
- */
- public boolean performReplace();
-
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/ui/ISearchPage.java b/org.eclipse.search/search/org/eclipse/search/ui/ISearchPage.java
deleted file mode 100644
index 76fea75..0000000
--- a/org.eclipse.search/search/org/eclipse/search/ui/ISearchPage.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.ui;
-
-import org.eclipse.jface.dialogs.IDialogPage;
-
-/**
- * Defines a page inside the search dialog.
- * Clients can contribute their own search page to the
- * dialog by implementing this interface, typically as a subclass
- * of <code>DialogPage</code>.
- * <p>
- * The search dialog calls the <code>performAction</code> method when the Search
- * button is pressed.
- * <p>
- *
- * @see org.eclipse.jface.dialogs.IDialogPage
- * @see org.eclipse.jface.dialogs.DialogPage
- */
-public interface ISearchPage extends IDialogPage {
-
- /**
- * Performs the action for this page.
- * The search dialog calls this method when the Search
- * button is pressed.
- *
- * @return <code>true</code> if the dialog can be closed after execution
- */
- public boolean performAction();
-
- /**
- * Sets the container of this page.
- * The search dialog calls this method to initialize this page.
- * Implementations may store the reference to the container.
- *
- * @param container the container for this page
- */
- public void setContainer(ISearchPageContainer container);
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/ui/ISearchPageContainer.java b/org.eclipse.search/search/org/eclipse/search/ui/ISearchPageContainer.java
deleted file mode 100644
index 27f6f4c..0000000
--- a/org.eclipse.search/search/org/eclipse/search/ui/ISearchPageContainer.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.ui;
-
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.viewers.ISelection;
-
-import org.eclipse.ui.IWorkingSet;
-
-/**
- * Offers client access to the search dialog.
- * A search page can enable or disable the dialog's action
- * button and get an operation context to perform the action.
- * The dialog itself cannot be accessed directly.
- * <p>
- * This interface is not intended to be implemented by clients.
- * </p>
- */
-public interface ISearchPageContainer {
-
- /**
- * Workspace scope (value <code>0</code>).
- *
- * @since 2.0
- */
- public static final int WORKSPACE_SCOPE= 0;
-
- /**
- * Selection scope (value <code>1</code>).
- *
- * @since 2.0
- */
- public static final int SELECTION_SCOPE= 1;
-
- /**
- * Working set scope (value <code>2</code>).
- *
- * @since 2.0
- */
- public static final int WORKING_SET_SCOPE= 2;
-
- /**
- * Current Project scope (value <code>3</code>).
- *
- * @since 3.0
- */
- public static final int SELECTED_PROJECTS_SCOPE= 3;
-
- /**
- * Returns the selection with which this container was opened.
- *
- * @return the selection passed to this container when it was opened
- */
- public ISelection getSelection();
-
- /**
- * Returns the context for the search operation.
- * This context allows progress to be shown inside the search dialog.
- *
- * @return the <code>IRunnableContext</code> for the search operation
- */
- public IRunnableContext getRunnableContext();
-
- /**
- * Sets the enable state of the perform action button
- * of this container.
- *
- * @param state <code>true</code> to enable the button which performs the action
- */
- public void setPerformActionEnabled(boolean state);
-
- /**
- * Returns search container's selected scope.
- * The scope is WORKSPACE_SCOPE, SELECTED_PROJECTS_SCOPE, SELECTION_SCOPE or WORKING_SET_SCOPE.
- *
- * @return the selected scope
- * @since 2.0
- */
- public int getSelectedScope();
-
- /**
- * Sets the selected scope of this search page container.
- * The scope is WORKSPACE_SCOPE, SELECTED_PROJECTS_SCOPE, SELECTION_SCOPE or WORKING_SET_SCOPE.
- *
- * @return the selected scope
- * @since 2.0
- */
- public void setSelectedScope(int scope);
-
- /**
- * Tells whether a valid scope is selected.
- *
- * @return a <code>true</code> if a valid scope is selected in this search page container
- * @since 2.0
- */
- public boolean hasValidScope();
-
- /**
- * Returns the selected working sets of this container.
- *
- * @return an array with the selected working sets or <code>null</code> if the scope is not WORKING_SET_SCOPE
- * @since 2.0
- */
- public IWorkingSet[] getSelectedWorkingSets();
-
- /**
- * Sets the selected working sets of this container.
- *
- * @param workingSets an array of IWorkingSet
- * @since 2.0
- */
- public void setSelectedWorkingSets(IWorkingSet[] workingSets);
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/ui/ISearchPageScoreComputer.java b/org.eclipse.search/search/org/eclipse/search/ui/ISearchPageScoreComputer.java
deleted file mode 100644
index e0caced..0000000
--- a/org.eclipse.search/search/org/eclipse/search/ui/ISearchPageScoreComputer.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.ui;
-
-/**
- * Computes a score that is used by the search dialog
- * to find the best fitting page for a selection when opened.
- * The score has no upper limit but must be at least
- * <code>LOWEST</code>. Higher values means the page is better
- * suited for the given selection input.
- * <p>
- * For example, a Java-specific search page score computer could test
- * if the page is a Java search page and returns high scores
- * for Java elements as selection input.
- * </p>
- */
-public interface ISearchPageScoreComputer {
-
- /**
- * Invalid score value indicating a score is unknown or undecided.
- */
- public static final int UNKNOWN= -1;
-
- /**
- * Lowest possible valid score.
- */
- public static final int LOWEST= 0;
-
- /**
- * Computes and returns a score indicating how good the page with the given
- * id can handle the given input element.
- * The search page id appears as the <code>id</code> attribute of the
- * <code><page></code> element contributed to the
- * search pages extension point (<code>"org.eclipse.search.searchPages"</code>).
- *
- * @param pageId the string id of the page for which the score is computed
- * @param input the object based on which the page should open
- * @return a score higher or equal to <code>LOWEST</code>, or
- * <code>UNKNOWN</code> if this computer cannot decide
- */
- public int computeScore(String pageId, Object input);
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/ui/ISearchResultView.java b/org.eclipse.search/search/org/eclipse/search/ui/ISearchResultView.java
deleted file mode 100644
index b8ae313..0000000
--- a/org.eclipse.search/search/org/eclipse/search/ui/ISearchResultView.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.ui;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ISelection;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.ui.IViewPart;
-
-/**
- * Provides client access to the search result view.
- * Each element in the view is a <code>ISearchResultViewEntry</code>,
- * which groups markers based on the <code>groupByKey</code> provided
- * by the client each time when adding a match. If every match should
- * show up in the search result view then the match itself can be used
- * as key.
- * <p>
- * The search result view has id <code>"org.eclipse.search.SearchResultView"</code>.
- * </p>
- * <p>
- * This interface is not intended to be implemented by clients.
- * </p>
- */
-public interface ISearchResultView extends IViewPart {
-
- /**
- * Informs the view that a search has started.
- * Provides all necessary information to create an entry in the search result
- * view.
- * If every match should show up in the search result view then the match
- * itself can be used as key.
- *
- * @param groupFactory the action group factory
- * or <code>null</code> if no factory is provided.
- * @param singularLabel the label to be used for this search occurrence
- * if there is one match
- * or <code>null</code> if the pluralLabelPattern should be used
- * @param pluralLabelPattern the label pattern to be used for this search occurrence
- * if there are more than one matches or none.
- * This string may contain {0} which will be replace by the match count
- * @param imageDescriptor the image descriptor to be used for this search occurrence,
- * or <code>null</code> if this search should not have an image
- * @param pageId the id of the search page which started the search
- * @param labelProvider the label provider used by this search result view
- * or <code>null</code> if the default provider should be used.
- * The default label provider shows the resource name and the corresponding image.
- * @param gotoAction the action used by the view to go to a marker
- * @param groupByKeyComputer the computer used by the view to compute the key for a marker
- * @param operation the runnable used by the view to repeat the search
- *
- * @see IActionGroupFactory
- * @since 2.0
- */
- public void searchStarted(
- IActionGroupFactory groupFactory,
- String singularLabel,
- String pluralLabelPattern,
- ImageDescriptor imageDescriptor,
- String pageId,
- ILabelProvider labelProvider,
- IAction gotoAction,
- IGroupByKeyComputer groupByKeyComputer,
- IRunnableWithProgress operation);
-
- /**
- * Returns the current selection of the search result view
- *
- * @return the current selection of the search result view
- * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection
- */
- public ISelection getSelection();
-
- /**
- * Informs the view that a search has started.
- * Provides all necessary information to create an entry in the search result
- * view.
- * If every match should show up in the search result view then the match
- * itself can be used as key.
- *
- * @param pageId the id of the search page which started the search
- * @param label the label to be used for this search occurrence
- * @param imageDescriptor the image descriptor to be used for this search occurrence,
- * or <code>null</code> if this search should not have an image
- * @param contributor the context menu contributor
- * or <code>null</code> if no context menu is contributed
- * @param labelProvider the label provider used by this search result view
- * or <code>null</code> if the default provider should be used.
- * The default label provider shows the resource name and the corresponding image.
- * @param gotoAction the action used by the view to go to a marker
- * @param groupByKeyComputer the computer used by the view to compute the key for a marker
- * @param operation the runnable used by the view to repeat the search
- * @deprecated As of build > 20011107, replaced by the new version with additonal parameter
- */
- public void searchStarted(
- String pageId,
- String label,
- ImageDescriptor imageDescriptor,
- IContextMenuContributor contributor,
- ILabelProvider labelProvider,
- IAction gotoAction,
- IGroupByKeyComputer groupByKeyComputer,
- IRunnableWithProgress operation);
-
- /**
- * Informs the view that a search has started.
- * Provides all necessary information to create an entry in the search result
- * view.
- * If every match should show up in the search result view then the match
- * itself can be used as key.
- *
- * @param pageId the id of the search page which started the search
- * @param singularLabel the label to be used for this search occurrence
- * if there is one match
- * or <code>null</code> if the pluralLabelPattern should be used
- * @param pluralLabelPattern the label pattern to be used for this search occurrence
- * if there are more than one matches or none.
- * This string may contain {0} which will be replace by the match count
- * @param imageDescriptor the image descriptor to be used for this search occurrence,
- * or <code>null</code> if this search should not have an image
- * @param contributor the context menu contributor
- * or <code>null</code> if no context menu is contributed
- * @param labelProvider the label provider used by this search result view
- * or <code>null</code> if the default provider should be used.
- * The default label provider shows the resource name and the corresponding image.
- * @param gotoAction the action used by the view to go to a marker
- * @param groupByKeyComputer the computer used by the view to compute the key for a marker
- * @param operation the runnable used by the view to repeat the search
- * @since 2.0
- * @deprecated As of build > 20020514, replaced by the new version which provides an action group factory
- */
- public void searchStarted(
- String pageId,
- String singularLabel,
- String pluralLabelPattern,
- ImageDescriptor imageDescriptor,
- IContextMenuContributor contributor,
- ILabelProvider labelProvider,
- IAction gotoAction,
- IGroupByKeyComputer groupByKeyComputer,
- IRunnableWithProgress operation);
-
- /**
- * Informs the view that the search has finished.
- * This method must also be called in case of the search
- * fails or has been canceled.
- */
- public void searchFinished();
-
- /**
- * Informs the view that a match has been found.
- * Provides all necessary information to create a search result entry in this
- * view.
- * <p>
- * Note: It is the clients responsibility to create the marker for this match.
- * </p>
- *
- * @param description the text description of the match
- * @param groupByKey the <code>Object</code> by which this match is grouped
- * @param marker the marker for this match
- * @param resource the marker's resource passed for optimization
- */
- public void addMatch(String description, Object groupByKey, IResource resource, IMarker marker);
-
- /**
- * Returns the label provider of a search result view.
- *
- * @return the label provider of a search result view or <code>null</code>
- * @since 2.0
- */
- public ILabelProvider getLabelProvider();
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/ui/ISearchResultViewEntry.java b/org.eclipse.search/search/org/eclipse/search/ui/ISearchResultViewEntry.java
deleted file mode 100644
index 08a4c40..0000000
--- a/org.eclipse.search/search/org/eclipse/search/ui/ISearchResultViewEntry.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.ui;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-
-/**
- * Specifies a search result view entry.
- * This entry provides information about the markers
- * it groups by a client defined key. Each entry in the search
- * result view corresponds to a different key.
- * <p>
- * The UI allows stepping through this entry's markers grouped by the key.
- * </p>
- * <p>
- * This interface is not intended to be implemented by clients.
- * </p>
- */
-public interface ISearchResultViewEntry {
-
- /**
- * Returns the key by which this entry's markers
- * are logically grouped. A line in a text could be such a key.
- * Clients supply this key as a parameter to <code>ISearchResultView.addMatch</code>.
- *
- * @return the common resource of this entry's markers
- * @see ISearchResultView#addMatch
- */
- public Object getGroupByKey();
-
- /**
- * Returns the resource to which this entry's markers are attached.
- * This is a convenience method for <code>getSelectedMarker().getResource()</code>.
- *
- * @return the common resource of this entry's markers
- */
- public IResource getResource();
-
- /**
- * Returns the number of markers grouped by this entry.
- *
- * @return the number of markers
- */
- public int getMatchCount();
-
- /**
- * Returns the selected marker of this entry, or the first one
- * if no marker is selected.
- * A search results view entry can group markers
- * which the UI allows the user to step through them while
- * this entry remains selected.
- *
- * @return the selected marker inside this entry, or
- * <code>null</code> if the entry has no markers
- */
- public IMarker getSelectedMarker();
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/ui/SearchUI.java b/org.eclipse.search/search/org/eclipse/search/ui/SearchUI.java
deleted file mode 100644
index f89aaa5..0000000
--- a/org.eclipse.search/search/org/eclipse/search/ui/SearchUI.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.ui;
-
-import org.eclipse.swt.graphics.Image;
-
-import org.eclipse.ui.IWorkbenchWindow;
-
-import org.eclipse.search.internal.ui.OpenSearchDialogAction;
-import org.eclipse.search.internal.ui.SearchPlugin;
-import org.eclipse.search.internal.ui.SearchPluginImages;
-import org.eclipse.search.internal.ui.SearchPreferencePage;
-
-/**
- * The central class for access to the Search Plug-in's User Interface.
- * This class cannot be instantiated; all functionality is provided by
- * static methods.
- *
- * Features provided:
- * <ul>
- * <li>convenient access to the search result view of the active workbench
- * window.</li>
- * </ul>
- *
- * @see ISearchResultView
- */
-public final class SearchUI {
-
- /**
- * Search Plug-in Id (value <code>"org.eclipse.search"</code>).
- */
- public static final String PLUGIN_ID= "org.eclipse.search"; //$NON-NLS-1$
-
- /**
- * Search marker type (value <code>"org.eclipse.search.searchmarker"</code>).
- *
- * @see org.eclipse.core.resources.IMarker
- */
- public static final String SEARCH_MARKER= PLUGIN_ID + ".searchmarker"; //$NON-NLS-1$
-
- /**
- * Line marker attribute (value <code>"line"</code>)
- * The value of the marker attribute is the line which contains the text search match.
- *
- * @see org.eclipse.core.resources.IMarker#getAttribute
- */
- public static final String LINE= "line"; //$NON-NLS-1$
-
- /**
- * Potential match marker attribute
- * (value <code>"potentialMatch"</code>).
- * <p>
- * This optional marker attribute tells whether a marker is
- * a potential or an exact match.
- * The marker is considered an exact match if the attribute is missing.
- * </p>
- * <p>
- * Potential matches are shown with a different background color in
- * the Search view. The color can be changed in the Search preferences.
- * </p>
- *
- * @see org.eclipse.core.resources.IMarker#getAttribute
- * @since 2.0
- */
- public static final String POTENTIAL_MATCH= "potentialMatch"; //$NON-NLS-1$
-
- /**
- * Id of the Search result view
- * (value <code>"org.eclipse.search.SearchResultView"</code>).
- */
- public static final String SEARCH_RESULT_VIEW_ID= "org.eclipse.search.SearchResultView"; //$NON-NLS-1$
-
- /**
- * Id of the Search action set
- * (value <code>"org.eclipse.search.searchActionSet"</code>).
- *
- * @since 2.0
- */
- public static final String ACTION_SET_ID= PLUGIN_ID + ".searchActionSet"; //$NON-NLS-1$
-
- /**
- * Activates the search result view in the active page of the
- * active workbench window. This call has no effect (but returns <code>true</code>
- * if the search result view is already activated.
- *
- * @return <code>true</code> if the search result view could be activated
- */
- public static boolean activateSearchResultView() {
- return SearchPlugin.activateSearchResultView();
- }
-
- /**
- * Opens the search dialog.
- * If <code>pageId</code> is specified and a corresponding page
- * is found then it is brought to top.
- *
- * @param pageId the page to select or <code>null</code>
- * if the best fitting page should be selected
- * @since 2.0
- */
- public static void openSearchDialog(IWorkbenchWindow window, String pageId) {
- new OpenSearchDialogAction(window, pageId).run();
- }
-
- /**
- * Returns the search result view of the active page of the
- * active workbench window.
- *
- * @return the search result view or <code>null</code>
- * if there is no active search result view
- */
- public static ISearchResultView getSearchResultView() {
- return SearchPlugin.getSearchResultView();
- }
-
- /**
- * Returns the shared search marker image.
- * Normally, editors show this icon in their vertical ruler.
- * This image is owned by the search UI plug-in and must not be disposed
- * by clients.
- *
- * @return the shared image
- */
- public static Image getSearchMarkerImage() {
- return SearchPluginImages.get(SearchPluginImages.IMG_OBJ_SEARCHMARKER);
- }
-
- /**
- * Returns the preference whether editors should be reused
- * when showing search results.
- *
- * The goto action can decide to use or ignore this preference.
- *
- * @return <code>true</code> if editors should be reused for showing search results
- * @since 2.0
- */
- public static boolean reuseEditor() {
- return SearchPreferencePage.isEditorReused();
- }
-
- /**
- * Returns the preference whether a search engine is
- * allowed to report potential matches or not.
- * <p>
- * Search engines which can report inexact matches must
- * respect this preference i.e. they should not report
- * inexact matches if this method returns <code>true</code>
- * </p>
- * @return <code>true</code> if search engine must not report inexact matches
- * @since 2.1
- */
- public static boolean arePotentialMatchesIgnored() {
- return SearchPreferencePage.arePotentialMatchesIgnored();
- }
-
- /**
- * Returns the ID of the default perspective.
- * <p>
- * The perspective with this ID will be used to show the Search view.
- * If no default perspective is set then the Search view will
- * appear in the current perspective.
- * </p>
- * @return the ID of the default perspective <code>null</code> if no default perspective is set
- * @since 2.1
- */
- public static String getDefaultPerspectiveId() {
- return SearchPreferencePage.getDefaultPerspectiveId();
- }
-
- /**
- * Block instantiation.
- */
- private SearchUI() {
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/ui/package.html b/org.eclipse.search/search/org/eclipse/search/ui/package.html
deleted file mode 100644
index f929088..0000000
--- a/org.eclipse.search/search/org/eclipse/search/ui/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.75 [en] (WinNT; U) [Netscape]">
- <title>Package-level Javadoc</title>
-</head>
-<body>
-Provides classes and interfaces for search pages.
-New search dialog pages can be contributed via a plug-in extension point.
-This package provides the interfaces and classes to implement these dialog
-pages and offers hooks to populate the search result view.
-<h2>
-Package Specification</h2>
-Each search dialog page must implement <tt>ISearchPage</tt>. A search page
-has access to its container (<tt>ISearchPageContainer</tt>) to modify search
-dialog properties. The class <tt>SearchUI</tt> can activate the search
-results view and provide access to the active search results view (<tt>ISearchResultView</tt>).
-<p>It is the clients responsibility to create a marker for each match and
-then report the match to the search result view together with a key (<tt>groupByKey</tt>).
-Each key corresponds to a search result view entry (<tt>ISearchResultViewEntry</tt>)
-which allows to step through the markers grouped by the key.
-</body>
-</html>
diff --git a/org.eclipse.text/.classpath b/org.eclipse.text/.classpath
deleted file mode 100644
index f2a7ad8..0000000
--- a/org.eclipse.text/.classpath
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="projection"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/org.eclipse.text/.cvsignore b/org.eclipse.text/.cvsignore
deleted file mode 100644
index c5e82d7..0000000
--- a/org.eclipse.text/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
\ No newline at end of file
diff --git a/org.eclipse.text/.project b/org.eclipse.text/.project
deleted file mode 100644
index 1481146..0000000
--- a/org.eclipse.text/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.text</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.eclipse.pde.PluginNature</nature>
- </natures>
-</projectDescription>
diff --git a/org.eclipse.text/about.html b/org.eclipse.text/about.html
deleted file mode 100644
index 9db411a..0000000
--- a/org.eclipse.text/about.html
+++ /dev/null
@@ -1,30 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<html>
-<head>
-<title>About</title>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</head>
-<body lang="EN-US">
-<h2>About This Content</h2>
-
-<p>20th June, 2002</p>
-<h3>License</h3>
-<p>Eclipse.org makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
-Common Public License Version 1.0 ("CPL"). A copy of the CPL is available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>.
-For purposes of the CPL, "Program" will mean the Content.</p>
-
-<h3>Contributions</h3>
-
-<p>If this Content is licensed to you under the terms and conditions of the CPL, any Contributions, as defined in the CPL, uploaded, submitted, or otherwise
-made available to Eclipse.org, members of Eclipse.org and/or the host of Eclipse.org web site, by you that relate to such
-Content are provided under the terms and conditions of the CPL and can be made available to others under the terms of the CPL.</p>
-
-<p>If this Content is licensed to you under license terms and conditions other than the CPL ("Other License"), any modifications, enhancements and/or
-other code and/or documentation ("Modifications") uploaded, submitted, or otherwise made available to Eclipse.org, members of Eclipse.org and/or the
-host of Eclipse.org, by you that relate to such Content are provided under terms and conditions of the Other License and can be made available
-to others under the terms of the Other License. In addition, with regard to Modifications for which you are the copyright holder, you are also
-providing the Modifications under the terms and conditions of the CPL and such Modifications can be made available to others under the terms of
-the CPL.</p>
-
-</body>
-</html>
\ No newline at end of file
diff --git a/org.eclipse.text/build.properties b/org.eclipse.text/build.properties
deleted file mode 100644
index 8bcb44e..0000000
--- a/org.eclipse.text/build.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-bin.includes = plugin.properties,\
- plugin.xml,\
- *.jar,\
- about.html
-source.text.jar = src/,\
- projection/
diff --git a/org.eclipse.text/plugin.properties b/org.eclipse.text/plugin.properties
deleted file mode 100644
index af35084..0000000
--- a/org.eclipse.text/plugin.properties
+++ /dev/null
@@ -1,12 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2003 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-pluginName= Text
-providerName= Eclipse.org
diff --git a/org.eclipse.text/plugin.xml b/org.eclipse.text/plugin.xml
deleted file mode 100644
index 65e46d2..0000000
--- a/org.eclipse.text/plugin.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
-<plugin
- id="org.eclipse.text"
- name="%pluginName"
- version="3.0.0"
- provider-name="%providerName">
-
- <runtime>
- <library name="text.jar">
- <export name="*"/>
- <packages prefixes="org.eclipse.jface.text,org.eclipse.text.edits"/>
- </library>
- </runtime>
-
-</plugin>
diff --git a/org.eclipse.text/projection/org/eclipse/jface/text/CoordinatesTranslator.java b/org.eclipse.text/projection/org/eclipse/jface/text/CoordinatesTranslator.java
deleted file mode 100644
index eb4af1d..0000000
--- a/org.eclipse.text/projection/org/eclipse/jface/text/CoordinatesTranslator.java
+++ /dev/null
@@ -1,350 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-import java.util.Arrays;
-import java.util.Comparator;
-
-/**
- * Implementation of <code>IDocumentInformationMapping</code> matching <code>ProjectionDocument</code> and
- * <code>ProjectionDocumentManager</code>. The parent document is considered the original document, the projection
- * document is considered the image document.<p>
- * This class is for internal use only.
- * @since 2.1
- * @deprecated
- */
-public class CoordinatesTranslator implements IDocumentInformationMapping {
-
- /** The parent document */
- private IDocument fParentDocument;
- /** The position category used to manage the projected regions of the parent document */
-// private String fParentCategory;
- /** The projection document */
- private ProjectionDocument fProjectionDocument;
- /** The position category to manage the fragments of the projection document. */
-// private String fProjectionCategory;
-
- /**
- * Creates a new mapping between the given parent document and the given projection document.
- *
- * @param parent the parent document
- * @param parentCategory the position category of the parent document used to manage the projected regions
- * @param projection the projection document
- * @param projectionCategory the position category of the projection document used to manage the fragments
- */
- public CoordinatesTranslator(IDocument parent, String parentCategory, ProjectionDocument projection, String projectionCategory) {
- fParentDocument= parent;
-// fParentCategory= parentCategory;
- fProjectionDocument= projection;
-// fProjectionCategory= projectionCategory;
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentInformationMapping#toOriginOffset(int)
- */
- public int toOriginOffset(int imageOffset) throws BadLocationException {
- Fragment fragment= (Fragment) getPositionOfOffset(fProjectionDocument, ProjectionDocument.FRAGMENT_CATEGORY, imageOffset);
- if (fragment == null) {
- if (imageOffset == 0)
- return 0;
- throw new BadLocationException();
- }
-
- int relative= imageOffset - fragment.offset;
- return fragment.getOrigin().offset + relative;
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentInformationMapping#toOriginRegion(org.eclipse.jface.text.IRegion)
- */
- public IRegion toOriginRegion(IRegion imageRegion) throws BadLocationException {
-
- int projectionOffset= imageRegion.getOffset();
- int projectionLength= imageRegion.getLength();
-
- if (projectionLength == 0) {
- if (projectionOffset == 0 && projectionLength == fProjectionDocument.getLength())
- return new Region(0, fParentDocument.getLength());
- return new Region(toOriginOffset(projectionOffset), 0);
- }
-
- int o1= toOriginOffset(projectionOffset);
- int o2= toOriginOffset(projectionOffset + projectionLength -1);
- return new Region(o1, o2 - o1 + 1);
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentInformationMapping#toOriginLines(int)
- */
- public IRegion toOriginLines(int imageLine) throws BadLocationException {
-
- IRegion projectionDocumentRegion= fProjectionDocument.getLineInformation(imageLine);
- IRegion parentDocumentRegion= toOriginRegion(projectionDocumentRegion);
-
- int startLine= fParentDocument.getLineOfOffset(parentDocumentRegion.getOffset());
- if (parentDocumentRegion.getLength() == 0)
- return new Region(startLine, 0);
-
- int endLine= fParentDocument.getLineOfOffset(parentDocumentRegion.getOffset() + parentDocumentRegion.getLength() -1);
- return new Region(startLine, endLine - startLine);
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentInformationMapping#toOriginLine(int)
- */
- public int toOriginLine(int imageLine) throws BadLocationException {
- IRegion lines= toOriginLines(imageLine);
- if (lines.getLength() > 0)
- throw new IllegalStateException();
- return lines.getOffset();
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentInformationMapping#toImageOffset(int)
- */
- public int toImageOffset(int originOffset) throws BadLocationException {
- ProjectionPosition projection= (ProjectionPosition) getPositionOfOffset(fParentDocument, ProjectionDocumentManager.PROJECTION_DOCUMENTS, originOffset);
- if (projection != null)
- return translateOffset(projection, originOffset, projection.getFragment());
- // not included
- return -1;
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentInformationMapping#toImageRegion(org.eclipse.jface.text.IRegion)
- */
- public IRegion toImageRegion(IRegion originRegion) throws BadLocationException {
-
- if (originRegion.getLength() == 0) {
- int projectionOffset= toImageOffset(originRegion.getOffset());
- return projectionOffset == -1 ? null : new Region(projectionOffset, 0);
- }
-
- Position[] positions= getPositionsOfRange(fParentDocument, ProjectionDocumentManager.PROJECTION_DOCUMENTS, originRegion, null);
- if (positions != null && positions.length > 0) {
- ProjectionPosition projection= (ProjectionPosition) positions[0];
-
- int offset= originRegion.getOffset();
- int length= originRegion.getLength();
-
- int delta= projection.getOffset() - offset;
- if (delta > 0) {
- offset += delta;
- length -= delta;
- }
- int start= translateOffset(projection, offset, projection.getFragment());
-
- projection= (ProjectionPosition) positions[positions.length -1];
- int decrease= 0;
- int endOffset= offset + length;
- if (length > 0)
- decrease= 1;
- endOffset -= decrease;
-
- delta= endOffset - (projection.getOffset() + Math.max(projection.getLength() -1, 0));
- if (delta > 0)
- endOffset -= delta;
-
- int end= translateOffset(projection, endOffset, projection.getFragment());
- return new Region(start, end - start + decrease);
- }
-
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentInformationMapping#toImageLine(int)
- */
- public int toImageLine(int originLine) throws BadLocationException {
-
- IRegion parentDocumentRegion= fParentDocument.getLineInformation(originLine);
- IRegion projectionDocumentRegion= toImageRegion(parentDocumentRegion);
- if (projectionDocumentRegion == null)
- return -1;
-
- int startLine= fProjectionDocument.getLineOfOffset(projectionDocumentRegion.getOffset());
- if (projectionDocumentRegion.getLength() == 0)
- return startLine;
-
- int endLine= fProjectionDocument.getLineOfOffset(projectionDocumentRegion.getOffset() + projectionDocumentRegion.getLength() -1);
- if (endLine != startLine)
- throw new IllegalStateException();
-
- return startLine;
- }
-
-
- //-----------------------------------------------------------------------------------------------------------------------------------
-
- /**
- * Translates the given offset relative to the given origin position into an
- * offset relative to the given target position.
- *
- * @param origin the origin position
- * @param originOffset the offset relative to <code>originOffset</code>
- * @param target the target position
- * @return <code>originOffset</code> translated to the given target position
- */
- private int translateOffset(Position origin, int originOffset, Position target) {
- int relative= originOffset - origin.offset;
- return target.offset + relative;
- }
-
- /**
- * Returns the position of the given category of the given document that includes the given offset
- * or <code>null</code> if there is no such position.
- *
- * @param document the document
- * @param category the position category of <code>document</code>
- * @param offset the offset into <code>document</code>
- * @return the position including the given offset or <code>null</code>
- * @throws BadLocationException if <code>offset</code> is not valid in the given document
- */
- private Position getPositionOfOffset(IDocument document, String category, int offset) throws BadLocationException {
- try {
- int index= getPositionIndexOfOffset(document, category, offset, 0);
- if (index > -1) {
- Position[] positions= document.getPositions(category);
- return positions[index];
- }
- } catch (BadPositionCategoryException x) {
- }
- return null;
- }
-
- /**
- * Returns an array of positions of the given category that cover the given range of the document.
- *
- * @param document the document
- * @param category the position category of <code>document</code>
- * @param range the range of <code>document</code>
- * @param comparator the comparator to sort the array to be returned
- * @return an array of positions that cover the given range in the given document
- */
- private Position[] getPositionsOfRange(IDocument document, String category, IRegion range, Comparator comparator) {
-
- int offset= range.getOffset();
- int length= range.getLength();
-
- try {
-
- int start= getPositionIndexOfOffset(document, category, offset, length);
- int end= getPositionIndexOfOffset(document, category, offset + length -1, 1 - length);
-
- if (start > -1 && end > -1) {
-
- Position[] positions= document.getPositions(category);
-
- if (start == end)
- return new Position[] { positions[start] };
-
- Position[] result= new Position[end - start + 1];
- for (int i= start; i <= end; i++)
- result[i - start]= positions[i];
-
- if (comparator != null)
- Arrays.sort(result, comparator);
-
- return result;
- }
-
- } catch (BadPositionCategoryException e) {
- } catch (BadLocationException e) {
- }
-
- return new Position[0];
- }
-
- /**
- * Returns the index of the position of the given category of the given document that includes the
- * given offset. <code>direction</code> indicates the direction into which the algorithm should search.
- *
- * @param document the document
- * @param category the position category of <code>document</code>
- * @param offset the offset into <code>document</code>
- * @param direction the search direction
- * @return the index of the position
- * @throws BadPositionCategoryException if <code>category</code> is not valid in <code>document</code>
- * @throws BadLocationException if <code>offset</code> is not valid in <code>document</code>
- */
- private int getPositionIndexOfOffset(IDocument document, String category, int offset, int direction ) throws BadPositionCategoryException, BadLocationException{
-
- Position[] positions= document.getPositions(category);
- if (positions != null && positions.length > 0) {
-
- // test for inclusion
- int index= document.computeIndexInCategory(category, offset);
- if (index < positions.length && positions[index].includes(offset))
- return index;
- if (index > 0 && positions[index -1].includes(offset))
- return index -1;
-
- // find next accorrding to direction
- if (direction != 0) {
- if (direction > 0) {
- if (index < positions.length && positions[index].overlapsWith(offset, direction))
- return index;
- } else {
- if (index > 0 && positions[index -1].overlapsWith(offset + direction, -direction))
- return index -1;
- }
- }
- }
-
- return -1;
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentInformationMapping#getCoverage()
- */
- public IRegion getCoverage() {
- Position coverage= fProjectionDocument.getParentDocumentCoverage();
- return new Region(coverage.getOffset(), coverage.getLength());
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentInformationMapping#toClosestImageLine(int)
- */
- public int toClosestImageLine(int originLine) throws BadLocationException {
- try {
-
- int modelLineOffset= fParentDocument.getLineOffset(originLine);
- int index= fParentDocument.computeIndexInCategory(ProjectionDocumentManager.PROJECTION_DOCUMENTS, modelLineOffset);
- Position[] projections= fParentDocument.getPositions(ProjectionDocumentManager.PROJECTION_DOCUMENTS);
-
- if (index < projections.length) {
- Position p= projections[index -1];
- int delta1= modelLineOffset - (p.getOffset() + p.getLength());
- p= projections[index];
- int delta2= modelLineOffset - (p.getOffset() + p.getLength());
- if (delta1 < delta2) {
- p= projections[index -1];
- originLine= fParentDocument.getLineOfOffset(p.getOffset() + Math.max(p.getLength() -1, 0));
- } else {
- originLine= fParentDocument.getLineOfOffset(p.getOffset());
- }
- } else if (projections.length > 0) {
- Position p= projections[index -1];
- originLine= fParentDocument.getLineOfOffset(p.getOffset() + Math.max(p.getLength() -1, 0));
- } else {
- return 0;
- }
-
- return toImageLine(originLine);
-
- } catch (BadLocationException x) {
- } catch (BadPositionCategoryException x) {
- }
-
- return 0;
- }
-}
diff --git a/org.eclipse.text/projection/org/eclipse/jface/text/Fragment.java b/org.eclipse.text/projection/org/eclipse/jface/text/Fragment.java
deleted file mode 100644
index ffaf017..0000000
--- a/org.eclipse.text/projection/org/eclipse/jface/text/Fragment.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-
-/**
- * Represents a fragment of a <code>ProjectionDocument</code>.<p>
- * This class is for internal use only.
- *
- * @since 2.1
- * @deprecated
- */
-public class Fragment extends Position {
-
- /** Position representing the corresponding range in the parent document. */
- private Position fOrigin;
-
- /**
- * Creates new position representing a fragment.
- *
- * @param offset the offset of the fragment
- * @param length the length of the fragment
- * @param origin the cooresponding range in the parent document
- */
- public Fragment(int offset, int length, Position origin) {
- super(offset, length);
- fOrigin= origin;
- }
-
- /**
- * Returns the corresponding range in the parent document.
- * @return the corresponding range in the parent document
- */
- public Position getOrigin() {
- return fOrigin;
- }
-
- /**
- * Sets the corresponding range in the parent document.
- * @param origin the cooresponding range in the parent document
- */
- public void setOrigin(Position origin) {
- fOrigin= origin;
- }
-}
diff --git a/org.eclipse.text/projection/org/eclipse/jface/text/FragmentUpdater.java b/org.eclipse.text/projection/org/eclipse/jface/text/FragmentUpdater.java
deleted file mode 100644
index c8c0732..0000000
--- a/org.eclipse.text/projection/org/eclipse/jface/text/FragmentUpdater.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-
-/**
- * The position updater used to adapt the fragments of a projection document to
- * changes of the master document. The updater supports two modes: a shifting mode
- * and a non shifting mode. In the shifting mode the updater behaves identical to the
- * <code>DefaultPositionUpdater</code>. In non shifting mode, if an insertion happens at
- * a fragment's offset, the fragment is extended rather than shifted. Also, the
- * last fragment is extended if an inserte operation happens at the end of the fragment.<p>
- * This class is for internal use only.
- *
- * @since 2.1
- * @deprecated
- */
-public class FragmentUpdater extends DefaultPositionUpdater {
-
- /** Indicates whether this updater is in shift mode. */
- private boolean fShiftMode= false;
- /** Indicates whether the positon currently being updated represents the last fragment. */
- private boolean fIsLast= false;
-
- /**
- * Creates the fragment updater for the given category.
- *
- * @param fragmentCategory the position category used for managing the fragments of a projection document
- */
- protected FragmentUpdater(String fragmentCategory) {
- super(fragmentCategory);
- }
-
- /**
- * Enables/disables the shift mode of this updater.
- *
- * @param enable <code>true</code> if shift mode should be enabled
- */
- public void enableShiftMode(boolean enable) {
- fShiftMode= enable;
- }
-
- /**
- * If an insertion happens at a fragment's offset, the fragment is extended
- * rather than shifted. Also, the last fragment is extended if an inserte operation
- * happens at the end of the fragment.
- */
- protected void adaptToInsert() {
-
- if (fShiftMode) {
- super.adaptToInsert();
- return;
- }
-
- int myStart= fPosition.offset;
- int myEnd= fPosition.offset + fPosition.length - (fIsLast ? 0 : 1);
- myEnd= Math.max(myStart, myEnd);
-
- int yoursStart= fOffset;
- int yoursEnd= fOffset + fReplaceLength -1;
- yoursEnd= Math.max(yoursStart, yoursEnd);
-
- if (myEnd < yoursStart)
- return;
-
- if (fLength <= 0) {
-
- if (myStart <= yoursStart)
- fPosition.length += fReplaceLength;
- else
- fPosition.offset += fReplaceLength;
-
- } else {
-
- if (myStart <= yoursStart && fOriginalPosition.offset <= yoursStart)
- fPosition.length += fReplaceLength;
- else
- fPosition.offset += fReplaceLength;
- }
- }
-
- /*
- * @see IPositionUpdater#update(DocumentEvent event)
- */
- public void update(DocumentEvent event) {
-
- try {
-
- Position[] category= event.getDocument().getPositions(getCategory());
-
- fOffset= event.getOffset();
- fLength= event.getLength();
- fReplaceLength= (event.getText() == null ? 0 : event.getText().length());
- fDocument= event.getDocument();
-
- for (int i= 0; i < category.length; i++) {
-
- fPosition= category[i];
- fIsLast= (i == category.length -1);
-
- fOriginalPosition.offset= fPosition.offset;
- fOriginalPosition.length= fPosition.length;
-
- if (notDeleted())
- adaptToReplace();
- }
-
- } catch (BadPositionCategoryException x) {
- // do nothing
- }
- }
-}
diff --git a/org.eclipse.text/projection/org/eclipse/jface/text/ProjectionDocument.java b/org.eclipse.text/projection/org/eclipse/jface/text/ProjectionDocument.java
deleted file mode 100644
index 9cbf9db..0000000
--- a/org.eclipse.text/projection/org/eclipse/jface/text/ProjectionDocument.java
+++ /dev/null
@@ -1,835 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-import java.util.Arrays;
-import java.util.Comparator;
-
-
-
-/**
- * A <code>ProjectionDocument</code> represents a projection of its master document.
- * The contents of a projection document is a sequence of fragments of the master document, i.e.
- * the projection document can be thought as being constructed from the master document by
- * not copying the whole master document by omitting serveral ranges of the master document. <p>
- * The projection document utilizes its master document as <code>ITextStore</code>.<p>
- * This class if for internal use only.
- *
- * @since 2.1
- * @deprecated
- */
-public final class ProjectionDocument extends AbstractDocument {
-
- /** The position category used by <code>ProjectionDocument</code>s to manage the fragments they consist of. */
- final public static String FRAGMENT_CATEGORY= "__fragment_category"; //$NON-NLS-1$
-
- /** The parent document */
- private IDocument fParentDocument;
- /** The parent document as document extension */
- private IDocumentExtension fExtension;
- /** The position category defining the projection */
- private String fProjectionCategory;
- /** The document event issued by the parent document */
- private DocumentEvent fParentEvent;
- /** The document event issued and to be issued by the projection document */
- private SlaveDocumentEvent fEvent;
- /** Indicates whether the projection document initiated a parent document update or not */
- private boolean fIsUpdating= false;
- /** The position updater for the positions managing the fragments */
- private FragmentUpdater fFragmentUpdater= new FragmentUpdater(FRAGMENT_CATEGORY);
-
- /**
- * Creates a projection document for the given parent document.
- *
- * @param parentDocument the parent Document
- * @param projectionCategory the document position category whose positions define the projection of the parent document
- */
- public ProjectionDocument(IDocument parentDocument, String projectionCategory) {
- super();
-
- fParentDocument= parentDocument;
- if (fParentDocument instanceof IDocumentExtension)
- fExtension= (IDocumentExtension) fParentDocument;
-
- ITextStore s= new ProjectionTextStore(this);
- ILineTracker tracker= new DefaultLineTracker();
-
- setTextStore(s);
- setLineTracker(tracker);
-
- completeInitialization();
-
- initializeProjection(projectionCategory);
- tracker.set(s.get(0, s.getLength()));
- }
-
- /**
- * Initializes the projection document from the parent document based on the given projection category.
- *
- * @param projectionCategory the document position category whose positions define the projection of the parent document
- */
- private void initializeProjection(String projectionCategory) {
-
- fProjectionCategory= projectionCategory;
-
- try {
-
- addPositionCategory(FRAGMENT_CATEGORY);
- addPositionUpdater(fFragmentUpdater);
-
- int offset= 0;
- Position[] patch= fParentDocument.getPositions(fProjectionCategory);
- for (int i= 0; i < patch.length; i++) {
- Position p= patch[i];
- addPosition(FRAGMENT_CATEGORY, new Fragment(offset, p.length, p));
- offset += p.length;
- }
-
- } catch (BadPositionCategoryException x) {
- } catch (BadLocationException x) {
- }
- }
-
- /**
- * Creates a fragment from a postion of the parent document.
- *
- * @param parentPosition a position of the parent document
- * @return the fragment representing the range given by the parent position
- */
- public Fragment createFragment(Position parentPosition) {
- try {
-
- int index= fParentDocument.computeIndexInCategory(fProjectionCategory, parentPosition.offset);
- if (index <= 0)
- return new Fragment(0, parentPosition.length, parentPosition);
-
- Position[] fragments= getPositions(FRAGMENT_CATEGORY);
- Position p= fragments[index -1];
- return new Fragment(p.offset + p.length, parentPosition.length, parentPosition);
-
- } catch (BadPositionCategoryException e) {
- } catch (BadLocationException e) {
- }
-
- return null;
- }
-
- /**
- * Returns the index of the position of the given category of the given document that includes the
- * given offset. <code>direction</code> indicates the direction into which the algorithm should search.
- *
- * @param document the document
- * @param category the position category of <code>document</code>
- * @param offset the offset into <code>document</code>
- * @param direction the search direction
- * @return the index of the position
- * @throws BadPositionCategoryException if <code>category</code> is not valid in <code>document</code>
- * @throws BadLocationException if <code>offset</code> is not valid in <code>document</code>
- */
- private int getPositionOfOffset(IDocument document, String category, int offset, int direction ) throws BadPositionCategoryException, BadLocationException{
-
- Position[] positions= document.getPositions(category);
- if (positions != null && positions.length > 0) {
-
- // test for inclusion
- int index= document.computeIndexInCategory(category, offset);
- if (index < positions.length && positions[index].includes(offset))
- return index;
- if (index > 0 && positions[index -1].includes(offset))
- return index -1;
-
- // find next accorrding to direction
- if (direction != 0) {
- if (direction > 0) {
- if (index < positions.length && positions[index].overlapsWith(offset, direction))
- return index;
- } else {
- if (index > 0 && positions[index -1].overlapsWith(offset + direction, -direction))
- return index -1;
- }
- }
- }
-
- return -1;
- }
-
- /**
- * Returns the position which is used to manage a parent
- * document range represented in this projection document and that
- * includes or is close to the given parent document offset. The distance
- * is computed based on the given direction hint.
- *
- * @param offsetInParent the parent document offset
- * @param direction the direction hint used for computing the distance
- * @return position the parent document position including or near to the parent document offset
- */
- private Position getParentDocumentPositionOfOffset(int offsetInParent, int direction ) {
- try {
-
- int index= getPositionOfOffset(fParentDocument, fProjectionCategory, offsetInParent, direction);
- if (index > -1) {
- Position[] positions= fParentDocument.getPositions(fProjectionCategory);
- return positions[index];
- }
-
- } catch (BadPositionCategoryException x) {
- } catch (BadLocationException x) {
- }
-
- return null;
- }
-
- /**
- * Returns the offset in the projection document corresponding to the
- * given parent document offset.
- *
- * @param offsetInParent the parent document offset
- * @return the projection document offset corresponding to the given parent document offset
- */
- private int toProjectionDocumentOffset(int offsetInParent, int direction) {
-
- Position p= getParentDocumentPositionOfOffset(offsetInParent, direction);
- if (p == null)
- return -1;
-
- int relative= offsetInParent - p.offset;
-
- if (direction > 0) {
- if (relative < 0)
- relative= 0;
- } else if (direction < 0) {
- if (relative >= p.length)
- relative= p.length -1;
- }
-
- Fragment f= findCorrespondingFragment(p);
- return f.offset + relative;
- }
-
- /**
- * Creates a position describing the projection document range corresponding to
- * the given parent document range.
- *
- * @param offsetInParent the parent document offset
- * @param lengthInParent the parent document lengh
- * @return position describing the projection document range corresponding to the given parent document range
- */
- public Position computeProjectionDocumentPosition(int offsetInParent, int lengthInParent) {
-
- Position p= getParentDocumentCoverage();
- if (p != null) {
-
- if (p.overlapsWith(offsetInParent, lengthInParent)) {
-
- int o1= toProjectionDocumentOffset(offsetInParent, lengthInParent);
- if (o1 == -1)
- return null;
-
- if (lengthInParent == 0)
- return new Position(o1, 0);
-
- int o2= toProjectionDocumentOffset(offsetInParent + lengthInParent -1, 1 - lengthInParent);
- if (o2 == -1)
- return null;
-
- return new Position(o1, o2 - o1 + 1);
-
- } else if (p.getOffset() + p.getLength() == offsetInParent + lengthInParent) {
-
- Position[] fragments= getFragmentation();
- if (fragments != null && fragments.length > 0) {
- Position last= fragments[fragments.length -1];
- return new Position(last.getOffset() + last.getLength());
- }
- }
- }
-
- return null;
- }
-
- /**
- * Returns the offset in the parent document that corresponds to the given offset in this
- * projection document.
- *
- * @param offset the offset in the projection document
- * @return the corresponding parent document offset
- * @throws BadLocationException if <code>offset</code> is not valid in this projection document
- */
- public int toParentDocumentOffset(int offset) throws BadLocationException {
- Fragment fragment= getFragmentOfOffset(offset);
-
- if (fragment == null) {
-
-// if (offset == 0)
-// return 0;
-// throw new BadLocationException();
-
- Position[] fragmentation= getFragmentation();
- if (fragmentation != null && fragmentation.length > 0) {
- Fragment last= (Fragment) fragmentation[fragmentation.length -1];
- if (last.offset + last.length == offset) {
- Position origin= last.getOrigin();
- return origin.offset + origin.length;
- }
- }
-
- throw new BadLocationException();
- }
-
- int relative= offset - fragment.offset;
- return fragment.getOrigin().offset + relative;
- }
-
- /**
- * Computes and returns the region of the parent document that corresponds to the given region of the
- * projection document.
- *
- * @param offset the offset of the projection document region
- * @param length the length of the projection document region
- * @return the corresponding region of the parent document
- * @throws BadLocationException if the given projection document region is not valid
- */
- public IRegion computeParentDocumentRegion(int offset, int length) throws BadLocationException {
-
- if (length == 0) {
- if (offset == 0 && length == getLength())
- return new Region(0, fParentDocument.getLength());
- return new Region(toParentDocumentOffset(offset), 0);
- }
-
- int o1= toParentDocumentOffset(offset);
- int o2= toParentDocumentOffset(offset + length -1);
- return new Region(o1, o2 - o1 + 1);
- }
-
- /**
- * Removes all fragments and thereby clears this projection document.
- */
- public void removeAllFragments() {
- Position[] projection= getProjection();
- if (projection == null)
- return;
-
- for (int i= 0; i < projection.length; i++) {
- try {
- removeFragment(projection[i]);
- } catch (BadLocationException e) {
- }
- }
- }
-
- /**
- * Add a new fragment of the parent document to this projection document.
- *
- * @param offsetInParent offset of the parent document range
- * @param lengthInParent length of the parent document range
- * @return returns the position representing the parent document range in this projection document
- * @throws BadLocationException
- */
- public void addFragment(int offsetInParent, int lengthInParent) throws BadLocationException {
-
- if (lengthInParent == 0)
- return;
-
- try {
-
- ProjectionPosition p= new ProjectionPosition(this, offsetInParent, lengthInParent);
- fParentDocument.addPosition(fProjectionCategory, p);
-
- Fragment fragment= createFragment(p);
- p.setFragment(fragment);
- fireDocumentProjectionChanged(new DocumentEvent(this, fragment.offset, 0, fParentDocument.get(offsetInParent, lengthInParent)));
- addPosition(FRAGMENT_CATEGORY, fragment);
-
-
- getTracker().set(getStore().get(0, getStore().getLength()));
-
- } catch (BadPositionCategoryException x) {
- }
-
- }
-
- /**
- * Joins all fragments that represent neighboring regions in the parent document.
- */
- public void joinFragments() {
- try {
- while (joinTwoFragments()) {}
- } catch (BadPositionCategoryException x) {
- }
- }
-
- /**
- * Joins the first two fragments that represent neighboring regions of the parent document.
- * @return <code>true</code> if two segments have been joined, <code>false</code> otherwise
- * @throws BadPositionCategoryException
- */
- private boolean joinTwoFragments() throws BadPositionCategoryException {
- Position[] projection= getProjection();
- if (projection != null && projection.length > 0) {
- Position previous= projection[0];
- for (int i= 1; i < projection.length; i++) {
- Position current= projection[i];
- if (previous.offset + previous.length == current.offset) {
- join(previous, current);
- return true;
- }
- previous= current;
- }
- }
- return false;
- }
-
- /**
- * Joins the fragments of this projection document that correspond to the two given,
- * neighboring ranges of the parent document.
- *
- * @param p1 lower range in the parent document
- * @param p2 higher range of the parent document
- * @throws BadPositionCategoryException if the fragment position category is not defined in this projection document
- */
- private void join(Position p1, Position p2) throws BadPositionCategoryException {
- // remove p2
- Fragment fragment= findCorrespondingFragment(p2);
- removePosition(FRAGMENT_CATEGORY, fragment);
- fParentDocument.removePosition(fProjectionCategory, p2);
- // extend p1 by length of p2
- fragment= findCorrespondingFragment(p1);
- fragment.length += p2.length;
- p1.length += p2.length;
- }
-
- /**
- * Removes the fragment that corresponds to the given parent document range.
- *
- * @param parentPosition the position representing the parent document range
- * @throws BadLocationException if the fragment position category is not defined in this projection document
- */
- public void removeFragment(Position parentPosition) throws BadLocationException {
- try {
-
- Fragment fragment= findCorrespondingFragment(parentPosition);
- if (fragment != null) {
- removePosition(FRAGMENT_CATEGORY, fragment);
- fParentDocument.removePosition(fProjectionCategory, parentPosition);
- fireDocumentProjectionChanged(new DocumentEvent(this, fragment.offset, fragment.length, null));
- getTracker().set(getStore().get(0, getStore().getLength()));
- }
-
- } catch (BadPositionCategoryException x) {
- }
- }
-
- /**
- * Returns the list of fragments whose corresponding ranges in the parent document overlap with
- * the specifed range of the parent document.
- *
- * @param offsetInParent the offset of the parent document range
- * @param lengthInParent the length of the parent document range
- * @return the list of affected fragments
- */
- public Position[] getAffectedFragments(int offsetInParent, int lengthInParent) {
-
- Position p= computeProjectionDocumentPosition(offsetInParent, lengthInParent);
- if (p == null)
- return null;
-
- Fragment[] f= getFragmentsOfRange(p.offset, p.length);
- if (f == null)
- return null;
-
- Position[] result= new Position[f.length];
- for (int i= 0; i < f.length; i++)
- result[i]= f[i].getOrigin();
- return result;
- }
-
- /**
- * Finds the fragment that represents the given parent document range in this projection document.
- *
- * @param parentPosition the parent document range
- * @return the fragment representing the given parent document range
- */
- private Fragment findCorrespondingFragment(Position parentPosition) {
- try {
- Position[] fragments= getPositions(FRAGMENT_CATEGORY);
- for (int i= 0; i < fragments.length; i++) {
- Fragment f= (Fragment) fragments[i];
- if (parentPosition.equals(f.getOrigin()))
- return f;
- }
- } catch (BadPositionCategoryException x) {
- }
-
- return null;
- }
-
- /**
- * Returns the fragment that contains the given offset.
- *
- * @param offset the offset
- * @return the fragment that contains the given offset
- * @throws BadLocationException if <code>offset</code> is not a valid offset
- */
- protected Fragment getFragmentOfOffset(int offset) throws BadLocationException {
- try {
- int index= getPositionOfOffset(this, FRAGMENT_CATEGORY, offset, 0);
- if (index > -1) {
- Position[] fragments= getPositions(FRAGMENT_CATEGORY);
- return (Fragment) fragments[index];
- }
- } catch (BadPositionCategoryException x) {
- }
- return null;
- }
-
- /**
- * Returns the minimal consecutive list of fragments that completely covers the given range.
- *
- * @param offset the offset of the range
- * @param length the length of the range
- * @return the minimal consecutive list of fragments convering the given range
- */
- protected Fragment[] getFragmentsOfRange(int offset, int length) {
-
- try {
-
- int start= getPositionOfOffset(this, FRAGMENT_CATEGORY, offset, length);
- int end= getPositionOfOffset(this, FRAGMENT_CATEGORY, offset + length -1, 1 - length);
-
- if (start > -1 && end > -1) {
-
- Position[] positions= getPositions(FRAGMENT_CATEGORY);
-
- if (start == end)
- return new Fragment[] { (Fragment) positions[start] };
-
- Fragment[] result= new Fragment[end - start + 1];
- for (int i= start; i <= end; i++)
- result[i - start]= (Fragment) positions[i];
- sortFragments(result);
- return result;
- }
-
- } catch (BadPositionCategoryException e) {
- } catch (BadLocationException e) {
- }
-
- return new Fragment[0];
- }
-
- /**
- * Sorts a list of fragments based on the offsets of their corresponding ranges in the parent document.
- *
- * @param result the list for fragments
- */
- private void sortFragments(Object[] result) {
-
- Comparator comparator= new Comparator() {
-
- public int compare(Object o1, Object o2) {
- Fragment f1= (Fragment) o1;
- Fragment f2= (Fragment) o2;
- return f1.getOrigin().getOffset() - f2.getOrigin().getOffset();
- }
-
- public boolean equals(Object obj) {
- return false;
- }
- };
-
- Arrays.sort(result, comparator);
- }
-
- /**
- * Returns the minimal range of the parent document that covers all ranges that
- * correspond to the fragments of this projection document.
- *
- * @return a position describing the minimal parent document range covering all fragments
- */
- public Position getParentDocumentCoverage() {
- Position[] projection= getProjection();
- if (projection != null && projection.length > 0) {
- Position first=projection[0];
- Position last= projection[projection.length -1];
- return new Position(first.offset, last.offset - first.offset + last.length);
- }
- return new Position(0, 0);
- }
-
- /**
- * The projection of the parent document has been changed by inserting or removing
- * new fragments into this projection document. The projection change is described in
- * the given <code>DocumentEvent</code>. All positions managed by this projection
- * document must be adapted accordingly.
- *
- * @param event the document event
- */
- private void fireDocumentProjectionChanged(DocumentEvent event) {
- fFragmentUpdater.enableShiftMode(true);
- try {
- updatePositions(event);
- } finally {
- fFragmentUpdater.enableShiftMode(false);
- }
- }
-
- /**
- * Returns parent document.
- *
- * @return the parent document
- */
- public IDocument getParentDocument() {
- return fParentDocument;
- }
-
- /**
- * Returns the ranges of the parent document that correspond to the fragments of this
- * projection document.
- *
- * @return the ranges of the parent document corresponding to the fragments
- */
- public Position[] getProjection() {
- try {
- return fParentDocument.getPositions(fProjectionCategory);
- } catch (BadPositionCategoryException x) {
- }
- return null;
- }
-
- /**
- * Returns the list of all fragments of this projection document.
- *
- * @return the list of all fragments of this projection document
- */
- public Position[] getFragmentation() {
- try {
-
- Position[] fragmentation= getPositions(FRAGMENT_CATEGORY);
- sortFragments(fragmentation);
- return fragmentation;
-
- } catch (BadPositionCategoryException x) {
- }
- return null;
- }
-
- /**
- * Transforms a document event of the parent document into a projection document
- * based document event.
- *
- * @param e the parent document event
- * @return the slave document event
- */
- private SlaveDocumentEvent normalize(DocumentEvent e) {
-
- Position c= computeProjectionDocumentPosition(e.getOffset(), e.getLength());
-
- if (c != null) {
- if (c.length == 0) {
- int insertLength= e.getText() == null ? 0 : e.getText().length();
- if (insertLength == 0)
- return null;
- }
- return new SlaveDocumentEvent(this, c.offset, c.length, e.getText(), e);
- }
-
- return null;
- }
-
- /**
- * When called, this projection document is informed about a forthcoming change
- * of its parent document. This projection document checks whether the parent
- * document change affects it and if so informs all document listeners.
- *
- * @param event the parent document event
- */
- public void parentDocumentAboutToBeChanged(DocumentEvent event) {
- fParentEvent= event;
- fEvent= normalize(event);
- if (fEvent != null)
- delayedFireDocumentAboutToBeChanged();
- }
-
- /**
- * When called, this projection document is informed about a change of its parent document.
- * If this projection document is affected it informs all of its document listeners.
- *
- * @param event the parent document event
- */
- public void parentDocumentChanged(DocumentEvent event) {
- if ( !fIsUpdating && event == fParentEvent && fEvent != null) {
- try {
- getTracker().replace(fEvent.getOffset(), fEvent.getLength(), fEvent.getText());
- fireDocumentChanged(fEvent);
- } catch (BadLocationException x) {
- Assert.isLegal(false);
- }
- }
- }
-
- /*
- * @see AbstractDocument#fireDocumentAboutToBeChanged(DocumentEvent)
- */
- protected void fireDocumentAboutToBeChanged(DocumentEvent event) {
- // delay it until there is a notification from the parent document
- // otherwise there it is expensive to construct the parent document information
- }
-
- /**
- * Fires the slave document event as about-to-be-changed event to all registed listeners.
- */
- private void delayedFireDocumentAboutToBeChanged() {
- super.fireDocumentAboutToBeChanged(fEvent);
- }
-
- /**
- * Ignores the given event and sends the semantically equal slave document event instead.
- *
- * @param event the event to be ignored
- */
- protected void fireDocumentChanged(DocumentEvent event) {
- super.fireDocumentChanged(fEvent);
- }
-
- /*
- * @see IDocument#replace(int, int, String)
- */
- public void replace(int offset, int length, String text) throws BadLocationException {
- try {
- fIsUpdating= true;
- if (fExtension != null)
- fExtension.stopPostNotificationProcessing();
-
- super.replace(offset, length, text);
-
- } finally {
- fIsUpdating= false;
- if (fExtension != null)
- fExtension.resumePostNotificationProcessing();
- }
- }
-
- /*
- * @see IDocument#set(String)
- */
- public void set(String text) {
- try {
- fIsUpdating= true;
- if (fExtension != null)
- fExtension.stopPostNotificationProcessing();
-
- super.set(text);
-
- } finally {
- fIsUpdating= false;
- if (fExtension != null)
- fExtension.resumePostNotificationProcessing();
- }
- }
-
- /*
- * @see IDocumentExtension#registerPostNotificationReplace(IDocumentListener, IDocumentExtension.IReplace)
- */
- public void registerPostNotificationReplace(IDocumentListener owner, IDocumentExtension.IReplace replace) {
- if (!fIsUpdating)
- throw new UnsupportedOperationException();
- super.registerPostNotificationReplace(owner, replace);
- }
-
-
- /**
- * Convenience method for removing and adapting the fragments whose corresponding
- * ranges in the parent document are included or overlap with the given range of the
- * parent document.
- *
- * @param offsetInParent the offset of the parent document range
- * @param lengthInParent the length of the parent document range
- */
- public void hide(int offsetInParent, int lengthInParent) {
-
- IDocument parent= getParentDocument();
- Position[] effected= getAffectedFragments(offsetInParent, lengthInParent);
-
- try {
-
- if (effected == null) {
- // populate new document with two new fragments, the left and the right of the hidden region
- int end= offsetInParent + lengthInParent;
- addFragment(0, offsetInParent);
- addFragment(end, parent.getLength() - end);
- } else if (effected.length == 1) {
- // the only affected fragment must be splitted into two
- Position fragment= effected[0];
- removeFragment(fragment);
- addFragment(fragment.offset, offsetInParent - fragment.offset);
- int secondOffset= offsetInParent + lengthInParent;
- addFragment(secondOffset, fragment.offset + fragment.length - secondOffset);
- } else {
- // first expand and than collapse
- internalShow(offsetInParent, lengthInParent, effected);
- hide(offsetInParent, lengthInParent);
- }
-
- joinFragments();
-
- } catch (BadLocationException x) {
- }
- }
-
- /**
- * Convenience method for adding fragments or adapting existing fragments so that their corresponding
- * ranges in the parent document include the given range of the parent document.
- *
- * @param offsetInParent the offset of the parent document range
- * @param lengthInParent the length of the parent document range
- */
- public void show(int offsetInParent, int lengthInParent) {
-
- Position[] effected= getAffectedFragments(offsetInParent, lengthInParent);
- if (effected == null || effected.length == 0) {
- try {
- addFragment(offsetInParent, lengthInParent);
- joinFragments();
- } catch (BadLocationException x) {
- }
- return;
- }
-
- internalShow(offsetInParent, lengthInParent, effected);
- joinFragments();
-
- }
-
- /**
- * Removes the given fragments and inserts a new fragment whose parent document
- * range corresponds the given range of the parent document.
- *
- * @param offsetInParent the offset of the parent document range
- * @param lengthInParent the length of the parent document range
- * @param effected the list for fragments to be removed
- */
- private void internalShow(int offsetInParent, int lengthInParent, Position[] effected) {
- try {
-
- int size= effected.length;
- for (int i= 0; i < size; i++)
- removeFragment(effected[i]);
-
- int offset= Math.min(offsetInParent, effected[0].offset);
- int end= Math.max(offsetInParent + lengthInParent, effected[size -1].offset + effected[size -1].length);
- addFragment(offset, end - offset);
-
- } catch (BadLocationException x) {
- }
- }
-}
diff --git a/org.eclipse.text/projection/org/eclipse/jface/text/ProjectionDocumentManager.java b/org.eclipse.text/projection/org/eclipse/jface/text/ProjectionDocumentManager.java
deleted file mode 100644
index 63c69bc..0000000
--- a/org.eclipse.text/projection/org/eclipse/jface/text/ProjectionDocumentManager.java
+++ /dev/null
@@ -1,321 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-
-
-/**
- * <code>ProjectionDocumentManager</code> is one particular implementation of
- * <code>ISlaveDocumentManager</code>. This manager creates so called projection
- * documents as slave documents for given master documents.<p>
- *
- * A projection document represents a particular projection of the parent
- * document and is accordingly adapted to changes of the parent document.
- * Vice versa, the parent document is accordingly adapted to changes of
- * its child documents. The manager does not maintain any particular management
- * structure but utilizes mechanisms given by <code>IDocument</code> such
- * as position categories and position updaters. <p>
- * This class if for internal use only.
- *
- * @since 2.1
- * @deprecated
- */
-public final class ProjectionDocumentManager implements IDocumentListener, ISlaveDocumentManager {
-
-
- /**
- * Name of the position category used to keep track of the parent document
- * ranges that correspond to the fragments of the projection documents.
- */
- public final static String PROJECTION_DOCUMENTS= "__projectiondocuments"; //$NON-NLS-1$
-
-
-// static class ProjectionDocumentPartitioner implements IDocumentPartitioner {
-//
-// protected ProjectionDocument fProjectionDocument;
-// protected IDocument fParentDocument;
-//
-// protected ProjectionDocumentPartitioner() {
-// }
-//
-// /*
-// * @see IDocumentPartitioner#getPartition(int)
-// */
-// public ITypedRegion getPartition(int offset) {
-// try {
-// offset += fProjectionDocument.getParentDocumentRange().getOffset();
-// return fParentDocument.getPartition(offset);
-// } catch (BadLocationException x) {
-// }
-//
-// return null;
-// }
-//
-// /*
-// * @see IDocumentPartitioner#computePartitioning(int, int)
-// */
-// public ITypedRegion[] computePartitioning(int offset, int length) {
-// try {
-// offset += fProjectionDocument.getParentDocumentRange().getOffset();
-// return fParentDocument.computePartitioning(offset, length);
-// } catch (BadLocationException x) {
-// }
-//
-// return null;
-// }
-//
-// /*
-// * @see IDocumentPartitioner#getContentType(int)
-// */
-// public String getContentType(int offset) {
-// try {
-// offset += fProjectionDocument.getParentDocumentRange().getOffset();
-// return fParentDocument.getContentType(offset);
-// } catch (BadLocationException x) {
-// }
-//
-// return null;
-// }
-//
-// /*
-// * @see IDocumentPartitioner#getLegalContentTypes()
-// */
-// public String[] getLegalContentTypes() {
-// return fParentDocument.getLegalContentTypes();
-// }
-//
-// /*
-// * @see IDocumentPartitioner#documentChanged(DocumentEvent)
-// */
-// public boolean documentChanged(DocumentEvent event) {
-// // ignore as the parent does this for us
-// return false;
-// }
-//
-// /*
-// * @see IDocumentPartitioner#documentAboutToBeChanged(DocumentEvent)
-// */
-// public void documentAboutToBeChanged(DocumentEvent event) {
-// // ignore as the parent does this for us
-// }
-//
-// /*
-// * @see IDocumentPartitioner#disconnect()
-// */
-// public void disconnect() {
-// fProjectionDocument= null;
-// fParentDocument= null;
-// }
-//
-// /*
-// * @see IDocumentPartitioner#connect(IDocument)
-// */
-// public void connect(IDocument childDocument) {
-// Assert.isTrue(childDocument instanceof ProjectionDocument);
-// fProjectionDocument= (ProjectionDocument) childDocument;
-// fParentDocument= fProjectionDocument.getParentDocument();
-// }
-// };
-
-
-
- /** The position updater shared by all master documents which have projection documents */
- private IPositionUpdater fProjectionPositionUpdater;
- /** Registry for master documents and their projection documents. */
- private Map fRegistar= new HashMap();
-
-
- /**
- * Returns the projection position updater. If necessary, it is dynamically created.
- *
- * @return the child position updater
- */
- protected IPositionUpdater getProjectionPositionUpdater() {
- if (fProjectionPositionUpdater == null)
- fProjectionPositionUpdater= new FragmentUpdater(PROJECTION_DOCUMENTS);
- return fProjectionPositionUpdater;
- }
-
- /**
- * Registers the given projection document for the given master document.
- *
- * @param parent the master document
- * @param projection the projection document
- */
- private void add(IDocument parent, ProjectionDocument projection) {
- List list= (List) fRegistar.get(parent);
- if (list == null) {
- list= new ArrayList(1);
- fRegistar.put(parent, list);
- }
- list.add(projection);
- }
-
- /**
- * Unregisters the given projection document from its master.
- *
- * @param parent the master document
- * @param projection the projection document
- */
- private void remove(IDocument parent, ProjectionDocument projection) {
- List list= (List) fRegistar.get(parent);
- if (list != null) {
- list.remove(projection);
- if (list.size() == 0)
- fRegistar.remove(parent);
- }
- }
-
- /**
- * Returns whether the given document is a master document.
- *
- * @param parent the document
- * @return <code>true</code> if the given document is a master document known to this manager
- */
- private boolean hasProjection(IDocument parent) {
- return (fRegistar.get(parent) instanceof List);
- }
-
- /**
- * Returns an iterator enumerating all projection documents registered for the given document or
- * <code>null</code> if the document is not a known master document.
- *
- * @param parent the document
- * @return an iterator for all registered projection documents or <code>null</code>
- */
- private Iterator getProjectionsIterator(IDocument parent) {
- List list= (List) fRegistar.get(parent);
- if (list != null)
- return list.iterator();
- return null;
- }
-
- /**
- * Informs all projection documents of the master document that issued the given document event.
- *
- * @param about indicates whether the change is about to happen or alread happend
- * @param event the document event which will be processed to inform the projection documents
- */
- protected void fireDocumentEvent(boolean about, DocumentEvent event) {
- IDocument parent= event.getDocument();
- Iterator e= getProjectionsIterator(parent);
- if (e == null)
- return;
-
- while (e.hasNext()) {
- ProjectionDocument document= (ProjectionDocument) e.next();
- if (about)
- document.parentDocumentAboutToBeChanged(event);
- else
- document.parentDocumentChanged(event);
- }
- }
-
- /*
- * @see IDocumentListener#documentChanged(DocumentEvent)
- */
- public void documentChanged(DocumentEvent event) {
- fireDocumentEvent(false, event);
- }
-
- /*
- * @see IDocumentListener#documentAboutToBeChanged(DocumentEvent)
- */
- public void documentAboutToBeChanged(DocumentEvent event) {
- fireDocumentEvent(true, event);
- }
-
- /*
- * @see org.eclipse.jface.text.ISlaveDocumentManager#createMasterSlaveMapping(org.eclipse.jface.text.IDocument)
- */
- public IDocumentInformationMapping createMasterSlaveMapping(IDocument slave) {
- if (slave instanceof ProjectionDocument) {
- ProjectionDocument projectionDocument= (ProjectionDocument) slave;
- return new CoordinatesTranslator(projectionDocument.getParentDocument(), PROJECTION_DOCUMENTS, projectionDocument, ProjectionDocument.FRAGMENT_CATEGORY);
- }
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.ISlaveDocumentManager#createSlaveDocument(org.eclipse.jface.text.IDocument)
- */
- public IDocument createSlaveDocument(IDocument master) {
- if (!master.containsPositionCategory(PROJECTION_DOCUMENTS)) {
- master.addPositionCategory(PROJECTION_DOCUMENTS);
- master.addPositionUpdater(getProjectionPositionUpdater());
- master.addDocumentListener(this);
- }
-
- ProjectionDocument slave= new ProjectionDocument(master, PROJECTION_DOCUMENTS);
-// IDocumentPartitioner partitioner= new ProjectionDocumentPartitioner();
-// slave.setDocumentPartitioner(partitioner);
-// partitioner.connect(master);
-
- add(master, slave);
- return slave;
- }
-
- /*
- * @see org.eclipse.jface.text.ISlaveDocumentManager#freeSlaveDocument(org.eclipse.jface.text.IDocument)
- */
- public void freeSlaveDocument(IDocument slave) {
-
- if ( !(slave instanceof ProjectionDocument))
- return;
-
- ProjectionDocument projectionDocument= (ProjectionDocument) slave;
-
-// projectionDocument.getDocumentPartitioner().disconnect();
-
- IDocument parent= projectionDocument.getParentDocument();
- remove(parent, projectionDocument);
-
- try {
- if (!hasProjection(parent)) {
- parent.removeDocumentListener(this);
- parent.removePositionUpdater(getProjectionPositionUpdater());
- parent.removePositionCategory(PROJECTION_DOCUMENTS);
- }
- } catch (BadPositionCategoryException x) {
- }
- }
-
- /*
- * @see org.eclipse.jface.text.ISlaveDocumentManager#getMasterDocument(org.eclipse.jface.text.IDocument)
- */
- public IDocument getMasterDocument(IDocument slave) {
- if (slave instanceof ProjectionDocument)
- return ((ProjectionDocument) slave).getParentDocument();
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.ISlaveDocumentManager#isSlaveDocument(org.eclipse.jface.text.IDocument)
- */
- public boolean isSlaveDocument(IDocument document) {
- return (document instanceof ProjectionDocument);
- }
-
- /*
- * @see org.eclipse.jface.text.ISlaveDocumentManager#setAutoExpandMode(org.eclipse.jface.text.IDocument, boolean)
- */
- public void setAutoExpandMode(IDocument slave, boolean autoExpand) {
- // TODO
- }
-}
diff --git a/org.eclipse.text/projection/org/eclipse/jface/text/ProjectionPosition.java b/org.eclipse.text/projection/org/eclipse/jface/text/ProjectionPosition.java
deleted file mode 100644
index 1724a13..0000000
--- a/org.eclipse.text/projection/org/eclipse/jface/text/ProjectionPosition.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-/**
- * Represents the corresponding parent document range of a fragment of a <code>ProjectionDocument</code>.<p>
- * This class is for internal use only.
- *
- * @since 2.1
- * @deprecated
- */
-public class ProjectionPosition extends Position {
-
- /** The projection document. */
-// private IDocument fProjectionDocument;
- /** The corresponding fragment. */
- private Fragment fFragment;
-
- /**
- * Creates a new position representing the corresponding range of a fragment.
- *
- * @param projectionDocument the projection document
- * @param offset the offset of the range of the parent document
- * @param length the length of the range of the parent document
- */
- public ProjectionPosition(IDocument projectionDocument, int offset, int length) {
- super(offset, length);
-// fProjectionDocument= projectionDocument;
- }
-
- /**
- * Sets the corresponding fragment.
- *
- * @param fragment the corresponding fragment
- */
- public void setFragment(Fragment fragment) {
- fFragment= fragment;
- }
-
- /**
- * Returns the corresponding fragment.
- * @return the corresponding fragment
- */
- public Fragment getFragment() {
- return fFragment;
- }
-
-// /**
-// * Changed to be compatible to the position updater behavior
-// * @see Position#overlapsWith(int, int)
-// */
-// public boolean overlapsWith(int offset, int length) {
-// boolean append= (offset == this.offset + this.length) && length == 0;
-// return append || super.overlapsWith(offset, length);
-// }
-}
diff --git a/org.eclipse.text/projection/org/eclipse/jface/text/ProjectionPositionUpdater.java b/org.eclipse.text/projection/org/eclipse/jface/text/ProjectionPositionUpdater.java
deleted file mode 100644
index 1ad05dd..0000000
--- a/org.eclipse.text/projection/org/eclipse/jface/text/ProjectionPositionUpdater.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-
-/**
- * The position updater used to adapt the positions corresponding to the fragments of
- * projection documents. The startegy of this updater differs from the
- * <code>DefaultPositionUpdater</code>. If an insertion happens at a start offset of a
- * range corresponding to a fragment, the range is extended rather than shifted. Also, if
- * text is added right behind the end of such a range, the range is extended rather than
- * kept stable.<p>
- * This class is for internal use only.
- *
- * @since 2.1
- * @deprecated
- */
-public class ProjectionPositionUpdater extends DefaultPositionUpdater {
-
- /**
- * Creates the position updater for the given category.
- *
- * @param category the category used to manage the positions representing the ranges corresponding to fragments
- */
- protected ProjectionPositionUpdater(String category) {
- super(category);
- }
-
- /**
- * Projection document ranges cannot be deleted other then by calling
- * <code>ProjectionDocumentManager#removeFragment</code>.
- * @return <code>true</code>
- */
- protected boolean notDeleted() {
- return true;
- }
-
- /**
- * If an insertion happens at a start offset of a
- * range corresponding to a fragment, the range is extended rather than shifted. Also, if
- * text is added right behind the end of such a range, the range is extended rather than
- * kept stable.
- */
- protected void adaptToInsert() {
-
- int myStart= fPosition.offset;
- int myEnd= fPosition.offset + fPosition.length;
- myEnd= Math.max(myStart, myEnd);
-
- int yoursStart= fOffset;
- int yoursEnd= fOffset + fReplaceLength -1;
- yoursEnd= Math.max(yoursStart, yoursEnd);
-
- if (myEnd < yoursStart)
- return;
-
- if (myStart <= yoursStart)
- fPosition.length += fReplaceLength;
- else
- fPosition.offset += fReplaceLength;
- }
-}
diff --git a/org.eclipse.text/projection/org/eclipse/jface/text/ProjectionTextStore.java b/org.eclipse.text/projection/org/eclipse/jface/text/ProjectionTextStore.java
deleted file mode 100644
index b163d04..0000000
--- a/org.eclipse.text/projection/org/eclipse/jface/text/ProjectionTextStore.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-
-/**
- * The text store of a <code>ProjectionDocument</code>. Implements the projection onto
- * the master document.<p>
- * This class is for internal use only.
- *
- * @since 2.1
- * @deprecated
- */
-public class ProjectionTextStore implements ITextStore {
-
- /** The projection document */
- private ProjectionDocument fProjectionDocument;
-
- /**
- * Creates a new projection text store for the given projection document.
- *
- * @param projectionDocument the projection document
- */
- public ProjectionTextStore(ProjectionDocument projectionDocument) {
- fProjectionDocument= projectionDocument;
- }
-
- /**
- * Computes the offset in the parent document that corresponds to the given offset.
- *
- * @param offset the offset
- * @return the corresponding parent document offset
- */
- private int computeParentDocumentOffset(int offset) {
- try {
- return fProjectionDocument.toParentDocumentOffset(offset);
- } catch (BadLocationException x) {
- throw new RuntimeException();
- }
- }
-
- /*
- * @see ITextStore#set(String)
- */
- public void set(String contents) {
-
- try {
-
- Position[] projection= fProjectionDocument.getProjection();
- if (projection != null && projection.length > 0) {
- Position first=projection[0];
- Position last= projection[projection.length -1];
- int length= last.offset - first.offset + last.length;
- getParentDocument().replace(first.getOffset(), length, contents);
- } else {
- getParentDocument().set(contents);
- }
-
- } catch (BadLocationException x) {
- }
- }
-
- /*
- * @see ITextStore#replace(int, int, String)
- */
- public void replace(int offset, int length, String text) {
-
- try {
-
- int endoffset= length > 0 ? offset + length -1 : offset;
- int o2= computeParentDocumentOffset(endoffset);
- if (length > 0)
- ++ o2;
-
- offset= computeParentDocumentOffset(offset);
- length= o2 - offset;
-
- getParentDocument().replace(offset, length, text);
-
- } catch (BadLocationException x) {
- // ignored as surrounding document should have handled this
- }
- }
-
- /*
- * @see ITextStore#getLength()
- */
- public int getLength() {
- Position[] projection= fProjectionDocument.getProjection();
- if (projection == null || projection.length == 0)
- return 0;
-
- int length= 0;
- for (int i= 0; i < projection.length; i++)
- length += projection[i].length;
- return length;
- }
-
- /*
- * @see ITextStore#get(int, int)
- */
- public String get(int offset, int length) {
- try {
-
- Fragment[] fragments= fProjectionDocument.getFragmentsOfRange(offset, length);
- if (fragments == null || fragments.length == 0)
- return ""; //$NON-NLS-1$
-
- StringBuffer buffer= new StringBuffer();
- for (int i= 0; i < fragments.length; i++) {
- Position p= fragments[i].getOrigin();
- buffer.append(getParentDocument().get(p.offset, p.length));
- }
-
- offset -= fragments[0].offset;
- return buffer.substring(offset, offset + length);
-
- } catch (BadLocationException x) {
- }
-
- return null;
- }
-
- /**
- * Returns the parent document of the store's document.
- *
- * @return the parent document of the store's document
- */
- private IDocument getParentDocument() {
- return fProjectionDocument.getParentDocument();
- }
-
- /*
- * @see ITextStore#get(int)
- */
- public char get(int offset) {
- try {
- int o= computeParentDocumentOffset(offset);
- return getParentDocument().getChar(o);
- } catch (BadLocationException x) {
- }
-
- return (char) 0;
- }
-}
diff --git a/org.eclipse.text/projection/org/eclipse/jface/text/projection/ChildDocument.java b/org.eclipse.text/projection/org/eclipse/jface/text/projection/ChildDocument.java
deleted file mode 100644
index c25d65f..0000000
--- a/org.eclipse.text/projection/org/eclipse/jface/text/projection/ChildDocument.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.projection;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.Position;
-
-/**
- * Implementation of a child document based on <code>ProjectionDocument</code>.
- * This class exists for compatibility reasons.
- * <p>
- * Internal class. Do not use. Public only for testing purposes.
- *
- * @since 3.0
- */
-public class ChildDocument extends ProjectionDocument {
-
- /**
- * Position reflecting a visible region. The exclusive end offset of the position
- * is considered being overlapping with the visible region.
- */
- static private class VisibleRegion extends Position {
-
- public VisibleRegion(int offset, int length) {
- super(offset, length);
- }
-
- /**
- * If offset is the end of the visible region and the length is 0,
- * the offset is considered overlapping with the visible region.
- */
- public boolean overlapsWith(int offset, int length) {
- boolean appending= (offset == this.offset + this.length) && length == 0;
- return appending || super.overlapsWith(offset, length);
- }
- }
-
- /**
- * Creates a new child document.
- *
- * @param masterDocument @inheritDoc
- */
- public ChildDocument(IDocument masterDocument) {
- super(masterDocument);
- }
-
- /**
- * Returns the parent document of this child document.
- *
- * @return the parent document of this child document
- * @see ProjectionDocument#getMasterDocument()
- */
- public IDocument getParentDocument() {
- return getMasterDocument();
- }
-
- /**
- * Sets the parent document range covered by this child document to the
- * given range.
- *
- * @param offset the offset of the range
- * @param length the length of the range
- */
- public void setParentDocumentRange(int offset, int length) throws BadLocationException {
- replaceMasterDocumentRanges(offset, length);
- }
-
- /**
- * Returns the parent document range of this child document.
- *
- * @return the parent document range of this child document
- */
- public Position getParentDocumentRange() {
- IRegion coverage= getProjectionMapping().getCoverage();
- return new VisibleRegion(coverage.getOffset(), coverage.getLength());
- }
-}
diff --git a/org.eclipse.text/projection/org/eclipse/jface/text/projection/ChildDocumentManager.java b/org.eclipse.text/projection/org/eclipse/jface/text/projection/ChildDocumentManager.java
deleted file mode 100644
index cebc9f6..0000000
--- a/org.eclipse.text/projection/org/eclipse/jface/text/projection/ChildDocumentManager.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.projection;
-
-import org.eclipse.jface.text.IDocument;
-
-/**
- * Implementation of a child document manager based on
- * <code>ProjectionDocumentManager</code>. This class exists for
- * compatibility reasons.
- * <p>
- * Internal class. Do not use. Only public for testing purposes.
- *
- * @since 3.0
- */
-public class ChildDocumentManager extends ProjectionDocumentManager {
-
- /*
- * @see org.eclipse.jface.text.projection.ProjectionDocumentManager#createProjectionDocument(org.eclipse.jface.text.IDocument)
- */
- protected ProjectionDocument createProjectionDocument(IDocument master) {
- return new ChildDocument(master);
- }
-}
diff --git a/org.eclipse.text/projection/org/eclipse/jface/text/projection/Fragment.java b/org.eclipse.text/projection/org/eclipse/jface/text/projection/Fragment.java
deleted file mode 100644
index 6744999..0000000
--- a/org.eclipse.text/projection/org/eclipse/jface/text/projection/Fragment.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.projection;
-
-import org.eclipse.jface.text.Position;
-
-/**
- * Internal class. Do not use. Only public for testing purposes.
- *
- * @since 3.0
- */
-public class Fragment extends Position {
-
- public Segment segment;
-
- public Fragment(int offset, int length) {
- super(offset, length);
- }
-}
diff --git a/org.eclipse.text/projection/org/eclipse/jface/text/projection/FragmentUpdater.java b/org.eclipse.text/projection/org/eclipse/jface/text/projection/FragmentUpdater.java
deleted file mode 100644
index 1f13a39..0000000
--- a/org.eclipse.text/projection/org/eclipse/jface/text/projection/FragmentUpdater.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.projection;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.DefaultPositionUpdater;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.Position;
-
-
-/**
- * The position updater used to adapt the fragments of a document. If an
- * insertion happens at a fragment's offset, the fragment is extended rather
- * than shifted. Also, the last fragment is extended if an insert operation
- * happens at the end of the fragment.
- * <p>
- * Internal class. Do not use. Only public for testing purposes.
- *
- * @since 3.0
- */
-public class FragmentUpdater extends DefaultPositionUpdater {
-
- /** Indicates whether the position being updated represents the last fragment. */
- private boolean fIsLast= false;
-
- /**
- * Creates the fragment updater for the given category.
- *
- * @param fragmentCategory the position category used for managing the fragments of a document
- */
- protected FragmentUpdater(String fragmentCategory) {
- super(fragmentCategory);
- }
-
- /*
- * @see org.eclipse.jface.text.IPositionUpdater#update(org.eclipse.jface.text.DocumentEvent)
- */
- public void update(DocumentEvent event) {
-
- try {
-
- Position[] category= event.getDocument().getPositions(getCategory());
-
- fOffset= event.getOffset();
- fLength= event.getLength();
- fReplaceLength= (event.getText() == null ? 0 : event.getText().length());
- fDocument= event.getDocument();
-
- for (int i= 0; i < category.length; i++) {
-
- fPosition= category[i];
- fIsLast= (i == category.length -1);
-
- fOriginalPosition.offset= fPosition.offset;
- fOriginalPosition.length= fPosition.length;
-
- if (notDeleted())
- adaptToReplace();
- }
-
- } catch (BadPositionCategoryException x) {
- // do nothing
- }
- }
-
- /*
- * @see org.eclipse.jface.text.DefaultPositionUpdater#adaptToInsert()
- */
- protected void adaptToInsert() {
- int myStart= fPosition.offset;
- int myEnd= Math.max(myStart, fPosition.offset + fPosition.length - (fIsLast || isAffectingReplace() ? 0 : 1));
-
- if (myEnd < fOffset)
- return;
-
- if (fLength <= 0) {
-
- if (myStart <= fOffset)
- fPosition.length += fReplaceLength;
- else
- fPosition.offset += fReplaceLength;
-
- } else {
-
- if (myStart <= fOffset && fOriginalPosition.offset <= fOffset)
- fPosition.length += fReplaceLength;
- else
- fPosition.offset += fReplaceLength;
- }
- }
-
- /**
- * Returns whether this updater considers any position affected by the given
- * document event. A position is affected if either the offset or the length
- * of the position is modified but the position is not just shifted.
- *
- * @param event the event
- * @return <code>true</code> if there is any affected position,
- * <code>false</code> otherwise
- */
- public boolean affectsPositions(DocumentEvent event) {
- IDocument document= event.getDocument();
- try {
-
- int index= document.computeIndexInCategory(getCategory(), event.getOffset());
- Position[] fragments= document.getPositions(getCategory());
-
- if (0 < index) {
- Position fragment= fragments[index - 1];
- if (fragment.overlapsWith(event.getOffset(), event.getLength()))
- return true;
- if (fragment.offset + fragment.length == event.getOffset())
- return index == fragments.length;
- }
-
- if (index < fragments.length) {
- Position fragment= fragments[index];
- return fragment.overlapsWith(event.getOffset(), event.getLength());
- }
-
- } catch (BadLocationException x) {
- } catch (BadPositionCategoryException x) {
- }
-
- return false;
- }
-}
diff --git a/org.eclipse.text/projection/org/eclipse/jface/text/projection/IMinimalMapping.java b/org.eclipse.text/projection/org/eclipse/jface/text/projection/IMinimalMapping.java
deleted file mode 100644
index 19cf110..0000000
--- a/org.eclipse.text/projection/org/eclipse/jface/text/projection/IMinimalMapping.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.projection;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IRegion;
-
-/**
- * Internal class. Do not use.
- *
- * @since 3.0
- */
-interface IMinimalMapping {
-
- /**
- * @return
- */
- IRegion getCoverage();
-
- /**
- * @param region
- * @return
- */
- IRegion toOriginRegion(IRegion region) throws BadLocationException;
-
- /**
- * @param offset
- * @return
- */
- int toOriginOffset(int offset) throws BadLocationException;
-
- /**
- * @return
- */
- IRegion[] toExactOriginRegions(IRegion region)throws BadLocationException;
-
- /**
- * @return
- */
- int getImageLength();
-}
diff --git a/org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionDocument.java b/org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionDocument.java
deleted file mode 100644
index 20906e9..0000000
--- a/org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionDocument.java
+++ /dev/null
@@ -1,781 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.projection;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.text.AbstractDocument;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.DefaultLineTracker;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentExtension;
-import org.eclipse.jface.text.IDocumentListener;
-import org.eclipse.jface.text.ILineTracker;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextStore;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.Region;
-
-
-
-/**
- * A <code>ProjectionDocument</code> represents a projection of its master
- * document. The contents of a projection document is a sequence of fragments of
- * the master document, i.e. the projection document can be thought as being
- * constructed from the master document by not copying the whole master document
- * but omitting several ranges of the master document.
- * <p>
- * The projection document utilizes its master document as
- * <code>ITextStore</code>.
- * <p>
- * API in progress. Do not yet use.
- *
- * @since 3.0
- */
-public class ProjectionDocument extends AbstractDocument {
-
-
- /**
- * Prefix of the name of the position category used to keep track of the master
- * document's fragments that correspond to the segments of the projection
- * document.
- */
- private final static String FRAGMENTS_CATEGORY_PREFIX= "__fragmentsCategory"; //$NON-NLS-1$
-
- /**
- * Name of the position category used to keep track of the project
- * document's segments that correspond to the fragments of the master
- * document.
- */
- private final static String SEGMENTS_CATEGORY= "__segmentsCategory"; //$NON-NLS-1$
-
-
- /** The master document */
- private IDocument fMasterDocument;
- /** The master document as document extension */
- private IDocumentExtension fMasterDocumentExtension;
- /** The fragments' position category */
- private String fFragmentsCategory;
- /** The segment's position category */
- private String fSegmentsCategory;
- /** The document event issued by the master document */
- private DocumentEvent fMasterEvent;
- /** The document event to be issued by the projection document */
- private ProjectionDocumentEvent fSlaveEvent;
- /** The original document event generated by a direct manipulation of this projection document */
- private DocumentEvent fOriginalEvent;
- /** Indicates whether the projection document initiated a master document update or not */
- private boolean fIsUpdating= false;
- /** Indicated whether the projection document is in auto expand mode nor not */
- private boolean fIsAutoExpanding= false;
- /** The position updater for the segments */
- private SegmentUpdater fSegmentUpdater;
- /** The position updater for the fragments */
- private FragmentUpdater fFragmentsUpdater;
- /** The projection mapping */
- private ProjectionMapping fMapping;
-
- /**
- * Creates a projection document for the given master document.
- *
- * @param masterDocument the master document
- */
- public ProjectionDocument(IDocument masterDocument) {
- super();
-
- fMasterDocument= masterDocument;
- if (fMasterDocument instanceof IDocumentExtension)
- fMasterDocumentExtension= (IDocumentExtension) fMasterDocument;
-
- fSegmentsCategory= SEGMENTS_CATEGORY;
- fFragmentsCategory= FRAGMENTS_CATEGORY_PREFIX + hashCode();
- fMasterDocument.addPositionCategory(fFragmentsCategory);
- fFragmentsUpdater= new FragmentUpdater(fFragmentsCategory);
- fMasterDocument.addPositionUpdater(fFragmentsUpdater);
-
- fMapping= new ProjectionMapping(masterDocument, fFragmentsCategory, this, fSegmentsCategory);
-
- ITextStore s= new ProjectionTextStore(masterDocument, fMapping);
- ILineTracker tracker= new DefaultLineTracker();
-
- setTextStore(s);
- setLineTracker(tracker);
-
- completeInitialization();
-
- initializeProjection();
- tracker.set(s.get(0, s.getLength()));
- }
-
- /**
- * Disposes this projection document.
- */
- public void dispose() {
- fMasterDocument.removePositionUpdater(fFragmentsUpdater);
- try {
- fMasterDocument.removePositionCategory(fFragmentsCategory);
- } catch (BadPositionCategoryException x) {
- // allow multiple dispose calls
- }
- }
-
- private void internalError() {
- throw new IllegalStateException();
- }
-
- protected final Position[] getFragments() {
- try {
- return fMasterDocument.getPositions(fFragmentsCategory);
- } catch (BadPositionCategoryException e) {
- internalError();
- }
- // unreachable
- return null;
- }
-
- protected final Position[] getSegments() {
- try {
- return getPositions(fSegmentsCategory);
- } catch (BadPositionCategoryException e) {
- internalError();
- }
- // unreachable
- return null;
- }
-
- /**
- * Returns the projection mapping used by this document.
- *
- * @return the projection mapping used by this document
- */
- public ProjectionMapping getProjectionMapping(){
- return fMapping;
- }
-
- /**
- * Returns the master document of this projection document.
- *
- * @return the master document of this projection document
- */
- public IDocument getMasterDocument() {
- return fMasterDocument;
- }
-
- /**
- * Initializes the projection document from the master document based on
- * the master's fragments.
- */
- private void initializeProjection() {
-
- try {
-
- addPositionCategory(fSegmentsCategory);
- fSegmentUpdater= new SegmentUpdater(fSegmentsCategory);
- addPositionUpdater(fSegmentUpdater);
-
- int offset= 0;
- Position[] fragments= getFragments();
- for (int i= 0; i < fragments.length; i++) {
- Fragment fragment= (Fragment) fragments[i];
- Segment segment= new Segment(offset, fragment.getLength());
- segment.fragment= fragment;
- addPosition(fSegmentsCategory, segment);
- offset += fragment.length;
- }
-
- } catch (BadPositionCategoryException x) {
- internalError();
- } catch (BadLocationException x) {
- internalError();
- }
- }
-
- private Segment createSegmentFor(Fragment fragment, int index) throws BadLocationException, BadPositionCategoryException {
-
- int offset= 0;
- if (index > 0) {
- Position[] segments= getSegments();
- Segment segment= (Segment) segments[index - 1];
- offset= segment.getOffset() + segment.getLength();
- }
-
- Segment segment= new Segment(offset, 0);
- segment.fragment= fragment;
- fragment.segment= segment;
- addPosition(fSegmentsCategory, segment);
- return segment;
- }
-
- /**
- * Adds the given range of the master document to this projection document.
- *
- * @param offsetInMaster offset of the master document range
- * @param lengthInMaster length of the master document range
- * @throws BadLocationException if the given range is invalid in the master document
- */
- private void internalAddMasterDocumentRange(int offsetInMaster, int lengthInMaster) throws BadLocationException {
-
- if (lengthInMaster == 0)
- return;
-
- try {
-
- Position[] fragments= getFragments();
- int index= fMasterDocument.computeIndexInCategory(fFragmentsCategory, offsetInMaster);
-
- Fragment left= null;
- Fragment right= null;
-
- if (index < fragments.length) {
- if (offsetInMaster == fragments[index].offset)
- throw new IllegalArgumentException("overlaps with existing fragment");
- if (offsetInMaster + lengthInMaster == fragments[index].offset)
- right= (Fragment) fragments[index];
- }
-
- if (0 < index && index <= fragments.length) {
- Fragment fragment= (Fragment) fragments[index - 1];
- if (fragment.includes(offsetInMaster))
- throw new IllegalArgumentException("overlaps with existing fragment");
- if (fragment.getOffset() + fragment.getLength() == offsetInMaster)
- left= fragment;
- }
-
- int offsetInSlave= 0;
- if (index > 0) {
- Fragment fragment= (Fragment) fragments[index - 1];
- Segment segment= fragment.segment;
- offsetInSlave= segment.getOffset() + segment.getLength();
- }
-
- ProjectionDocumentEvent event= new ProjectionDocumentEvent(this, offsetInSlave, 0, fMasterDocument.get(offsetInMaster, lengthInMaster));
- super.fireDocumentAboutToBeChanged(event);
-
- // check for neighboring fragment
- if (left != null && right != null) {
-
- int endOffset= right.getOffset() + right.getLength();
- left.setLength(endOffset - left.getOffset());
- left.segment.setLength(left.segment.getLength() + right.segment.getLength());
-
- removePosition(fSegmentsCategory, right.segment);
- fMasterDocument.removePosition(fFragmentsCategory, right);
-
- } else if (left != null) {
- int endOffset= offsetInMaster +lengthInMaster;
- left.setLength(endOffset - left.getOffset());
- left.segment.markForStretch();
-
- } else if (right != null) {
- right.setOffset(right.getOffset() - lengthInMaster);
- right.setLength(right.getLength() + lengthInMaster);
- right.segment.markForStretch();
-
- } else {
- // create a new segment
- Fragment fragment= new Fragment(offsetInMaster, lengthInMaster);
- fMasterDocument.addPosition(fFragmentsCategory, fragment);
- Segment segment= createSegmentFor(fragment, index);
- segment.markForStretch();
- }
-
- getTracker().replace(event.getOffset(), event.getLength(), event.getText());
- super.fireDocumentChanged(event);
-
- } catch (BadPositionCategoryException x) {
- internalError();
- }
- }
-
- /**
- * Finds the fragment of the master document that represents the given range.
- *
- * @param offsetInMaster the offset of the range in the master document
- * @param lengthInMaster the length of the range in the master document
- * @return the fragment representing the given master document range
- */
- private Fragment findFragment(int offsetInMaster, int lengthInMaster) {
- Position[] fragments= getFragments();
- for (int i= 0; i < fragments.length; i++) {
- Fragment f= (Fragment) fragments[i];
- if (f.getOffset() <= offsetInMaster && offsetInMaster + lengthInMaster <= f.getOffset() + f.getLength())
- return f;
- }
- return null;
- }
-
- /**
- * Removes the given range of the master document from this projection
- * document.
- *
- * @param offsetInMaster the offset of the range in the master document
- * @param lengthInMaster the length of the range in the master document
- *
- * @throws BadLocationException if the given range is not valid in the
- * master document
- * @throws IllegalArgumentException if the given range is not projected in
- * this projection document or is not completely comprised by
- * an existing fragment
- */
- private void internalRemoveMasterDocumentRange(int offsetInMaster, int lengthInMaster) throws BadLocationException {
- try {
-
- IRegion imageRegion= fMapping.toExactImageRegion(new Region(offsetInMaster, lengthInMaster));
- if (imageRegion == null)
- throw new IllegalArgumentException();
-
- Fragment fragment= findFragment(offsetInMaster, lengthInMaster);
- if (fragment == null)
- throw new IllegalArgumentException();
-
- ProjectionDocumentEvent event= new ProjectionDocumentEvent(this, imageRegion.getOffset(), imageRegion.getLength(), null);
- super.fireDocumentAboutToBeChanged(event);
-
- if (fragment.getOffset() == offsetInMaster) {
- fragment.setOffset(offsetInMaster + lengthInMaster);
- fragment.setLength(fragment.getLength() - lengthInMaster);
- } else if (fragment.getOffset() + fragment.getLength() == offsetInMaster + lengthInMaster) {
- fragment.setLength(fragment.getLength() - lengthInMaster);
- } else {
- // split fragment into three fragments, let position updater remove it
-
- // add fragment for the region to be removed
- Fragment newFragment= new Fragment(offsetInMaster, lengthInMaster);
- Segment segment= new Segment(imageRegion.getOffset(), imageRegion.getLength());
- newFragment.segment= segment;
- segment.fragment= newFragment;
- fMasterDocument.addPosition(fFragmentsCategory, newFragment);
- addPosition(fSegmentsCategory, segment);
-
- // add fragment for the remainder right of the deleted range in the original fragment
- int offset= offsetInMaster + lengthInMaster;
- newFragment= new Fragment(offset, fragment.getOffset() + fragment.getLength() - offset);
- offset= imageRegion.getOffset() + imageRegion.getLength();
- segment= new Segment(offset, fragment.segment.getOffset() + fragment.segment.getLength() - offset);
- newFragment.segment= segment;
- segment.fragment= newFragment;
- fMasterDocument.addPosition(fFragmentsCategory, newFragment);
- addPosition(fSegmentsCategory, segment);
-
- // adjust length of initial fragment (the left one)
- fragment.setLength(offsetInMaster - fragment.getOffset());
- fragment.segment.setLength(imageRegion.getOffset() - fragment.segment.getOffset());
- }
-
- getTracker().replace(event.getOffset(), event.getLength(), event.getText());
- super.fireDocumentChanged(event);
-
- } catch (BadPositionCategoryException x) {
- internalError();
- }
- }
-
- private IRegion[] computeUnprojectedMasterRegions(int offsetInMaster, int lengthInMaster) throws BadLocationException {
-
- IRegion[] fragments= null;
- IRegion imageRegion= fMapping.toImageRegion(new Region(offsetInMaster, lengthInMaster));
- if (imageRegion != null)
- fragments= fMapping.toExactOriginRegions(imageRegion);
-
- if (fragments == null || fragments.length == 0)
- return new IRegion[] { new Region(offsetInMaster, lengthInMaster) };
-
- List gaps= new ArrayList();
-
- IRegion region= fragments[0];
- if (offsetInMaster < region.getOffset())
- gaps.add(new Region(offsetInMaster, region.getOffset() - offsetInMaster));
-
- for (int i= 0; i < fragments.length - 1; i++) {
- IRegion left= fragments[i];
- IRegion right= fragments[i + 1];
- int leftEnd= left.getOffset() + left.getLength();
- if (leftEnd < right.getOffset())
- gaps.add(new Region(leftEnd, right.getOffset() - leftEnd));
- }
-
- region= fragments[fragments.length - 1];
- int leftEnd= region.getOffset() + region.getLength();
- int rightEnd= offsetInMaster + lengthInMaster;
- if (leftEnd < rightEnd)
- gaps.add(new Region(leftEnd, rightEnd - leftEnd));
-
- IRegion[] result= new IRegion[gaps.size()];
- gaps.toArray(result);
- return result;
- }
-
- /**
- * Ensures that the given range of the master document is part of this
- * projection document.
- *
- * @param offsetInMaster the offset of the master document range
- * @param lengthInMaster the length of the master document range
- */
- public void addMasterDocumentRange(int offsetInMaster, int lengthInMaster) throws BadLocationException {
-
- IRegion[] gaps= computeUnprojectedMasterRegions(offsetInMaster, lengthInMaster);
- if (gaps == null)
- return;
-
- for (int i= 0; i < gaps.length; i++) {
- IRegion gap= gaps[i];
- internalAddMasterDocumentRange(gap.getOffset(), gap.getLength());
- }
- }
-
- /**
- * Ensures that the given range of the master document is not part of this
- * projection document.
- *
- * @param offsetInMaster the offset of the master document range
- * @param lengthInMaster the length of the master document range
- */
- public void removeMasterDocumentRange(int offsetInMaster, int lengthInMaster) throws BadLocationException {
-
- IRegion[] fragments= null;
- IRegion imageRegion= fMapping.toImageRegion(new Region(offsetInMaster, lengthInMaster));
- if (imageRegion != null)
- fragments= fMapping.toExactOriginRegions(imageRegion);
-
- if (fragments == null || fragments.length == 0)
- return;
-
- for (int i= 0; i < fragments.length; i++) {
- IRegion fragment= fragments[i];
- internalRemoveMasterDocumentRange(fragment.getOffset(), fragment.getLength());
- }
- }
-
- /**
- * Returns whether this project is being updated.
- *
- * @return <code>true</code> if the document is updating
- */
- protected boolean isUpdating() {
- return fIsUpdating;
- }
-
- /*
- * @see org.eclipse.jface.text.IDocument#replace(int, int, java.lang.String)
- */
- public void replace(int offset, int length, String text) throws BadLocationException {
- try {
- fIsUpdating= true;
- if (fMasterDocumentExtension != null)
- fMasterDocumentExtension.stopPostNotificationProcessing();
-
- super.replace(offset, length, text);
-
- } finally {
- fIsUpdating= false;
- if (fMasterDocumentExtension != null)
- fMasterDocumentExtension.resumePostNotificationProcessing();
- }
- }
-
- /*
- * @see org.eclipse.jface.text.IDocument#set(java.lang.String)
- */
- public void set(String text) {
- try {
- fIsUpdating= true;
- if (fMasterDocumentExtension != null)
- fMasterDocumentExtension.stopPostNotificationProcessing();
-
- super.set(text);
-
- } finally {
- fIsUpdating= false;
- if (fMasterDocumentExtension != null)
- fMasterDocumentExtension.resumePostNotificationProcessing();
- }
- }
-
- /**
- * Transforms a document event of the master document into a projection
- * document based document event.
- *
- * @param masterEvent the master document event
- * @return the slave document event
- */
- private ProjectionDocumentEvent normalize(DocumentEvent masterEvent) throws BadLocationException {
- if (!isUpdating()) {
- IRegion imageRegion= fMapping.toExactImageRegion(new Region(masterEvent.getOffset(), masterEvent.getLength()));
- if (imageRegion != null)
- return new ProjectionDocumentEvent(this, imageRegion.getOffset(), imageRegion.getLength(), masterEvent.getText(), masterEvent);
- return null;
- } else {
- ProjectionDocumentEvent event= new ProjectionDocumentEvent(this, fOriginalEvent.getOffset(), fOriginalEvent.getLength(), fOriginalEvent.getText(), masterEvent);
- fOriginalEvent= null;
- return event;
- }
- }
-
- private boolean includes(IRegion region, int offset) {
- if (region == null)
- return false;
- return region.getOffset() <= offset && offset <= region.getOffset() + region.getLength();
- }
-
- private boolean includes(IRegion region1, int offset, int length) {
- if (region1 == null)
- return false;
- return region1.getOffset() <= offset && (offset + length <= region1.getOffset() + region1.getLength());
- }
-
- /**
- * Compute the gaps that must be covered in order to ensure that the range affected
- * by the given document event is completely projected.
- *
- * @param event the master document event
- * @return the gaps to be covered
- */
- private IRegion[] computeCoverageGap(DocumentEvent event) {
-
- IRegion left= null;
- List gaps= new ArrayList();
-
- try {
- // deal with the beginning of the event region
- int imageOffset= fMapping.toImageOffset(event.getOffset());
- if (imageOffset == -1) {
- Position[] fragments= getFragments();
- int index= fMasterDocument.computeIndexInCategory(fFragmentsCategory, event.getOffset());
- if (index < fragments.length) {
- Fragment fragment= (Fragment) fragments[index];
- left= new Region(event.getOffset(), fragment.getOffset() - event.getOffset());
- gaps.add(left);
- }
- }
-
- // the event itself
- if (!includes(left, event.getOffset(), event.getLength()))
- gaps.add(new Region(event.getOffset(), event.getLength()));
-
- // deal with the end of the event region
- int inclusiveOriginEndOffset= event.getOffset() + Math.max(0, event.getLength() - 1);
- int inclusiveImageEndOffset= fMapping.toImageOffset(inclusiveOriginEndOffset);
- if (inclusiveImageEndOffset == -1 && !includes(left, inclusiveOriginEndOffset)) {
- int index= fMasterDocument.computeIndexInCategory(fFragmentsCategory, inclusiveOriginEndOffset);
- if (0 < index) {
- Position[] fragments= getFragments();
- Fragment fragment= (Fragment) fragments[index - 1];
- gaps.add(new Region(fragment.getOffset(), inclusiveOriginEndOffset + 1 - fragment.getOffset()));
- }
- }
-
- } catch (BadLocationException e) {
- internalError();
- } catch (BadPositionCategoryException e) {
- internalError();
- }
-
- IRegion[] result= new IRegion[gaps.size()];
- gaps.toArray(result);
- return result;
- }
-
- /**
- * Ensures that when the master event effects this projection document, that the whole region described by the
- * event is part of this projection document.
- *
- * @param masterEvent the master document event
- * @return <code>true</code> if masterEvent affects this projection document
- * @throws BadLocationException in case the master event is not valid
- */
- protected final boolean adaptProjectionToMasterChange(DocumentEvent masterEvent) throws BadLocationException {
- if (!isUpdating() && fFragmentsUpdater.affectsPositions(masterEvent) || fIsAutoExpanding) {
-
- IRegion[] gaps= computeCoverageGap(masterEvent);
- for (int i= 0; i < gaps.length; i++) {
- IRegion gap= gaps[i];
- addMasterDocumentRange(gap.getOffset(), gap.getLength());
- }
- return true;
-
- } else if (fMapping.getImageLength() == 0 && masterEvent.getLength() == 0) {
-
- // there is no segment in this projection document, thus one must be created
- // need to bypass the usual infrastructure as the new segment/fragment would be of length 0 and thus the segmentation be not well formed
-
- try {
- Fragment fragment= new Fragment(0, 0);
- fMasterDocument.addPosition(fFragmentsCategory, fragment);
- createSegmentFor(fragment, 0);
- } catch (BadPositionCategoryException x) {
- internalError();
- }
- }
-
- return isUpdating();
- }
-
- /**
- * When called, this projection document is informed about a forthcoming
- * change of its master document. This projection document checks whether
- * the master document change affects it and if so informs all document
- * listeners.
- *
- * @param masterEvent the master document event
- */
- public void masterDocumentAboutToBeChanged(DocumentEvent masterEvent) {
- try {
-
- boolean assertNotNull= adaptProjectionToMasterChange(masterEvent);
- fSlaveEvent= normalize(masterEvent);
- if (assertNotNull && fSlaveEvent == null)
- internalError();
-
- fMasterEvent= masterEvent;
- if (fSlaveEvent != null)
- delayedFireDocumentAboutToBeChanged();
-
- } catch (BadLocationException e) {
- internalError();
- }
- }
-
- /**
- * When called, this projection document is informed about a change of its
- * master document. If this projection document is affected it informs all
- * of its document listeners.
- *
- * @param masterEvent the master document event
- */
- public void masterDocumentChanged(DocumentEvent masterEvent) {
- if ( !isUpdating() && masterEvent == fMasterEvent) {
- if (fSlaveEvent != null) {
- try {
- getTracker().replace(fSlaveEvent.getOffset(), fSlaveEvent.getLength(), fSlaveEvent.getText());
- fireDocumentChanged(fSlaveEvent);
- } catch (BadLocationException e) {
- internalError();
- }
- } else {
- ensureWellFormedSegmentation();
- }
- }
- }
-
- /*
- * @see org.eclipse.jface.text.AbstractDocument#fireDocumentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent)
- */
- protected void fireDocumentAboutToBeChanged(DocumentEvent event) {
- fOriginalEvent= event;
- // delay it until there is a notification from the master document
- // at this point, it is expensive to construct the master document information
- }
-
- /**
- * Fires the slave document event as about-to-be-changed event to all registered listeners.
- */
- private void delayedFireDocumentAboutToBeChanged() {
- super.fireDocumentAboutToBeChanged(fSlaveEvent);
- }
-
- /**
- * Ignores the given event and sends the semantically equal slave document event instead.
- *
- * @param event the event to be ignored
- */
- protected void fireDocumentChanged(DocumentEvent event) {
- super.fireDocumentChanged(fSlaveEvent);
- }
-
- /*
- * @see org.eclipse.jface.text.AbstractDocument#updateDocumentStructures(org.eclipse.jface.text.DocumentEvent)
- */
- protected void updateDocumentStructures(DocumentEvent event) {
- super.updateDocumentStructures(event);
- ensureWellFormedSegmentation();
- }
-
- private void ensureWellFormedSegmentation() {
- Position[] segments= getSegments();
- for (int i= 0; i < segments.length; i++) {
- Segment segment= (Segment) segments[i];
- if (segment.isDeleted()) {
- try {
- removePosition(fSegmentsCategory, segment);
- fMasterDocument.removePosition(fFragmentsCategory, segment.fragment);
- } catch (BadPositionCategoryException e) {
- internalError();
- }
- } else if (i < segments.length - 1) {
- Segment next= (Segment) segments[i + 1];
- if (next.isDeleted())
- continue;
- Fragment fragment= segment.fragment;
- if (fragment.getOffset() + fragment.getLength() == next.fragment.getOffset()) {
- // join fragments and their corresponding segments
- segment.setLength(segment.getLength() + next.getLength());
- fragment.setLength(fragment.getLength() + next.fragment.getLength());
- next.delete();
- }
- }
- }
- }
-
- /*
- * @see IDocumentExtension#registerPostNotificationReplace(IDocumentListener, IDocumentExtension.IReplace)
- */
- public void registerPostNotificationReplace(IDocumentListener owner, IDocumentExtension.IReplace replace) {
- if (!isUpdating())
- throw new UnsupportedOperationException();
- super.registerPostNotificationReplace(owner, replace);
- }
-
- /**
- * Sets the auto expand mode for this document.
- */
- public void setAutoExpandMode(boolean autoExpandMode) {
- fIsAutoExpanding= autoExpandMode;
- }
-
- /**
- * Replaces all master document ranges with the given master document range.
- *
- * @param offsetInMaster the offset in the master document
- * @param lengthInMaster the length in the master document
- * @throws BadLocationException if the given range of the master document is not valid
- */
- public void replaceMasterDocumentRanges(int offsetInMaster, int lengthInMaster) throws BadLocationException {
- try {
-
- ProjectionDocumentEvent event= new ProjectionDocumentEvent(this, 0, fMapping.getImageLength(), fMasterDocument.get(offsetInMaster, lengthInMaster));
- super.fireDocumentAboutToBeChanged(event);
-
- Position[] fragments= getFragments();
- for (int i= 0; i < fragments.length; i++) {
- Fragment fragment= (Fragment) fragments[i];
- fMasterDocument.removePosition(fFragmentsCategory, fragment);
- removePosition(fSegmentsCategory, fragment.segment);
- }
-
- Fragment fragment= new Fragment(offsetInMaster, lengthInMaster);
- Segment segment= new Segment(0, 0);
- segment.fragment= fragment;
- fragment.segment= segment;
- fMasterDocument.addPosition(fFragmentsCategory, fragment);
- addPosition(fSegmentsCategory, segment);
-
- getTracker().set(fMasterDocument.get(offsetInMaster, lengthInMaster));
- super.fireDocumentChanged(event);
-
- } catch (BadPositionCategoryException x) {
- internalError();
- }
- }
-}
diff --git a/org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionDocumentEvent.java b/org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionDocumentEvent.java
deleted file mode 100644
index f443d51..0000000
--- a/org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionDocumentEvent.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.projection;
-
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.SlaveDocumentEvent;
-
-/**
- * Internal class. Do not use. Only public for testing purposes.
- *
- * @since 3.0
- */
-public class ProjectionDocumentEvent extends SlaveDocumentEvent {
-
- public final static Object PROJECTION_CHANGE= new Object();
- public final static Object CONTENT_CHANGE= new Object();
-
- private Object fChangeType;
-
- public ProjectionDocumentEvent(IDocument doc, int offset, int length, String text, DocumentEvent masterEvent) {
- super(doc, offset, length, text, masterEvent);
- fChangeType= CONTENT_CHANGE;
- }
-
- public ProjectionDocumentEvent(IDocument doc, int offset, int length, String text) {
- super(doc, offset, length, text, null);
- fChangeType= PROJECTION_CHANGE;
- }
-
- public Object getChangeType() {
- return fChangeType;
- }
-}
diff --git a/org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionDocumentManager.java b/org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionDocumentManager.java
deleted file mode 100644
index 9e6bbc8..0000000
--- a/org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionDocumentManager.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.projection;
-
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentInformationMapping;
-import org.eclipse.jface.text.IDocumentListener;
-import org.eclipse.jface.text.ISlaveDocumentManager;
-import org.eclipse.jface.text.ISlaveDocumentManagerExtension;
-
-
-
-/**
- * <code>ProjectionDocumentManager</code> is one particular implementation of
- * <code>ISlaveDocumentManager</code>. This manager creates so called
- * projection documents as slave documents for given master documents.
- * <p>
- * A projection document represents a particular projection of the master
- * document and is accordingly adapted to changes of the master document. Vice
- * versa, the master document is accordingly adapted to changes of its slave
- * documents. The manager does not maintain any particular management structure
- * but utilizes mechanisms given by <code>IDocument</code> such as position
- * categories and position updaters.
- * <p>
- * API in progress. Do not yet use.
- *
- * @since 3.0
- */
-public class ProjectionDocumentManager implements IDocumentListener, ISlaveDocumentManager, ISlaveDocumentManagerExtension {
-
- /** Registry for master documents and their projection documents. */
- private Map fProjectionRegistry= new HashMap();
-
- /**
- * Registers the given projection document for the given master document.
- *
- * @param master the master document
- * @param projection the projection document
- */
- private void add(IDocument master, ProjectionDocument projection) {
- List list= (List) fProjectionRegistry.get(master);
- if (list == null) {
- list= new ArrayList(1);
- fProjectionRegistry.put(master, list);
- }
- list.add(projection);
- }
-
- /**
- * Unregisters the given projection document from its master.
- *
- * @param master the master document
- * @param projection the projection document
- */
- private void remove(IDocument master, ProjectionDocument projection) {
- List list= (List) fProjectionRegistry.get(master);
- if (list != null) {
- list.remove(projection);
- if (list.size() == 0)
- fProjectionRegistry.remove(master);
- }
- }
-
- /**
- * Returns whether the given document is a master document.
- *
- * @param master the document
- * @return <code>true</code> if the given document is a master document known to this manager
- */
- private boolean hasProjection(IDocument master) {
- return (fProjectionRegistry.get(master) instanceof List);
- }
-
- /**
- * Returns an iterator enumerating all projection documents registered for the given document or
- * <code>null</code> if the document is not a known master document.
- *
- * @param master the document
- * @return an iterator for all registered projection documents or <code>null</code>
- */
- private Iterator getProjectionsIterator(IDocument master) {
- List list= (List) fProjectionRegistry.get(master);
- if (list != null)
- return list.iterator();
- return null;
- }
-
- /**
- * Informs all projection documents of the master document that issued the given document event.
- *
- * @param about indicates whether the change is about to happen or happened already
- * @param masterEvent the document event which will be processed to inform the projection documents
- */
- protected void fireDocumentEvent(boolean about, DocumentEvent masterEvent) {
- IDocument master= masterEvent.getDocument();
- Iterator e= getProjectionsIterator(master);
- if (e == null)
- return;
-
- while (e.hasNext()) {
- ProjectionDocument document= (ProjectionDocument) e.next();
- if (about)
- document.masterDocumentAboutToBeChanged(masterEvent);
- else
- document.masterDocumentChanged(masterEvent);
- }
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentListener#documentChanged(org.eclipse.jface.text.DocumentEvent)
- */
- public void documentChanged(DocumentEvent event) {
- fireDocumentEvent(false, event);
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentListener#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent)
- */
- public void documentAboutToBeChanged(DocumentEvent event) {
- fireDocumentEvent(true, event);
- }
-
- /*
- * @see org.eclipse.jface.text.ISlaveDocumentManager#createMasterSlaveMapping(org.eclipse.jface.text.IDocument)
- */
- public IDocumentInformationMapping createMasterSlaveMapping(IDocument slave) {
- if (slave instanceof ProjectionDocument) {
- ProjectionDocument projectionDocument= (ProjectionDocument) slave;
- return projectionDocument.getProjectionMapping();
- }
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.ISlaveDocumentManager#createSlaveDocument(org.eclipse.jface.text.IDocument)
- */
- public IDocument createSlaveDocument(IDocument master) {
- if (!hasProjection(master))
- master.addDocumentListener(this);
- ProjectionDocument slave= createProjectionDocument(master);
- add(master, slave);
- return slave;
- }
-
- /**
- * Factory method for projection documents.
- *
- * @param master the master document
- * @return the newly created projection document
- */
- protected ProjectionDocument createProjectionDocument(IDocument master) {
- return new ProjectionDocument(master);
- }
-
- /*
- * @see org.eclipse.jface.text.ISlaveDocumentManager#freeSlaveDocument(org.eclipse.jface.text.IDocument)
- */
- public void freeSlaveDocument(IDocument slave) {
- if (slave instanceof ProjectionDocument) {
- ProjectionDocument projectionDocument= (ProjectionDocument) slave;
- IDocument master= projectionDocument.getMasterDocument();
- remove(master, projectionDocument);
- projectionDocument.dispose();
- if (!hasProjection(master))
- master.removeDocumentListener(this);
- }
- }
-
- /*
- * @see org.eclipse.jface.text.ISlaveDocumentManager#getMasterDocument(org.eclipse.jface.text.IDocument)
- */
- public IDocument getMasterDocument(IDocument slave) {
- if (slave instanceof ProjectionDocument)
- return ((ProjectionDocument) slave).getMasterDocument();
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.ISlaveDocumentManager#isSlaveDocument(org.eclipse.jface.text.IDocument)
- */
- public boolean isSlaveDocument(IDocument document) {
- return (document instanceof ProjectionDocument);
- }
-
- /*
- * @see org.eclipse.jface.text.ISlaveDocumentManager#setAutoExpandMode(org.eclipse.jface.text.IDocument, boolean)
- */
- public void setAutoExpandMode(IDocument slave, boolean autoExpanding) {
- if (slave instanceof ProjectionDocument)
- ((ProjectionDocument) slave).setAutoExpandMode(autoExpanding);
- }
-
- /*
- * @see org.eclipse.jface.text.ISlaveDocumentManagerExtension#getSlaveDocuments(org.eclipse.jface.text.IDocument)
- */
- public IDocument[] getSlaveDocuments(IDocument master) {
- List list= (List) fProjectionRegistry.get(master);
- if (list != null) {
- IDocument[] result= new IDocument[list.size()];
- list.toArray(result);
- return result;
- }
- return null;
- }
-}
diff --git a/org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionMapping.java b/org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionMapping.java
deleted file mode 100644
index 07ca37d..0000000
--- a/org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionMapping.java
+++ /dev/null
@@ -1,467 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.projection;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentInformationMapping;
-import org.eclipse.jface.text.IDocumentInformationMappingExtension;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.Region;
-
-/**
- * Internal class. Do not use. Only public for testing purposes.
- * <p>
- * Implementation of <code>IDocumentInformationMapping</code> for the
- * projection mapping between a master and a slave document.
- *
- * @since 3.0
- */
-public class ProjectionMapping implements IDocumentInformationMapping , IDocumentInformationMappingExtension, IMinimalMapping {
-
- private static final int LEFT= -1;
- private static final int NONE= 0;
- private static final int RIGHT= +1;
-
- /** The master document */
- private IDocument fMasterDocument;
- /** The position category used to manage the projection fragments inside the master document */
- private String fFragmentsCategory;
- /** The projection document */
- private IDocument fSlaveDocument;
- /** The position category to manage the projection segments inside the slave document. */
- private String fSegmentsCategory;
-
-
- /**
- * Creates a new mapping between the given parent document and the given projection document.
- *
- * @param masterDocument the master document
- * @param fragmentsCategory the position category of the parent document used to manage the projected regions
- * @param slaveDocument the slave document
- * @param segmentsCategory the position category of the projection document used to manage the fragments
- */
- public ProjectionMapping(IDocument masterDocument, String fragmentsCategory, IDocument slaveDocument, String segmentsCategory) {
- fMasterDocument= masterDocument;
- fFragmentsCategory= fragmentsCategory;
- fSlaveDocument= slaveDocument;
- fSegmentsCategory= segmentsCategory;
- }
-
- private Position[] getSegments() {
- try {
- return fSlaveDocument.getPositions(fSegmentsCategory);
- } catch (BadPositionCategoryException e) {
- }
-
- return new Position[0];
- }
-
- private Position[] getFragments() {
- try {
- return fMasterDocument.getPositions(fFragmentsCategory);
- } catch (BadPositionCategoryException e) {
- }
-
- return new Position[0];
- }
-
- private int findSegmentIndex(int offset) throws BadLocationException {
- Position[] segments= getSegments();
- if (segments.length == 0) {
- if (offset > 0)
- throw new BadLocationException();
- return -1;
- }
-
- try {
- int index= fSlaveDocument.computeIndexInCategory(fSegmentsCategory, offset);
- if (index == segments.length && offset > (segments[index-1].offset + segments[index-1].length))
- throw new BadLocationException();
-
- if (index < segments.length && offset == segments[index].offset)
- return index;
-
- if (index > 0)
- index--;
-
- return index;
-
- } catch (BadPositionCategoryException e) {
- throw new IllegalStateException();
- }
- }
-
- private Segment findSegment(int offset) throws BadLocationException {
-
- if (offset < 0 || getImageLength() < offset)
- throw new BadLocationException();
-
- int index= findSegmentIndex(offset);
- if (index == -1) {
-
- Segment s= new Segment(0, 0);
- Fragment f= new Fragment(0, 0);
- s.fragment= f;
- f.segment= s;
- return s;
- }
-
- Position[] segments= getSegments();
- return (Segment) segments[index];
- }
-
- private int findFragmentIndex(int offset, int extensionDirection) throws BadLocationException {
- try {
-
- Position[] fragments= getFragments();
- if (fragments.length == 0)
- return -1;
-
- int index= fMasterDocument.computeIndexInCategory(fFragmentsCategory, offset);
-
- if (index < fragments.length && offset == fragments[index].offset)
- return index;
-
- if (0 < index && index <= fragments.length && fragments[index - 1].includes(offset))
- return index - 1;
-
- switch(extensionDirection) {
- case LEFT:
- return Math.max(index - 1, 0);
- case RIGHT:
- return Math.min(index, fragments.length - 1);
- }
-
- return -1;
-
- } catch (BadPositionCategoryException e) {
- throw new IllegalStateException();
- }
- }
-
- private Fragment findFragment(int offset) throws BadLocationException {
-
- int length= fMasterDocument.getLength();
- if (offset < 0 || length < offset)
- throw new BadLocationException();
-
- int index= findFragmentIndex(offset, NONE);
- Position[] fragments= getFragments();
- if (index == -1) {
- if (fragments.length > 0) {
- Fragment last= (Fragment) fragments[fragments.length - 1];
- if (last.getOffset() + last.getLength() == offset)
- return last;
- }
- return null;
- }
- return (Fragment) fragments[index];
- }
-
- private Fragment[] findFragments(IRegion region, boolean exact) throws BadLocationException {
- int offset= region.getOffset();
- if (offset < 0 || fMasterDocument.getLength() < offset)
- throw new BadLocationException();
-
- int inclusiveEndOffset= region.getOffset() + region.getLength() - 1;
- if (inclusiveEndOffset < 0 || fMasterDocument.getLength() < inclusiveEndOffset)
- throw new BadLocationException();
-
- int startIndex= findFragmentIndex(offset, exact ? NONE : LEFT);
- if (startIndex == -1)
- return new Fragment[0];
-
- int endIndex= findFragmentIndex(inclusiveEndOffset, exact ? NONE : RIGHT);
- if (endIndex == -1)
- return new Fragment[0];
-
- Position[] fragments= getFragments();
- while (startIndex <= endIndex && !fragments[startIndex].overlapsWith(region.getOffset(), region.getLength()))
- ++startIndex;
-
- while (endIndex >= startIndex && !fragments[endIndex].overlapsWith(region.getOffset(), region.getLength()))
- --endIndex;
-
- int length= Math.max(0, endIndex - startIndex + 1);
- Fragment[] result= new Fragment[length];
- for (int i= 0; i < length; i++)
- result[i]= (Fragment) fragments[startIndex + i];
- return result;
- }
-
- private IRegion toImageRegion(IRegion originRegion, boolean exact) throws BadLocationException {
- if (originRegion.getLength() == 0) {
- int imageOffset= toImageOffset(originRegion.getOffset());
- return imageOffset == -1 ? null : new Region(imageOffset, 0);
- }
-
- Fragment[] fragments= findFragments(originRegion, exact);
- if (fragments.length > 0) {
-
- // translate start offset
- Fragment fragment= fragments[0];
- int originOffset= originRegion.getOffset();
- int relative= originOffset - fragment.getOffset();
- if (relative < 0) {
- Assert.isTrue(!exact);
- relative= 0;
- }
- int imageOffset= fragment.segment.getOffset() + relative;
-
- // translate end offset
- fragment= fragments[fragments.length - 1];
- int exclusiveOriginEndOffset= originRegion.getOffset() + originRegion.getLength();
- relative= exclusiveOriginEndOffset - fragment.getOffset();
- if (relative > fragment.getLength()) {
- Assert.isTrue(!exact);
- int delta= relative - fragment.getLength();
- relative -= delta;
- }
- int exclusiveImageEndOffset= fragment.segment.getOffset() + relative;
-
- return new Region(imageOffset, exclusiveImageEndOffset - imageOffset);
- }
-
- return null;
- }
-
- private IRegion createOriginStartRegion(Segment original, int offsetShift) {
- return new Region(original.fragment.getOffset() + offsetShift, original.fragment.getLength() - offsetShift);
- }
-
- private IRegion createOriginRegion(Segment origin) {
- return new Region(origin.fragment.getOffset(), origin.fragment.getLength());
- }
-
- private IRegion createOriginEndRegion(Segment original, int lengthReduction) {
- return new Region(original.fragment.getOffset(), original.fragment.getLength() - lengthReduction);
- }
-
- private IRegion getIntersectingRegion(IRegion left, IRegion right) {
- int offset= Math.max(left.getOffset(), right.getOffset());
- int exclusiveEndOffset= Math.min(left.getOffset() + left.getLength(), right.getOffset() + right.getLength());
- if (exclusiveEndOffset < offset)
- return null;
- return new Region(offset, exclusiveEndOffset - offset);
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentInformationMapping#getCoverage()
- */
- public IRegion getCoverage() {
- Position[] fragments= getFragments();
- if (fragments != null && fragments.length > 0) {
- Position first=fragments[0];
- Position last= fragments[fragments.length -1];
- return new Region(first.offset, (last.offset + last.length) - first.offset);
- }
- return new Region(0, 0);
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentInformationMapping#toOriginOffset(int)
- */
- public int toOriginOffset(int imageOffset) throws BadLocationException {
- Segment segment= findSegment(imageOffset);
- int relative= imageOffset - segment.offset;
- return segment.fragment.offset + relative;
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentInformationMapping#toOriginRegion(org.eclipse.jface.text.IRegion)
- */
- public IRegion toOriginRegion(IRegion imageRegion) throws BadLocationException {
- int imageOffset= imageRegion.getOffset();
- int imageLength= imageRegion.getLength();
-
- if (imageLength == 0) {
- if (imageOffset == 0 && getImageLength() == 0)
- return new Region(0, fMasterDocument.getLength());
- return new Region(toOriginOffset(imageOffset), 0);
- }
-
- int originOffset= toOriginOffset(imageOffset);
- int inclusiveImageEndOffset= imageOffset + imageLength -1;
- int inclusiveOriginEndOffset= toOriginOffset(inclusiveImageEndOffset);
-
- return new Region(originOffset, (inclusiveOriginEndOffset + 1) - originOffset);
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentInformationMapping#toOriginLines(int)
- */
- public IRegion toOriginLines(int imageLine) throws BadLocationException {
- IRegion imageRegion= fSlaveDocument.getLineInformation(imageLine);
- IRegion originRegion= toOriginRegion(imageRegion);
-
- int originStartLine= fMasterDocument.getLineOfOffset(originRegion.getOffset());
- if (originRegion.getLength() == 0)
- return new Region(originStartLine, 1);
-
- int inclusiveOriginEndOffset= originRegion.getOffset() + originRegion.getLength() -1;
- int originEndLine= fMasterDocument.getLineOfOffset(inclusiveOriginEndOffset);
- return new Region(originStartLine, (originEndLine + 1) - originStartLine);
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentInformationMapping#toOriginLine(int)
- */
- public int toOriginLine(int imageLine) throws BadLocationException {
- IRegion lines= toOriginLines(imageLine);
- return (lines.getLength() > 1 ? -1 : lines.getOffset());
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentInformationMapping#toImageOffset(int)
- */
- public int toImageOffset(int originOffset) throws BadLocationException {
- Fragment fragment= findFragment(originOffset);
- if (fragment != null) {
- int relative= originOffset - fragment.offset;
- return fragment.segment.offset + relative;
- }
- return -1;
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentInformationMappingExtension#toExactImageRegion(org.eclipse.jface.text.IRegion)
- */
- public IRegion toExactImageRegion(IRegion originRegion) throws BadLocationException {
- return toImageRegion(originRegion, true);
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentInformationMapping#toImageRegion(org.eclipse.jface.text.IRegion)
- */
- public IRegion toImageRegion(IRegion originRegion) throws BadLocationException {
- return toImageRegion(originRegion, false);
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentInformationMapping#toImageLine(int)
- */
- public int toImageLine(int originLine) throws BadLocationException {
- IRegion originRegion= fMasterDocument.getLineInformation(originLine);
- IRegion imageRegion= toImageRegion(originRegion);
- if (imageRegion == null) {
- int imageOffset= toImageOffset(originRegion.getOffset());
- if (imageOffset > -1)
- imageRegion= new Region(imageOffset, 0);
- else
- return -1;
- }
-
- int startLine= fSlaveDocument.getLineOfOffset(imageRegion.getOffset());
- if (imageRegion.getLength() == 0)
- return startLine;
-
- int endLine= fSlaveDocument.getLineOfOffset(imageRegion.getOffset() + imageRegion.getLength());
- if (endLine != startLine)
- throw new IllegalStateException();
-
- return startLine;
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentInformationMapping#toClosestImageLine(int)
- */
- public int toClosestImageLine(int originLine) throws BadLocationException {
- try {
-
- int imageLine= toImageLine(originLine);
- if (imageLine > -1)
- return imageLine;
-
- Position[] fragments= getFragments();
- if (fragments.length == 0)
- return -1;
-
- IRegion originLineRegion= fMasterDocument.getLineInformation(originLine);
- int index= fMasterDocument.computeIndexInCategory(fFragmentsCategory, originLineRegion.getOffset());
-
- if (0 < index && index < fragments.length) {
- Fragment left= (Fragment) fragments[index - 1];
- int leftDistance= originLineRegion.getOffset() - (left.getOffset() + left.getLength());
- Fragment right= (Fragment) fragments[index];
- int rightDistance= right.getOffset() - (originLineRegion.getOffset() + originLineRegion.getLength());
-
- if (leftDistance <= rightDistance)
- originLine= fMasterDocument.getLineOfOffset(left.getOffset() + Math.max(left.getLength() - 1, 0));
- else
- originLine= fMasterDocument.getLineOfOffset(right.getOffset());
-
- } else if (index == 0) {
- Fragment right= (Fragment) fragments[index];
- originLine= fMasterDocument.getLineOfOffset(right.getOffset());
- } else if (index == fragments.length) {
- Fragment left= (Fragment) fragments[index - 1];
- originLine= fMasterDocument.getLineOfOffset(left.getOffset() + left.getLength());
- }
-
- return toImageLine(originLine);
-
- } catch (BadPositionCategoryException x) {
- }
-
- return -1;
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentInformationMappingExtension#toExactOriginRegions(org.eclipse.jface.text.IRegion)
- */
- public IRegion[] toExactOriginRegions(IRegion imageRegion) throws BadLocationException {
-
- if (imageRegion.getLength() == 0)
- return new IRegion[] { new Region(toOriginOffset(imageRegion.getOffset()), 0) };
-
- int endOffset= imageRegion.getOffset() + imageRegion.getLength();
- Position[] segments= getSegments();
- int firstIndex= findSegmentIndex(imageRegion.getOffset());
- int lastIndex= findSegmentIndex(endOffset - 1);
-
- int resultLength= lastIndex - firstIndex + 1;
- IRegion[] result= new IRegion[resultLength];
-
- // first
- result[0]= createOriginStartRegion((Segment) segments[firstIndex], imageRegion.getOffset() - segments[firstIndex].getOffset());
- // middles
- for (int i= 1; i < resultLength - 1; i++)
- result[i]= createOriginRegion((Segment) segments[firstIndex + i]);
- // last
- Segment last= (Segment) segments[lastIndex];
- int segmentEndOffset= last.getOffset() + last.getLength();
- IRegion lastRegion= createOriginEndRegion(last, segmentEndOffset - endOffset);
- if (resultLength > 1) {
- // first != last
- result[resultLength - 1]= lastRegion;
- } else {
- // merge first and last
- result[0]= getIntersectingRegion(result[0], lastRegion);
- }
-
- return result;
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentInformationMappingExtension#getImageLength()
- */
- public int getImageLength() {
- Position[] segments= getSegments();
- int length= 0;
- for (int i= 0; i < segments.length; i++)
- length += segments[i].length;
- return length;
- }
-}
diff --git a/org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionTextStore.java b/org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionTextStore.java
deleted file mode 100644
index 8a6d492..0000000
--- a/org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionTextStore.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text.projection;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextStore;
-import org.eclipse.jface.text.Region;
-
-/**
- * * Internal class. Do not use. Only public for testing purposes.
- * <p>
- * A text store representing the projection defined by the given document
- * information mapping.
- *
- * @since 3.0
- */
-public class ProjectionTextStore implements ITextStore {
-
- /**
- * Implementation of <code>IRegion</code> that can be reused
- * by setting the offset and the length.
- */
- private static class ReusableRegion implements IRegion {
-
- private int fOffset;
- private int fLength;
-
- /*
- * @see org.eclipse.jface.text.IRegion#getLength()
- */
- public int getLength() {
- return fLength;
- }
-
- /*
- * @see org.eclipse.jface.text.IRegion#getOffset()
- */
- public int getOffset() {
- return fOffset;
- }
-
- /**
- * Updates this region.
- *
- * @param offset the new offset
- * @param length the new length
- */
- public void update(int offset, int length) {
- fOffset= offset;
- fLength= length;
- }
- }
-
- /** The master document */
- private IDocument fMasterDocument;
- /** The document information mapping */
- private IMinimalMapping fMapping;
- /** Internal region used for querying the mapping. */
- private ReusableRegion fReusableRegion= new ReusableRegion();
-
-
- /**
- * Creates a new projection text store for the given master document and
- * the given document information mapping.
- *
- * @param masterDocument the master document
- * @param mapping the document information mapping
- */
- public ProjectionTextStore(IDocument masterDocument, IMinimalMapping mapping) {
- fMasterDocument= masterDocument;
- fMapping= mapping;
- }
-
- private void internalError() {
- throw new IllegalStateException();
- }
-
- /*
- * @see org.eclipse.jface.text.ITextStore#set(java.lang.String)
- */
- public void set(String contents) {
-
- IRegion masterRegion= fMapping.getCoverage();
- if (masterRegion == null)
- internalError();
-
- try {
- fMasterDocument.replace(masterRegion.getOffset(), masterRegion.getLength(), contents);
- } catch (BadLocationException e) {
- internalError();
- }
- }
-
- /*
- * @see org.eclipse.jface.text.ITextStore#replace(int, int, java.lang.String)
- */
- public void replace(int offset, int length, String text) {
- fReusableRegion.update(offset, length);
- try {
- IRegion masterRegion= fMapping.toOriginRegion(fReusableRegion);
- fMasterDocument.replace(masterRegion.getOffset(), masterRegion.getLength(), text);
- } catch (BadLocationException e) {
- internalError();
- }
- }
-
- /*
- * @see org.eclipse.jface.text.ITextStore#getLength()
- */
- public int getLength() {
- return fMapping.getImageLength();
- }
-
- /*
- * @see org.eclipse.jface.text.ITextStore#get(int)
- */
- public char get(int offset) {
- try {
- int originOffset= fMapping.toOriginOffset(offset);
- return fMasterDocument.getChar(originOffset);
- } catch (BadLocationException e) {
- internalError();
- }
-
- // unreachable
- return (char) 0;
- }
-
- /*
- * @see ITextStore#get(int, int)
- */
- public String get(int offset, int length) {
- try {
- IRegion[] fragments= fMapping.toExactOriginRegions(new Region(offset, length));
- StringBuffer buffer= new StringBuffer();
- for (int i= 0; i < fragments.length; i++) {
- IRegion fragment= fragments[i];
- buffer.append(fMasterDocument.get(fragment.getOffset(), fragment.getLength()));
- }
- return buffer.toString();
- } catch (BadLocationException e) {
- internalError();
- }
-
- // unreachable
- return null;
- }
-}
diff --git a/org.eclipse.text/projection/org/eclipse/jface/text/projection/Segment.java b/org.eclipse.text/projection/org/eclipse/jface/text/projection/Segment.java
deleted file mode 100644
index febbc27..0000000
--- a/org.eclipse.text/projection/org/eclipse/jface/text/projection/Segment.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.projection;
-
-import org.eclipse.jface.text.Position;
-
-/**
- * Internal class. Do not use. Only public for testing purposes.
- *
- * @since 3.0
- */
-public class Segment extends Position {
-
- public Fragment fragment;
- public boolean isMarkedForStretch;
- public boolean isMarkedForShift;
-
- public Segment(int offset, int length) {
- super(offset, length);
- }
-
- public void markForStretch() {
- isMarkedForStretch= true;
- }
-
- public boolean isMarkedForStretch() {
- return isMarkedForStretch;
- }
-
- public void markForShift() {
- isMarkedForShift= true;
- }
-
- public boolean isMarkedForShift() {
- return isMarkedForShift;
- }
-
- public void clearMark() {
- isMarkedForStretch= false;
- isMarkedForShift= false;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.text/projection/org/eclipse/jface/text/projection/SegmentUpdater.java b/org.eclipse.text/projection/org/eclipse/jface/text/projection/SegmentUpdater.java
deleted file mode 100644
index cb242e3..0000000
--- a/org.eclipse.text/projection/org/eclipse/jface/text/projection/SegmentUpdater.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.projection;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.DefaultPositionUpdater;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.Position;
-
-
-/**
- * Internal class. Do not use. Only public for testing purposes.
- * <p>
- * The position updater used to adapt the segments of a projection document to
- * changes of the master document. If an insertion happens at a segment's
- * offset, the segment is extended rather than shifted. Also, the last segment
- * is extended if an insert operation happens at the end of the segment.
- *
- * @since 3.0
- */
-public class SegmentUpdater extends DefaultPositionUpdater {
-
- private Segment fNextSegment= null;
- private boolean fIsProjectionChange= false;
-
- /**
- * Creates the segment updater for the given category.
- *
- * @param segmentCategory the position category used for managing the segments of a projection document
- */
- protected SegmentUpdater(String segmentCategory) {
- super(segmentCategory);
- }
-
- /*
- * @see org.eclipse.jface.text.IPositionUpdater#update(org.eclipse.jface.text.DocumentEvent)
- */
- public void update(DocumentEvent event) {
-
- Assert.isTrue(event instanceof ProjectionDocumentEvent);
- fIsProjectionChange= ((ProjectionDocumentEvent) event).getChangeType() == ProjectionDocumentEvent.PROJECTION_CHANGE;
-
- try {
-
- Position[] category= event.getDocument().getPositions(getCategory());
-
- fOffset= event.getOffset();
- fLength= event.getLength();
- fReplaceLength= (event.getText() == null ? 0 : event.getText().length());
- fDocument= event.getDocument();
-
- for (int i= 0; i < category.length; i++) {
-
- fPosition= category[i];
- Assert.isTrue(fPosition instanceof Segment);
-
- if (i < category.length - 1)
- fNextSegment= (Segment) category[i + 1];
- else
- fNextSegment= null;
-
- fOriginalPosition.offset= fPosition.offset;
- fOriginalPosition.length= fPosition.length;
-
- if (notDeleted())
- adaptToReplace();
-
- if (fPosition.getLength() == 0)
- fPosition.isDeleted= true;
- }
-
- } catch (BadPositionCategoryException x) {
- // do nothing
- }
- }
-
- /*
- * @see org.eclipse.jface.text.DefaultPositionUpdater#adaptToInsert()
- */
- protected void adaptToInsert() {
-
- Segment segment= (Segment) fPosition;
- int myStart= segment.offset;
- int myEnd= segment.offset + segment.length - (segment.isMarkedForStretch || fNextSegment == null || isAffectingReplace() ? 0 : 1);
- myEnd= Math.max(myStart, myEnd);
- int yoursStart= fOffset;
-
- try {
-
- if (myEnd < yoursStart)
- return;
-
- if (segment.isMarkedForStretch) {
- Assert.isTrue(fIsProjectionChange);
- segment.isMarkedForShift= false;
- if (fNextSegment != null) {
- fNextSegment.isMarkedForShift= true;
- fNextSegment.isMarkedForStretch= false;
- }
- }
-
- if (fLength <= 0) {
-
- if (myStart < (yoursStart + (segment.isMarkedForShift ? 0 : 1)))
- fPosition.length += fReplaceLength;
- else
- fPosition.offset += fReplaceLength;
-
- } else {
-
- if (myStart <= yoursStart && fOriginalPosition.offset <= yoursStart)
- fPosition.length += fReplaceLength;
- else
- fPosition.offset += fReplaceLength;
- }
-
- } finally {
- segment.clearMark();
- }
- }
-}
diff --git a/org.eclipse.text/scripts/exportplugin.xml b/org.eclipse.text/scripts/exportplugin.xml
deleted file mode 100644
index 335b970..0000000
--- a/org.eclipse.text/scripts/exportplugin.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<project name="Export Text" default="export" basedir="..">
- <target name="init">
- <tstamp/>
- <property name="destdir" value="../../plugin-export" />
- <property name="plugin" value="org.eclipse.text" />
- <property name="version" value="_3.0.0" />
- <property name="dest" value="${destdir}/${plugin}${version}" />
- </target>
-
- <target name="build" depends="init">
- <eclipse.incrementalBuild project="${plugin}" kind="incr"/>
- </target>
-
- <target name="export" depends="build">
- <mkdir dir="${destdir}" />
- <delete dir="${dest}" />
- <mkdir dir="${dest}" />
- <jar
- jarfile="${dest}/text.jar"
- basedir="bin"
- />
- <copy file="plugin.xml" todir="${dest}"/>
- <copy file="plugin.properties" todir="${dest}"/>
- <zip zipfile="${dest}/textsrc.zip">
- <fileset dir="src" />
- <fileset dir="projection"/>
- </zip>
- </target>
-</project>
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/AbstractDocument.java b/org.eclipse.text/src/org/eclipse/jface/text/AbstractDocument.java
deleted file mode 100644
index 1e426e7..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/AbstractDocument.java
+++ /dev/null
@@ -1,1285 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.PatternSyntaxException;
-
-
-/**
- * Abstract implementation of <code>IDocument</code>.
- * Implements the complete contract of <code>IDocument</code>, <code>IDocumentExtension</code>,
- * and <code>IDocumentExtension2</code>.<p>
- *
- * An <code>AbstractDocument</code> supports the following implementation plug-ins:
- * <ul>
- * <li> a text store for storing and managing the document's content,
- * <li> a line tracker to map character positions to line numbers and vice versa
- * </ul>
- * The document can dynamically change the text store when switching between
- * sequential rewrite mode and normal mode.<p>
- *
- * This class must be subclassed. Subclasses must configure which implementation
- * plug-ins the document should use. Subclasses are not intended to overwrite existing methods.
- *
- * @see IDocument
- * @see ITextStore
- * @see ILineTracker
- */
-public abstract class AbstractDocument implements IDocument, IDocumentExtension, IDocumentExtension2, IDocumentExtension3, IRepairableDocument {
-
- /**
- * Inner class to bundle a registered post notification replace operation together with its
- * owner.
- *
- * @since 2.0
- */
- static private class RegisteredReplace {
- /** The owner of this replace operation. */
- IDocumentListener fOwner;
- /** The replace operation */
- IDocumentExtension.IReplace fReplace;
-
- /**
- * Creates a new bundle object.
- * @param owner the document listener owning the replace operation
- * @param replace the replace operation
- */
- RegisteredReplace(IDocumentListener owner, IDocumentExtension.IReplace replace) {
- fOwner= owner;
- fReplace= replace;
- }
- }
-
-
- /** The document's text store */
- private ITextStore fStore;
- /** The document's line tracker */
- private ILineTracker fTracker;
- /** The registered document listeners */
- private List fDocumentListeners;
- /** The registered prenotified document listeners */
- private List fPrenotifiedDocumentListeners;
- /** The registered document partitioning listeners */
- private List fDocumentPartitioningListeners;
- /** All positions managed by the document */
- private Map fPositions;
- /** All registered document position updaters */
- private List fPositionUpdaters;
- /**
- * The list of post notification changes
- * @since 2.0
- */
- private List fPostNotificationChanges;
- /**
- * The reentrance count for post notification changes.
- * @since 2.0
- */
- private int fReentranceCount= 0;
- /**
- * Indicates whether post notification change processing has been stopped.
- * @since 2.0
- */
- private int fStoppedCount= 0;
- /**
- * Indicates whether the registration of post notification changes should be
- * ignored.
- * @since 2.1
- */
- private boolean fAcceptPostNotificationReplaces= true;
- /**
- * Indicates whether the notification of listeners has been stopped.
- * @since 2.1
- */
- private int fStoppedListenerNotification= 0;
- /**
- * The document event to be sent after listener notification has been resumed.
- * @since 2.1
- */
- private DocumentEvent fDeferredDocumentEvent;
- /**
- * The registered document partitioners.
- * @since 3.0
- */
- private Map fDocumentPartitioners;
- /**
- * The partitioning changed event.
- * @since 3.0
- */
- private DocumentPartitioningChangedEvent fDocumentPartitioningChangedEvent;
- /**
- * The find/replace document adapter.
- * @since 3.0
- */
- private FindReplaceDocumentAdapter fFindReplaceDocumentAdapter;
-
-
- /**
- * The default constructor does not perform any configuration
- * but leaves it to the clients who must first initialize the
- * implementation plug-ins and then call <code>completeInitialization</code>.
- * Results in the construction of an empty document.
- */
- protected AbstractDocument() {
- }
-
-
- //--- accessor to fields -------------------------------
-
- /**
- * Returns the document's text store. Assumes that the
- * document has been initialized with a text store.
- *
- * @return the document's text store
- */
- protected ITextStore getStore() {
- Assert.isNotNull(fStore);
- return fStore;
- }
-
- /**
- * Returns the document's line tracker. Assumes that the
- * document has been initialized with a line tracker.
- *
- * @return the document's line tracker
- */
- protected ILineTracker getTracker() {
- Assert.isNotNull(fTracker);
- return fTracker;
- }
-
- /**
- * Returns the document's document listeners.
- *
- * @return the document's document listeners
- */
- protected List getDocumentListeners() {
- return fDocumentListeners;
- }
-
- /**
- * Returns the document's partitioning listeners .
- *
- * @return the document's partitioning listeners
- */
- protected List getDocumentPartitioningListeners() {
- return fDocumentPartitioningListeners;
- }
-
- /**
- * Returns all positions managed by the document grouped by category.
- *
- * @return the document's positions
- */
- protected Map getDocumentManagedPositions() {
- return fPositions;
- }
-
- /*
- * @see IDocument#getDocumentPartitioner
- */
- public IDocumentPartitioner getDocumentPartitioner() {
- return getDocumentPartitioner(DEFAULT_PARTITIONING);
- }
-
-
-
- //--- implementation configuration interface ------------
-
- /**
- * Sets the document's text store.
- * Must be called at the beginning of the constructor.
- *
- * @param store the document's text store
- */
- protected void setTextStore(ITextStore store) {
- fStore= store;
- }
-
- /**
- * Sets the document's line tracker.
- * Must be called at the beginnng of the constructor.
- *
- * @param tracker the document's line tracker
- */
- protected void setLineTracker(ILineTracker tracker) {
- fTracker= tracker;
- }
-
- /*
- * @see org.eclipse.jface.text.IDocument#setDocumentPartitioner(org.eclipse.jface.text.IDocumentPartitioner)
- */
- public void setDocumentPartitioner(IDocumentPartitioner partitioner) {
- setDocumentPartitioner(DEFAULT_PARTITIONING, partitioner);
- }
-
- /**
- * Initializes document listeners, positions, and position updaters.
- * Must be called inside the constructor after the implementation plug-ins
- * have been set.
- */
- protected void completeInitialization() {
-
- fPositions= new HashMap();
- fPositionUpdaters= new ArrayList();
- fDocumentListeners= new ArrayList();
- fPrenotifiedDocumentListeners= new ArrayList();
- fDocumentPartitioningListeners= new ArrayList();
-
- addPositionCategory(DEFAULT_CATEGORY);
- addPositionUpdater(new DefaultPositionUpdater(DEFAULT_CATEGORY));
- }
-
-
- //-------------------------------------------------------
-
- /*
- * @see org.eclipse.jface.text.IDocument#addDocumentListener(org.eclipse.jface.text.IDocumentListener)
- */
- public void addDocumentListener(IDocumentListener listener) {
- Assert.isNotNull(listener);
- if (! fDocumentListeners.contains(listener))
- fDocumentListeners.add(listener);
- }
-
- /*
- * @see org.eclipse.jface.text.IDocument#removeDocumentListener(org.eclipse.jface.text.IDocumentListener)
- */
- public void removeDocumentListener(IDocumentListener listener) {
- Assert.isNotNull(listener);
- fDocumentListeners.remove(listener);
- }
-
- /*
- * @see IDocument#addPrenotifiedDocumentListener(IDocumentListener)
- */
- public void addPrenotifiedDocumentListener(IDocumentListener listener) {
- Assert.isNotNull(listener);
- if (! fPrenotifiedDocumentListeners.contains(listener))
- fPrenotifiedDocumentListeners.add(listener);
- }
-
- /*
- * @see IDocument#removePrenotifiedDocumentListener(IDocumentListener)
- */
- public void removePrenotifiedDocumentListener(IDocumentListener listener) {
- Assert.isNotNull(listener);
- fPrenotifiedDocumentListeners.remove(listener);
- }
-
- /*
- * @see org.eclipse.jface.text.IDocument#addDocumentPartitioningListener(org.eclipse.jface.text.IDocumentPartitioningListener)
- */
- public void addDocumentPartitioningListener(IDocumentPartitioningListener listener) {
- Assert.isNotNull(listener);
- if (! fDocumentPartitioningListeners.contains(listener))
- fDocumentPartitioningListeners.add(listener);
- }
-
- /*
- * @see org.eclipse.jface.text.IDocument#removeDocumentPartitioningListener(org.eclipse.jface.text.IDocumentPartitioningListener)
- */
- public void removeDocumentPartitioningListener(IDocumentPartitioningListener listener) {
- Assert.isNotNull(listener);
- fDocumentPartitioningListeners.remove(listener);
- }
-
- /*
- * @see org.eclipse.jface.text.IDocument#addPosition(java.lang.String, org.eclipse.jface.text.Position)
- */
- public void addPosition(String category, Position position) throws BadLocationException, BadPositionCategoryException {
-
- if ((0 > position.offset) || (0 > position.length) || (position.offset + position.length > getLength()))
- throw new BadLocationException();
-
- if (category == null)
- throw new BadPositionCategoryException();
-
- List list= (List) fPositions.get(category);
- if (list == null)
- throw new BadPositionCategoryException();
-
- list.add(computeIndexInPositionList(list, position.offset), position);
- }
-
- /*
- * @see org.eclipse.jface.text.IDocument#addPosition(org.eclipse.jface.text.Position)
- */
- public void addPosition(Position position) throws BadLocationException {
- try {
- addPosition(DEFAULT_CATEGORY, position);
- } catch (BadPositionCategoryException e) {
- }
- }
-
- /*
- * @see org.eclipse.jface.text.IDocument#addPositionCategory(java.lang.String)
- */
- public void addPositionCategory(String category) {
-
- if (category == null)
- return;
-
- if (!containsPositionCategory(category))
- fPositions.put(category, new ArrayList());
- }
-
- /*
- * @see org.eclipse.jface.text.IDocument#addPositionUpdater(org.eclipse.jface.text.IPositionUpdater)
- */
- public void addPositionUpdater(IPositionUpdater updater) {
- insertPositionUpdater(updater, fPositionUpdaters.size());
- }
-
- /*
- * @see org.eclipse.jface.text.IDocument#containsPosition(java.lang.String, int, int)
- */
- public boolean containsPosition(String category, int offset, int length) {
-
- if (category == null)
- return false;
-
- List list= (List) fPositions.get(category);
- if (list == null)
- return false;
-
- int size= list.size();
- if (size == 0)
- return false;
-
- int index= computeIndexInPositionList(list, offset);
- if (index < size) {
- Position p= (Position) list.get(index);
- while (p != null && p.offset == offset) {
- if (p.length == length)
- return true;
- ++ index;
- p= (index < size) ? (Position) list.get(index) : null;
- }
- }
-
- return false;
- }
-
- /*
- * @see org.eclipse.jface.text.IDocument#containsPositionCategory(java.lang.String)
- */
- public boolean containsPositionCategory(String category) {
- if (category != null)
- return fPositions.containsKey(category);
- return false;
- }
-
-
- /**
- * Computes the index in the list of positions at which a position with the given
- * offset would be inserted. The position is supposed to become the first in this list
- * of all positions with the same offset.
- *
- * @param positions the list in which the index is computed
- * @param offset the offset for which the index is computed
- * @return the computed index
- *
- * @see IDocument#computeIndexInCategory(String, int)
- */
- protected int computeIndexInPositionList(List positions, int offset) {
-
- if (positions.size() == 0)
- return 0;
-
- int left= 0;
- int right= positions.size() -1;
- int mid= 0;
- Position p= null;
-
- while (left < right) {
-
- mid= (left + right) / 2;
-
- p= (Position) positions.get(mid);
- if (offset < p.getOffset()) {
- if (left == mid)
- right= left;
- else
- right= mid -1;
- } else if (offset > p.getOffset()) {
- if (right == mid)
- left= right;
- else
- left= mid +1;
- } else if (offset == p.getOffset()) {
- left= right= mid;
- }
-
- }
-
- int pos= left;
- p= (Position) positions.get(pos);
- if (offset > p.getOffset()) {
- // append to the end
- pos++;
- } else {
- // entry will became the first of all entries with the same offset
- do {
- --pos;
- if (pos < 0)
- break;
- p= (Position) positions.get(pos);
- } while (offset == p.getOffset());
- ++pos;
- }
-
- Assert.isTrue(0 <= pos && pos <= positions.size());
-
- return pos;
- }
-
- /*
- * @see org.eclipse.jface.text.IDocument#computeIndexInCategory(java.lang.String, int)
- */
- public int computeIndexInCategory(String category, int offset) throws BadLocationException, BadPositionCategoryException {
-
- if (0 > offset || offset > getLength())
- throw new BadLocationException();
-
- List c= (List) fPositions.get(category);
- if (c == null)
- throw new BadPositionCategoryException();
-
- return computeIndexInPositionList(c, offset);
- }
-
- /**
- * Fires the document partitioning changed notification to all registered
- * document partitioning listeners. Uses a robust iterator.
- *
- * @deprecated use <code>fireDocumentPartitioningChanged(IRegion)</code> instead
- */
- protected void fireDocumentPartitioningChanged() {
-
- if (fDocumentPartitioningListeners != null && fDocumentPartitioningListeners.size() > 0) {
-
- List list= new ArrayList(fDocumentPartitioningListeners);
- Iterator e= list.iterator();
- while (e.hasNext()) {
- IDocumentPartitioningListener l= (IDocumentPartitioningListener) e.next();
- l.documentPartitioningChanged(this);
- }
- }
- }
-
- /**
- * Fires the document partitioning changed notification to all registered
- * document partitioning listeners. Uses a robust iterator.
- *
- * @param region the region in which partitioning has changed
- *
- * @see IDocumentPartitioningListenerExtension
- * @since 2.0
- * @deprecated use <code>fireDocumentPartitioningChanged(DocumentPartitioningChangedEvent)</code> instead
- */
- protected void fireDocumentPartitioningChanged(IRegion region) {
-
- if (fDocumentPartitioningListeners != null && fDocumentPartitioningListeners.size() > 0) {
-
- List list= new ArrayList(fDocumentPartitioningListeners);
- Iterator e= list.iterator();
- while (e.hasNext()) {
- IDocumentPartitioningListener l= (IDocumentPartitioningListener) e.next();
- if (l instanceof IDocumentPartitioningListenerExtension)
- ((IDocumentPartitioningListenerExtension) l).documentPartitioningChanged(this, region);
- else
- l.documentPartitioningChanged(this);
- }
- }
- }
-
- /**
- * Fires the document partitioning changed notification to all registered
- * document partitioning listeners. Uses a robust iterator.
- *
- * @param event the document partitioning changed event
- *
- * @see IDocumentPartitioningListenerExtension2
- * @since 3.0
- */
- protected void fireDocumentPartitioningChanged(DocumentPartitioningChangedEvent event) {
- if (fDocumentPartitioningListeners == null || fDocumentPartitioningListeners.size() == 0)
- return;
-
- List list= new ArrayList(fDocumentPartitioningListeners);
- Iterator e= list.iterator();
- while (e.hasNext()) {
- IDocumentPartitioningListener l= (IDocumentPartitioningListener) e.next();
- if (l instanceof IDocumentPartitioningListenerExtension2) {
- IDocumentPartitioningListenerExtension2 extension2= (IDocumentPartitioningListenerExtension2) l;
- extension2.documentPartitioningChanged(event);
- } else if (l instanceof IDocumentPartitioningListenerExtension) {
- IDocumentPartitioningListenerExtension extension= (IDocumentPartitioningListenerExtension) l;
- extension.documentPartitioningChanged(this, event.getCoverage());
- } else {
- l.documentPartitioningChanged(this);
- }
- }
-
- }
-
- /**
- * Fires the given document event to all registers document listeners informing them
- * about the forthcoming document manipulation. Uses a robust iterator.
- *
- * @param event the event to be sent out
- */
- protected void fireDocumentAboutToBeChanged(DocumentEvent event) {
-
- // IDocumentExtension
- if (fReentranceCount == 0)
- flushPostNotificationChanges();
-
- if (fDocumentPartitioners != null) {
- Iterator e= fDocumentPartitioners.values().iterator();
- while (e.hasNext()) {
- IDocumentPartitioner p= (IDocumentPartitioner) e.next();
- p.documentAboutToBeChanged(event);
- }
- }
-
- if (fPrenotifiedDocumentListeners.size() > 0) {
-
- List list= new ArrayList(fPrenotifiedDocumentListeners);
- Iterator e= list.iterator();
- while (e.hasNext()) {
- IDocumentListener l= (IDocumentListener) e.next();
- l.documentAboutToBeChanged(event);
- }
- }
-
- if (fDocumentListeners.size() > 0) {
-
- List list= new ArrayList(fDocumentListeners);
- Iterator e= list.iterator();
- while (e.hasNext()) {
- IDocumentListener l= (IDocumentListener) e.next();
- l.documentAboutToBeChanged(event);
- }
- }
- }
-
-
- /**
- * Updates document partitioning and document positions according to the
- * specification given by the document event.
- *
- * @param event the document event describing the change to which structures must be adapted
- */
- protected void updateDocumentStructures(DocumentEvent event) {
-
- if (fDocumentPartitioners != null) {
- fDocumentPartitioningChangedEvent= new DocumentPartitioningChangedEvent(this);
- Iterator e= fDocumentPartitioners.keySet().iterator();
- while (e.hasNext()) {
- String partitioning= (String) e.next();
- IDocumentPartitioner partitioner= (IDocumentPartitioner) fDocumentPartitioners.get(partitioning);
- if (partitioner instanceof IDocumentPartitionerExtension) {
- IDocumentPartitionerExtension extension= (IDocumentPartitionerExtension) partitioner;
- IRegion r= extension.documentChanged2(event);
- if (r != null)
- fDocumentPartitioningChangedEvent.setPartitionChange(partitioning, r.getOffset(), r.getLength());
- } else {
- if (partitioner.documentChanged(event))
- fDocumentPartitioningChangedEvent.setPartitionChange(partitioning, 0, event.getDocument().getLength());
- }
- }
- }
-
- if (fPositions.size() > 0)
- updatePositions(event);
- }
-
- /**
- * Notifies all listeners about the given document change.
- * Uses a robust iterator. <p>
- * Executes all registered post notification replace operation.
- *
- * @param event the event to be sent out.
- */
- protected void doFireDocumentChanged(DocumentEvent event) {
- boolean changed= fDocumentPartitioningChangedEvent != null && !fDocumentPartitioningChangedEvent.isEmpty();
- IRegion change= changed ? fDocumentPartitioningChangedEvent.getCoverage() : null;
- doFireDocumentChanged(event, changed, change);
- }
-
- /**
- * Notifies all listeners about the given document change.
- * Uses a robust iterator. <p>
- * Executes all registered post notification replace operation.
- *
- * @param event the event to be sent out
- * @param firePartitionChange <code>true</code> if a partition change notification should be sent
- * @param partitionChange the region whose partitioning changed
- * @since 2.0
- * @deprecated use doFireDocumentChanged2(DocumentEvent) instead; this method will be removed
- */
- protected void doFireDocumentChanged(DocumentEvent event, boolean firePartitionChange, IRegion partitionChange) {
- doFireDocumentChanged2(event);
- }
-
- /**
- * Notifies all listeners about the given document change.
- * Uses a robust iterator. <p>
- * Executes all registered post notification replace operation.
- *
- * @param event the event to be sent out
- * @since 3.0
- * @deprecated this method will be renamed to <code>doFireDocumentChanged</code>
- */
- protected void doFireDocumentChanged2(DocumentEvent event) {
-
- DocumentPartitioningChangedEvent p= fDocumentPartitioningChangedEvent;
- fDocumentPartitioningChangedEvent= null;
- if (p != null && !p.isEmpty())
- fireDocumentPartitioningChanged(p);
-
- if (fPrenotifiedDocumentListeners.size() > 0) {
-
- List list= new ArrayList(fPrenotifiedDocumentListeners);
- Iterator e= list.iterator();
- while (e.hasNext()) {
- IDocumentListener l= (IDocumentListener) e.next();
- l.documentChanged(event);
- }
- }
-
- if (fDocumentListeners.size() > 0) {
-
- List list= new ArrayList(fDocumentListeners);
- Iterator e= list.iterator();
- while (e.hasNext()) {
- IDocumentListener l= (IDocumentListener) e.next();
- l.documentChanged(event);
- }
- }
-
- // IDocumentExtension
- ++ fReentranceCount;
- try {
- if (fReentranceCount == 1)
- executePostNotificationChanges();
- } finally {
- -- fReentranceCount;
- }
- }
-
- /**
- * Updates the internal document structures and informs all document listeners
- * if listener notification has been enabled. Otherwise it remembers the event
- * to be sent to the listeners on resume.
- *
- * @param event the document event to be sent out
- */
- protected void fireDocumentChanged(DocumentEvent event) {
- updateDocumentStructures(event);
-
- if (fStoppedListenerNotification == 0)
- doFireDocumentChanged(event);
- else
- fDeferredDocumentEvent= event;
- }
-
- /*
- * @see org.eclipse.jface.text.IDocument#getChar(int)
- */
- public char getChar(int pos) throws BadLocationException {
- if ((0 > pos) || (pos >= getLength()))
- throw new BadLocationException();
- return getStore().get(pos);
- }
-
- /*
- * @see org.eclipse.jface.text.IDocument#getContentType(int)
- */
- public String getContentType(int offset) throws BadLocationException {
- String contentType= null;
- try {
- contentType= getContentType(DEFAULT_PARTITIONING, offset);
- Assert.isNotNull(contentType);
- } catch (BadPartitioningException e) {
- Assert.isTrue(false);
- }
- return contentType;
- }
-
- /*
- * @see IDocument#getLegalContentTypes()
- */
- public String[] getLegalContentTypes() {
- String[] contentTypes= null;
- try {
- contentTypes= getLegalContentTypes(DEFAULT_PARTITIONING);
- Assert.isNotNull(contentTypes);
- } catch (BadPartitioningException e) {
- Assert.isTrue(false);
- }
- return contentTypes;
- }
-
- /*
- * @see IDocument#getLength()
- */
- public int getLength() {
- return getStore().getLength();
- }
-
- /*
- * @see org.eclipse.jface.text.IDocument#getLineDelimiter(int)
- */
- public String getLineDelimiter(int line) throws BadLocationException {
- return getTracker().getLineDelimiter(line);
- }
-
- /*
- * @see IDocument#getLegalLineDelimiters()
- */
- public String[] getLegalLineDelimiters() {
- return getTracker().getLegalLineDelimiters();
- }
-
- /*
- * @see IDocument#getLineLength(int)
- */
- public int getLineLength(int line) throws BadLocationException {
- return getTracker().getLineLength(line);
- }
-
- /*
- * @see IDocument#getLineOfOffset(int)
- */
- public int getLineOfOffset(int pos) throws BadLocationException {
- return getTracker().getLineNumberOfOffset(pos);
- }
-
- /*
- * @see IDocument#getLineOffset(int)
- */
- public int getLineOffset(int line) throws BadLocationException {
- return getTracker().getLineOffset(line);
- }
-
- /*
- * @see IDocument#getLineInformation(int)
- */
- public IRegion getLineInformation(int line) throws BadLocationException {
- return getTracker().getLineInformation(line);
- }
-
- /*
- * @see IDocument#getLineInformationOfOffset(int)
- */
- public IRegion getLineInformationOfOffset(int offset) throws BadLocationException {
- return getTracker().getLineInformationOfOffset(offset);
- }
-
- /*
- * @see IDocument#getNumberOfLines()
- */
- public int getNumberOfLines() {
- return getTracker().getNumberOfLines();
- }
-
- /*
- * @see IDocument#getNumberOfLines(int, int)
- */
- public int getNumberOfLines(int offset, int length) throws BadLocationException {
- return getTracker().getNumberOfLines(offset, length);
- }
-
- /*
- * @see IDocument#computeNumberOfLines(String)
- */
- public int computeNumberOfLines(String text) {
- return getTracker().computeNumberOfLines(text);
- }
-
- /*
- * @see IDocument#getPartition(int)
- */
- public ITypedRegion getPartition(int offset) throws BadLocationException {
- ITypedRegion partition= null;
- try {
- partition= getPartition(DEFAULT_PARTITIONING, offset);
- Assert.isNotNull(partition);
- } catch (BadPartitioningException e) {
- Assert.isTrue(false);
- }
- return partition;
- }
-
- /*
- * @see IDocument#computePartitioning(int, int)
- */
- public ITypedRegion[] computePartitioning(int offset, int length) throws BadLocationException {
- ITypedRegion[] partitioning= null;
- try {
- partitioning= computePartitioning(DEFAULT_PARTITIONING, offset, length);
- Assert.isNotNull(partitioning);
- } catch (BadPartitioningException e) {
- Assert.isTrue(false);
- }
- return partitioning;
- }
-
- /*
- * @see IDocument#getPositions(String)
- */
- public Position[] getPositions(String category) throws BadPositionCategoryException {
-
- if (category == null)
- throw new BadPositionCategoryException();
-
- List c= (List) fPositions.get(category);
- if (c == null)
- throw new BadPositionCategoryException();
-
- Position[] positions= new Position[c.size()];
- c.toArray(positions);
- return positions;
- }
-
- /*
- * @see IDocument#getPositionCategories()
- */
- public String[] getPositionCategories() {
- String[] categories= new String[fPositions.size()];
- Iterator keys= fPositions.keySet().iterator();
- for (int i= 0; i < categories.length; i++)
- categories[i]= (String) keys.next();
- return categories;
- }
-
- /*
- * @see IDocument#getPositionUpdaters()
- */
- public IPositionUpdater[] getPositionUpdaters() {
- IPositionUpdater[] updaters= new IPositionUpdater[fPositionUpdaters.size()];
- fPositionUpdaters.toArray(updaters);
- return updaters;
- }
-
- /*
- * @see IDocument#get()
- */
- public String get() {
- return getStore().get(0, getLength());
- }
-
- /*
- * @see IDocument#get(int, int)
- */
- public String get(int pos, int length) throws BadLocationException {
- int myLength= getLength();
- if ((0 > pos) || (0 > length) || (pos + length > myLength))
- throw new BadLocationException();
- return getStore().get(pos, length);
- }
-
- /*
- * @see IDocument#insertPositionUpdater(IPositionUpdater, int)
- */
- public void insertPositionUpdater(IPositionUpdater updater, int index) {
-
- for (int i= fPositionUpdaters.size() - 1; i >= 0; i--) {
- if (fPositionUpdaters.get(i) == updater)
- return;
- }
-
- if (index == fPositionUpdaters.size())
- fPositionUpdaters.add(updater);
- else
- fPositionUpdaters.add(index, updater);
- }
-
- /*
- * @see org.eclipse.jface.text.IDocument#removePosition(java.lang.String, org.eclipse.jface.text.Position)
- */
- public void removePosition(String category, Position position) throws BadPositionCategoryException {
-
- if (position == null)
- return;
-
- if (category == null)
- throw new BadPositionCategoryException();
-
- List c= (List) fPositions.get(category);
- if (c == null)
- throw new BadPositionCategoryException();
-
- // remove based on identity not equality
- int size= c.size();
- for (int i= 0; i < size; i++) {
- if (position == c.get(i)) {
- c.remove(i);
- return;
- }
- }
- }
-
- /*
- * @see IDocument#removePosition(Position)
- */
- public void removePosition(Position position) {
- try {
- removePosition(DEFAULT_CATEGORY, position);
- } catch (BadPositionCategoryException e) {
- }
- }
-
- /*
- * @see IDocument#removePositionCategory(String)
- */
- public void removePositionCategory(String category) throws BadPositionCategoryException {
-
- if (category == null)
- return;
-
- if ( !containsPositionCategory(category))
- throw new BadPositionCategoryException();
-
- fPositions.remove(category);
- }
-
- /*
- * @see IDocument#removePositionUpdater(IPositionUpdater)
- */
- public void removePositionUpdater(IPositionUpdater updater) {
- for (int i= fPositionUpdaters.size() - 1; i >= 0; i--) {
- if (fPositionUpdaters.get(i) == updater) {
- fPositionUpdaters.remove(i);
- return;
- }
- }
- }
-
- /*
- * @see IDocument#replace(int, int, String)
- */
- public void replace(int pos, int length, String text) throws BadLocationException {
- if ((0 > pos) || (0 > length) || (pos + length > getLength()))
- throw new BadLocationException();
-
- DocumentEvent e= new DocumentEvent(this, pos, length, text);
- fireDocumentAboutToBeChanged(e);
-
- getStore().replace(pos, length, text);
- getTracker().replace(pos, length, text);
-
- fireDocumentChanged(e);
- }
-
- /*
- * @see IDocument#set(String)
- */
- public void set(String text) {
- int length= getStore().getLength();
- DocumentEvent e= new DocumentEvent(this, 0, length, text);
- fireDocumentAboutToBeChanged(e);
-
- getStore().set(text);
- getTracker().set(text);
-
- fireDocumentChanged(e);
- }
-
- /**
- * Updates all positions of all categories to the change
- * described by the document event. All registered document
- * updaters are called in the sequence they have been arranged.
- * Uses a robust iterator.
- *
- * @param event the document event describing the change to which to adapt the positions
- */
- protected void updatePositions(DocumentEvent event) {
- List list= new ArrayList(fPositionUpdaters);
- Iterator e= list.iterator();
- while (e.hasNext()) {
- IPositionUpdater u= (IPositionUpdater) e.next();
- u.update(event);
- }
- }
-
- /*
- * @see org.eclipse.jface.text.IDocument#search(int, java.lang.String, boolean, boolean, boolean)
- */
- public int search(int startPosition, String findString, boolean forwardSearch, boolean caseSensitive, boolean wholeWord) throws BadLocationException {
- try {
- IRegion region= getFindReplaceDocumentAdapter().search(startPosition, findString, forwardSearch, caseSensitive, wholeWord, false);
- if (region == null)
- return -1;
- else
- return region.getOffset();
- } catch (IllegalStateException ex) {
- return -1;
- } catch (PatternSyntaxException ex) {
- return -1;
- }
- }
-
- /**
- * Returns the find/replace adapter for this document.
- *
- * @return this document's find/replace document adapter
- * @since 3.0
- */
- private FindReplaceDocumentAdapter getFindReplaceDocumentAdapter() {
- if (fFindReplaceDocumentAdapter == null)
- fFindReplaceDocumentAdapter= new FindReplaceDocumentAdapter(this);
-
- return fFindReplaceDocumentAdapter;
- }
-
- /**
- * Flushes all registered post notification changes.
- *
- * @since 2.0
- */
- private void flushPostNotificationChanges() {
- if (fPostNotificationChanges != null)
- fPostNotificationChanges.clear();
- }
-
- /**
- * Executes all registered post notification changes. The process is
- * repeated until no new post notification changes are added.
- *
- * @since 2.0
- */
- private void executePostNotificationChanges() {
-
- if (fStoppedCount > 0)
- return;
-
- while (fPostNotificationChanges != null) {
- List changes= fPostNotificationChanges;
- fPostNotificationChanges= null;
-
- Iterator e= changes.iterator();
- while (e.hasNext()) {
- RegisteredReplace replace = (RegisteredReplace) e.next();
- replace.fReplace.perform(this, replace.fOwner);
- }
- }
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentExtension2#acceptPostNotificationReplaces()
- * @since 2.1
- */
- public void acceptPostNotificationReplaces() {
- fAcceptPostNotificationReplaces= true;
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentExtension2#ignorePostNotificationReplaces()
- * @since 2.1
- */
- public void ignorePostNotificationReplaces() {
- fAcceptPostNotificationReplaces= false;
- }
-
- /*
- * @see IDocumentExtension#registerPostNotificationReplace(IDocumentListener, IDocumentExtension.IReplace)
- * @since 2.0
- */
- public void registerPostNotificationReplace(IDocumentListener owner, IDocumentExtension.IReplace replace) {
- if (fAcceptPostNotificationReplaces) {
- if (fPostNotificationChanges == null)
- fPostNotificationChanges= new ArrayList(1);
- fPostNotificationChanges.add(new RegisteredReplace(owner, replace));
- }
- }
-
- /*
- * @see IDocumentExtension#stopPostNotificationProcessing()
- * @since 2.0
- */
- public void stopPostNotificationProcessing() {
- ++ fStoppedCount;
- }
-
- /*
- * @see IDocumentExtension#resumePostNotificationProcessing()
- * @since 2.0
- */
- public void resumePostNotificationProcessing() {
- -- fStoppedCount;
- if (fStoppedCount == 0 && fReentranceCount == 0)
- executePostNotificationChanges();
- }
-
- /*
- * @see IDocumentExtension#startSequentialRewrite(boolean)
- * @since 2.0
- */
- public void startSequentialRewrite(boolean normalized) {
- }
-
- /*
- * @see IDocumentExtension#stopSequentialRewrite()
- * @since 2.0
- */
- public void stopSequentialRewrite() {
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentExtension2#resumeListenerNotification()
- * @since 2.1
- */
- public void resumeListenerNotification() {
- -- fStoppedListenerNotification;
- if (fStoppedListenerNotification == 0) {
- resumeDocumentListenerNotification();
- }
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentExtension2#stopListenerNotification()
- * @since 2.1
- */
- public void stopListenerNotification() {
- ++ fStoppedListenerNotification;
- }
-
- /**
- * Resumes the document listener notification by sending out the remembered
- * partition changed and document event.
- *
- * @since 2.1
- */
- private void resumeDocumentListenerNotification() {
- if (fDeferredDocumentEvent != null) {
- DocumentEvent event= fDeferredDocumentEvent;
- fDeferredDocumentEvent= null;
- doFireDocumentChanged(event);
- }
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentExtension3#computePartitioning(java.lang.String, int, int)
- * @since 3.0
- */
- public ITypedRegion[] computePartitioning(String partitioning, int offset, int length) throws BadLocationException, BadPartitioningException {
- if ((0 > offset) || (0 > length) || (offset + length > getLength()))
- throw new BadLocationException();
- IDocumentPartitioner partitioner= getDocumentPartitioner(partitioning);
- if (partitioner != null)
- return partitioner.computePartitioning(offset, length);
- if (DEFAULT_PARTITIONING.equals(partitioning))
- return new TypedRegion[] { new TypedRegion(offset, length, DEFAULT_CONTENT_TYPE) };
- throw new BadPartitioningException();
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentExtension3#getContentType(java.lang.String, int)
- * @since 3.0
- */
- public String getContentType(String partitioning, int offset) throws BadLocationException, BadPartitioningException {
- if ((0 > offset) || (offset > getLength()))
- throw new BadLocationException();
- IDocumentPartitioner partitioner= getDocumentPartitioner(partitioning);
- if (partitioner != null)
- return partitioner.getContentType(offset);
- if (DEFAULT_PARTITIONING.equals(partitioning))
- return DEFAULT_CONTENT_TYPE;
- throw new BadPartitioningException();
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentExtension3#getDocumentPartitioner(java.lang.String)
- * @since 3.0
- */
- public IDocumentPartitioner getDocumentPartitioner(String partitioning) {
- return fDocumentPartitioners != null ? (IDocumentPartitioner) fDocumentPartitioners.get(partitioning) : null;
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentExtension3#getLegalContentTypes(java.lang.String)
- * @since 3.0
- */
- public String[] getLegalContentTypes(String partitioning) throws BadPartitioningException {
- IDocumentPartitioner partitioner= getDocumentPartitioner(partitioning);
- if (partitioner != null)
- return partitioner.getLegalContentTypes();
- if (DEFAULT_PARTITIONING.equals(partitioning))
- return new String[] { DEFAULT_CONTENT_TYPE };
- throw new BadPartitioningException();
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentExtension3#getPartition(java.lang.String, int)
- * @since 3.0
- */
- public ITypedRegion getPartition(String partitioning, int offset) throws BadLocationException, BadPartitioningException {
- if ((0 > offset) || (offset > getLength()))
- throw new BadLocationException();
- IDocumentPartitioner partitioner= getDocumentPartitioner(partitioning);
- if (partitioner != null)
- return partitioner.getPartition(offset);
- if (DEFAULT_PARTITIONING.equals(partitioning))
- return new TypedRegion(0, getLength(), DEFAULT_CONTENT_TYPE);
- throw new BadPartitioningException();
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentExtension3#getPartitionings()
- * @since 3.0
- */
- public String[] getPartitionings() {
- if (fDocumentPartitioners == null)
- return new String[0];
- String[] partitionings= new String[fDocumentPartitioners.size()];
- fDocumentPartitioners.keySet().toArray(partitionings);
- return partitionings;
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentExtension3#setDocumentPartitioner(java.lang.String, org.eclipse.jface.text.IDocumentPartitioner)
- * @since 3.0
- */
- public void setDocumentPartitioner(String partitioning, IDocumentPartitioner partitioner) {
- if (partitioner == null) {
- if (fDocumentPartitioners != null) {
- fDocumentPartitioners.remove(partitioning);
- if (fDocumentPartitioners.size() == 0)
- fDocumentPartitioners= null;
- }
- } else {
- if (fDocumentPartitioners == null)
- fDocumentPartitioners= new HashMap();
- fDocumentPartitioners.put(partitioning, partitioner);
- }
- DocumentPartitioningChangedEvent event= new DocumentPartitioningChangedEvent(this);
- event.setPartitionChange(partitioning, 0, getLength());
- fireDocumentPartitioningChanged(event);
- }
-
- /*
- * @see org.eclipse.jface.text.IRepairableDocument#repairLineInformation()
- * @since 3.0
- */
- public void repairLineInformation() {
- getTracker().set(get());
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/AbstractLineTracker.java b/org.eclipse.text/src/org/eclipse/jface/text/AbstractLineTracker.java
deleted file mode 100644
index 02a328c..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/AbstractLineTracker.java
+++ /dev/null
@@ -1,557 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-
-
-/**
- * Abstract implementation of <code>ILineTracker</code>. It lets the
- * definition of line delimiters to subclasses. Assuming that '\n' is
- * the only line delimiter, this abstract implementation defines the
- * following line scheme:
- * <ul>
- * <li> "" -> [0,0]
- * <li> "a" -> [0,1]
- * <li> "\n" -> [0,1], [1,0]
- * <li> "a\n" -> [0,2], [2,0]
- * <li> "a\nb" -> [0,2], [2,1]
- * <li> "a\nbc\n" -> [0,2], [2,3], [5,0]
- * </ul>
- * This class must be subclassed.
- */
-public abstract class AbstractLineTracker implements ILineTracker {
-
-
- /**
- * Combines the information of the occurence of a line delimiter.
- * <code>delimiterIndex</code> is the index where a line delimiter
- * starts, whereas <code>delimiterLength</code>, indicates the length
- * of the delimiter.
- */
- protected static class DelimiterInfo {
- public int delimiterIndex;
- public int delimiterLength;
- public String delimiter;
- }
-
-
- /** The line information */
- private List fLines= new ArrayList();
- /** The length of the tracked text */
- private int fTextLength;
-
-
- /**
- * Creates a new line tracker.
- */
- protected AbstractLineTracker() {
- }
-
- /**
- * Binary search for the line at a given offset.
- *
- * @param offset the offset whose line should be found
- * @return the line of the offset
- */
- private int findLine(int offset) {
-
- if (fLines.size() == 0)
- return -1;
-
- int left= 0;
- int right= fLines.size() -1;
- int mid= 0;
- Line line= null;
-
- while (left < right) {
-
- mid= (left + right) / 2;
-
- line= (Line) fLines.get(mid);
- if (offset < line.offset) {
- if (left == mid)
- right= left;
- else
- right= mid -1;
- } else if (offset > line.offset) {
- if (right == mid)
- left= right;
- else
- left= mid +1;
- } else if (offset == line.offset) {
- left= right= mid;
- }
- }
-
- line= (Line) fLines.get(left);
- if (line.offset > offset)
- -- left;
- return left;
- }
-
- /**
- * Returns the number of lines covered by the specified text range.
- *
- * @param startLine the line where the text range starts
- * @param offset the start offset of the text range
- * @param length the length of the text range
- * @return the number of lines covered by this text range
- * @exception BadLocationException if range is undefined in this tracker
- */
- private int getNumberOfLines(int startLine, int offset, int length) throws BadLocationException {
-
- if (length == 0)
- return 1;
-
- int target= offset + length;
-
- Line l= (Line) fLines.get(startLine);
-
- if (l.delimiter == null)
- return 1;
-
- if (l.offset + l.length > target)
- return 1;
-
- if (l.offset + l.length == target)
- return 2;
-
- return getLineNumberOfOffset(target) - startLine + 1;
- }
-
- /*
- * @see ILineTracker#getLineLength(int)
- */
- public int getLineLength(int line) throws BadLocationException {
-
- int lines= fLines.size();
-
- if (line < 0 || line > lines)
- throw new BadLocationException();
-
- if (lines == 0 || lines == line)
- return 0;
-
- Line l= (Line) fLines.get(line);
- return l.length;
- }
-
- /*
- * @see ILineTracker#getLineNumberOfOffset(int)
- */
- public int getLineNumberOfOffset(int position) throws BadLocationException {
-
- if (position > fTextLength)
- throw new BadLocationException();
-
- if (position == fTextLength) {
-
- int lastLine= fLines.size() - 1;
- if (lastLine < 0)
- return 0;
-
- Line l= (Line) fLines.get(lastLine);
- return (l.delimiter != null ? lastLine + 1 : lastLine);
- }
-
- return findLine(position);
- }
-
- /*
- * @see ILineTracker#getLineInformationOfOffset(int)
- */
- public IRegion getLineInformationOfOffset(int position) throws BadLocationException {
- if (position > fTextLength)
- throw new BadLocationException();
-
- if (position == fTextLength) {
- int size= fLines.size();
- if (size == 0)
- return new Region(0, 0);
- Line l= (Line) fLines.get(size - 1);
- return (l.delimiter != null ? new Line(fTextLength, 0) : new Line(fTextLength - l.length, l.length));
- }
-
- return getLineInformation(findLine(position));
- }
-
- /*
- * @see ILineTracker#getLineInformation(int)
- */
- public IRegion getLineInformation(int line) throws BadLocationException {
-
- int lines= fLines.size();
-
- if (line < 0 || line > lines)
- throw new BadLocationException();
-
- if (lines == 0)
- return new Line(0, 0);
-
- if (line == lines) {
- Line l= (Line) fLines.get(line - 1);
- return new Line(l.offset + l.length, 0);
- }
-
- Line l= (Line) fLines.get(line);
- return (l.delimiter != null ? new Line(l.offset, l.length - l.delimiter.length()) : l);
- }
-
- /*
- * @see ILineTracker#getLineOffset(int)
- */
- public int getLineOffset(int line) throws BadLocationException {
-
- int lines= fLines.size();
-
- if (line < 0 || line > lines)
- throw new BadLocationException();
-
- if (lines == 0)
- return 0;
-
- if (line == lines) {
- Line l= (Line) fLines.get(line - 1);
- return l.offset + l.length;
- }
-
- Line l= (Line) fLines.get(line);
- return l.offset;
- }
-
- /*
- * @see ILineTracker#getNumberOfLines()
- */
- public int getNumberOfLines() {
-
- int lines= fLines.size();
-
- if (lines == 0)
- return 1;
-
- Line l= (Line) fLines.get(lines - 1);
- return (l.delimiter != null ? lines + 1 : lines);
- }
-
- /*
- * @see ILineTracker#getNumberOfLines(int, int)
- */
- public int getNumberOfLines(int position, int length) throws BadLocationException {
-
- if (position < 0 || position + length > fTextLength)
- throw new BadLocationException();
-
- if (length == 0) // optimization
- return 1;
-
- return getNumberOfLines(getLineNumberOfOffset(position), position, length);
- }
-
- /*
- * @see ILineTracker#computeNumberOfLines(String)
- */
- public int computeNumberOfLines(String text) {
- int count= 0;
- int start= 0;
- DelimiterInfo delimiterInfo= nextDelimiterInfo(text, start);
- while (delimiterInfo != null && delimiterInfo.delimiterIndex > -1) {
- ++count;
- start= delimiterInfo.delimiterIndex + delimiterInfo.delimiterLength;
- delimiterInfo= nextDelimiterInfo(text, start);
- }
- return count;
- }
-
-
- /* ----------------- manipulation ------------------------------ */
-
-
- /**
- * Returns the info of the first delimiter found in the given
- * text starting at the given offset.
- *
- * @param text the text to be searched
- * @param offset the offset in the given text
- * @return the info of the first found delimiter or <code>null</code> if
- * there is no such info
- */
- protected abstract DelimiterInfo nextDelimiterInfo(String text, int offset);
-
-
- /**
- * Creates the line structure for the given text. Newly created lines
- * are inserted into the line structure starting at the given
- * position. Returns the number of newly created lines.
- *
- * @param text the text for which to create a line structure
- * @param insertPosition the position at which the newly created lines are inserted
- * into the tracker's line structure
- * @param offset the offset of all newly created lines
- * @return the number of newly created lines
- */
- private int createLines(String text, int insertPosition, int offset) {
-
- int count= 0;
- int start= 0;
- DelimiterInfo delimiterInfo= nextDelimiterInfo(text, 0);
-
-
- while (delimiterInfo != null && delimiterInfo.delimiterIndex > -1) {
-
- int index= delimiterInfo.delimiterIndex + (delimiterInfo.delimiterLength - 1);
-
- if (insertPosition + count >= fLines.size())
- fLines.add(new Line(offset + start, offset + index, delimiterInfo.delimiter));
- else
- fLines.add(insertPosition + count, new Line(offset + start, offset + index, delimiterInfo.delimiter));
-
- ++count;
- start= index + 1;
- delimiterInfo= nextDelimiterInfo(text, start);
- }
-
- if (start < text.length()) {
- if (insertPosition + count < fLines.size()) {
- // there is a line below the current
- Line l= (Line) fLines.get(insertPosition + count);
- int delta= text.length() - start;
- l.offset -= delta;
- l.length += delta;
- } else {
- fLines.add(new Line(offset + start, offset + text.length() - 1, null));
- ++count;
- }
- }
-
- return count;
- }
-
- /**
- * Keeps track of the line information when text is inserted.
- * Returns the number of inserted lines.
- *
- * @param lineNumber the line at which the insert happens
- * @param offset at which the insert happens
- * @param text the inserted text
- * @return the number of inserted lines
- * @exception BadLocationException if offset is invalid in this tracker
- */
- private int insert(int lineNumber, int offset, String text) throws BadLocationException {
-
- if (text == null || text.length() == 0)
- return 0;
-
- fTextLength += text.length();
-
- int size= fLines.size();
-
- if (size == 0 || lineNumber >= size)
- return createLines(text, size, offset);
-
- Line line= (Line) fLines.get(lineNumber);
- DelimiterInfo delimiterInfo= nextDelimiterInfo(text, 0);
- if (delimiterInfo == null || delimiterInfo.delimiterIndex == -1) {
- line.length += text.length();
- return 0;
- }
-
-
- // as there is a line break, split line but do so only if rest of line is not of length 0
- int restLength= line.offset + line.length - offset;
- if (restLength > 0) {
- // determine start and end of the second half of the splitted line
- Line lineRest= new Line(offset, restLength);
- lineRest.delimiter= line.delimiter;
- // shift it by the inserted text
- lineRest.offset += text.length();
- // and insert in line structure
- fLines.add(lineNumber + 1, lineRest);
- }
-
- // adapt the beginning of the splitted line
- line.delimiter= delimiterInfo.delimiter;
- int nextStart= offset + delimiterInfo.delimiterIndex + delimiterInfo.delimiterLength;
- line.length= nextStart - line.offset;
-
- // insert lines for the remaining text
- text= text.substring(delimiterInfo.delimiterIndex + delimiterInfo.delimiterLength);
- return createLines(text, lineNumber + 1, nextStart) + 1;
- }
-
- /**
- * Keeps track of the line information when text is removed. Returns
- * whether the line at which the deletion start will thereby be deleted.
- *
- * @param lineNumber the lineNumber at which the deletion starts
- * @param offset the offset of the first deleted character
- * @param length the number of deleted characters
- * @return whethere the start line of the deletion has been deleted
- * @exception BadLocationException if position is unkown to the tracker
- */
- private boolean remove(int lineNumber, int offset, int length) throws BadLocationException {
-
- if (length == 0)
- return false;
-
- int removedLineEnds= getNumberOfLines(lineNumber, offset, length) - 1;
- Line line= (Line) fLines.get(lineNumber);
-
- if ((lineNumber == fLines.size() - 1) && removedLineEnds > 0) {
- line.length -= length;
- line.delimiter= null;
- } else {
-
- ++ lineNumber;
- for (int i= 1; i <= removedLineEnds; i++) {
-
- if (lineNumber == fLines.size()) {
- line.delimiter= null;
- break;
- }
-
- Line line2= (Line) fLines.get(lineNumber);
- line.length += line2.length;
- line.delimiter= line2.delimiter;
- fLines.remove(lineNumber);
- }
- line.length -= length;
- }
-
- fTextLength -= length;
-
- if (line.length == 0) {
- fLines.remove(line);
- return true;
- }
-
- return false;
- }
-
- /**
- * Adapts the offset of all lines with line numbers greater than the specified
- * one to the given delta.
- *
- * @param lineNumber the line number after which to start
- * @param delta the offset delta to be applied
- */
- private void adaptLineOffsets(int lineNumber, int delta) {
- int size= fLines.size();
- for (int i= lineNumber + 1; i < size; i++) {
- Line l= (Line) fLines.get(i);
- l.offset += delta;
- }
- }
-
- /*
- * @see ILineTracker#replace(int, int, String)
- */
- public void replace(int position, int length, String text) throws BadLocationException {
-
- int firstLine= getLineNumberOfOffset(position);
- int insertLineNumber= firstLine;
-
- if (remove(firstLine, position, length))
- -- firstLine;
-
- int lastLine= firstLine + insert(insertLineNumber, position, text);
-
-// int lines= fLines.size();
-// if (lines > 0) {
-//
-// // try to collapse the first and the second line if second line is empty
-// if (0 <= firstLine && firstLine + 1 < lines) {
-// Line l2= (Line) fLines.get(firstLine + 1);
-// if (l2.delimiter != null && l2.length == l2.delimiter.length()) {
-// // line is empty
-//
-// // append empty line to precessor
-// Line l1= (Line) fLines.get(firstLine);
-// StringBuffer buffer= new StringBuffer();
-// buffer.append(l1.delimiter);
-// buffer.append(l2.delimiter);
-//
-// // test whether this yields just one line rather then two
-// DelimiterInfo info= nextDelimiterInfo(buffer.toString(), 0);
-// if (info != null && info.delimiterIndex == 0 && info.delimiterLength == buffer.length()) {
-// l1.length += l2.length;
-// l1.delimiter += l2.delimiter;
-// fLines.remove(firstLine + 1);
-// -- lastLine;
-// }
-// }
-// }
-//
-// // try to collapse the last inserted line with the following line
-// if (lastLine < lines) {
-// Line l2= (Line) fLines.get(lastLine);
-// if (l2.delimiter != null && l2.length == l2.delimiter.length()) {
-// // line is empty
-//
-// // append empty line to precessor
-// Line l1= (Line) fLines.get(lastLine -1);
-// StringBuffer buffer= new StringBuffer();
-// buffer.append(l1.delimiter);
-// buffer.append(l2.delimiter);
-//
-// // test whether this yields just one line rather then two
-// DelimiterInfo info= nextDelimiterInfo(buffer.toString(), 0);
-// if (info != null && info.delimiterIndex == 0 && info.delimiterLength == buffer.length()) {
-// l1.length += l2.length;
-// l1.delimiter += l2.delimiter;
-// fLines.remove(lastLine);
-// }
-// }
-// }
-// }
-
- int delta= -length;
- if (text != null)
- delta= text.length() + delta;
-
- if (delta != 0)
- adaptLineOffsets(lastLine, delta);
- }
-
- /*
- * @see ILineTracker#set(String)
- */
- public void set(String text) {
- fLines.clear();
- if (text != null) {
- fTextLength= text.length();
- createLines(text, 0, 0);
- }
- }
-
- /*
- * @see ILineTracker#getLineDelimiter(int)
- */
- public String getLineDelimiter(int line) throws BadLocationException {
-
- int lines= fLines.size();
-
- if (line < 0 || line > lines)
- throw new BadLocationException();
-
- if (lines == 0)
- return null;
-
- if (line == lines)
- return null;
-
- Line l= (Line) fLines.get(line);
- return l.delimiter;
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/Assert.java b/org.eclipse.text/src/org/eclipse/jface/text/Assert.java
deleted file mode 100644
index 40d65ab..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/Assert.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-
-/**
- * <code>Assert</code> is useful for for embedding runtime sanity checks
- * in code. The static predicate methods all test a condition and throw some
- * type of unchecked exception if the condition does not hold.
- * <p>
- * Assertion failure exceptions, like most runtime exceptions, are
- * thrown when something is misbehaving. Assertion failures are invariably
- * unspecified behavior; consequently, clients should never rely on
- * these being thrown (or not thrown). <b>If you find yourself in the
- * position where you need to catch an assertion failure, you have most
- * certainly written your program incorrectly.</b>
- * </p>
- * <p>
- * Note that an <code>assert</code> statement is slated to be added to the
- * Java language in JDK 1.4, rending this class obsolete.
- * </p>
- */
-public final class Assert {
-
- /**
- * <code>AssertionFailedException</code> is a runtime exception thrown
- * by some of the methods in <code>Assert</code>.
- * <p>
- * This class is not declared public to prevent some misuses; programs that catch
- * or otherwise depend on assertion failures are susceptible to unexpected
- * breakage when assertions in the code are added or removed.
- * </p>
- */
- private static class AssertionFailedException extends RuntimeException {
-
- /**
- * Constructs a new exception.
- */
- public AssertionFailedException() {
- }
-
- /**
- * Constructs a new exception with the given message.
- */
- public AssertionFailedException(String detail) {
- super(detail);
- }
- }
-
- /* This class is not intended to be instantiated. */
- private Assert() {
- }
-
- /**
- * Asserts that an argument is legal. If the given boolean is
- * not <code>true</code>, an <code>IllegalArgumentException</code>
- * is thrown.
- *
- * @param expression the outcome of the check
- * @return <code>true</code> if the check passes (does not return
- * if the check fails)
- * @exception IllegalArgumentException if the legality test failed
- */
- public static boolean isLegal(boolean expression) {
- // succeed as quickly as possible
- if (expression) {
- return true;
- }
- return isLegal(expression, "");//$NON-NLS-1$
- }
-
- /**
- * Asserts that an argument is legal. If the given boolean is
- * not <code>true</code>, an <code>IllegalArgumentException</code>
- * is thrown.
- * The given message is included in that exception, to aid debugging.
- *
- * @param expression the outcome of the check
- * @param message the message to include in the exception
- * @return <code>true</code> if the check passes (does not return
- * if the check fails)
- * @exception IllegalArgumentException if the legality test failed
- */
- public static boolean isLegal(boolean expression, String message) {
- if (!expression)
- throw new IllegalArgumentException("assertion failed; " + message); //$NON-NLS-1$
- return expression;
- }
-
- /**
- * Asserts that the given object is not <code>null</code>. If this
- * is not the case, some kind of unchecked exception is thrown.
- * <p>
- * As a general rule, parameters passed to API methods must not be
- * <code>null</code> unless <b>explicitly</b> allowed in the method's
- * specification. Similarly, results returned from API methods are never
- * <code>null</code> unless <b>explicitly</b> allowed in the method's
- * specification. Implementations are encouraged to make regular use of
- * <code>Assert.isNotNull</code> to ensure that <code>null</code>
- * parameters are detected as early as possible.
- * </p>
- *
- * @param object the value to test
- * @exception Throwable an unspecified unchecked exception if the object
- * is <code>null</code>
- */
- public static void isNotNull(Object object) {
- // succeed as quickly as possible
- if (object != null) {
- return;
- }
- isNotNull(object, "");//$NON-NLS-1$
- }
-
- /**
- * Asserts that the given object is not <code>null</code>. If this
- * is not the case, some kind of unchecked exception is thrown.
- * The given message is included in that exception, to aid debugging.
- * <p>
- * As a general rule, parameters passed to API methods must not be
- * <code>null</code> unless <b>explicitly</b> allowed in the method's
- * specification. Similarly, results returned from API methods are never
- * <code>null</code> unless <b>explicitly</b> allowed in the method's
- * specification. Implementations are encouraged to make regular use of
- * <code>Assert.isNotNull</code> to ensure that <code>null</code>
- * parameters are detected as early as possible.
- * </p>
- *
- * @param object the value to test
- * @param message the message to include in the exception
- * @exception Throwable an unspecified unchecked exception if the object
- * is <code>null</code>
- */
- public static void isNotNull(Object object, String message) {
- if (object == null)
- throw new AssertionFailedException("null argument;" + message);//$NON-NLS-1$
- }
-
- /**
- * Asserts that the given boolean is <code>true</code>. If this
- * is not the case, some kind of unchecked exception is thrown.
- *
- * @param expression the outcome of the check
- * @return <code>true</code> if the check passes (does not return
- * if the check fails)
- */
- public static boolean isTrue(boolean expression) {
- // succeed as quickly as possible
- if (expression) {
- return true;
- }
- return isTrue(expression, "");//$NON-NLS-1$
- }
-
- /**
- * Asserts that the given boolean is <code>true</code>. If this
- * is not the case, some kind of unchecked exception is thrown.
- * The given message is included in that exception, to aid debugging.
- *
- * @param expression the outcome of the check
- * @param message the message to include in the exception
- * @return <code>true</code> if the check passes (does not return
- * if the check fails)
- */
- public static boolean isTrue(boolean expression, String message) {
- if (!expression)
- throw new AssertionFailedException("Assertion failed: "+message);//$NON-NLS-1$
- return expression;
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/BadLocationException.java b/org.eclipse.text/src/org/eclipse/jface/text/BadLocationException.java
deleted file mode 100644
index 8348b1f..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/BadLocationException.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-
-
-/**
- * Indicates the attempt to access a non-existing position.
- * The attempt has been performed on a text store such as a document or string.
- */
-public class BadLocationException extends Exception {
-
- /**
- * Creates a new bad location exception.
- */
- public BadLocationException() {
- super();
- }
-
- /**
- * Creates a new bad location exception.
- *
- * @param message the exception message
- */
- public BadLocationException(String message) {
- super(message);
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/BadPartitioningException.java b/org.eclipse.text/src/org/eclipse/jface/text/BadPartitioningException.java
deleted file mode 100644
index fc69e3a..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/BadPartitioningException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**********************************************************************
-Copyright (c) 2000, 2003 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-
-Contributors:
- IBM Corporation - Initial implementation
-**********************************************************************/
-package org.eclipse.jface.text;
-
-/**
- * Represents the attempt to refer to a non-existing document partitioning.
- * @see org.eclipse.jface.text.IDocument
- * @see org.eclipse.jface.text.IDocumentExtension3
- * @since 3.0
- */
-public class BadPartitioningException extends Exception {
-
- /**
- * Creates a new bad partitioning exception.
- */
- public BadPartitioningException() {
- }
-
- /**
- * Creates a new bad partitioning exception.
- *
- * @param message message describing the exception
- */
- public BadPartitioningException(String message) {
- super(message);
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/BadPositionCategoryException.java b/org.eclipse.text/src/org/eclipse/jface/text/BadPositionCategoryException.java
deleted file mode 100644
index c838292..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/BadPositionCategoryException.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-
-
-/**
- * Indicates the attempt to access a non-existing position
- * category in a document.
- *
- * @see IDocument
- */
-public class BadPositionCategoryException extends Exception {
-
- /**
- * Creates a new bad position category exception.
- */
- public BadPositionCategoryException() {
- super();
- }
-
- /**
- * Creates a new bad position category exception.
- *
- * @param message the exception's message
- */
- public BadPositionCategoryException(String message) {
- super(message);
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/ChildDocument.java b/org.eclipse.text/src/org/eclipse/jface/text/ChildDocument.java
deleted file mode 100644
index fa1eaa2..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/ChildDocument.java
+++ /dev/null
@@ -1,454 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-
-
-/**
- * A child document is one particular example of a slave document. Child documents
- * are created by the <code>ChildDocumentManager</code>, an implementation of
- * <code>ISlaveDocumentManager</code>.<p>
- *
- * A child document represents one consequetive range of its master document.
- * The master document is called parent document. The child document is always in sync
- * with its parent document by utilizing the parent document as its <code>ITextStore</code>.<p>
- *
- * This class is for internal use only.
- *
- * @see ITextStore
- * @deprecated
- */
-public final class ChildDocument extends AbstractDocument {
-
-
- /**
- * Implements <code>ITextStore</code> based on <code>IDocument</code>.
- */
- class TextStore implements ITextStore {
-
- /*
- * @see ITextStore#set(String)
- */
- public void set(String txt) {
- try {
- fParentDocument.replace(fRange.getOffset(), fRange.getLength(), txt);
- } catch (BadLocationException x) {
- // cannot happen
- }
- }
-
- /*
- * @see ITextStore#replace(int, int, String)
- */
- public void replace(int offset, int length, String txt) {
- try {
- fParentDocument.replace(fRange.getOffset() + offset, length, txt);
- } catch (BadLocationException x) {
- // ignored as surrounding document should have handled this
- }
- }
-
- /*
- * @see ITextStore#getLength()
- */
- public int getLength() {
- return fRange.getLength();
- }
-
- /*
- * @see ITextStore#get(int, int)
- */
- public String get(int offset, int length) {
- try {
- return fParentDocument.get(fRange.getOffset() + offset, length);
- } catch (BadLocationException x) {
- }
-
- return "";
- }
-
- /*
- * @see ITextStore#get(int)
- */
- public char get(int offset) {
- try {
- return fParentDocument.getChar(fRange.getOffset() + offset);
- } catch (BadLocationException x) {
- }
-
- return (char) 0;
- }
- }
-
-
-
- /** The parent document */
- private IDocument fParentDocument;
- /**
- * The parent document as <code>IDocumentExtension</code>
- * @since 2.0
- */
- private IDocumentExtension fExtension;
- /**
- * The parent document as <code>IDocumentExtension2</code>
- * @since 2.1
- */
- private IDocumentExtension2 fExtension2;
- /** The section inside the parent document */
- private Position fRange;
- /** The document event issued by the parent document */
- private DocumentEvent fParentEvent;
- /** The document event issued and to be issued by the child document */
- private DocumentEvent fEvent;
- /** Indicates whether the child document initiated a parent document update or not */
- private boolean fIsUpdating= false;
- /**
- * The expected document content after the parent document changed.
- * @since 2.1
- */
- private String fExpectedContent;
- /**
- * The length of this child document prior to the change of the parent document
- * @since 2.1
- */
- private int fRememberedLength;
- /**
- * Indicates whether this document is in auto expand mode.
- * @since 2.1
- */
- private boolean fIsAutoExpanding= false;
-
-
- /**
- * Creates a child document for the given range of the given parent document.
- *
- * @param parentDocument the parent Document
- * @param range the parent document range covered by the child document
- */
- public ChildDocument(IDocument parentDocument, Position range) {
- super();
-
- fParentDocument= parentDocument;
- if (fParentDocument instanceof IDocumentExtension)
- fExtension= (IDocumentExtension) fParentDocument;
- if (fParentDocument instanceof IDocumentExtension2)
- fExtension2= (IDocumentExtension2) fParentDocument;
-
- fRange= range;
-
- ITextStore s= new TextStore();
- ILineTracker tracker= new DefaultLineTracker();
- tracker.set(s.get(0, fRange.getLength()));
-
- setTextStore(s);
- setLineTracker(tracker);
-
- completeInitialization();
- }
-
- /**
- * Sets the child document's parent document range.
- *
- * @param offset the offset of the parent document range
- * @param length the length of the parent document range
- */
- public void setParentDocumentRange(int offset, int length) throws BadLocationException {
-
- if (offset < 0 || length < 0 || offset + length > fParentDocument.getLength())
- throw new BadLocationException();
-
- fRange.setOffset(offset);
- fRange.setLength(length);
-
- getTracker().set(fParentDocument.get(offset, length));
- }
-
- /**
- * Returns parent document
- *
- * @return the parent document
- */
- public IDocument getParentDocument() {
- return fParentDocument;
- }
-
- /**
- * Returns the range of the parent document covered by this child document.
- *
- * @return the child document's parent document range
- */
- public Position getParentDocumentRange() {
- return fRange;
- }
-
- /**
- * <p>Transforms a document event of the parent document into a child document
- * based document event. This method considers whether the document is in
- * auto expand mode.</p>
- * This method is public for test purposes only.
- *
- * @param e the parent document event
- * @return the child document event
- */
- public DocumentEvent normalize(DocumentEvent event) {
-
- int delta= event.getOffset() - fRange.getOffset();
-
- if (isAutoExpandEvent(event)) {
-
- if (delta < 0) {
- int eventEndOffset= event.getOffset() + event.getLength();
-
- if (eventEndOffset <= fRange.getOffset()) {
-
- // case 1
- StringBuffer buffer= new StringBuffer();
- if (event.getText() != null)
- buffer.append(event.getText());
- try {
- buffer.append(fParentDocument.get(eventEndOffset, -delta - event.getLength()));
- } catch (BadLocationException e) {
- // should not happen as the event is a valid parent document event
- }
-
- return new SlaveDocumentEvent(this, 0, 0, buffer.toString(), event);
-
- } else {
-
- // cases 2 and 3
- int length= Math.min(eventEndOffset - fRange.getOffset(), fRange.getLength());
- return new SlaveDocumentEvent(this, 0, length, event.getText(), event);
- }
-
- } else {
- int rangeEndOffset= fRange.getOffset() + fRange.getLength();
-
- if (event.getOffset() >= rangeEndOffset) {
-
- // case 5
- StringBuffer buffer= new StringBuffer();
- try {
- buffer.append(fParentDocument.get(rangeEndOffset, event.getOffset() - rangeEndOffset));
- } catch (BadLocationException e) {
- // should not happen as this event is a valid parent document event
- }
- if (event.getText() != null)
- buffer.append(event.getText());
-
- return new SlaveDocumentEvent(this, fRange.getLength(), 0, buffer.toString(), event);
-
- } else {
-
- // case 4 and 6
- int offset= event.getOffset() - fRange.getOffset();
- int length= Math.min(rangeEndOffset - event.getOffset(), event.getLength());
- return new SlaveDocumentEvent(this, offset, length, event.getText(), event);
- }
- }
-
- } else if (fRange.overlapsWith(event.fOffset, event.fLength)) {
-
- int offset= delta < 0 ? 0 : delta;
- int length= delta < 0 ? event.fLength + delta : event.fLength;
- if (offset + length > fRange.getLength())
- length= fRange.getLength() - offset;
-
- return new SlaveDocumentEvent(this, offset, length, event.fText, event);
- }
-
- return null;
- }
-
- /**
- * When called this child document is informed about a forthcoming change
- * of its parent document. This child document checks whether the parent
- * document change affects it and if so informs all document listeners.
- *
- * @param event the parent document event
- */
- public void parentDocumentAboutToBeChanged(DocumentEvent event) {
-
- fParentEvent= event;
-
- fEvent= normalize(event);
- if (fEvent != null) {
-
- StringBuffer buffer= new StringBuffer(get());
- fRememberedLength= buffer.length();
- buffer.replace(fEvent.fOffset, fEvent.fOffset+ fEvent.fLength, fEvent.fText == null ? "" : fEvent.fText); //$NON-NLS-1$
- fExpectedContent= buffer.toString();
-
- delayedFireDocumentAboutToBeChanged();
- }
- }
-
- /**
- * When called this child document is informed about a change of its parent document.
- * If this child document is affected it informs all of its document listeners.
- *
- * @param event the parent document event
- */
- public void parentDocumentChanged(DocumentEvent event) {
- if ( !fIsUpdating && event == fParentEvent && fEvent != null) {
- try {
-
- if (!fExpectedContent.equals(get())) {
- // patch the event
- fEvent.fOffset= 0;
- fEvent.fLength= fRememberedLength;
- fEvent.fText= get();
- }
-
- fRememberedLength= 0;
- fExpectedContent= null;
-
- getTracker().replace(fEvent.fOffset, fEvent.fLength, fEvent.fText);
- fireDocumentChanged(fEvent);
-
- } catch (BadLocationException x) {
- Assert.isLegal(false);
- }
- }
- }
-
- /*
- * @see AbstractDocument#fireDocumentAboutToBeChanged(DocumentEvent)
- */
- protected void fireDocumentAboutToBeChanged(DocumentEvent event) {
- // delay it until there is a notification from the parent document
- // otherwise there it is expensive to construct the parent document information
- }
-
- /**
- * Fires the child document event as about-to-be-changed event to all
- * registed listeners.
- */
- private void delayedFireDocumentAboutToBeChanged() {
- super.fireDocumentAboutToBeChanged(fEvent);
- }
-
- /**
- * Ignores the given event and sends the similar child document event instead.
- *
- * @param event the event to be ignored
- */
- protected void fireDocumentChanged(DocumentEvent event) {
- super.fireDocumentChanged(fEvent);
- }
-
- /*
- * @see IDocument#replace(int, int, String)
- * @since 2.0
- */
- public void replace(int offset, int length, String text) throws BadLocationException {
- try {
- fIsUpdating= true;
- if (fExtension != null)
- fExtension.stopPostNotificationProcessing();
-
- if ((0 > offset) || (0 > length) || (offset + length > getLength()))
- throw new BadLocationException();
-
- DocumentEvent event= new DocumentEvent(this, offset, length, text);
- fireDocumentAboutToBeChanged(event);
-
- try {
-
- if (fExtension2 != null)
- fExtension2.stopListenerNotification();
-
- getStore().replace(offset, length, text);
- getTracker().replace(offset, length, text);
- updateDocumentStructures(fEvent);
-
- } finally {
- if (fExtension2 != null)
- fExtension2.resumeListenerNotification();
- }
-
- doFireDocumentChanged(fEvent);
-
- } finally {
- fIsUpdating= false;
- if (fExtension != null)
- fExtension.resumePostNotificationProcessing();
- }
- }
-
- /*
- * @see IDocument#set(String)
- * @since 2.0
- */
- public void set(String text) {
- try {
- fIsUpdating= true;
- if (fExtension != null)
- fExtension.stopPostNotificationProcessing();
-
- int length= getStore().getLength();
- DocumentEvent event= new DocumentEvent(this, 0, length, text);
- fireDocumentAboutToBeChanged(event);
-
- try {
-
- if (fExtension2 != null)
- fExtension2.stopListenerNotification();
-
- getStore().set(text);
- getTracker().set(text);
- updateDocumentStructures(fEvent);
-
- } finally {
- if (fExtension2 != null)
- fExtension2.resumeListenerNotification();
- }
-
- doFireDocumentChanged(fEvent);
-
- } finally {
- fIsUpdating= false;
- if (fExtension != null)
- fExtension.resumePostNotificationProcessing();
- }
- }
-
- /*
- * @see IDocumentExtension#registerPostNotificationReplace(IDocumentListener, IDocumentExtension.IReplace)
- * @since 2.0
- */
- public void registerPostNotificationReplace(IDocumentListener owner, IDocumentExtension.IReplace replace) {
- if (!fIsUpdating)
- throw new UnsupportedOperationException();
- super.registerPostNotificationReplace(owner, replace);
- }
-
- /**
- * Sets the auto expand mode of this document.
- *
- * @param autoExpand <code>true</code> if auto expanding, <code>false</code> otherwise
- * @since 2.1
- */
- public void setAutoExpandMode(boolean autoExpand) {
- fIsAutoExpanding= autoExpand;
- }
-
- /**
- * Returns whether the given document might cause this document to auto expand.
- * This default implementation always answers with its auto expand state.
- *
- * @param event the document event
- * @return <code>true</code> if the given event might cause this document to auto expand
- */
- public boolean isAutoExpandEvent(DocumentEvent event) {
- return fIsAutoExpanding;
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/ChildDocumentManager.java b/org.eclipse.text/src/org/eclipse/jface/text/ChildDocumentManager.java
deleted file mode 100644
index be81990..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/ChildDocumentManager.java
+++ /dev/null
@@ -1,466 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-
-/**
- * <code>ChildDocumentManager</code> is one particular implementation of
- * <code>ISlaveDocumentManager</code>. This manager creates so called child
- * documents as slave documents for given master documents.<p>
- *
- * A child document represents a particular range of the parent
- * document and is accordingly adapted to changes of the parent document.
- * Vice versa, the parent document is accordingly adapted to changes of
- * its child documents. The manager does not maintain any particular management
- * structure but utilizes mechanisms given by <code>IDocument</code> such
- * as position categories and position updaters. <p>
- *
- * For internal use only.
- * @deprecated
- */
-public final class ChildDocumentManager implements IDocumentListener, ISlaveDocumentManager {
-
-
- /**
- * Name of the position category used to keep track of the ranges of the parent documents
- * that correspond to child documents.
- */
- public final static String CHILDDOCUMENTS= "__childdocuments"; //$NON-NLS-1$
-
-
- /**
- * Positions which are used to mark the child documents offset ranges into
- * the parent documents. This position uses as bidirectional reference as
- * it knows the child document as well as the parent document.
- */
- static class ChildPosition extends Position {
-
- /** The parent document. */
- public IDocument fParentDocument;
- /* The child document */
- public ChildDocument fChildDocument;
-
- /**
- * Creates a new child position for the given parent document.
- * @param parentDocument the parent document
- * @param offset the offset into the parent document
- * @param length the length in the parent document
- */
- public ChildPosition(IDocument parentDocument, int offset, int length) {
- super(offset, length);
- fParentDocument= parentDocument;
- }
-
- /**
- * Changed to be compatible to the position updater behavior
- * @see Position#overlapsWith(int, int)
- */
- public boolean overlapsWith(int offset, int length) {
- boolean append= (offset == this.offset + this.length) && length == 0;
- return append || super.overlapsWith(offset, length);
- }
- }
-
-
- /**
- * The position updater used to adapt the positions representing
- * the child document ranges to changes of the parent document.
- */
- static class ChildPositionUpdater extends DefaultPositionUpdater {
-
- /** Cached document event */
- private DocumentEvent fDocumentEvent;
-
- /**
- * Creates the position updated.
- */
- protected ChildPositionUpdater() {
- super(CHILDDOCUMENTS);
- }
-
- /**
- * Child document ranges cannot be deleted other then by calling
- * freeChildDocument.
- */
- protected boolean notDeleted() {
- return true;
- }
-
- /*
- * @see org.eclipse.jface.text.DefaultPositionUpdater#update(org.eclipse.jface.text.DocumentEvent)
- */
- public void update(DocumentEvent event) {
- try {
- fDocumentEvent= event;
- super.update(event);
- } finally {
- fDocumentEvent= null;
- }
- }
-
- /**
- * If an insertion happens at a child document's start offset, the
- * position is extended rather than shifted. Also, if something is added
- * right behind the end of the position, the position is extended rather
- * than kept stable.
- *
- * In auto expand mode the position is always streched to contain the
- * whole area of the change.
- */
- protected void adaptToInsert() {
-
- int myStart= fPosition.offset;
- int myEnd= fPosition.offset + fPosition.length;
- boolean isAutoExpanding= isAutoExpanding();
-
- if (fLength != 0 && fOffset < myEnd && !isAutoExpanding) {
- super.adaptToInsert();
- return;
- }
-
- int yoursStart= fOffset;
- int yoursEnd= fOffset + fReplaceLength -1;
- yoursEnd= Math.max(yoursStart, yoursEnd);
-
- if (myEnd < yoursStart) {
- if (isAutoExpanding)
- fPosition.length= yoursEnd - myStart + 1;
- return;
- }
-
- if (myStart <= yoursStart) {
- if (yoursStart < myEnd || fLength == 0)
- fPosition.length += fReplaceLength;
- } else { // yoursStart < myStart
- if (isAutoExpanding) {
- fPosition.offset= yoursStart;
- fPosition.length += (myStart - yoursStart + fReplaceLength);
- } else {
- fPosition.offset += fReplaceLength;
- }
- }
- }
-
- /**
- * Returns whether the child documents should automatically expand to include
- * any parent document change.
- *
- * @return <code>true</code> if auto expanding, <code>false</code> otherwise
- * @since 2.1
- */
- private boolean isAutoExpanding() {
- if (fPosition instanceof ChildPosition) {
- ChildPosition position= (ChildPosition) fPosition;
- return position.fChildDocument.isAutoExpandEvent(fDocumentEvent);
- }
- return false;
- }
- }
-
- /**
- * The child document partitioner uses the parent document to answer all questions.
- */
- static class ChildPartitioner implements IDocumentPartitioner {
-
- /** The child document. */
- protected ChildDocument fChildDocument;
- /** The parent document */
- protected IDocument fParentDocument;
- /**
- * The parent document as <code>IDocumentExtensions3</code>.
- * @since 3.0
- */
- protected IDocumentExtension3 fParentDocument3;
- /**
- * The partitioning of this partitioner.
- * @since 3.0
- */
- protected String fPartitioning;
-
- /**
- * Creates a new child document partitioner for the given document
- * partitioning.
- *
- * @param partitioning the document partitioning
- * @since 3.0
- */
- protected ChildPartitioner(String partitioning) {
- fPartitioning= partitioning;
- }
-
- /**
- * Creates a new child document partitioner.
- */
- protected ChildPartitioner() {
- fPartitioning= null;
- }
-
- /*
- * @see IDocumentPartitioner#getPartition(int)
- */
- public ITypedRegion getPartition(int offset) {
- try {
- offset += fChildDocument.getParentDocumentRange().getOffset();
- if (fParentDocument3 != null)
- return fParentDocument3.getPartition(fPartitioning, offset);
- return fParentDocument.getPartition(offset);
- } catch (BadLocationException x) {
- } catch (BadPartitioningException x) {
- }
-
- return null;
- }
-
- /*
- * @see IDocumentPartitioner#computePartitioning(int, int)
- */
- public ITypedRegion[] computePartitioning(int offset, int length) {
- try {
- offset += fChildDocument.getParentDocumentRange().getOffset();
- if (fParentDocument3 != null)
- return fParentDocument3.computePartitioning(fPartitioning, offset, length);
- return fParentDocument.computePartitioning(offset, length);
- } catch (BadLocationException x) {
- } catch (BadPartitioningException x) {
- }
-
- return null;
- }
-
- /*
- * @see IDocumentPartitioner#getContentType(int)
- */
- public String getContentType(int offset) {
- try {
- offset += fChildDocument.getParentDocumentRange().getOffset();
- if (fParentDocument3 != null)
- return fParentDocument3.getContentType(fPartitioning, offset);
- return fParentDocument.getContentType(offset);
- } catch (BadLocationException x) {
- } catch (BadPartitioningException x) {
- }
-
- return null;
- }
-
- /*
- * @see IDocumentPartitioner#getLegalContentTypes()
- */
- public String[] getLegalContentTypes() {
- if (fParentDocument3 != null)
- try {
- return fParentDocument3.getLegalContentTypes(fPartitioning);
- } catch (BadPartitioningException x) {
- return new String[0];
- }
- return fParentDocument.getLegalContentTypes();
- }
-
- /*
- * @see IDocumentPartitioner#documentChanged(DocumentEvent)
- */
- public boolean documentChanged(DocumentEvent event) {
- // ignore as the parent does this for us
- return false;
- }
-
- /*
- * @see IDocumentPartitioner#documentAboutToBeChanged(DocumentEvent)
- */
- public void documentAboutToBeChanged(DocumentEvent event) {
- // ignore as the parent does this for us
- }
-
- /*
- * @see IDocumentPartitioner#disconnect()
- */
- public void disconnect() {
- fChildDocument= null;
- fParentDocument= null;
- fParentDocument3= null;
- }
-
- /*
- * @see IDocumentPartitioner#connect(IDocument)
- */
- public void connect(IDocument childDocument) {
- Assert.isTrue(childDocument instanceof ChildDocument);
- fChildDocument= (ChildDocument) childDocument;
- fParentDocument= fChildDocument.getParentDocument();
- if (fParentDocument instanceof IDocumentExtension3)
- fParentDocument3= (IDocumentExtension3) fParentDocument;
- }
- }
-
-
-
- /** The position updater shared by all documents which have child documents */
- private IPositionUpdater fChildPositionUpdater;
-
-
- /**
- * Returns the child position updater. If necessary, it is dynamically created.
- *
- * @return the child position updater
- */
- protected IPositionUpdater getChildPositionUpdater() {
- if (fChildPositionUpdater == null)
- fChildPositionUpdater= new ChildPositionUpdater();
- return fChildPositionUpdater;
- }
-
- /*
- * @see org.eclipse.jface.text.ISlaveDocumentManager#createSlaveDocument(org.eclipse.jface.text.IDocument)
- */
- public IDocument createSlaveDocument(IDocument master) {
-
- if (!master.containsPositionCategory(CHILDDOCUMENTS)) {
- master.addPositionCategory(CHILDDOCUMENTS);
- master.addPositionUpdater(getChildPositionUpdater());
- master.addDocumentListener(this);
- }
-
- ChildPosition pos= new ChildPosition(master, 0, 0);
- try {
- master.addPosition(CHILDDOCUMENTS, pos);
- } catch (BadPositionCategoryException x) {
- // cannot happen
- } catch (BadLocationException x) {
- // (0, 0) is OK
- }
-
- ChildDocument child= new ChildDocument(master, pos);
- if (master instanceof IDocumentExtension3) {
- IDocumentExtension3 extension3= (IDocumentExtension3) master;
- String[] partitionings= extension3.getPartitionings();
- for (int i= 0; i < partitionings.length; i++) {
- IDocumentPartitioner partitioner= new ChildPartitioner(partitionings[i]);
- child.setDocumentPartitioner(partitionings[i], partitioner);
- partitioner.connect(child);
- }
- } else {
- IDocumentPartitioner partitioner= new ChildPartitioner();
- child.setDocumentPartitioner(partitioner);
- partitioner.connect(child);
- }
-
- pos.fChildDocument= child;
-
- return child;
- }
-
- /*
- * @see org.eclipse.jface.text.ISlaveDocumentManager#freeSlaveDocument(org.eclipse.jface.text.IDocument)
- */
- public void freeSlaveDocument(IDocument slave) {
-
- if (! (slave instanceof ChildDocument))
- return;
-
- ChildDocument childDocument= (ChildDocument) slave;
-
- String[] partitionings= childDocument.getPartitionings();
- for (int i= 0; i < partitionings.length; i ++) {
- IDocumentPartitioner partitioner= childDocument.getDocumentPartitioner(partitionings[i]);
- if (partitioner != null)
- partitioner.disconnect();
- }
-
- ChildPosition pos= (ChildPosition) childDocument.getParentDocumentRange();
- IDocument parent= pos.fParentDocument;
-
- try {
- parent.removePosition(CHILDDOCUMENTS, pos);
- Position[] category= parent.getPositions(CHILDDOCUMENTS);
- if (category.length == 0) {
- parent.removeDocumentListener(this);
- parent.removePositionUpdater(getChildPositionUpdater());
- parent.removePositionCategory(CHILDDOCUMENTS);
- }
- } catch (BadPositionCategoryException x) {
- // cannot happen
- }
- }
-
- /*
- * @see org.eclipse.jface.text.ISlaveDocumentManager#createMasterSlaveMapping(org.eclipse.jface.text.IDocument)
- */
- public IDocumentInformationMapping createMasterSlaveMapping(IDocument slave) {
- if (slave instanceof ChildDocument)
- return new ParentChildMapping((ChildDocument) slave);
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.ISlaveDocumentManager#getMasterDocument(org.eclipse.jface.text.IDocument)
- */
- public IDocument getMasterDocument(IDocument slave) {
- if (slave instanceof ChildDocument)
- return ((ChildDocument) slave).getParentDocument();
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.ISlaveDocumentManager#isSlaveDocument(org.eclipse.jface.text.IDocument)
- */
- public boolean isSlaveDocument(IDocument document) {
- return (document instanceof ChildDocument);
- }
-
- /**
- * Informs all child documents of the document which issued this document event.
- *
- * @param about indicates whether the change is about to happen or alread happend
- * @param event the document event which will be processed to inform child documents
- */
- protected void fireDocumentEvent(boolean about, DocumentEvent event) {
- try {
-
- IDocument parent= event.getDocument();
- Position[] children= parent.getPositions(CHILDDOCUMENTS);
- for (int i= 0; i < children.length; i++) {
- Object o= children[i];
- if (o instanceof ChildPosition) {
- ChildPosition pos= (ChildPosition) o;
- if (about)
- pos.fChildDocument.parentDocumentAboutToBeChanged(event);
- else
- pos.fChildDocument.parentDocumentChanged(event);
- }
- }
- } catch (BadPositionCategoryException x) {
- // cannot happen
- }
- }
-
- /*
- * @see IDocumentListener#documentChanged(DocumentEvent)
- */
- public void documentChanged(DocumentEvent event) {
- fireDocumentEvent(false, event);
- }
-
- /*
- * @see IDocumentListener#documentAboutToBeChanged(DocumentEvent)
- */
- public void documentAboutToBeChanged(DocumentEvent event) {
- fireDocumentEvent(true, event);
- }
-
- /*
- * @see org.eclipse.jface.text.ISlaveDocumentManager#setAutoExpandMode(org.eclipse.jface.text.IDocument, boolean)
- */
- public void setAutoExpandMode(IDocument slaveDocument, boolean autoExpand) {
- if (slaveDocument instanceof ChildDocument)
- ((ChildDocument) slaveDocument).setAutoExpandMode(autoExpand);
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/ConfigurableLineTracker.java b/org.eclipse.text/src/org/eclipse/jface/text/ConfigurableLineTracker.java
deleted file mode 100644
index 301b64c..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/ConfigurableLineTracker.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-
-
-
-/**
- * Standard implementation of a generic <code>ILineTracker</code>.
- * The line tracker can be configured with the set of legal line delimiters.
- * Line delimiters are unconstrainted. The line delimiters are used to
- * compute the tracker's line structure. In the case of overlapping line delimiters,
- * the longest line delimiter is given precedence of the shorter ones.<p>
- * This class is not intended to be subclassed.
- */
-public class ConfigurableLineTracker extends AbstractLineTracker {
-
-
- /** The strings which are considered being the line delimiter */
- private String[] fDelimiters;
- /** A predefined delimiter info which is always reused as return value */
- private DelimiterInfo fDelimiterInfo= new DelimiterInfo();
-
-
- /**
- * Creates a standard line tracker for the given line delimiters.
- *
- * @param legalLineDelimiters the tracker's legal line delimiters,
- * may not be <code>null</code> and must be longer than 0
- */
- public ConfigurableLineTracker(String[] legalLineDelimiters) {
- Assert.isTrue(legalLineDelimiters != null && legalLineDelimiters.length > 0);
- fDelimiters= legalLineDelimiters;
- }
-
- /*
- * @see ILineDelimiter@getLegalLineDelimiters()
- */
- public String[] getLegalLineDelimiters() {
- return fDelimiters;
- }
-
- /*
- * @see AbstractLineTracker#nextDelimiterInfo(String, int)
- */
- protected DelimiterInfo nextDelimiterInfo(String text, int offset) {
- int[] info= TextUtilities.indexOf(fDelimiters, text, offset);
- if (info[0] == -1)
- return null;
-
- fDelimiterInfo.delimiterIndex= info[0];
- fDelimiterInfo.delimiter= fDelimiters[info[1]];
- fDelimiterInfo.delimiterLength= fDelimiterInfo.delimiter.length();
- return fDelimiterInfo;
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/DefaultLineTracker.java b/org.eclipse.text/src/org/eclipse/jface/text/DefaultLineTracker.java
deleted file mode 100644
index f7d68bb..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/DefaultLineTracker.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-
-
-
-/**
- * Standard implementation of <code>ILineTracker</code>.
- * The line tracker considers the three common line
- * delimiters which are '\n', '\r', '\r\n'.<p>
- * This class is not intended to be subclassed.
- */
-public class DefaultLineTracker extends AbstractLineTracker {
-
- /** The predefined delimiters of this tracker */
- public final static String[] DELIMITERS= { "\r", "\n", "\r\n" }; //$NON-NLS-3$ //$NON-NLS-1$ //$NON-NLS-2$
- /** A predefined delimiter info which is always reused as return value */
- private DelimiterInfo fDelimiterInfo= new DelimiterInfo();
-
-
- /**
- * Creates a standard line tracker.
- */
- public DefaultLineTracker() {
- }
-
- /*
- * @see ILineDelimiter@getLegalLineDelimiters()
- */
- public String[] getLegalLineDelimiters() {
- return DELIMITERS;
- }
-
- /*
- * @see AbstractLineTracker#nextDelimiterInfo(String, int)
- */
- protected DelimiterInfo nextDelimiterInfo(String text, int offset) {
-
- char ch;
- int length= text.length();
- for (int i= offset; i < length; i++) {
-
- ch= text.charAt(i);
- if (ch == '\r') {
-
- if (i + 1 < length) {
- if (text.charAt(i + 1) == '\n') {
- fDelimiterInfo.delimiter= DELIMITERS[2];
- fDelimiterInfo.delimiterIndex= i;
- fDelimiterInfo.delimiterLength= 2;
- return fDelimiterInfo;
- }
- }
-
- fDelimiterInfo.delimiter= DELIMITERS[0];
- fDelimiterInfo.delimiterIndex= i;
- fDelimiterInfo.delimiterLength= 1;
- return fDelimiterInfo;
-
- } else if (ch == '\n') {
-
- fDelimiterInfo.delimiter= DELIMITERS[1];
- fDelimiterInfo.delimiterIndex= i;
- fDelimiterInfo.delimiterLength= 1;
- return fDelimiterInfo;
- }
- }
-
- return null;
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/DefaultPositionUpdater.java b/org.eclipse.text/src/org/eclipse/jface/text/DefaultPositionUpdater.java
deleted file mode 100644
index a3fe149..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/DefaultPositionUpdater.java
+++ /dev/null
@@ -1,239 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-
-/**
- * Default implementation of <code>IPositionUpdater</code>.
- * A default position updater must be configured with the position category
- * whose positions it will update. Other position categories are not affected
- * by this updater.<p>
- * This implementation follows the following specification:
- * <ul>
- * <li> Inserting or deleting text before the position shifts the position accordingly.
- * <li> Inserting text at the position offset shifts the position accordingly.
- * <li> Inserting or deleting text completely surrounded by the position shrinks or stretches the position.
- * <li> Inserting or deleting text after a position does not affect the position.
- * <li> Deleting text which completely contains the position deletes the position.
- * <li> Replacing text overlapping with the position considered as a sequence of first
- * deleting the replaced text and afterwards inserting the new text. Thus, a
- * position might first be shifted and shrink and then be stretched.
- * </ul>
- * This class can be used as is or be adapted by subclasses. Fields are protected to
- * allow subclasses direct access. Because of the frequency with which position updaters
- * are used this is a performance decision.
- */
-public class DefaultPositionUpdater implements IPositionUpdater {
-
- /** The position category the updater draws responsible for */
- private String fCategory;
-
- /** Caches the currently investigated position */
- protected Position fPosition;
- /**
- * Remembers the original state of the investigated position
- * @since 2.1
- */
- protected Position fOriginalPosition= new Position(0, 0);
- /** Caches the offset of the replaced text */
- protected int fOffset;
- /** Caches the length of the replaced text */
- protected int fLength;
- /** Caches the length of the newly inserted text */
- protected int fReplaceLength;
- /** Catches the document */
- protected IDocument fDocument;
-
-
- /**
- * Creates a new default position updater for the given category.
- *
- * @param category the category the updater is responsible for
- */
- public DefaultPositionUpdater(String category) {
- fCategory= category;
- }
-
- /**
- * Returns the category this updater is responsible for.
- *
- * @return the category this updater is responsible for
- */
- protected String getCategory() {
- return fCategory;
- }
-
- /**
- * Returns whether the current event describes a well formed replace
- * by which the current position is directly affected.
- *
- * @return <code>true</code> the current position is directly affected
- * @since 3.0
- */
- protected boolean isAffectingReplace() {
- return fLength > 0 && fReplaceLength > 0 && fPosition.length < fOriginalPosition.length;
- }
-
- /**
- * Adapts the currently investigated position to an insertion.
- */
- protected void adaptToInsert() {
-
- int myStart= fPosition.offset;
- int myEnd= fPosition.offset + fPosition.length - (isAffectingReplace() ? 0 : 1);
- myEnd= Math.max(myStart, myEnd);
-
- int yoursStart= fOffset;
- int yoursEnd= fOffset + fReplaceLength -1;
- yoursEnd= Math.max(yoursStart, yoursEnd);
-
- if (myEnd < yoursStart)
- return;
-
- if (fLength <= 0) {
-
- if (myStart < yoursStart)
- fPosition.length += fReplaceLength;
- else
- fPosition.offset += fReplaceLength;
-
- } else {
-
- if (myStart <= yoursStart && fOriginalPosition.offset <= yoursStart)
- fPosition.length += fReplaceLength;
- else
- fPosition.offset += fReplaceLength;
- }
- }
-
- /**
- * Adapts the currently investigated position to a deletion.
- */
- protected void adaptToRemove() {
-
- int myStart= fPosition.offset;
- int myEnd= fPosition.offset + fPosition.length -1;
- myEnd= Math.max(myStart, myEnd);
-
- int yoursStart= fOffset;
- int yoursEnd= fOffset + fLength -1;
- yoursEnd= Math.max(yoursStart, yoursEnd);
-
- if (myEnd < yoursStart)
- return;
-
- if (myStart <= yoursStart) {
-
- if (yoursEnd <= myEnd)
- fPosition.length -= fLength;
- else
- fPosition.length -= (myEnd - yoursStart +1);
-
- } else if (yoursStart < myStart) {
-
- if (yoursEnd < myStart)
- fPosition.offset -= fLength;
- else {
- fPosition.offset -= (myStart - yoursStart);
- fPosition.length -= (yoursEnd - myStart +1);
- }
-
- }
-
- // validate position to allowed values
- if (fPosition.offset < 0)
- fPosition.offset= 0;
-
- if (fPosition.length < 0)
- fPosition.length= 0;
- }
-
- /**
- * Adapts the currently investigated position to the replace operation.
- * First it checks whether the change replaces the whole range of the position.
- * If not, it performs first the deletion of the previous text and afterwards
- * the insertion of the new text.
- */
- protected void adaptToReplace() {
-
- if (fPosition.offset == fOffset && fPosition.length == fLength && fPosition.length > 0) {
-
- // replace the whole range of the position
- fPosition.length += (fReplaceLength - fLength);
- if (fPosition.length < 0) {
- fPosition.offset += fPosition.length;
- fPosition.length= 0;
- }
-
- } else {
-
- if (fLength > 0)
- adaptToRemove();
-
- if (fReplaceLength > 0)
- adaptToInsert();
- }
- }
-
- /**
- * Determines whether the currently investigated position has been deleted by
- * the replace operation specified in the current event. If so, it deletes
- * the position and removes it from the document's position category.
- *
- * @return <code>true</code> if position has been deleted
- */
- protected boolean notDeleted() {
-
- if (fOffset < fPosition.offset && (fPosition.offset + fPosition.length < fOffset + fLength)) {
-
- fPosition.delete();
-
- try {
- fDocument.removePosition(fCategory, fPosition);
- } catch (BadPositionCategoryException x) {
- }
-
- return false;
- }
-
- return true;
- }
-
- /*
- * @see IPositionUpdater#update(DocumentEvent event)
- */
- public void update(DocumentEvent event) {
-
- try {
-
-
- fOffset= event.getOffset();
- fLength= event.getLength();
- fReplaceLength= (event.getText() == null ? 0 : event.getText().length());
- fDocument= event.getDocument();
-
- Position[] category= fDocument.getPositions(fCategory);
- for (int i= 0; i < category.length; i++) {
-
- fPosition= category[i];
- fOriginalPosition.offset= fPosition.offset;
- fOriginalPosition.length= fPosition.length;
-
- if (notDeleted())
- adaptToReplace();
- }
-
- } catch (BadPositionCategoryException x) {
- // do nothing
- }
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/Document.java b/org.eclipse.text/src/org/eclipse/jface/text/Document.java
deleted file mode 100644
index b3fa42b..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/Document.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-
-/**
- * Default document implementation. Uses a <code>GapTextStore</code> as default
- * text store and a <code>SequentialRewriteTextStore</code> when in sequential
- * rewrite mode. The used line tracker considers the following strings as line delimiters
- * "\n", "\r", "\r\n". The document is ready to use. It has a default position
- * category for which a default position updater is installed.
- *
- * @see org.eclipse.jface.text.GapTextStore
- * @see org.eclipse.jface.text.SequentialRewriteTextStore
- */
-public class Document extends AbstractDocument {
-
-
- /**
- * Creates a new empty document.
- */
- public Document() {
- super();
- setTextStore(new GapTextStore(50, 300));
- setLineTracker(new DefaultLineTracker());
- completeInitialization();
- }
-
- /**
- * Creates a new document with the given initial content.
- *
- * @param initialContent the document's initial content
- */
- public Document(String initialContent) {
- super();
- setTextStore(new GapTextStore(50, 300));
- setLineTracker(new DefaultLineTracker());
- getStore().set(initialContent);
- getTracker().set(initialContent);
- completeInitialization();
- }
-
- /*
- * @see IDocumentExtension#startSequentialRewrite(boolean)
- * @since 2.0
- */
- public void startSequentialRewrite(boolean normalized) {
- ITextStore store= new SequentialRewriteTextStore(getStore());
- setTextStore(store);
- }
-
- /*
- * @see IDocumentExtension#stopSequentialRewrite()
- * @since 2.0
- */
- public void stopSequentialRewrite() {
- if (getStore() instanceof SequentialRewriteTextStore) {
- SequentialRewriteTextStore srws= (SequentialRewriteTextStore) getStore();
- ITextStore source= srws.getSourceStore();
- setTextStore(source);
- srws.dispose();
- }
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/DocumentEvent.java b/org.eclipse.text/src/org/eclipse/jface/text/DocumentEvent.java
deleted file mode 100644
index f63ed66..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/DocumentEvent.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-
-/**
- * Specification of changes applied to documents.
- * All changes are represented as replace commands, i.e.
- * specifying a document range whose text gets replaced with different text.
- * In addition to this information, the event also contains the changed document.
- *
- * @see IDocument
- */
-public class DocumentEvent {
-
- /** The changed document */
- public IDocument fDocument;
- /** The document offset */
- public int fOffset;
- /** Length of the replaced document text */
- public int fLength;
- /** Text inserted into the document */
- public String fText;
-
- /**
- * Creates a new document event.
- *
- * @param doc the changed document
- * @param offset the offset of the replaced text
- * @param length the length of the replaced text
- * @param text the substitution text
- */
- public DocumentEvent(IDocument doc, int offset, int length, String text) {
-
- Assert.isNotNull(doc);
- Assert.isTrue(offset >= 0);
- Assert.isTrue(length >= 0);
-
- fDocument= doc;
- fOffset= offset;
- fLength= length;
- fText= text;
- }
-
- /**
- * Creates a new uninitialized document event.
- */
- public DocumentEvent() {
- }
-
- /**
- * Returns the changed document.
- *
- * @return the changed document
- */
- public IDocument getDocument() {
- return fDocument;
- }
-
- /**
- * Returns the offset of the change
- *
- * @return the offset of the change
- */
- public int getOffset() {
- return fOffset;
- }
-
- /**
- * Returns the length of the replaced text.
- *
- * @return the length of the replaced text
- */
- public int getLength() {
- return fLength;
- }
-
- /**
- * Returns the text that has been inserted.
- *
- * @return the text that has been inserted
- */
- public String getText() {
- return fText;
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/DocumentPartitioningChangedEvent.java b/org.eclipse.text/src/org/eclipse/jface/text/DocumentPartitioningChangedEvent.java
deleted file mode 100644
index 3b852c6..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/DocumentPartitioningChangedEvent.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/**********************************************************************
-Copyright (c) 2000, 2003 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-
-Contributors:
- IBM Corporation - Initial implementation
-**********************************************************************/
-package org.eclipse.jface.text;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-/**
- * Event describing the change of document partitionings.
- *
- * @see org.eclipse.jface.text.IDocumentExtension3
- * @since 3.0
- */
-public class DocumentPartitioningChangedEvent {
-
- /** The document whose partitionings changed */
- private final IDocument fDocument;
- /** The map of partitionings to changed regions. */
- private final Map fMap= new HashMap();
-
-
- /**
- * Creates a new document partitioning changed event for the given document.
- *
- * @param document the changed document
- */
- public DocumentPartitioningChangedEvent(IDocument document) {
- fDocument= document;
- }
-
- /**
- * Returns the changed document.
- *
- * @return the changed document
- */
- public IDocument getDocument() {
- return fDocument;
- }
-
- /**
- * Returns the changed region of the given partitioning or <code>null</code>
- * if the given partitioning did not change.
- *
- * @param partitioning the partitioning
- * @return the changed regionn of the given partitioning or <code>null</code>
- */
- public IRegion getChangedRegion(String partitioning) {
- return (IRegion) fMap.get(partitioning);
- }
-
-
- /**
- * Returns the set of changed partitionings.
- *
- * @return the set of changed partitionings
- */
- public String[] getChangedPartitionings() {
- String[] partitionings= new String[fMap.size()];
- fMap.keySet().toArray(partitionings);
- return partitionings;
- }
-
- /**
- * Sets the specified range as changed region for the given partitioning.
- *
- * @param partitioning the partitioning
- * @param offset the region offset
- * @param length the region length
- */
- public void setPartitionChange(String partitioning, int offset, int length) {
- Assert.isNotNull(partitioning);
- fMap.put(partitioning, new Region(offset, length));
- }
-
- /**
- * Returns <code>true</code> if the set of changed partitionings is empty. <code>false</code>
- * otherwise.
- *
- * @return <code>true</code> if the set of changed partitionings is empty.
- */
- public boolean isEmpty() {
- return fMap.isEmpty();
- }
-
- /**
- * Returns the coverage of this event. This is the minimal region that contains all
- * changed regions of all changed partitionings.
- *
- * @return the coverage of this event
- */
- public IRegion getCoverage() {
- if (fMap.isEmpty())
- return new Region(0, 0);
-
- int offset= -1;
- int endOffset= -1;
- Iterator e= fMap.values().iterator();
- while (e.hasNext()) {
- IRegion r= (IRegion) e.next();
-
- if (offset < 0 || r.getOffset() < offset)
- offset= r.getOffset();
-
- int end= r.getOffset() + r.getLength();
- if (end > endOffset)
- endOffset= end;
- }
-
- return new Region(offset, endOffset - offset);
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/FindReplaceDocumentAdapter.java b/org.eclipse.text/src/org/eclipse/jface/text/FindReplaceDocumentAdapter.java
deleted file mode 100644
index 90e3115..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/FindReplaceDocumentAdapter.java
+++ /dev/null
@@ -1,313 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.regex.PatternSyntaxException;
-
-
-/**
- * Adapts {@link org.eclipse.jface.text.IDocument} for doing search and
- * replace operations.
- *
- * @since 3.0
- */
-public class FindReplaceDocumentAdapter implements CharSequence {
-
- // Shortcuts to findReplace operation codes
- private static final FindReplaceOperationCode FIND_FIRST= FindReplaceOperationCode.FIND_FIRST;
- private static final FindReplaceOperationCode FIND_NEXT= FindReplaceOperationCode.FIND_NEXT;
- private static final FindReplaceOperationCode REPLACE= FindReplaceOperationCode.REPLACE;
- private static final FindReplaceOperationCode REPLACE_FIND_NEXT= FindReplaceOperationCode.REPLACE_FIND_NEXT;
-
- /**
- * The adapted document.
- */
- private IDocument fDocument;
-
- /**
- * State for findReplace.
- */
- private FindReplaceOperationCode fFindReplaceState= null;
-
- /**
- * The matcher used in findReplace.
- */
- private Matcher fFindReplaceMatcher;
-
- /**
- * The match offset from the last findReplace call.
- */
- private int fFindReplaceMatchOffset;
-
- /**
- * Constructs a new find replace document adapter.
- *
- * @param document the adapted document
- */
- public FindReplaceDocumentAdapter(IDocument document) {
- Assert.isNotNull(document);
- fDocument= document;
- }
-
- /**
- * Returns the region of a given search string in the document based on a set of search criteria.
- *
- * @param startOffset document offset at which search starts
- * @param findString the string to find
- * @param forwardSearch the search direction
- * @param caseSensitive indicates whether lower and upper case should be distinguished
- * @param wholeWord indicates whether the findString should be limited by white spaces as
- * defined by Character.isWhiteSpace. 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 find or replace region or <code>null</code> if there was no match
- * @throws BadLocationException if startOffset is an invalid document offset
- * @throws PatternSyntaxException if a regular expression has invalid syntax
- */
- public IRegion search(int startOffset, String findString, boolean forwardSearch, boolean caseSensitive, boolean wholeWord, boolean regExSearch) throws BadLocationException {
- Assert.isTrue(!(regExSearch && wholeWord));
-
- // Adjust offset to special meaning of -1
- if (startOffset == -1 && forwardSearch)
- startOffset= 0;
- if (startOffset == -1 && !forwardSearch)
- startOffset= length() - 1;
-
- return findReplace(FIND_FIRST, startOffset, findString, null, forwardSearch, caseSensitive, wholeWord, regExSearch);
- }
-
- /**
- * Stateful findReplace executes a FIND, REPLACE, REPLACE_FIND or FIND_FIRST operation.
- * In case of REPLACE and REPLACE_FIND it sends a <code>DocumentEvent</code> to all
- * registered <code>IDocumentListener</code>.
- *
- * @param startOffset document offset at which search starts
- * this value is only used in the FIND_FIRST operation and otherwise ignored
- * @param findString the string to find
- * this value is only used in the FIND_FIRST operation and otherwise ignored
- * @param replaceString the string to replace the current match
- * this value is only used in the REPLACE and REPLACE_FIND operations and otherwise ignored
- * @param forwardSearch the search direction
- * @param caseSensitive indicates whether lower and upper case should be distinguished
- * @param wholeWord indicates whether the findString should be limited by white spaces as
- * defined by Character.isWhiteSpace. Must not be used in combination with <code>regExSearch</code>.
- * @param regExSearch if <code>true</code> this operation represents a regular expression
- * Must not be used in combination with <code>wholeWord</code>.
- * @param operationCode specifies what kind of operation is executed
- * @return the find or replace region or <code>null</code> if there was no match
- * @throws BadLocationException if startOffset is an invalid document offset
- * @throws IllegalStateException if a REPLACE or REPLACE_FIND operation is not preceded by a successful FIND operation
- * @throws PatternSyntaxException if a regular expression has invalid syntax
- *
- * @see FindReplaceOperationCode#FIND_FIRST
- * @see FindReplaceOperationCode#FIND_NEXT
- * @see FindReplaceOperationCode#REPLACE
- * @see FindReplaceOperationCode#REPLACE_FIND_NEXT
- */
- public IRegion findReplace(FindReplaceOperationCode operationCode, int startOffset, String findString, String replaceText, boolean forwardSearch, boolean caseSensitive, boolean wholeWord, boolean regExSearch) throws BadLocationException {
-
- // Validate option combinations
- Assert.isTrue(!(regExSearch && wholeWord));
-
- // Validate state
- if ((operationCode == REPLACE || operationCode == REPLACE_FIND_NEXT) && (fFindReplaceState != FIND_FIRST && fFindReplaceState != FIND_NEXT))
- throw new IllegalStateException("illegal findReplace state: cannot replace without preceding find"); //$NON-NLS-1$
-
- if (operationCode == FIND_FIRST) {
- // Reset
-
- if (findString == null || findString.length() == 0)
- return null;
-
- // Validate start offset
- if (startOffset < 0 || startOffset >= length())
- throw new BadLocationException();
-
- int patternFlags= 0;
-
- if (regExSearch)
- patternFlags |= Pattern.MULTILINE;
-
- if (!caseSensitive)
- patternFlags |= Pattern.CASE_INSENSITIVE;
-
- if (wholeWord)
- findString= "\\b" + findString + "\\b"; //$NON-NLS-1$ //$NON-NLS-2$
-
- if (!regExSearch && !wholeWord)
- findString= asRegPattern(findString);
-
- fFindReplaceMatchOffset= startOffset;
- if (fFindReplaceMatcher != null && fFindReplaceMatcher.pattern().pattern().equals(findString) && fFindReplaceMatcher.pattern().flags() == patternFlags) {
- /*
- * Commented out for optimazation:
- * The call is not needed since FIND_FIRST uses find(int) which resets the matcher
- */
- // fFindReplaceMatcher.reset();
- } else {
- Pattern pattern= Pattern.compile(findString, patternFlags);
- fFindReplaceMatcher= pattern.matcher(this);
- }
- }
-
- // Set state
- fFindReplaceState= operationCode;
-
- if (operationCode == REPLACE || operationCode == REPLACE_FIND_NEXT) {
- if (regExSearch) {
- Pattern pattern= fFindReplaceMatcher.pattern();
- Matcher replaceTextMatcher= pattern.matcher(fFindReplaceMatcher.group());
- try {
- replaceText= replaceTextMatcher.replaceFirst(replaceText);
- } catch (IndexOutOfBoundsException ex) {
- throw new PatternSyntaxException(ex.getLocalizedMessage(), replaceText, -1);
- }
- }
-
- int offset= fFindReplaceMatcher.start();
- fDocument.replace(offset, fFindReplaceMatcher.group().length(), replaceText);
-
- if (operationCode == REPLACE) {
- return new Region(offset, replaceText.length());
- }
- }
-
- if (operationCode != REPLACE) {
- if (forwardSearch) {
-
- boolean found= false;
- if (operationCode == FIND_FIRST)
- found= fFindReplaceMatcher.find(startOffset);
- else
- found= fFindReplaceMatcher.find();
-
- fFindReplaceState= operationCode;
-
- if (found && fFindReplaceMatcher.group().length() > 0) {
- return new Region(fFindReplaceMatcher.start(), fFindReplaceMatcher.group().length());
- } else {
- return null;
- }
- } else { // backward search
-
- boolean found= fFindReplaceMatcher.find(0);
- int index= -1;
- int length= -1;
- while (found && fFindReplaceMatcher.start() <= fFindReplaceMatchOffset) {
- index= fFindReplaceMatcher.start();
- length= fFindReplaceMatcher.group().length();
- found= fFindReplaceMatcher.find(index + 1);
- }
- fFindReplaceMatchOffset= index;
- if (index > -1) {
- // must set matcher to correct position
- fFindReplaceMatcher.find(index);
- return new Region(index, length);
- } else
- return null;
- }
- }
- return null;
- }
-
- /**
- * Converts a non-regex string to a pattern
- * that can be used with the regex search engine.
- *
- * @param string the non-regex pattern
- * @return the string converted to a regex pattern
- */
- private String asRegPattern(String string) {
- StringBuffer out= new StringBuffer(string.length());
- boolean quoting= false;
-
- for (int i= 0, length= string.length(); i < length; i++) {
- char ch= string.charAt(i);
- if (ch == '\\') {
- if (quoting) {
- out.append("\\E"); //$NON-NLS-1$
- quoting= false;
- }
- out.append("\\\\"); //$NON-NLS-1$
- continue;
- }
- if (!quoting) {
- out.append("\\Q"); //$NON-NLS-1$
- quoting= true;
- }
- out.append(ch);
- }
- if (quoting)
- out.append("\\E"); //$NON-NLS-1$
-
- return out.toString();
- }
-
- /**
- * Subsitutes the previous match with the given text.
- * Sends a <code>DocumentEvent</code> to all registered <code>IDocumentListener</code>.
- *
- * @param length the length of the specified range
- * @param text the substitution text
- * @param isRegExReplace if <code>true</code> <code>text</code> represents a regular expression
- * @return the replace region or <code>null</code> if there was no match
- * @throws BadLocationException if startOffset is an invalid document offset
- * @throws IllegalStateException if a REPLACE or REPLACE_FIND operation is not preceded by a successful FIND operation
- * @throws PatternSyntaxException if a regular expression has invalid syntax
- *
- * @see DocumentEvent
- * @see IDocumentListener
- */
- public IRegion replace(String text, boolean regExReplace) throws BadLocationException {
- return findReplace(FindReplaceOperationCode.REPLACE, -1, null, text, false, false, false, regExReplace);
- }
-
- // ---------- CharSequence implementation ----------
-
- /*
- * @see java.lang.CharSequence#length()
- */
- public int length() {
- return fDocument.getLength();
- }
-
- /*
- * @see java.lang.CharSequence#charAt(int)
- */
- public char charAt(int index) {
- try {
- return fDocument.getChar(index);
- } catch (BadLocationException e) {
- throw new IndexOutOfBoundsException();
- }
- }
-
- /*
- * @see java.lang.CharSequence#subSequence(int, int)
- */
- public CharSequence subSequence(int start, int end) {
- try {
- return fDocument.get(start, end - start);
- } catch (BadLocationException e) {
- throw new IndexOutOfBoundsException();
- }
- }
-
- /*
- * @see java.lang.Object#toString()
- */
- public String toString() {
- return fDocument.get();
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/FindReplaceOperationCode.java b/org.eclipse.text/src/org/eclipse/jface/text/FindReplaceOperationCode.java
deleted file mode 100644
index c348699..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/FindReplaceOperationCode.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-
-/**
- * Enumeration type declaring the available findReplace operation codes.
- *
- * @see org.eclipse.jface.text.FindReplaceDocumentAdapter#findReplace(int, String, String, boolean, boolean, boolean, boolean, int)
- * @since 3.0
- */
-public final class FindReplaceOperationCode {
-
- /**
- * The operation code's name.
- */
- private final String fName;
-
- /**
- * Creates and returns a new findReplace operation code.
- */
- private FindReplaceOperationCode(String operationName) {
- Assert.isNotNull(operationName);
- fName= operationName;
- }
-
- /*
- * @see Object#toString()
- */
- public String toString() {
- return fName;
- }
-
- /**
- * findReplace operation code used to find the first match.
- */
- public static final FindReplaceOperationCode FIND_FIRST= new FindReplaceOperationCode("findFirst"); //$NON-NLS-1$
-
- /**
- * findReplace operation code to find the next match.
- */
- public static final FindReplaceOperationCode FIND_NEXT= new FindReplaceOperationCode("findNext"); //$NON-NLS-1$
-
- /**
- * findReplace operation code to replace the current match.
- * This operation must be preceded by a <code>FIND_FIRST</code> or <code>FIND_NEXT</code> operation.
- */
- public static final FindReplaceOperationCode REPLACE= new FindReplaceOperationCode("replace"); //$NON-NLS-1$
-
- /**
- * findReplace operation code to replace the current match and find the next one.
- * This operation must be preceded by a <code>FIND_FIRST</code> or <code>FIND_NEXT</code> operation.
- */
- public static final FindReplaceOperationCode REPLACE_FIND_NEXT= new FindReplaceOperationCode("replaceAndFindNext"); //$NON-NLS-1$
-}
\ No newline at end of file
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/GapTextStore.java b/org.eclipse.text/src/org/eclipse/jface/text/GapTextStore.java
deleted file mode 100644
index e0946cb..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/GapTextStore.java
+++ /dev/null
@@ -1,259 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-
-
-
-/**
- * Implements a gap managing text store. The gap text store
- * relies on the assumption that subsequent changes of a document are co-located.
- * The start of the gap is always moved to the location of the last change. The
- * size of the gap varies between the low water mark and the high water mark. <p>
- * This class is not intended to be subclassed.
- */
-public class GapTextStore implements ITextStore {
-
- /** The store's content */
- private char[] fContent= new char[0];
- /** Starting index of the gap */
- private int fGapStart= -1;
- /** End index of the gap */
- private int fGapEnd= -1;
-
- /** The high water mark. If the gap is larger than this, it will be shrunken */
- private int fHighWatermark;
- /** The low water mark, If this gap is smaller than this, it will be extended */
- private int fLowWatermark;
-
- /**
- * Creates a new empty text store using the specified low and high watermarks.
- *
- * @param lowWatermark if this gap is ever smaller than this, it will automatically be extended
- * @param highWatermark if the gap is ever larger than this, it will automatically be shrunken
- */
- public GapTextStore(int lowWatermark, int highWatermark) {
- Assert.isTrue(lowWatermark < highWatermark);
- fLowWatermark= lowWatermark;
- fHighWatermark= highWatermark;
- }
-
- /**
- * Adjusts the gap so that is at the right offset and capable of handling
- * the addition of a specified number of characters without having to be shifted.
- * The <code>sizeHint</code> represents the range that will be filled afterwards.
- * If the gap is already at the right offset, it must only be
- * resized if it will be no longer between the low and high watermark. However,
- * on delete (sizeHint < 0) at the edges of the gap, the gap is only enlarged.
- *
- * @param offset the offset at which the change happens
- * @param sizeHint the number of character which will be inserted
- */
- private void adjustGap(int offset, int sizeHint) {
-
- if (offset == fGapStart) {
- int size= (fGapEnd - fGapStart) - sizeHint;
- if (fLowWatermark <= size && size <= fHighWatermark)
- return;
- }
-
- moveAndResizeGap(offset, sizeHint);
- }
-
- /**
- * Moves the gap to the specified offset and adjust its size to the
- * anticipated change size. The given size represents the expected
- * range of the gap that will be filled after the gap has been moved.
- * Thus the gap is resized to actual size + the specified size and
- * moved to the given offset.
- *
- * @param offset the offset where the gap is moved to
- * @param size the anticipated size of the change
- */
- private void moveAndResizeGap(int offset, int size) {
-
- char[] content= null;
- int oldSize= fGapEnd - fGapStart;
- int newSize= fHighWatermark + size;
-
-
- if (newSize < 0) {
-
- if (oldSize > 0) {
- content= new char[fContent.length - oldSize];
- System.arraycopy(fContent, 0, content, 0, fGapStart);
- System.arraycopy(fContent, fGapEnd, content, fGapStart, content.length - fGapStart);
- fContent= content;
- }
- fGapStart= fGapEnd= offset;
- return;
- }
-
-
- content= new char[fContent.length + (newSize - oldSize)];
-
- int newGapStart= offset;
- int newGapEnd= newGapStart + newSize;
-
- if (oldSize == 0) {
-
- System.arraycopy(fContent, 0, content, 0, newGapStart);
- System.arraycopy(fContent, newGapStart, content, newGapEnd, content.length - newGapEnd);
-
- } else if (newGapStart < fGapStart) {
-
- int delta= fGapStart - newGapStart;
- System.arraycopy(fContent, 0, content, 0, newGapStart);
- System.arraycopy(fContent, newGapStart, content, newGapEnd, delta);
- System.arraycopy(fContent, fGapEnd, content, newGapEnd + delta, fContent.length - fGapEnd);
-
- } else {
-
- int delta= newGapStart - fGapStart;
- System.arraycopy(fContent, 0, content, 0, fGapStart);
- System.arraycopy(fContent, fGapEnd, content, fGapStart, delta);
- System.arraycopy(fContent, fGapEnd + delta, content, newGapEnd, content.length - newGapEnd);
- }
-
-
- fContent= content;
- fGapStart= newGapStart;
- fGapEnd= newGapEnd;
- }
-
- /*
- * @see ITextStore#get(int)
- */
- public char get(int offset) {
-
- if (offset < fGapStart)
- return fContent[offset];
-
- int gapLength= fGapEnd - fGapStart;
- return fContent[offset + gapLength];
- }
-
- /*
- * @see ITextStore#get(int, int)
- */
- public String get(int offset, int length) {
-
- int end= offset + length;
-
- if (fContent == null)
- return ""; //$NON-NLS-1$
-
- if (end <= fGapStart)
- return new String(fContent, offset, length);
-
- if (fGapStart < offset) {
- int gapLength= fGapEnd - fGapStart;
- return new String(fContent, offset + gapLength , length);
- }
-
- StringBuffer buf= new StringBuffer();
- buf.append(fContent, offset, fGapStart - offset);
- buf.append(fContent, fGapEnd, end - fGapStart);
- return buf.toString();
- }
-
- /*
- * @see ITextStore#getLength()
- */
- public int getLength() {
- int length= fGapEnd - fGapStart;
- return (fContent.length - length);
- }
-
-
- /*
- * @see ITextStore#replace(int, int, String)
- */
- public void replace(int offset, int length, String text) {
-
- int textLength= (text == null ? 0 : text.length());
-
- // handle delete at the edges of the gap
- if (textLength == 0) {
- if (offset <= fGapStart && offset + length >= fGapStart && fGapStart > -1 && fGapEnd > -1) {
- length -= fGapStart - offset;
- fGapStart= offset;
- fGapEnd += length;
- return;
- }
- }
-
- // move gap
- adjustGap(offset + length, textLength - length);
-
- // overwrite
- int min= Math.min(textLength, length);
- for (int i= offset, j= 0; i < offset + min; i++, j++)
- fContent[i]= text.charAt(j);
-
- if (length > textLength) {
- // enlarge the gap
- fGapStart -= (length - textLength);
- } else if (textLength > length) {
- // shrink gap
- fGapStart += (textLength - length);
- for (int i= length; i < textLength; i++)
- fContent[offset + i]= text.charAt(i);
- }
- }
-
- /**
- * Sets the content to <code>text</code> and removes the gap
- * since there are no sensible predictions about
- * where the next change will occur.
- * @see ITextStore#set(String)
- */
- public void set(String text) {
-
- if (text == null)
- text= ""; //$NON-NLS-1$
-
- fContent= text.toCharArray();
-
- fGapStart= -1;
- fGapEnd= -1;
- }
-
- /**
- * Returns a copy of the content of this text store.
- * For internal use only.
- *
- * @return a copy of the content of this text store
- */
- protected String getContentAsString() {
- return new String(fContent);
- }
-
- /**
- * Returns the start index of the gap managed by this text store.
- * For internal use only.
- *
- * @return the start index of the gap managed by this text store
- */
- protected int getGapStartIndex() {
- return fGapStart;
- }
-
- /**
- * Returns the end index of the gap managed by this text store.
- * For internal use only.
- *
- * @return the end index of the gap managed by this text store
- */
- protected int getGapEndIndex() {
- return fGapEnd;
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/IDocument.java b/org.eclipse.text/src/org/eclipse/jface/text/IDocument.java
deleted file mode 100644
index 7887dbc..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/IDocument.java
+++ /dev/null
@@ -1,571 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-
-/**
- * An <code>IDocument</code> represents text providing support for
- * <ul>
- * <li> text manipulation
- * <li> positions
- * <li> partitions
- * <li> line information
- * <li> search
- * <li> document change listeners
- * <li> document partition change listeners
- * </ul>
- *
- * A document allows to set its content and to manipulate it. For manipulation
- * a document provides the <code>replace</code> method which substitutes a given
- * string for a specified text range in the document. On each document change, all
- * registered document listeners are informed exactly once.
- *
- * Positions are stickers to the document's text that are updated when the
- * document is changed. Positions are updated by <code>IPositionUpdater</code>s. Position
- * updaters are managed as a list. The list defines the sequence in which position
- * updaters are invoked.This way, position updaters may rely on each other.
- * Positions are grouped into categories. A category is a ordered list of positions.
- * the document defines the order of position in a category based on the position's offset
- * based on the implementation of the method <code>computeIndexInCategory</code>.
- * Each document must support a default position category whose name is specified by this
- * interface.<p>
- *
- * A document can be considered consisting of a sequence of not overlapping partitions.
- * A partition is defined by its offset, its length, and its type. Partitions are
- * updated on every document manipulation and ensured to be up-to-date when the document
- * listeners are informed. A document uses an <code>IDocumentPartitioner</code> to
- * manage its partitions. A document may be unpartitioned which happens when there is no
- * partitioner. In this case, the document is considered as one single partition of a
- * default type. The default type is specified by this interface. If a document change
- * changes the document's partitioning all registered partitioning listeners are
- * informed exactly once.<p>
- *
- * An <code>IDocument</code> provides methods to map line numbers and character
- * positions onto each other based on the document's line delimiters. When moving text
- * between documents using different line delimiters, the text must be converted to
- * use the target document's line delimiters. <p>
- *
- * <code>IDocument</code> throws <code>BadLocationException</code> if the parameters of
- * queries or manipulation requests are not inside the bounds of the document. The purpose
- * of this style of exception handling is
- * <ul>
- * <li> prepare document for multi-thread access
- * <li> allow clients to implement backtracking recovery methods
- * <li> prevent clients from upfront contract checking when dealing with documents.
- * </ul>
- * Clients may implement this interface or use the default implementation provided
- * by <code>AbstractDocument</code> and <code>Document</code>.
- *
- * @see Position
- * @see IPositionUpdater
- * @see IDocumentPartitioner
- * @see ILineTracker
- * @see IDocumentListener
- * @see IDocumentPartitioningListener
- */
-public interface IDocument {
-
-
- /**
- * The identifier of the default position category.
- */
- final static String DEFAULT_CATEGORY= "__dflt_position_category"; //$NON-NLS-1$
-
- /**
- * The identifier of the default partition content type.
- */
- final static String DEFAULT_CONTENT_TYPE= "__dftl_partition_content_type"; //$NON-NLS-1$
-
-
-
-
- /* --------------- text access and manipulation --------------------------- */
-
- /**
- * Returns the character at the given document offset in this document.
- *
- * @param offset a document offset
- * @return the character at the offset
- * @exception BadLocationException if the offset is invalid in this document
- */
- char getChar(int offset) throws BadLocationException;
-
- /**
- * Returns the number of characters in this document.
- *
- * @return the number of characters in this document
- */
- int getLength();
-
- /**
- * Returns this document's complete text.
- *
- * @return the document's complete text
- */
- String get();
-
- /**
- * Returns this document's text for the specified range.
- *
- * @param offset the document offset
- * @param length the length of the specified range
- * @return the document's text for the specified range
- * @exception BadLocationException if the range is invalid in this document
- */
- String get(int offset, int length) throws BadLocationException;
-
- /**
- * Replaces the content of the document with the given text.
- * Sends a <code>DocumentEvent</code> to all registered <code>IDocumentListener</code>.
- * This method is a convenience method for <code>
- * replace(0, getLength(), text)</code>.
- *
- * @param text the new content of the document
- *
- * @see DocumentEvent
- * @see IDocumentListener
- */
- void set(String text);
-
- /**
- * Subsitutes the given text for the specified document range.
- * Sends a <code>DocumentEvent</code> to all registered <code>IDocumentListener</code>.
- *
- * @param offset the document offset
- * @param length the length of the specified range
- * @param text the substitution text
- * @exception BadLocationException if the offset is invalid in this document
- *
- * @see DocumentEvent
- * @see IDocumentListener
- */
- void replace(int offset, int length, String text) throws BadLocationException;
-
- /**
- * Registers the document listener with the document. After registration
- * the IDocumentListener is informed about each change of this document.
- * If the listener is already registered nothing happens.<p>
- * An <code>IDocumentListener</code> may call back to this method
- * when being inside a document notification.
- *
- * @param listener the listener to be registered
- */
- void addDocumentListener(IDocumentListener listener);
-
- /**
- * Removes the listener from the document's list of document listeners.
- * If the listener is not registered with the document nothing happens.<p>
- * An <code>IDocumentListener</code> may call back to this method
- * when being inside a document notification.
- *
- * @param listener the listener to be removed
- */
- void removeDocumentListener(IDocumentListener listener);
-
- /**
- * Adds the given document listener as one which is notified before
- * those document listeners added with <code>addDocumentListener</code>
- * are notified. If the given listener is also registered using
- * <code>addDocumentListener</code> it will be notified twice.
- * If the listener is already registered nothing happens.<p>
- *
- * This method is not for public use, it may only be called by
- * implementers of <code>IDocumentAdapter</code> and only if those
- * implementers need to implement <code>IDocumentListener</code>.
- *
- * @param documentAdapter the listener to be added as prenotified document listener
- */
- void addPrenotifiedDocumentListener(IDocumentListener documentAdapter);
-
- /**
- * Removes the given document listener from the document's list of
- * prenotified document listeners. If the listener is not registered
- * with the document nothing happens. <p>
- *
- * This method is not for public use, it may only be called by
- * implementers of <code>IDocumentAdapter</code> and only if those
- * implementers need to implement <code>IDocumentListener</code>.
- *
- * @param documentAdapter the listener to be removed
- *
- * @see #addPrenotifiedDocumentListener(IDocumentListener)
- */
- void removePrenotifiedDocumentListener(IDocumentListener documentAdapter);
-
-
-
- /* -------------------------- positions ----------------------------------- */
-
- /**
- * Adds a new position category to the document. If the position category
- * already exists nothing happens.
- *
- * @param category the category to be added
- */
- void addPositionCategory(String category);
-
- /**
- * Deletes the position category from the document. All positions
- * in this category are thus deleted as well.
- *
- * @param category the category to be removed
- * @exception BadPositionCategoryException if category is undefined in this document
- */
- void removePositionCategory(String category) throws BadPositionCategoryException;
-
- /**
- * Returns all position categories of this document. This
- * includes the default position category.
- *
- * @return the document's position categories
- */
- String[] getPositionCategories();
-
- /**
- * Checks the presence of the specified position category.
- *
- * @param category the category to check
- * @return <code>true</code> if category is defined
- */
- boolean containsPositionCategory(String category);
-
- /**
- * Adds the position to the document's default position category.
- * This is a convenience method for <code>addPosition(DEFAULT_CATEGORY, position)</code>.
- *
- * @param position the position to be added
- * @exception BadLocationException if position describes an invalid range in this document
- */
- void addPosition(Position position) throws BadLocationException;
-
- /**
- * Removes the given position from the document's default position category.
- * This is a convenience method for <code>removePosition(DEFAULT_CATEGORY, position)</code>.
- *
- * @param position the position to be removed
- */
- void removePosition(Position position);
-
- /**
- * Adds the position to the specified position category of the document.
- * A position that has been added to a position category is updated on each
- * change applied to the document. Positions may be added multiple times.
- * The order of the category is maintained.
- *
- * @param category the category to which to add
- * @param position the position to be added
- * @exception BadLocationException if position describes an invalid range in this document
- * @exception BadPositionCategoryException if the category is undefined in this document
- */
- void addPosition(String category, Position position) throws BadLocationException, BadPositionCategoryException;
-
- /**
- * Removes the given position from the specified position category.
- * If the position is not part of the specified category nothing happens.
- * If the position has been added multiple times, only the first occurence is deleted.
- *
- * @param category the category from which to delete
- * @param position the position to be deleted
- * @exception BadPositionCategoryException if category is undefined in this document
- */
- void removePosition(String category, Position position) throws BadPositionCategoryException;
-
- /**
- * Returns all positions of the given position category.
- * The positions are ordered according to the category's order.
- * Manipulating this list does not affect the document, but manipulating the
- * position does affect the document.
- *
- * @param category the category
- * @return the list of all positions
- * @exception BadPositionCategoryException if category is undefined in this document
- */
- Position[] getPositions(String category) throws BadPositionCategoryException;
-
- /**
- * Determines whether a position described by the parameters is managed by this document.
- *
- * @param category the category to check
- * @param offset the offset of the position to find
- * @param length the length of the position to find
- * @return <code>true</code> if position is found
- */
- boolean containsPosition(String category, int offset, int length);
-
- /**
- * Computes the index at which a <code>Position</code> with the
- * specified offset would be inserted into the given category. As the
- * ordering inside a category only depends on the offset, the index must be
- * choosen to be the first of all positions with the same offset.
- *
- * @param category the category in which would be added
- * @param offset the position offset to be considered
- * @return the index into the category
- * @exception BadLocationException if offset is invalid in this document
- * @exception BadPositionCategoryException if category is undefined in this document
- */
- int computeIndexInCategory(String category, int offset) throws BadLocationException, BadPositionCategoryException;
-
- /**
- * Appends a new position updater to the document's list of position updaters.
- * Position updaters may be added multiple times.<p>
- * An <code>IPositionUpdater</code> may call back to this method
- * when being inside a document notification.
- *
- * @param updater the updater to be added
- */
- void addPositionUpdater(IPositionUpdater updater);
-
- /**
- * Removes the position updater from the document's list of position updaters.
- * If the position updater has multiple occurences only the first occurence is
- * removed. If the position updater is not registered with this document, nothing
- * happens.<p>
- * An <code>IPositionUpdater</code> may call back to this method
- * when being inside a document notification.
- *
- * @param updater the updater to be removed
- */
- void removePositionUpdater(IPositionUpdater updater);
-
- /**
- * Inserts the position updater at the specified index in the document's
- * list of position updaters. Positions updaters may be inserted multiple times.<p>
- * An <code>IPositionUpdater</code> may call back to this method
- * when being inside a document notification.
- *
- * @param updater the updater to be inserted
- * @param index the index in the document's updater list
- */
- void insertPositionUpdater(IPositionUpdater updater, int index);
-
- /**
- * Returns the list of position updaters attached to the document.
- *
- * @return the list of position updaters
- */
- IPositionUpdater[] getPositionUpdaters();
-
-
-
-
- /* -------------------------- partitions ---------------------------------- */
-
- /**
- * Returns the set of legal content types of document partitions.
- * This set can be empty. The set can contain more content types than
- * contained by the result of <code>getPartitioning(0, getLength())</code>.
- *
- * @return the set of legal content types
- */
- String[] getLegalContentTypes();
-
- /**
- * Returns the type of the document partition containing the given offset.
- * This is a convenience method for <code>getPartition(offset).getType()</code>.
- *
- * @param offset the document offset
- * @return the partition type
- * @exception BadLocationException if offset is invalid in this document
- */
- String getContentType(int offset) throws BadLocationException;
-
- /**
- * Returns the document partition in which the position is located.
- *
- * @param offset the document offset
- * @return a specification of the partition
- * @exception BadLocationException if offset is invalid in this document
- */
- ITypedRegion getPartition(int offset) throws BadLocationException;
-
- /**
- * Computes the partitioning of the given document range using the
- * document's partitioner.
- *
- * @param offset the document offset at which the range starts
- * @param length the length of the document range
- * @return a specification of the range's partitioning
- * @exception BadLocationException if the range is invalid in this document
- */
- ITypedRegion[] computePartitioning(int offset, int length) throws BadLocationException;
-
- /**
- * Registers the document partitioning listener with the document. After registration
- * the document partitioning listener is informed about each partition change
- * cause by a document manipulation or by changing the document's partitioner.
- * If a document partitioning listener is also
- * a document listener, the following notification sequence is guaranteed if a
- * document manipulation changes the document partitioning:
- * <ul>
- * <li>listener.documentAboutToBeChanged(DocumentEvent);
- * <li>listener.documentPartitioningChanged();
- * <li>listener.documentChanged(DocumentEvent);
- * </ul>
- * If the listener is already registered nothing happens.<p>
- * An <code>IDocumentPartitioningListener</code> may call back to this method
- * when being inside a document notification.
- *
- * @param listener the listener to be added
- */
- void addDocumentPartitioningListener(IDocumentPartitioningListener listener);
-
- /**
- * Removes the listener from this document's list of document partitioning
- * listeners. If the listener is not registered with the document nothing
- * happens.<p>
- * An <code>IDocumentPartitioningListener</code> may call back to this method
- * when being inside a document notification.
- *
- * @param listener the listener to be removed
- */
- void removeDocumentPartitioningListener(IDocumentPartitioningListener listener);
-
- /**
- * Sets this document's partitioner. The caller of this method is responsible for
- * disconnecting the document's old partitioner from the document and to
- * connect the new partitioner to the document. Informs all document partitioning
- * listeners about this change.
- *
- * @param partitioner the document's new partitioner
- *
- * @see IDocumentPartitioningListener
- */
- void setDocumentPartitioner(IDocumentPartitioner partitioner);
-
- /**
- * Returns this document's partitioner.
- *
- * @return this document's partitioner
- */
- IDocumentPartitioner getDocumentPartitioner();
-
-
-
- /* ---------------------- line information -------------------------------- */
-
- /**
- * Returns the length of the given line including the line's delimiter.
- *
- * @param line the line of interest
- * @return the length of the line
- * @exception BadLocationException if the line number is invalid in this document
- */
- int getLineLength(int line) throws BadLocationException;
-
- /**
- * Returns the number of the line at which the character of the specified position is located.
- * The first line has the line number 0. A new line starts directly after a line
- * delimiter. <code>(pos == document length)</code> is a valid argument also there is no
- * corresponding character.
- *
- * @param offset the document offset
- * @return the number of the line
- * @exception BadLocationException if the offset is invalid in this document
- */
- int getLineOfOffset(int offset) throws BadLocationException;
-
- /**
- * Determines the offset of the first character of the given line.
- *
- * @param line the line of interest
- * @return the document offset
- * @exception BadLocationException if the line number is invalid in this document
- */
- int getLineOffset(int line) throws BadLocationException;
-
- /**
- * Returns a description of the specified line. The line is described by its
- * offset and its length excluding the line's delimiter.
- *
- * @param line the line of interest
- * @return a line description
- * @exception BadLocationException if the line number is invalid in this document
- */
- IRegion getLineInformation(int line) throws BadLocationException;
-
- /**
- * Returns a description of the line at the given offset.
- * The description contains the offset and the length of the line
- * excluding the line's delimiter.
- *
- * @param offset the offset whose line should be described
- * @return a region describing the line
- * @exception BadLocationException if offset is invalid in this document
- */
- IRegion getLineInformationOfOffset(int offset) throws BadLocationException;
-
- /**
- * Returns the number of lines in this document
- *
- * @return the number of lines in this document
- */
- int getNumberOfLines();
-
- /**
- * Returns the number of lines which are occupied by a given text range.
- *
- * @param offset the offset of the specified text range
- * @param length the length of the specified text range
- * @return the number of lines occupied by the specified range
- * @exception BadLocationException if specified range is invalid in this tracker
- */
- int getNumberOfLines(int offset, int length) throws BadLocationException;
-
- /**
- * Computes the number of lines in the given text. For a given
- * implementer of this interface this method returns the same
- * result as <code>set(text); getNumberOfLines()</code>.
- *
- * @param text the text whose number of lines should be computed
- * @return the number of lines in the given text
- */
- int computeNumberOfLines(String text);
-
-
- /* ------------------ line delimiter conversion --------------------------- */
-
- /**
- * Returns the document's legal line delimiters.
- *
- * @return the document's legal line delimiters
- */
- String[] getLegalLineDelimiters();
-
- /**
- * Returns the line delimiter of that line or <code>null</code> if the
- * line is not closed with a line delimiter.
- *
- * @param line the line of interest
- * @return the line's delimiter or <code>null</code> if line does not have a delimiter
- * @exception BadLocationException if the line number is invalid in this document
- */
- String getLineDelimiter(int line) throws BadLocationException;
-
-
- /* ---------------------------- search ------------------------------------ */
-
- /**
- * Returns the offset of a given search string in the document based on a set of search criteria.
- *
- * @param startOffset document offset at which search starts
- * @param findString the string to find
- * @param forwardSearch the search direction
- * @param caseSensitive indicates whether lower and upper case should be distinguished
- * @param wholeWord indicates whether the findString should be limited by white spaces as
- * defined by Character.isWhiteSpace
- * @return the offset of the first occurence of findString based on the parameters or -1 if no match is found
- * @exception BadLocationException if startOffset is an invalid document offset
- * @deprecated as of 3.0 search is provided by {@link FindReplaceDocumentAdapter}
- */
- int search(int startOffset, String findString, boolean forwardSearch, boolean caseSensitive, boolean wholeWord) throws BadLocationException;
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/IDocumentExtension.java b/org.eclipse.text/src/org/eclipse/jface/text/IDocumentExtension.java
deleted file mode 100644
index 293469a..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/IDocumentExtension.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-/**
- * Extension interface for <code>IDocument</code>. <p>
- *
- * It introduces the notion of sequentially rewriting a document. This is to tell a
- * document that a sequence of non-overlapping replace operation is about to be
- * performed.<p>
- *
- * Is also introduces the concept of post notification replaces. This is, a document
- * listener who is informed about a document change can cause a derived document
- * change. As the listener is not allowed to directly modify the document, it can
- * register a replace operation that is performed directly after all document listeners
- * have been notified.
- *
- * @since 2.0
- */
-public interface IDocumentExtension {
-
- /**
- * Interface for a post notification replace operation.
- */
- public interface IReplace {
-
- /**
- * Executes the replace operation on the given document.
- * @param document the document to be changed
- * @param owner the owner of this replace operation
- */
- void perform(IDocument document, IDocumentListener owner);
- };
-
- /**
- * Callback for document listeners to be used inside <code>documentChanged</code>
- * to register a post notification replace operation on the document notifying them.
- *
- * @param owner the owner of the replace operation
- * @param replace the replace operation to be executed
- * @exception UnsupportedOperationException if <code>registerPostNotificationReplace</code>
- * is not supported by this document
- */
- void registerPostNotificationReplace(IDocumentListener owner, IReplace replace) throws UnsupportedOperationException;
-
- /**
- * Stops the processing of registered post notification replace operations until
- * <code>resumePostNotificationProcessing</code> is called.
- */
- void stopPostNotificationProcessing();
-
- /**
- * Resumes the processing of post notification replace operations. If the queue of registered
- * <code>IDocumentExtension.IReplace</code> objects is not empty, they are immediately processed if the
- * document is not inside a replace operation. If the document is inside a replace operation,
- * they are processed directly after the replace operation has finished.
- */
- void resumePostNotificationProcessing();
-
- /**
- * Tells the document that it is about to be sequentially rewritten. That is a
- * sequence of non-overlapping replace operations will be performed on it. The
- * <code>normalize</code> flag indicates whether the rewrite is preformed from
- * the start of the document to its end or from an arbitrary start offset.
- *
- * @param normalize <code>true</code> if performed from the start to the end of the document
- */
- void startSequentialRewrite(boolean normalize);
-
- /**
- * Tells the document that the sequential rewrite has been finished.
- */
- void stopSequentialRewrite();
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/IDocumentExtension2.java b/org.eclipse.text/src/org/eclipse/jface/text/IDocumentExtension2.java
deleted file mode 100644
index c785a67..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/IDocumentExtension2.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-/**
- * Extension interface for <code>IDocument</code>. <p>
- * It adds configurability to the mechanism of post notification replaces and allows to
- * postpone document listener notification.
- *
- * @since 2.1
- */
-public interface IDocumentExtension2 {
-
- /**
- * Tells the receiver to ignore calls to
- * <code>registerPostNotificationReplace</code> until
- * <code>acceptPostNotificationReplaces</code> is called.
- */
- void ignorePostNotificationReplaces();
-
- /**
- * Tells the receiver to accept calls to
- * <code>registerPostNotificationReplace</code> until
- * <code>ignorePostNotificationReplaces</code> is called.
- */
- void acceptPostNotificationReplaces();
-
- /**
- * Can be called prior to a <code>replace</code> operation. After the
- * <code>replace</code> <code>resumeListenerNotification</code> must be
- * called. The affect of these calls is that no document listener is notified
- * until <code>resumeListenerNotification</code> is called. This allows clients
- * to update structure before any listener is informed about the change.<p>
- * Listener notification can only be stopped for a single document manipulation.
- * Otherwise, document change notifications will be lost.
- */
- void stopListenerNotification();
-
- /**
- * Resumes the notification of document listeners which must previously
- * have been stopped by a call to <code>stopListenerNotification</code>.
- */
- void resumeListenerNotification();
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/IDocumentExtension3.java b/org.eclipse.text/src/org/eclipse/jface/text/IDocumentExtension3.java
deleted file mode 100644
index fbea0a8..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/IDocumentExtension3.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/**********************************************************************
-Copyright (c) 2000, 2003 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-
-Contributors:
- IBM Corporation - Initial implementation
-**********************************************************************/
-package org.eclipse.jface.text;
-
-/**
- * Extension interface for <code>IDocument</code>. Adds the concept of multiple partitionings.
- *
- * @since 3.0
- */
-public interface IDocumentExtension3 {
-
- /**
- * The identifier of the default partitioning.
- */
- final static String DEFAULT_PARTITIONING= "__dftl_partitioning"; //$NON-NLS-1$
-
-
- /**
- * Returns the exisiting partitionings for this document. This includes
- * the default partitioning.
- *
- * @return the existing partitionings for this document
- */
- String[] getPartitionings();
-
- /**
- * Returns the set of legal content types of document partitions for the given partitioning
- * This set can be empty. The set can contain more content types than contained by the
- * result of <code>getPartitioning(partitioning, 0, getLength())</code>.
- *
- * @param partitioning the partitioning for which to return the legal content types
- * @return the set of legal content types
- * @exception BadPartitioningException if partitioning is invalid for this document
- */
- String[] getLegalContentTypes(String partitioning) throws BadPartitioningException;
-
- /**
- * Returns the type of the document partition containing the given offset for the
- * given partitioning. This is a convenience method for
- * <code>getPartition(partitioning, offset).getType()</code>.
- *
- * @param partitioning the partitioning
- * @param offset the document offset
- * @return the partition type
- * @exception BadLocationException if offset is invalid in this document
- * @exception BadPartitioningException if partitioning is invalid for this document
- */
- String getContentType(String partitioning, int offset) throws BadLocationException, BadPartitioningException;
-
- /**
- * Returns the document partition of the given partitioning in which the given offset is located.
- *
- * @param partitioning the document partitioning
- * @param offset the document offset
- * @return a specification of the partition
- * @exception BadLocationException if offset is invalid in this document
- * @exception BadPartitioningException if partitioning is invalid for this document
- */
- ITypedRegion getPartition(String partitioning, int offset) throws BadLocationException, BadPartitioningException;
-
- /**
- * Computes the partitioning of the given document range based on the given partitioning.
- *
- * @param partitioning the document's partitioning
- * @param offset the document offset at which the range starts
- * @param length the length of the document range
- * @return a specification of the range's partitioning
- * @exception BadLocationException if the range is invalid in this document
- */
- ITypedRegion[] computePartitioning(String partitioning, int offset, int length) throws BadLocationException, BadPartitioningException;
-
- /**
- * Sets this document's partitioner. The caller of this method is responsible for
- * disconnecting the document's old partitioner from the document and to
- * connect the new partitioner to the document. Informs all document partitioning
- * listeners about this change.
- *
- * @param partitioning the partitioning for which to set the partitioner
- * @param the document's new partitioner
- * @see IDocumentPartitioningListener
- */
- void setDocumentPartitioner(String partitioning, IDocumentPartitioner partitioner);
-
- /**
- * Returns the partitioner for the given partitioning or <code>null</code> if
- * no partitioner is registered.
- *
- * @return the partitioner for the given partitioning
- */
- IDocumentPartitioner getDocumentPartitioner(String partitioning);
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/IDocumentInformationMapping.java b/org.eclipse.text/src/org/eclipse/jface/text/IDocumentInformationMapping.java
deleted file mode 100644
index 32f2f7b..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/IDocumentInformationMapping.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-
-/**
- * A <code>IDocumentInformationMapping</code> represents a mapping between the coordinates of two
- * <code>IDocument</code> objects: the original and the image. The document information mapping
- * can translate document information such as line numbers or character ranges given for the original into
- * the corresponding information of the image and vice versa.
- *
- * @since 2.1
- */
-public interface IDocumentInformationMapping {
-
- /**
- * Returns the minimal region of the original document that completely comprises all of the image document
- * or <code>null</code> if there is no such region.
- *
- * @return the minimal region of the original document comprising the image document or <code>null</code>
- */
- IRegion getCoverage();
-
- /**
- * Returns the offset in the original document that corresponds to the given offset in the image document
- * or <code>-1</code> if there is no such offset
- *
- * @param imageOffset the offset in the image document
- * @return the corresponding offset in the original document or <code>-1</code>
- * @throws BadLocationException if <code>imageOffset</code> is not a valid offset in the image document
- */
- int toOriginOffset(int imageOffset) throws BadLocationException;
-
- /**
- * Returns the minimal region of the original document that completely comprises the given region of the
- * image document or <code>null</code> if there is no such region.
- *
- * @param imageRegion the region of the image document
- * @return the minimal region of the original document comprising the given region of the image document
- * @throws BadLocationException if <code>imageRegion</code> is not a valid region of the image document
- */
- IRegion toOriginRegion(IRegion imageRegion) throws BadLocationException;
-
- /**
- * Returns the range of lines of the original document that corresponds to the given line of the image document or
- * <code>null</code> if there are no such lines.
- *
- * @param imageLine the line of the image document
- * @return the corresponding lines of the original document or <code>null</code>
- * @throws BadLocationException if <code>imageLine</code> is not a valid line number in the image document
- */
- IRegion toOriginLines(int imageLine) throws BadLocationException;
-
- /**
- * Returns the line of the original document that corresponds to the given line of the image document or
- * <code>-1</code> if there is no such line.
- *
- * @param imageLine the line of the image document
- * @return the corresponding line of the original document or <code>-1</code>
- * @throws BadLocationException if <code>imageLine</code> is not a valid line number in the image document
- */
- int toOriginLine(int imageLine) throws BadLocationException;
-
-
-
- /**
- * Returns the offset in the image document that corresponds to the given offset in the original document
- * or <code>-1</code> if there is no such offset
- *
- * @param originOffset the offset in the original document
- * @return the corresponding offset in the image document or <code>-1</code>
- * @throws BadLocationException if <code>originOffset</code> is not a valid offset in the original document
- */
- int toImageOffset(int originOffset) throws BadLocationException;
-
- /**
- * Returns the minimal region of the image document that completely comprises the given region of the
- * original document or <code>null</code> if there is no such region.
- *
- * @param originRegion the region of the original document
- * @return the minimal region of the image document comprising the given region of the original document or <code>null</code>
- * @throws BadLocationException if <code>originRegion</code> is not a valid region of the original document
- */
- IRegion toImageRegion(IRegion originRegion) throws BadLocationException;
-
- /**
- * Returns the line of the image document that corresponds to the given line of the original document or
- * <code>-1</code> if there is no such line.
- *
- * @param originLine the line of the original document
- * @return the corresponding line of the image document or <code>-1</code>
- * @throws BadLocationException if <code>originLine</code> is not a valid line number in the original document
- */
- int toImageLine(int originLine) throws BadLocationException;
-
- /**
- * Returns the line of the image document whose corresponding line in the original document
- * is closest to the given line in the original document.
- *
- * @param originLine the line in the original document
- * @return the line in the image document that corresponds best to the given line in the original document
- * @throws BadLocationException if <code>originLine</code>is not a valid line in the original document
- */
- int toClosestImageLine(int originLine) throws BadLocationException;
-}
\ No newline at end of file
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/IDocumentInformationMappingExtension.java b/org.eclipse.text/src/org/eclipse/jface/text/IDocumentInformationMappingExtension.java
deleted file mode 100644
index 27b3778..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/IDocumentInformationMappingExtension.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-/**
- * Extension to <code>IDocumentInformationMapping</code>.
- *
- * @since 3.0
- */
-public interface IDocumentInformationMappingExtension {
-
- /**
- * Adheres to originRegion= toOriginRegion(toExactImageRegion(originRegion)), if toExactImageRegion(originRegion) != null.
- *
- * @param originRegion the origin region
- * @return the exact image region
- * @throws BadLocationException if origin region is not valid a valid region in the master document
- */
- IRegion toExactImageRegion(IRegion originRegion) throws BadLocationException;
-
-
- /**
- * Returns the fragments of the original document that exactly correspond
- * to the given region of the image document.
- *
- * @param imageRegion the region in the image document
- * @return the fragments of the original document
- * @throws BadLocationException in case the given image region is not valid in the image document
- */
- IRegion[] toExactOriginRegions(IRegion imageRegion) throws BadLocationException;
-
- /**
- * Returns the length of the image document.
- *
- * @return the length of the image document
- */
- int getImageLength();
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/IDocumentListener.java b/org.eclipse.text/src/org/eclipse/jface/text/IDocumentListener.java
deleted file mode 100644
index 6111bf7..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/IDocumentListener.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-
-
-/**
- * Interface for objects which are interested in getting informed about
- * document changes. A listener is informed about document changes before
- * they are applied and after they have been applied. It is ensured that
- * the document event passed into the listener is the same for the two
- * notifications, i.e. the two document events can be checked using object identity.
- * Clients may implement this interface.
- */
-public interface IDocumentListener {
-
-
- /**
- * The manipulation described by the document event will be performed.
- *
- * @param event the document event describing the document change
- */
- void documentAboutToBeChanged(DocumentEvent event);
-
- /**
- * The manipulation described by the document event has been performed.
- *
- * @param event the document event describing the document change
- */
- void documentChanged(DocumentEvent event);
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/IDocumentPartitioner.java b/org.eclipse.text/src/org/eclipse/jface/text/IDocumentPartitioner.java
deleted file mode 100644
index f0c8699..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/IDocumentPartitioner.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-
-
-/**
- * A document partitioner divides a document into a set
- * of disjoint text partitions. Each partition has a content type, an
- * offset, and a length. The document partitioner is connected to one document
- * and informed about all changes of this document before any of the
- * document's document listeners. A document partitioner can thus
- * incrementally update on the receipt of a document change event.
- * Clients may implement this interface or use the standard
- * implementation <code>RuleBasedDocumentPartitioner</code>.
- *
- * @see IDocument
- */
-public interface IDocumentPartitioner {
-
- /**
- * Connects the partitioner to a document.
- * Connect indicates the begin of the usage of the receiver
- * as partitioner of the given document. Thus, resources the partitioner
- * needs to be operational for this document should be allocated.<p>
- * The caller of this method must ensure that this partitioner is
- * also set as the document's document partitioner.
- *
- * @param document the document to be connected to
- */
- void connect(IDocument document);
-
- /**
- * Disconnects the partitioner from the document it is connected to.
- * Disconnect indicates the end of the usage of the receiver as
- * partitioner of the connected document. Thus, resources the partitioner
- * needed to be operation for its connected document should be deallocated.<p>
- * The caller of this method should also must ensure that this partitioner is
- * no longer the document's partitioner.
- */
- void disconnect();
-
- /**
- * Informs about a forthcoming document change. Will be called by the
- * connected document and is not intended to be used by clients
- * other than the connected document.
- *
- * @param event the event describing the forthcoming change
- */
- void documentAboutToBeChanged(DocumentEvent event);
-
- /**
- * The document has been changed. The partitioner updates
- * the document's partitioning and returns whether the structure of the
- * document partitioning has been changed, i.e. whether partitions
- * have been added or removed. Will be called by the connected document and
- * is not intended to be used by clients other than the connected document.
- *
- * @param event the event describing the document change
- * @return <code>true</code> if partitioning changed
- */
- boolean documentChanged(DocumentEvent event);
-
- /**
- * Returns the set of all legal content types of this partitioner.
- * I.e. any result delivered by this partitioner may not contain a content type
- * which would not be included in this method's result.
- *
- * @return the set of legal content types
- */
- String[] getLegalContentTypes();
-
- /**
- * Returns the content type of the partition containing the
- * given offset in the connected document. There must be a
- * document connected to this partitioner.
- *
- * @param offset the offset in the connected document
- * @return the content type of the offset's partition
- */
- String getContentType(int offset);
-
- /**
- * Returns the partitioning of the given range of the connected
- * document. There must be a document connected to this partitioner.
- *
- * @param offset the offset of the range of interest
- * @param length the length of the range of interest
- * @return the partitioning of the range
- */
- ITypedRegion[] computePartitioning(int offset, int length);
-
- /**
- * Returns the partition containing the given offset of
- * the connected document. There must be a document connected to this
- * partitioner.
- *
- * @param offset the offset for which to determine the partition
- * @return the partition containing the offset
- */
- ITypedRegion getPartition(int offset);
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/IDocumentPartitionerExtension.java b/org.eclipse.text/src/org/eclipse/jface/text/IDocumentPartitionerExtension.java
deleted file mode 100644
index a7d636c..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/IDocumentPartitionerExtension.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-
-/**
- * Extension interface for <code>IDocumentPartitioner</code>. Extends the original
- * concept of a document partitioner by returning the minimal region that includes all
- * partition changes caused by the invocation of the document partitioner.
- *
- * The method <code>documentChanged2</code> is considered the replacement of
- * <code>IDocumentPartitioner.documentChanged</code>.
- *
- * @since 2.0
-
-*/
-public interface IDocumentPartitionerExtension {
-
- /**
- * The document has been changed. The partitioner updates
- * the document's partitioning and returns the minimal region that comprises
- * all partition changes caused by the given document event. This method returns
- * <code>null</code> if the partitioning did not change.<p>
- *
- * Will be called by the connected document and is not intended to be used by
- * clients other than the connected document.
- *
- * @param event the event describing the document change
- * @return the region of the document in which the partition type changed
- */
- IRegion documentChanged2(DocumentEvent event);
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/IDocumentPartitionerExtension2.java b/org.eclipse.text/src/org/eclipse/jface/text/IDocumentPartitionerExtension2.java
deleted file mode 100644
index bc4a25a..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/IDocumentPartitionerExtension2.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-
-/**
- * Extension interface for <code>IDocumentPartitioner</code>. Extends the original
- * concept of a document partitioner to answer the position categories that are used
- * to manage the partitioning information.
- *
- * @since 3.0
-
-*/
-public interface IDocumentPartitionerExtension2 {
-
- /**
- * Returns the position categories that this partitoners uses in order to manage
- * the partitioning information of the documents. Returns <code>null</code> if
- * no position category is used.
- *
- * @return the position categories used to manage partitioning information
- */
- String[] getManagingPositionCategories();
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/IDocumentPartitioningListener.java b/org.eclipse.text/src/org/eclipse/jface/text/IDocumentPartitioningListener.java
deleted file mode 100644
index 320f499..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/IDocumentPartitioningListener.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-
-
-/**
- * Interface of objects which are interested in getting informed
- * about changes of a document's partitioning. Clients may
- * implement this interface.
- *
- * @see IDocument
- * @see IDocumentPartitioner
- */
-public interface IDocumentPartitioningListener {
-
- /**
- * The partitioning of the given document changed.
- *
- * @param document the document whose partitioning changed
- *
- * @see IDocument#addDocumentPartitioningListener
- */
- void documentPartitioningChanged(IDocument document);
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/IDocumentPartitioningListenerExtension.java b/org.eclipse.text/src/org/eclipse/jface/text/IDocumentPartitioningListenerExtension.java
deleted file mode 100644
index 8f1b4e3..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/IDocumentPartitioningListenerExtension.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-
-/**
- * Extension interface for <code>IDocumentPartitioningListener</code>. Extends the original
- * partitioning listener concept by telling the listener the minimal region that comprises all
- * partitioning changes.
- *
- * @see org.eclipse.jface.text.IDocumentPartitionerExtension
- * @since 2.0
- */
-public interface IDocumentPartitioningListenerExtension {
-
- /**
- * The partitioning of the given document changed in the given region.
- *
- * @param document the document whose partitioning changed
- * @param region the region in which the partitioning changed
- * @see IDocument#addDocumentPartitioningListener
- */
- void documentPartitioningChanged(IDocument document, IRegion region);
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/IDocumentPartitioningListenerExtension2.java b/org.eclipse.text/src/org/eclipse/jface/text/IDocumentPartitioningListenerExtension2.java
deleted file mode 100644
index 229149e..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/IDocumentPartitioningListenerExtension2.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**********************************************************************
-Copyright (c) 2000, 2003 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-
-Contributors:
- IBM Corporation - Initial implementation
-**********************************************************************/
-package org.eclipse.jface.text;
-
-/**
- * Extension interface to <code>|DocumentPartitioningListener</code>. Replaces the previous concepts.
- *
- * @since 3.0
- */
-public interface IDocumentPartitioningListenerExtension2 {
-
- /**
- * Signals the change of document partitionings.
- *
- * @param event the event describing the change
- * @see IDocument#addDocumentPartitioningListener
- */
- void documentPartitioningChanged(DocumentPartitioningChangedEvent event);
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/ILineTracker.java b/org.eclipse.text/src/org/eclipse/jface/text/ILineTracker.java
deleted file mode 100644
index 837b845..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/ILineTracker.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-
-/**
- * A line tracker maps character positions to line numbers and vice versa.
- * Initially the line tracker is informed about its underlying text
- * in order to initialize the mapping information. After that, the line
- * tracker is informed about all changes of the underlying text allowing
- * for incremental updates of the mapping information. It is the client's
- * responsibility to actively inform the line tacker about text changes.
- * For example, when using a line tracker in combination with a document
- * the document controls the line tracker.<p>
- * Clients may implement this interface or use the standard implementation
- * <code>DefaultLineTracker</code>.
- */
-public interface ILineTracker {
-
- /**
- * Returns the strings this tracker considers as legal line delimiters.
- *
- * @return the legal line delimiters
- */
- String[] getLegalLineDelimiters();
-
- /**
- * Returns the line delimiter of the specified line. Returns <code>null</code> if the
- * line is not closed with a line delimiter.
- *
- * @param line the line whose line delimiter is queried
- * @return the line's delimiter or <code>null</code> if line does not have a delimiter
- * @exception BadLocationException if the line number is invalid in this tracker's line structure
- */
- String getLineDelimiter(int line) throws BadLocationException;
-
- /**
- * Computes the number of lines in the given text.
- *
- * @param text the text whose number of lines should be computed
- * @return the number of lines in the given text
- */
- int computeNumberOfLines(String text);
-
- /**
- * Returns the number of lines.
- *
- * @return the number of lines in this tracker's line structure
- */
- int getNumberOfLines();
-
- /**
- * Returns the number of lines which are occupied by a given text range.
- *
- * @param offset the offset of the specified text range
- * @param length the length of the specified text range
- * @return the number of lines occupied by the specified range
- * @exception BadLocationException if specified range is unknown to this tracker
- */
- int getNumberOfLines(int offset, int length) throws BadLocationException;
-
- /**
- * Returns the position of the first character of the specified line.
- *
- * @param line the line of interest
- * @return offset of the first character of the line
- * @exception BadLocationException if the line is unknown to this tracker
- */
- int getLineOffset(int line) throws BadLocationException;
-
- /**
- * Returns length of the specified line including the line's delimiter.
- *
- * @param line the line of interest
- * @return the length of the line
- * @exception BadLocationException if line is unknown to this tracker
- */
- int getLineLength(int line) throws BadLocationException;
-
- /**
- * Returns the line number the character at the given offset belongs to.
- *
- * @param offset the offset whose line number to be determined
- * @return the number of the line the offset is on
- * @exception BadLocationException if the offset is invalid in this tracker
- */
- int getLineNumberOfOffset(int offset) throws BadLocationException;
-
- /**
- * Returns a line description of the line at the given offset.
- * The description contains the start offset and the length of the line
- * excluding the line's delimiter.
- *
- * @param offset the offset whose line should be described
- * @return a region describing the line
- * @exception BadLocationException if offset is invalid in this tracker
- */
- IRegion getLineInformationOfOffset(int offset) throws BadLocationException;
-
- /**
- * Returns a line description of the given line. The description
- * contains the start offset and the length of the line excluding the line's
- * delimiter.
- *
- * @param line the line that should be described
- * @return a region describing the line
- * @exception BadLocationException if line is unknown to this tracker
- */
- IRegion getLineInformation(int line) throws BadLocationException;
-
- /**
- * Informs the line tracker about the specified change in the tracked text.
- *
- * @param offset the offset of the replaced text
- * @param length the length of the replaced text
- * @param text the substitution text
- * @exception BadLocationException if specified range is unknown to this tracker
- */
- void replace(int offset, int length, String text) throws BadLocationException;
-
- /**
- * Sets the tracked text to the specified text.
- *
- * @param text the new tracked text
- */
- void set(String text);
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/IPositionUpdater.java b/org.eclipse.text/src/org/eclipse/jface/text/IPositionUpdater.java
deleted file mode 100644
index 44e48f9..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/IPositionUpdater.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-
-/**
- * A position updater is responsible for adapting document positions.
- * When installed on a document, the position updater updates the
- * document's positions to changes applied to this document. Document
- * updaters can be selective, i.e. they might only update positions of
- * a certain category.<p>
- * Position updaters are of primary importance for the definition of
- * the semantics of positions.<p>
- * Clients may implement this interface or use the standard implementation
- * <code>DefaultPositionUpdater</code>.
- *
- * @see IDocument
- * @see Position
- */
-public interface IPositionUpdater {
-
- /**
- * Adapts positions to the change specified by the document event.
- * It is ensured that the document's partitioning has been adapted to
- * this document change and that all the position updaters which have
- * a smaller index in the document's position updater list have been called.
- *
- * @param event the document event describing the document change
- */
- void update(DocumentEvent event);
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/IRegion.java b/org.eclipse.text/src/org/eclipse/jface/text/IRegion.java
deleted file mode 100644
index 3c80bbd..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/IRegion.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-
-/**
- * A region describes a certain range in an indexed text store.
- * Text stores are for example documents or strings. A region is
- * defined by its offset into the text store and its length.<p>
- * A region is considered a value object. Its offset or length
- * do not change over time. <p>
- * Clients may implement this interface or use the standard implementation
- * <code>Region</code>.
- */
-public interface IRegion {
-
- /**
- * Returns the length of the region.
- *
- * @return the length of the region
- */
- int getLength();
-
- /**
- * Returns the offset of the region.
- *
- * @return the offset of the region
- */
- int getOffset();
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/IRepairableDocument.java b/org.eclipse.text/src/org/eclipse/jface/text/IRepairableDocument.java
deleted file mode 100644
index 69dbdaf..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/IRepairableDocument.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**********************************************************************
-Copyright (c) 2000, 2003 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-
-Contributors:
- IBM Corporation - Initial implementation
-**********************************************************************/
-package org.eclipse.jface.text;
-
-/**
- * Interface implemented by <code>IDocument</code> implementers that offer
- * repair methods on their documents. The following repair methods are
- * provided:
- * <ul>
- * <li>repairing line information</li>
- * </ul>
- *
- * @since 3.0
- */
-public interface IRepairableDocument {
-
-
- /**
- * Repairs the line information of this document.
- */
- void repairLineInformation();
-
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/ISlaveDocumentManager.java b/org.eclipse.text/src/org/eclipse/jface/text/ISlaveDocumentManager.java
deleted file mode 100644
index 98e9d48..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/ISlaveDocumentManager.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-/**
- * Slave documents are documents whose contents is defined in terms of a master
- * document. Thus, slave documents usually reflect a projection of the master document.
- * Slave documents are causally connected to the master document. This means, changes
- * of the master document have immediate effect in the slave document and vice versa.<p>
- *
- * A slave document manager creates slave documents for given master documents. manages the
- * life cycle of the slave documents and keeps track of the information flow between
- * master and slave documents. The slave document manager defines the construction rules of the
- * slave documents in terms of the master document.<p>
- *
- * @since 2.1
- */
-public interface ISlaveDocumentManager {
-
- /**
- * Creates a new slave document for the given master document. The slave document
- * is causally connected to its master document until <code>freeSlaveDocument</code>
- * is called. The connection between the newly created slave document and the master
- * document is managed by this slave document manager.
- *
- * @param master the master document
- * @return the newly created slave document
- * @see ISlaveDocumentManager#freeSlaveDocument(IDocument)
- */
- IDocument createSlaveDocument(IDocument master);
-
- /**
- * Frees the given slave document. If the given document is not a slave document known
- * to this slave document manager, this call does not have any effect. A slave
- * document is known to this slave document manager if it has been created by
- * this manager using <code>createSlaveDocument</code>.
- *
- * @param slave the slave document to be freed
- */
- void freeSlaveDocument(IDocument slave);
-
- /**
- * Creates a new document information mapping between the given slave document and
- * its master document. Returns <code>null</code> if the given document is unknown
- * to this slave document manager.
- *
- * @param slave the slave document
- * @return a document information mapping between the slave document and its master document or
- * <code>null</code>
- */
- IDocumentInformationMapping createMasterSlaveMapping(IDocument slave);
-
- /**
- * Returns the master document of the given slave document or <code>null</code> if the
- * given document is unknown to this slave document manager.
- *
- * @param slave the slave document
- * @return the master document of the given slave document or <code>null</code>
- */
- IDocument getMasterDocument(IDocument slave);
-
- /**
- * Returns whether the given document is a slave document known to this slave document manager. A slave document
- * is known to this slave document manager, if the document has been created by this manager.
- *
- * @param document the document to be checked whether it is a slave document known to this manager
- * @return <code>true</code> if the document is a slave document, <code>false</code> otherwise
- */
- boolean isSlaveDocument(IDocument document);
-
- /**
- * Sets the given slave document's auto expand mode. In auto expand mode, a
- * slave document is automatically adapted to reflect all changes applied to it's master document.
- * Assume a master document contains 30 lines and the slave is defined to contain the lines 11-20.
- * In auto expand mode, when the master document is changed at line 8, the slave document is expanded
- * to contain the lines 8-20.<p>
- * This call is without effect if the given document is unknown to this slave document manager.
- *
- * @param slave the slave whose auto expand mode should be set
- * @param autoExpand <code>true</code> for auto expand, <code>false</code> otherwise
- */
- void setAutoExpandMode(IDocument slave, boolean autoExpand);
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/ISlaveDocumentManagerExtension.java b/org.eclipse.text/src/org/eclipse/jface/text/ISlaveDocumentManagerExtension.java
deleted file mode 100644
index d4868f9..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/ISlaveDocumentManagerExtension.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-/**
- * Extension interface for <code>ISlaveDocumentManager</code>. Adds access to
- * the list of all slave documents for a given master document.
- *
- * @since 3.0
- */
-public interface ISlaveDocumentManagerExtension {
-
- /**
- * Returns the list of slave documents for the given master document.
- *
- * @param master the master document
- * @return the list of slave documents or <code>null</code>
- */
- IDocument[] getSlaveDocuments(IDocument master);
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/ITextStore.java b/org.eclipse.text/src/org/eclipse/jface/text/ITextStore.java
deleted file mode 100644
index b11b23a..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/ITextStore.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-
-/**
- * Interface for storing and managing text.
- * Provides access to the stored text and allows to manipulate it.
- * Clients may implement this interface or use <code>GapTextStore</code>.
- */
-public interface ITextStore {
-
- /**
- * Returns the character at the specified offset.
- *
- * @param offset the offset in this text store
- * @return the character at this offset
- */
- char get(int offset);
-
- /**
- * Returns the text of the specified character range.
- *
- * @param offset the offset of the range
- * @param length the length of the range
- * @return the text of the range
- */
- String get(int offset, int length);
-
- /**
- * Returns number of characters stored in this text store.
- *
- * @return the number of characters stored in this text store
- */
- int getLength();
-
- /**
- * Replaces the specified character range with the given text.
- * <code>replace(getLength(), 0, "some text")</code> is a valid
- * call and appends text to the end of the text store.
- *
- * @param offset the offset of the range to be replaced
- * @param length the number of characters to be replaced
- * @param text the substitution text
- */
- void replace(int offset, int length, String text);
-
- /**
- * Replace the content of the text store with the given text.
- * Convenience method for <code>replace(0, getLength(), text</code>.
- *
- * @param text the new content of the text store
- */
- void set(String text);
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/ITypedRegion.java b/org.eclipse.text/src/org/eclipse/jface/text/ITypedRegion.java
deleted file mode 100644
index 2ea3162..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/ITypedRegion.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-
-
-/**
- * Describes a region of an indexed text store such as document or string.
- * The region consists of offset, length, and type. The type is defines as
- * a string. A typed region can, e.g., be used to described document partitions.
- * Clients may implement this interface or use the standard impementation
- * <code>TypedRegion</code>.
- */
-public interface ITypedRegion extends IRegion {
-
- /**
- * Returns the content type of the region.
- *
- * @return the content type of the region
- */
- String getType();
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/Line.java b/org.eclipse.text/src/org/eclipse/jface/text/Line.java
deleted file mode 100644
index 86dfd60..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/Line.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-
-
-/**
- * Describes a line as a particular number of characters beginning at
- * a particular offset, consisting of a particular number of characters,
- * and being closed with a particular line delimiter.
- */
-class Line implements IRegion {
-
- /** The offset of the line */
- public int offset;
- /** The length of the line */
- public int length;
- /** The delimiter of this line */
- public String delimiter;
-
- /**
- * Creates a new Line.
- *
- * @param offset the offset of the line
- * @param end the last including character offset of the line
- * @param delimiter the line's delimiter
- */
- public Line(int offset, int end, String delimiter) {
- this.offset= offset;
- this.length= (end - offset) +1;
- this.delimiter= delimiter;
- }
-
- /**
- * Creates a new Line.
- *
- * @param offset the offset of the line
- * @param length the length of the line
- */
- public Line(int offset, int length) {
- this.offset= offset;
- this.length= length;
- this.delimiter= null;
- }
-
- /*
- * @see IRegion#getOffset()
- */
- public int getOffset() {
- return offset;
- }
-
- /*
- * @see IRegion#getLength()
- */
- public int getLength() {
- return length;
- }
-}
-
-
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/ParentChildMapping.java b/org.eclipse.text/src/org/eclipse/jface/text/ParentChildMapping.java
deleted file mode 100644
index 3bff41a..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/ParentChildMapping.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-/**
- * Implementation of <code>IDocumentInformationMapping</code> matching <code>ChildDocument</code> and
- * <code>ChildDocumentManager</code>. The parent document is considered the original document, the child
- * document is considered the image document.
- *
- * @deprecated
- */
-public class ParentChildMapping implements IDocumentInformationMapping {
-
- /** The parent document */
- private IDocument fParentDocument;
- /** The child document */
- private ChildDocument fChildDocument;
-
-
- /**
- * Creates a new document mapping between the parent document of the given
- * child document and the child document.
- *
- * @param childDocument
- */
- public ParentChildMapping(ChildDocument childDocument) {
- fParentDocument= childDocument.getParentDocument();
- fChildDocument= childDocument;
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentInformationMapping#getCoverage()
- */
- public IRegion getCoverage() {
- Position p= fChildDocument.getParentDocumentRange();
- return new Region(p.getOffset(), p.getLength());
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentInformationMapping#toOriginOffset(int)
- */
- public int toOriginOffset(int imageOffset) throws BadLocationException {
- int anchorOffset= fChildDocument.getParentDocumentRange().getOffset();
- return anchorOffset + imageOffset;
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentInformationMapping#toOriginRegion(org.eclipse.jface.text.IRegion)
- */
- public IRegion toOriginRegion(IRegion imageRegion) throws BadLocationException {
- int anchorOffset= fChildDocument.getParentDocumentRange().getOffset();
- return new Region(anchorOffset + imageRegion.getOffset(), imageRegion.getLength());
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentInformationMapping#toOriginLines(int)
- */
- public IRegion toOriginLines(int imageLine) throws BadLocationException {
- IRegion imageDocumentRegion= fChildDocument.getLineInformation(imageLine);
- IRegion originDocumentRegion= toOriginRegion(imageDocumentRegion);
-
- int startLine= fParentDocument.getLineOfOffset(originDocumentRegion.getOffset());
- if (originDocumentRegion.getLength() == 0)
- return new Region(startLine, 0);
-
- int endLine= fParentDocument.getLineOfOffset(originDocumentRegion.getOffset() + originDocumentRegion.getLength() -1);
- return new Region(startLine, endLine - startLine);
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentInformationMapping#toOriginLine(int)
- */
- public int toOriginLine(int imageLine) throws BadLocationException {
- int anchorOffset= fChildDocument.getParentDocumentRange().getOffset();
- return fParentDocument.getLineOfOffset(anchorOffset) + imageLine;
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentInformationMapping#toImageOffset(int)
- */
- public int toImageOffset(int originOffset) throws BadLocationException {
- Position p= fChildDocument.getParentDocumentRange();
- if (p.includes(originOffset))
- return originOffset - p.getOffset();
- return -1;
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentInformationMapping#toImageRegion(org.eclipse.jface.text.IRegion)
- */
- public IRegion toImageRegion(IRegion originRegion) throws BadLocationException {
-
- int offset= originRegion.getOffset();
- int length= originRegion.getLength();
-
- if (length < 0) {
- length= -length;
- offset -= length;
- }
-
- Position p= fChildDocument.getParentDocumentRange();
- if (p.overlapsWith(offset, length)) {
-
- if (offset < p.getOffset())
- offset= p.getOffset();
-
- int end= offset + length;
- int e= p.getOffset() + p.getLength();
- if (end > e)
- end= e;
-
- offset -= p.getOffset();
- end -= p.getOffset();
-
- if (originRegion.getLength() < 0)
- return new Region(end, offset - end);
- return new Region(offset, end - offset);
- }
-
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentInformationMapping#toImageLine(int)
- */
- public int toImageLine(int originLine) throws BadLocationException {
- int anchorOffset= fChildDocument.getParentDocumentRange().getOffset();
- int startLine= fParentDocument.getLineOfOffset(anchorOffset);
-
- int imageLine= originLine - startLine;
- if (imageLine < 0 || imageLine > fChildDocument.getNumberOfLines())
- return -1;
- return imageLine;
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentInformationMapping#toClosestImageLine(int)
- */
- public int toClosestImageLine(int originLine) throws BadLocationException {
- int anchorOffset= fChildDocument.getParentDocumentRange().getOffset();
- int startLine= fParentDocument.getLineOfOffset(anchorOffset);
-
- int imageLine= originLine - startLine;
- if (imageLine < 0)
- return 0;
-
- int maxLine= fChildDocument.getNumberOfLines();
- if (imageLine > maxLine)
- return maxLine;
-
- return imageLine;
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/Position.java b/org.eclipse.text/src/org/eclipse/jface/text/Position.java
deleted file mode 100644
index b88cf27..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/Position.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-
-/**
- * Positions describe text ranges of a document. Positions are
- * adapted to changes applied to that document. The text range
- * is specified by an offset and a length. Positions can be marked as
- * deleted. Deleted positions are considered to no longer represent
- * a valid text range in the managing document. <p>
- * Positions attached to documents are ususally updated by position updaters.
- * Because position updaters are freely defineable and because of the
- * frequence in which they are used, the fields of a position are made
- * publicly accessible. Clients other than position updaters are not
- * allowed to access these public fields.
- *
- * @see IDocument
- */
-public class Position {
-
- /** The offset of the position */
- public int offset;
- /** The length of the position */
- public int length;
- /** Indicates whether the position has been deleted */
- public boolean isDeleted;
-
- /**
- * Creates a new position with the given offset and length 0.
- *
- * @param offset the position offset, must be >= 0
- */
- public Position(int offset) {
- this(offset, 0);
- }
-
- /**
- * Creates a new position with the given offset and length.
- *
- * @param offset the position offset, must be >= 0
- * @param length the position length, must be >= 0
- */
- public Position(int offset, int length) {
- Assert.isTrue(offset >= 0);
- Assert.isTrue(length >= 0);
- this.offset= offset;
- this.length= length;
- }
-
- /**
- * Creates a new uninitialized position.
- */
- protected Position() {
- }
-
- /*
- * @see Object#hashCode
- */
- public int hashCode() {
- int deleted= isDeleted ? 0 : 1;
- return (offset << 24) | (length << 16) | deleted;
- }
-
- /**
- * Marks this position as deleted.
- */
- public void delete() {
- isDeleted= true;
- }
-
- /**
- * Marks this position as not deleted.
- * @since 2.0
- */
- public void undelete() {
- isDeleted= false;
- }
-
- /*
- * @see Object#equals(Object)
- */
- public boolean equals(Object other) {
- if (other instanceof Position) {
- Position rp= (Position) other;
- return (rp.offset == offset) && (rp.length == length);
- }
- return super.equals(other);
- }
-
- /**
- * Returns the length of this position.
- *
- * @return the length of this position
- */
- public int getLength() {
- return length;
- }
-
- /**
- * Returns the offset of this position.
- *
- * @return the length of this position
- */
- public int getOffset() {
- return offset;
- }
-
- /**
- * Checks whether the given offset is inside
- * of this position's text range.
- *
- * @param offset the offset to check
- * @return <code>true</code> if offset is inside of this position
- */
- public boolean includes(int offset) {
-
- if (isDeleted)
- return false;
-
- return (this.offset <= offset) && (offset < this.offset + length);
- }
-
- /**
- * Checks whether the intersection of the given text range
- * and the text range represented by this position is empty
- * or not.
- *
- * @param offset the offset of the range to check
- * @param length the length of the range to check
- * @return <code>true</code> if intersection is not empty
- */
- public boolean overlapsWith(int offset, int length) {
-
- if (isDeleted)
- return false;
-
- int end= offset + length;
- int thisEnd= this.offset + this.length;
-
- if (length > 0) {
- if (this.length > 0)
- return this.offset < end && offset < thisEnd;
- return offset <= this.offset && this.offset < end;
- }
-
- if (this.length > 0)
- return this.offset <= offset && offset < thisEnd;
- return this.offset == offset;
- }
-
- /**
- * Returns whether this position has been deleted or not.
- *
- * @return <code>true</code> if position has been deleted
- */
- public boolean isDeleted() {
- return isDeleted;
- }
-
- /**
- * Changes the length of this position to the given length.
- *
- * @param length the new length of this position
- */
- public void setLength(int length) {
- Assert.isTrue(length >= 0);
- this.length= length;
- }
-
- /**
- * Changes the offset of this position to the given offset.
- *
- * @param offset the new offset of this position
- */
- public void setOffset(int offset) {
- Assert.isTrue(offset >= 0);
- this.offset= offset;
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/Region.java b/org.eclipse.text/src/org/eclipse/jface/text/Region.java
deleted file mode 100644
index 7ca94e0..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/Region.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-
-
-/**
- * A default implementation of the <code>IRegion</code> interface.
- */
-public class Region implements IRegion {
-
- /** The region offset */
- private int fOffset;
- /** The region length */
- private int fLength;
-
- /**
- * Create a new region.
- *
- * @param offset the offset of the region
- * @param length the length of the region
- */
- public Region(int offset, int length) {
- fOffset= offset;
- fLength= length;
- }
-
- /*
- * @see IRegion#getLength()
- */
- public int getLength() {
- return fLength;
- }
-
- /*
- * @see IRegion#getOffset()
- */
- public int getOffset() {
- return fOffset;
- }
-
- /**
- * Two regions are equal if they have the same offset and length.
- *
- * @see Object#equals(Object)
- */
- public boolean equals(Object o) {
- if (o instanceof IRegion) {
- IRegion r= (IRegion) o;
- return r.getOffset() == fOffset && r.getLength() == fLength;
- }
- return false;
- }
-
- /*
- * @see Object#hashCode()
- */
- public int hashCode() {
- return (fOffset << 24) | (fLength << 16);
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/SequentialRewriteTextStore.java b/org.eclipse.text/src/org/eclipse/jface/text/SequentialRewriteTextStore.java
deleted file mode 100644
index 3e3ffab..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/SequentialRewriteTextStore.java
+++ /dev/null
@@ -1,273 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-
-/**
- * A text store that optimizes a given source text store for sequential rewriting.
- * While rewritten it keeps a list of replace command that serve as patches for
- * the source store. Only on request, the source store is indeed manipulated
- * by applying the patch commands to the source text store.
- *
- * @since 2.0
- */
-public class SequentialRewriteTextStore implements ITextStore {
-
- /**
- * A buffered replace command.
- */
- private static class Replace {
- public int newOffset;
- public final int offset;
- public final int length;
- public final String text;
-
- public Replace(int offset, int newOffset, int length, String text) {
- this.newOffset= newOffset;
- this.offset= offset;
- this.length= length;
- this.text= text;
- }
- }
-
- /** The list of buffered replacements. */
- private List fReplaceList;
- /** The source text store */
- private ITextStore fSource;
- /** A flag to enforce sequential access. */
- private static final boolean ASSERT_SEQUENTIALITY= false;
-
-
- /**
- * Creates a new sequential rewrite store for the given source store.
- *
- * @param source the source text store
- */
- public SequentialRewriteTextStore(ITextStore source) {
- fReplaceList= new LinkedList();
- fSource= source;
- }
-
- /**
- * Returns the source store of this rewrite store.
- *
- * @return the source store of this rewrite store
- */
- public ITextStore getSourceStore() {
- commit();
- return fSource;
- }
-
- /*
- * @see ITextStore#replace(int, int, String)
- */
- public void replace(int offset, int length, String text) {
-
- if (fReplaceList.size() == 0) {
- fReplaceList.add(new Replace(offset, offset, length, text));
-
- } else {
- Replace firstReplace= (Replace) fReplaceList.get(0);
- Replace lastReplace= (Replace) fReplaceList.get(fReplaceList.size() - 1);
-
- // backward
- if (offset + length <= firstReplace.newOffset) {
- int delta= text.length() - length;
- if (delta != 0) {
- for (Iterator i= fReplaceList.iterator(); i.hasNext(); ) {
- Replace replace= (Replace) i.next();
- replace.newOffset += delta;
- }
- }
-
- fReplaceList.add(0, new Replace(offset, offset, length, text));
-
- // forward
- } else if (offset >= lastReplace.newOffset + lastReplace.text.length()) {
- int delta= getDelta(lastReplace);
- fReplaceList.add(new Replace(offset - delta, offset, length, text));
-
- } else if (ASSERT_SEQUENTIALITY) {
- throw new IllegalArgumentException();
-
- } else {
- commit();
- fSource.replace(offset, length, text);
- }
- }
- }
-
- /*
- * @see ITextStore#set(String)
- */
- public void set(String text) {
- fSource.set(text);
- fReplaceList.clear();
- }
-
- /*
- * @see ITextStore#get(int, int)
- */
- public String get(int offset, int length) {
-
- if (fReplaceList.size() == 0) {
- return fSource.get(offset, length);
-
- } else {
- Replace firstReplace= (Replace) fReplaceList.get(0);
- Replace lastReplace= (Replace) fReplaceList.get(fReplaceList.size() - 1);
-
- // before
- if (offset + length <= firstReplace.newOffset) {
- return fSource.get(offset, length);
-
- // after
- } else if (offset >= lastReplace.newOffset + lastReplace.text.length()) {
- int delta= getDelta(lastReplace);
- return fSource.get(offset - delta, length);
-
- } else if (ASSERT_SEQUENTIALITY) {
- throw new IllegalArgumentException();
-
- } else {
-
- int delta= 0;
- for (Iterator i= fReplaceList.iterator(); i.hasNext(); ) {
- Replace replace= (Replace) i.next();
-
- if (offset + length < replace.newOffset) {
- return fSource.get(offset - delta, length);
-
- } else if (offset >= replace.newOffset && offset + length <= replace.newOffset + replace.text.length()) {
- return replace.text.substring(offset - replace.newOffset, offset - replace.newOffset + length);
-
- } else if (offset >= replace.newOffset + replace.text.length()) {
- delta= getDelta(replace);
- continue;
-
- } else {
- commit();
- return fSource.get(offset, length);
- }
- }
-
- return fSource.get(offset - delta, length);
- }
- }
- }
-
- /**
- * Returns the difference between the offset in the source store and the "same" offset in the
- * rewrite store after the replace operation.
- *
- * @param replace the replace command
- */
- private static final int getDelta(Replace replace) {
- return replace.newOffset - replace.offset + replace.text.length() - replace.length;
- }
-
- /*
- * @see ITextStore#get(int)
- */
- public char get(int offset) {
- if (fReplaceList.size() == 0) {
- return fSource.get(offset);
-
- } else {
- Replace firstReplace= (Replace) fReplaceList.get(0);
- Replace lastReplace= (Replace) fReplaceList.get(fReplaceList.size() - 1);
-
- // before
- if (offset < firstReplace.newOffset) {
- return fSource.get(offset);
-
- // after
- } else if (offset >= lastReplace.newOffset + lastReplace.text.length()) {
- int delta= getDelta(lastReplace);
- return fSource.get(offset - delta);
-
- } else if (ASSERT_SEQUENTIALITY) {
- throw new IllegalArgumentException();
-
- } else {
-
- int delta= 0;
- for (Iterator i= fReplaceList.iterator(); i.hasNext(); ) {
- Replace replace= (Replace) i.next();
-
- if (offset < replace.newOffset)
- return fSource.get(offset - delta);
-
- else if (offset < replace.newOffset + replace.text.length())
- return replace.text.charAt(offset - replace.newOffset);
-
- delta= getDelta(replace);
- }
-
- return fSource.get(offset - delta);
- }
- }
- }
-
- /*
- * @see ITextStore#getLength()
- */
- public int getLength() {
- if (fReplaceList.size() == 0) {
- return fSource.getLength();
-
- } else {
- Replace lastReplace= (Replace) fReplaceList.get(fReplaceList.size() - 1);
- return fSource.getLength() + getDelta(lastReplace);
- }
- }
-
- /**
- * Disposes this rewrite store.
- */
- public void dispose() {
- fReplaceList= null;
- fSource= null;
- }
-
- /**
- * Commits all buffered replace commands.
- */
- private void commit() {
-
- if (fReplaceList.size() == 0)
- return;
-
- StringBuffer buffer= new StringBuffer();
-
- int delta= 0;
- for (Iterator i= fReplaceList.iterator(); i.hasNext(); ) {
- Replace replace= (Replace) i.next();
-
- int offset= buffer.length() - delta;
- buffer.append(fSource.get(offset, replace.offset - offset));
- buffer.append(replace.text);
- delta= getDelta(replace);
- }
-
- int offset= buffer.length() - delta;
- buffer.append(fSource.get(offset, fSource.getLength() - offset));
-
- fSource.set(buffer.toString());
- fReplaceList.clear();
- }
-
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/SlaveDocumentEvent.java b/org.eclipse.text/src/org/eclipse/jface/text/SlaveDocumentEvent.java
deleted file mode 100644
index 60fcd52..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/SlaveDocumentEvent.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-/**
- * A slave document event represents a master document event as a slave-relative
- * document event. It also carries the master document event.
- */
-public class SlaveDocumentEvent extends DocumentEvent {
-
- /** The master document event */
- private DocumentEvent fMasterEvent;
-
- /**
- * Creates a new slave document event.
- *
- * @param doc the slave document
- * @param offset the offset in the slave document
- * @param length the length in the slave document
- * @param text the substitution text
- * @param masterEvent the master document event
- */
- public SlaveDocumentEvent(IDocument doc, int offset, int length, String text, DocumentEvent masterEvent) {
- super(doc, offset, length, text);
- fMasterEvent= masterEvent;
- }
-
- /**
- * Returns this event's master event.
- *
- * @return this event's master event
- */
- public DocumentEvent getMasterEvent() {
- return fMasterEvent;
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/TextUtilities.java b/org.eclipse.text/src/org/eclipse/jface/text/TextUtilities.java
deleted file mode 100644
index 42bed0f..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/TextUtilities.java
+++ /dev/null
@@ -1,488 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.text;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-import java.util.Set;
-
-
-/**
- * Collection of text functions.
- */
-public class TextUtilities {
-
- /**
- * Default line delimiters used by these text functons.
- */
- public final static String[] DELIMITERS= new String[] { "\n", "\r", "\r\n" }; //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$
-
- /**
- * Default line delimiters used by these text functions.
- *
- * @deprecated use DELIMITERS instead
- */
- public final static String[] fgDelimiters= DELIMITERS;
-
-
-
- /**
- * Determines which one of default line delimiters appears first in the list. If none of them the
- * hint is returned.
- *
- * @param text the text to be checked
- * @param hint the line delimiter hint
- */
- public static String determineLineDelimiter(String text, String hint) {
- try {
- int[] info= indexOf(DELIMITERS, text, 0);
- return DELIMITERS[info[1]];
- } catch (ArrayIndexOutOfBoundsException x) {
- }
- return hint;
- }
-
- /**
- * Returns the starting position and the index of the longest matching search string
- * in the given text that is greater than the given offset. Returns <code>[-1, -1]</code>
- * if no match can be found.
- *
- * @param searchStrings the strings to search for
- * @param text the text to be searched
- * @param offset the offset at which to start the search
- * @return an <code>int[]</code> with two elements" the first is the starting offset, the second the index of the found
- * search string in the given <code>searchStrings</code> array, returns <code>[-1, -1]</code> if no match exists
- */
- public static int[] indexOf(String[] searchStrings, String text, int offset) {
-
- int[] result= { -1, -1 };
- int zeroIndex= -1;
-
- for (int i= 0; i < searchStrings.length; i++) {
-
- int length= searchStrings[i].length();
-
- if (length == 0) {
- zeroIndex= i;
- continue;
- }
-
- int index= text.indexOf(searchStrings[i], offset);
- if (index >= 0) {
-
- if (result[0] == -1) {
- result[0]= index;
- result[1]= i;
- } else if (index < result[0]) {
- result[0]= index;
- result[1]= i;
- } else if (index == result[0] && length > searchStrings[result[1]].length()) {
- result[0]= index;
- result[1]= i;
- }
- }
- }
-
- if (zeroIndex > -1 && result[0] == -1) {
- result[0]= 0;
- result[1]= zeroIndex;
- }
-
- return result;
- }
-
- /**
- * Returns the index of the longest search string with which the given text ends or
- * <code>-1</code> if none matches.
- *
- * @param searchStrings the strings to search for
- * @param text the text to search
- * @return the index in <code>searchStrings</code> of the longest string with which <code>text</code> ends or <code>-1</code>
- */
- public static int endsWith(String[] searchStrings, String text) {
-
- int index= -1;
-
- for (int i= 0; i < searchStrings.length; i++) {
- if (text.endsWith(searchStrings[i])) {
- if (index == -1 || searchStrings[i].length() > searchStrings[index].length())
- index= i;
- }
- }
-
- return index;
- }
-
- /**
- * Returns the index of the longest search string with which the given text starts or <code>-1</code>
- * if none matches.
- *
- * @param searchStrings the strings to search for
- * @param text the text to search
- * @return the index in <code>searchStrings</code> of the longest string with which <code>text</code> starts or <code>-1</code>
- */
- public static int startsWith(String[] searchStrings, String text) {
-
- int index= -1;
-
- for (int i= 0; i < searchStrings.length; i++) {
- if (text.startsWith(searchStrings[i])) {
- if (index == -1 || searchStrings[i].length() > searchStrings[index].length())
- index= i;
- }
- }
-
- return index;
- }
-
- /**
- * Returns the index of the first compare string that equals the given text or <code>-1</code>
- * if none is equal.
- *
- * @param compareStrings the strings to compare with
- * @param text the text to check
- * @return the index of the first equal compare string or <code>-1</code>
- */
- public static int equals(String[] compareStrings, String text) {
- for (int i= 0; i < compareStrings.length; i++) {
- if (text.equals(compareStrings[i]))
- return i;
- }
- return -1;
- }
-
- /**
- * Returns a document event which is an accumulation of a list of document events,
- * <code>null</code> if the list of documentEvents is empty.
- * The document of the document events are ignored.
- *
- * @param unprocessedDocument the document to which the document events would be applied
- * @param documentEvents the list of document events to merge
- * @return returns the merged document event
- * @throws BadLocationException might be thrown if document is not in the correct state with respect to document events
- */
- public static DocumentEvent mergeUnprocessedDocumentEvents(IDocument unprocessedDocument, List documentEvents) throws BadLocationException {
-
- if (documentEvents.size() == 0)
- return null;
-
- final Iterator iterator= documentEvents.iterator();
- final DocumentEvent firstEvent= (DocumentEvent) iterator.next();
-
- // current merged event
- final IDocument document= unprocessedDocument;
- int offset= firstEvent.getOffset();
- int length= firstEvent.getLength();
- final StringBuffer text= new StringBuffer(firstEvent.getText() == null ? "" : firstEvent.getText()); //$NON-NLS-1$
-
- while (iterator.hasNext()) {
-
- final int delta= text.length() - length;
-
- final DocumentEvent event= (DocumentEvent) iterator.next();
- final int eventOffset= event.getOffset();
- final int eventLength= event.getLength();
- final String eventText= event.getText() == null ? "" : event.getText(); //$NON-NLS-1$
-
- // event is right from merged event
- if (eventOffset > offset + length + delta) {
- final String string= document.get(offset + length, (eventOffset - delta) - (offset + length));
- text.append(string);
- text.append(eventText);
-
- length= (eventOffset - delta) + eventLength - offset;
-
- // event is left from merged event
- } else if (eventOffset + eventLength < offset) {
- final String string= document.get(eventOffset + eventLength, offset - (eventOffset + eventLength));
- text.insert(0, string);
- text.insert(0, eventText);
-
- length= offset + length - eventOffset;
- offset= eventOffset;
-
- // events overlap eachother
- } else {
- final int start= Math.max(0, eventOffset - offset);
- final int end= Math.min(text.length(), eventLength + eventOffset - offset);
- text.replace(start, end, eventText);
-
- offset= Math.min(offset, eventOffset);
- final int totalDelta= delta + eventText.length() - eventLength;
- length= text.length() - totalDelta;
- }
- }
-
- return new DocumentEvent(document, offset, length, text.toString());
- }
-
- /**
- * Returns a document event which is an accumulation of a list of document events,
- * <code>null</code> if the list of document events is empty.
- * The document events being merged must all refer to the same document, to which
- * the document changes have been already applied.
- *
- * @param documentEvents the list of document events to merge
- * @return returns the merged document event
- * @throws BadLocationException might be thrown if document is not in the correct state with respect to document events
- */
- public static DocumentEvent mergeProcessedDocumentEvents(List documentEvents) throws BadLocationException {
-
- if (documentEvents.size() == 0)
- return null;
-
- final ListIterator iterator= documentEvents.listIterator(documentEvents.size());
- final DocumentEvent firstEvent= (DocumentEvent) iterator.previous();
-
- // current merged event
- final IDocument document= firstEvent.getDocument();
- int offset= firstEvent.getOffset();
- int length= firstEvent.getLength();
- int textLength= firstEvent.getText() == null ? 0 : firstEvent.getText().length();
-
- while (iterator.hasPrevious()) {
-
- final int delta= length - textLength;
-
- final DocumentEvent event= (DocumentEvent) iterator.previous();
- final int eventOffset= event.getOffset();
- final int eventLength= event.getLength();
- final int eventTextLength= event.getText() == null ? 0 : event.getText().length();
-
- // event is right from merged event
- if (eventOffset > offset + textLength + delta) {
- length= (eventOffset - delta) - (offset + textLength) + length + eventLength;
- textLength= (eventOffset - delta) + eventTextLength - offset;
-
- // event is left from merged event
- } else if (eventOffset + eventTextLength < offset) {
- length= offset - (eventOffset + eventTextLength) + length + eventLength;
- textLength= offset + textLength - eventOffset;
- offset= eventOffset;
-
- // events overlap eachother
- } else {
- final int start= Math.max(0, eventOffset - offset);
- final int end= Math.min(length, eventTextLength + eventOffset - offset);
- length += eventLength - (end - start);
-
- offset= Math.min(offset, eventOffset);
- final int totalDelta= delta + eventLength - eventTextLength;
- textLength= length - totalDelta;
- }
- }
-
- final String text= document.get(offset, textLength);
- return new DocumentEvent(document, offset, length, text);
- }
-
- /**
- * Removes all connected document partitioners from the given document and stores them
- * under their partitioning name in a map. This map is returned. After this method has been called
- * the given document is no longer connected to any document partitioner.
- *
- * @param document the document
- * @return the map containing the removed partitioners
- */
- public static Map removeDocumentPartitioners(IDocument document) {
- Map partitioners= new HashMap();
- if (document instanceof IDocumentExtension3) {
- IDocumentExtension3 extension3= (IDocumentExtension3) document;
- String[] partitionings= extension3.getPartitionings();
- for (int i= 0; i < partitionings.length; i++) {
- IDocumentPartitioner partitioner= extension3.getDocumentPartitioner(partitionings[i]);
- if (partitioner != null) {
- extension3.setDocumentPartitioner(partitionings[i], null);
- partitioner.disconnect();
- partitioners.put(partitionings[i], partitioner);
- }
- }
- } else {
- IDocumentPartitioner partitioner= document.getDocumentPartitioner();
- if (partitioner != null) {
- document.setDocumentPartitioner(null);
- partitioner.disconnect();
- partitioners.put(IDocumentExtension3.DEFAULT_PARTITIONING, partitioner);
- }
- }
- return partitioners;
- }
-
- /**
- * Connects the given document with all document partitioners stored in the given map under
- * their partitioning name. This method cleans the given map.
- *
- * @param document the document
- * @param partitioners the map containing the partitioners to be connected
- * @since 3.0
- */
- public static void addDocumentPartitioners(IDocument document, Map partitioners) {
- if (document instanceof IDocumentExtension3) {
- IDocumentExtension3 extension3= (IDocumentExtension3) document;
- Iterator e= partitioners.keySet().iterator();
- while (e.hasNext()) {
- String partitioning= (String) e.next();
- IDocumentPartitioner partitioner= (IDocumentPartitioner) partitioners.get(partitioning);
- partitioner.connect(document);
- extension3.setDocumentPartitioner(partitioning, partitioner);
- }
- partitioners.clear();
- } else {
- IDocumentPartitioner partitioner= (IDocumentPartitioner) partitioners.get(IDocumentExtension3.DEFAULT_PARTITIONING);
- partitioner.connect(document);
- document.setDocumentPartitioner(partitioner);
- }
- }
-
- /**
- * Returns the content type at the given offset of the given document.
- *
- * @param document the document
- * @param partitioning the partitioning to be used
- * @param offset the offset
- * @return the content type at the given offset of the document
- * @throws BadLocationException if offset is invalid in the document
- * @since 3.0
- */
- public static String getContentType(IDocument document, String partitioning, int offset) throws BadLocationException {
- if (document instanceof IDocumentExtension3) {
- IDocumentExtension3 extension3= (IDocumentExtension3) document;
- try {
- return extension3.getContentType(partitioning, offset);
- } catch (BadPartitioningException x) {
- return IDocument.DEFAULT_CONTENT_TYPE;
- }
- } else {
- return document.getContentType(offset);
- }
- }
-
- /**
- * Returns the partition of the given offset of the given document.
- *
- * @param document the document
- * @param partitioning the partitioning to be used
- * @param offset the offset
- * @return the content type at the given offset of this viewer's input document
- * @throws BadLocationException if offset is invalid in the given document
- * @since 3.0
- */
- public static ITypedRegion getPartition(IDocument document, String partitioning, int offset) throws BadLocationException {
- if (document instanceof IDocumentExtension3) {
- IDocumentExtension3 extension3= (IDocumentExtension3) document;
- try {
- return extension3.getPartition(partitioning, offset);
- } catch (BadPartitioningException x) {
- return new TypedRegion(0, document.getLength(), IDocument.DEFAULT_CONTENT_TYPE);
- }
- } else {
- return document.getPartition(offset);
- }
- }
-
- /**
- * Computes and returns the partitioning for the given region of the given document for the given partitioning name.
- *
- * @param document the document
- * @param partitioning the partitioning name
- * @param offset the region offset
- * @param length the region length
- * @return the partitioning for the given region of the given document for the given partitioning name
- * @throws BadLocationException if the given region is invalid for the given document
- * @since 3.0
- */
- public static ITypedRegion[] computePartitioning(IDocument document, String partitioning, int offset, int length) throws BadLocationException {
- if (document instanceof IDocumentExtension3) {
- IDocumentExtension3 extension3= (IDocumentExtension3) document;
- try {
- return extension3.computePartitioning(partitioning, offset, length);
- } catch (BadPartitioningException x) {
- return new ITypedRegion[0];
- }
- } else {
- return document.computePartitioning(offset, length);
- }
- }
-
- /**
- * Computes and returns the partition managing position categories for the
- * given document or <code>null</code> if this was impossible.
- *
- * @param document the document
- * @return the partition managing position categories
- * @since 3.0
- */
- public static String[] computePartitionManagingCategories(IDocument document) {
- if (document instanceof IDocumentExtension3) {
- IDocumentExtension3 extension3= (IDocumentExtension3) document;
- String[] partitionings= extension3.getPartitionings();
- if (partitionings != null) {
- Set categories= new HashSet();
- for (int i= 0; i < partitionings.length; i++) {
- IDocumentPartitioner p= extension3.getDocumentPartitioner(partitionings[i]);
- if (p instanceof IDocumentPartitionerExtension2) {
- IDocumentPartitionerExtension2 extension2= (IDocumentPartitionerExtension2) p;
- String[] c= extension2.getManagingPositionCategories();
- if (c != null) {
- for (int j= 0; j < c.length; j++)
- categories.add(c[j]);
- }
- }
- }
- String[] result= new String[categories.size()];
- categories.toArray(result);
- return result;
- }
- }
- return null;
- }
-
- /**
- * Returns the default line delimiter for the given document. This is either the delimiter of the first line, or the platform line delimiter if it is
- * a legal line delimiter or the first one of the legal line delimiters. The default line delimiter should be used when performing document
- * manipulations that span multiple lines.
- *
- * @param document the document
- * @return the document's default line delimiter
- * @since 3.0
- */
- public static String getDefaultLineDelimiter(IDocument document) {
-
- String lineDelimiter= null;
-
- try {
- lineDelimiter= document.getLineDelimiter(0);
- } catch (BadLocationException x) {
- }
-
- if (lineDelimiter == null) {
- String sysLineDelimiter= System.getProperty("line.separator"); //$NON-NLS-1$
- String[] delimiters= document.getLegalLineDelimiters();
- Assert.isTrue(delimiters.length > 0);
- for (int i= 0; i < delimiters.length; i++) {
- if (delimiters[i].equals(sysLineDelimiter)) {
- lineDelimiter= sysLineDelimiter;
- break;
- }
- }
-
- if (lineDelimiter == null)
- lineDelimiter= delimiters[0];
- }
-
- return lineDelimiter;
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/TypedPosition.java b/org.eclipse.text/src/org/eclipse/jface/text/TypedPosition.java
deleted file mode 100644
index 328bc3d..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/TypedPosition.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-
-
-/**
- * Convenience class for position like typed regions.
- */
-public class TypedPosition extends Position {
-
- /** The type of the region described by this position */
- private String fType;
-
- /**
- * Creates a position along the given specification.
- *
- * @param offset the offset of this position
- * @param length the length of this position
- * @param type the type of this position
- */
- public TypedPosition(int offset, int length, String type) {
- super(offset, length);
- fType= type;
- }
-
- /**
- * Creates a position based on the typed region.
- *
- * @param region the typed region
- */
- public TypedPosition(ITypedRegion region) {
- super(region.getOffset(), region.getLength());
- fType= region.getType();
- }
-
- /**
- * Returns the type of the position
- *
- * @return the type of this position
- */
- public String getType() {
- return fType;
- }
-
- /*
- * @see Object#equals
- */
- public boolean equals(Object o) {
- if (o instanceof TypedPosition) {
- if (super.equals(o)) {
- TypedPosition p= (TypedPosition) o;
- return (fType == null && p.getType() == null) || fType.equals(p.getType());
- }
- }
- return false;
- }
-
- /*
- * @see Object#hashCode
- */
- public int hashCode() {
- int type= fType == null ? 0 : fType.hashCode();
- return super.hashCode() | type;
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/TypedRegion.java b/org.eclipse.text/src/org/eclipse/jface/text/TypedRegion.java
deleted file mode 100644
index 0a7b122..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/TypedRegion.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text;
-
-
-
-/**
- * Default implementation of <code>ITypedRegion</code>.
- */
-public class TypedRegion extends Region implements ITypedRegion {
-
- /** The region's type */
- private String fType;
-
- /**
- * Creates a typed region based on the given specification.
- *
- * @param offset the region's offset
- * @param length the region's length
- * @param type the region's type
- */
- public TypedRegion(int offset, int length, String type) {
- super(offset, length);
- fType= type;
- }
-
- /*
- * @see ITypedRegion#getType()
- */
- public String getType() {
- return fType;
- }
-
- /**
- * Two typed positions are equal if they have the same offset, length, and type.
- *
- * @see Object#equals(java.lang.Object)
- */
- public boolean equals(Object o) {
- if (o instanceof TypedRegion) {
- TypedRegion r= (TypedRegion) o;
- return super.equals(r) && ((fType == null && r.getType() == null) || fType.equals(r.getType()));
- }
- return false;
- }
-
- /*
- * @see Object#hashCode()
- */
- public int hashCode() {
- int type= fType == null ? 0 : fType.hashCode();
- return super.hashCode() | type;
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/link/ExclusivePositionUpdater.java b/org.eclipse.text/src/org/eclipse/jface/text/link/ExclusivePositionUpdater.java
deleted file mode 100644
index 039fb59..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/link/ExclusivePositionUpdater.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.link;
-
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IPositionUpdater;
-import org.eclipse.jface.text.Position;
-
-/**
- * Position updater that takes any changes at the borders of a position to not belong to the position.
- *
- * @since 3.0
- */
-public class ExclusivePositionUpdater implements IPositionUpdater {
-
- /** The position category. */
- private final String fCategory;
-
- /**
- * Creates a new updater for the given <code>category</code>.
- *
- * @param category the new category.
- */
- public ExclusivePositionUpdater(String category) {
- fCategory= category;
- }
-
- /*
- * @see org.eclipse.jface.text.IPositionUpdater#update(org.eclipse.jface.text.DocumentEvent)
- */
- public void update(DocumentEvent event) {
-
- int eventOffset= event.getOffset();
- int eventOldLength= event.getLength();
- int eventNewLength= event.getText() == null ? 0 : event.getText().length();
- int deltaLength= eventNewLength - eventOldLength;
-
- try {
- Position[] positions= event.getDocument().getPositions(fCategory);
-
- for (int i= 0; i != positions.length; i++) {
-
- Position position= positions[i];
-
- if (position.isDeleted())
- continue;
-
- int offset= position.getOffset();
- int length= position.getLength();
- int end= offset + length;
-
- if (offset >= eventOffset + eventOldLength)
- // position comes
- // after change - shift
- position.setOffset(offset + deltaLength);
- else if (end <= eventOffset)
- // position comes way before change -
- // leave alone
- ;
- else if (offset <= eventOffset && end >= eventOffset + eventOldLength) {
- // event completely internal to the position - adjust length
- position.setLength(length + deltaLength);
- } else if (offset < eventOffset) {
- // event extends over end of position - adjust length
- int newEnd= eventOffset;
- position.setLength(newEnd - offset);
- } else if (end > eventOffset + eventOldLength) {
- // event extends from before position into it - adjust offset
- // and length
- // offset becomes end of event, length ajusted acordingly
- int newOffset= eventOffset + eventNewLength;
- position.setOffset(newOffset);
- position.setLength(end - newOffset);
- } else {
- // event consumes the position - delete it
- position.delete();
- }
- }
- } catch (BadPositionCategoryException e) {
- // ignore and return
- }
- }
-
- /**
- * Returns the position category.
- *
- * @return the position category
- */
- public String getCategory() {
- return fCategory;
- }
-
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/link/ILinkedListener.java b/org.eclipse.text/src/org/eclipse/jface/text/link/ILinkedListener.java
deleted file mode 100644
index 2d6dcc6..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/link/ILinkedListener.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.link;
-
-
-/**
- * Protocol used by <code>LinkedEnvironment</code>s to communicate state changes, such
- * as leaving the environment, suspending it due to a child environment coming up, and resuming
- * after a child environment has left.
- *
- * @since 3.0
- */
-public interface ILinkedListener {
- /** Flag to <code>leave</code> specifying no special action. */
- static final int NONE= 0;
- /** Flag to <code>leave</code> specifying that all nested environments should exit. */
- static final int EXIT_ALL= 1 << 0;
- /** Flag to <code>leave</code> specifying that the caret should be moved to the exit position. */
- static final int UPDATE_CARET= 1 << 1;
- /** Flag to <code>leave</code> specifying that a UI of a parent environment should select the current position. */
- static final int SELECT= 1 << 2;
- /** Flag to <code>leave</code> specifying that document content outside of a linked position was modified. */
- static final int EXTERNAL_MODIFICATION= 1 << 3;
- /**
- * The leave event occurs when a linked environment exits.
- *
- * @param environment the leaving environment
- * @param flags the reason and commands for leaving linked mode
- */
- void left(LinkedEnvironment environment, int flags);
- /**
- * The suspend event occurs when a nested linked environment is installed on this environment.
- *
- * @param environment the environment being suspended due to a nested environment being installed
- */
- void suspend(LinkedEnvironment environment);
- /**
- * The resume event occurs when a nested linked environment exits.
- *
- * @param environment the environment being resumed due to a nested environment exiting
- * @param flags the commands to execute when resuming after suspend
- */
- void resume(LinkedEnvironment environment, int flags);
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/link/InclusivePositionUpdater.java b/org.eclipse.text/src/org/eclipse/jface/text/link/InclusivePositionUpdater.java
deleted file mode 100644
index 35dc529..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/link/InclusivePositionUpdater.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.link;
-
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IPositionUpdater;
-import org.eclipse.jface.text.Position;
-
-/**
- * Position updater that takes any change in [position.offset, position.offset + position.length] as
- * belonging to the position.
- *
- * @since 3.0
- */
-public class InclusivePositionUpdater implements IPositionUpdater {
-
- /** The position category. */
- private final String fCategory;
-
- /**
- * Creates a new updater for the given <code>category</code>.
- *
- * @param category the new category.
- */
- public InclusivePositionUpdater(String category) {
- fCategory= category;
- }
-
- /*
- * @see org.eclipse.jface.text.IPositionUpdater#update(org.eclipse.jface.text.DocumentEvent)
- */
- public void update(DocumentEvent event) {
-
- int eventOffset= event.getOffset();
- int eventOldLength= event.getLength();
- int eventNewLength= event.getText() == null ? 0 : event.getText().length();
- int deltaLength= eventNewLength - eventOldLength;
-
- try {
- Position[] positions= event.getDocument().getPositions(fCategory);
-
- for (int i= 0; i != positions.length; i++) {
-
- Position position= positions[i];
-
- if (position.isDeleted())
- continue;
-
- int offset= position.getOffset();
- int length= position.getLength();
- int end= offset + length;
-
- if (offset > eventOffset + eventOldLength)
- // position comes way
- // after change - shift
- position.setOffset(offset + deltaLength);
- else if (end < eventOffset)
- // position comes way before change -
- // leave alone
- ;
- else if (offset <= eventOffset && end >= eventOffset + eventOldLength) {
- // event completely internal to the position - adjust length
- position.setLength(length + deltaLength);
- } else if (offset < eventOffset) {
- // event extends over end of position - adjust length
- int newEnd= eventOffset + eventNewLength;
- position.setLength(newEnd - offset);
- } else if (end > eventOffset + eventOldLength) {
- // event extends from before position into it - adjust offset
- // and length
- // offset becomes end of event, length ajusted acordingly
- // we want to recycle the overlapping part
- position.setOffset(eventOffset);
- int deleted= eventOffset + eventOldLength - offset;
- position.setLength(length - deleted + eventNewLength);
- } else {
- // event consumes the position - delete it
- position.delete();
- }
- }
- } catch (BadPositionCategoryException e) {
- // ignore and return
- }
- }
-
- /**
- * Returns the position category.
- *
- * @return the position category
- */
- public String getCategory() {
- return fCategory;
- }
-
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/link/LinkedEnvironment.java b/org.eclipse.text/src/org/eclipse/jface/text/link/LinkedEnvironment.java
deleted file mode 100644
index f26f48d..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/link/LinkedEnvironment.java
+++ /dev/null
@@ -1,712 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.link;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.text.edits.MalformedTreeException;
-import org.eclipse.text.edits.TextEdit;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentExtension;
-import org.eclipse.jface.text.IDocumentListener;
-import org.eclipse.jface.text.IPositionUpdater;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.IDocumentExtension.IReplace;
-
-/**
- * A <code> LinkedEnvironment</code> umbrellas several <code>LinkedPositionGroup</code>s.
- * Responsible for updating the siblings of a linked position when a change
- * occurs.
- *
- * @since 3.0
- */
-public class LinkedEnvironment {
-
- /**
- * Checks whether there is alreay a linked environment installed on <code>document</code>.
- *
- * @param document the <code>IDocument</code> of interest
- * @return <code>true</code> if there is an existing environment, <code>false</code>
- * otherwise
- */
- public static boolean hasEnvironment(IDocument document) {
- // if there is a manager, there also is an enviroment
- return LinkedManager.hasManager(document);
- }
-
- /**
- * Checks whether there is alreay a linked environment installed on any of
- * the <code>documents</code>.
- *
- * @param documents the <code>IDocument</code> s of interest
- * @return <code>true</code> if there is an existing environment, <code>false</code>
- * otherwise
- */
- public static boolean hasEnvironment(IDocument[] documents) {
- // if there is a manager, there also is an enviroment
- return LinkedManager.hasManager(documents);
- }
-
- /**
- * Cancels any linked environment on the specified document. If there is no
- * environment, nothing happens.
- *
- * @param document the document whose <code>LinkedEnvironment</code> should
- * be cancelled
- */
- public static void closeEnvironment(IDocument document) {
- LinkedManager.cancelManager(document);
- }
-
- /**
- * Returns the environment currently active on <code>document</code> at
- * <code>offset</code>, or <code>null</code> if there is none.
- *
- * @param document the document for which the caller asks for an
- * environment
- * @param offset the offset into <code>document</code>, as there may be
- * several environments on a document
- * @return the environment currently active on <code>document</code>, or
- * <code>null</code>
- */
- public static LinkedEnvironment getEnvironment(IDocument document, int offset) {
- LinkedManager mgr= LinkedManager.getLinkedManager(new IDocument[] {document}, false);
- if (mgr != null)
- return mgr.getTopEnvironment();
- else
- return null;
- }
-
- /**
- * Encapsulates the edition triggered by a change to a linked position. Can
- * be applied to a document as a whole.
- */
- private class Replace implements IReplace {
-
- /** The edition to apply on a document. */
- private TextEdit fEdit;
-
- /**
- * Creates a new instance.
- *
- * @param edit the edition to apply to a document.
- */
- public Replace(TextEdit edit) {
- fEdit= edit;
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentExtension.IReplace#perform(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IDocumentListener)
- */
- public void perform(IDocument document, IDocumentListener owner) throws RuntimeException, MalformedTreeException {
- document.removeDocumentListener(owner);
- fIsChanging= true;
- try {
- fEdit.apply(document, TextEdit.UPDATE_REGIONS | TextEdit.CREATE_UNDO);
- } catch (BadLocationException e) {
- /* perform should really throw a BadLocationException
- * TODO see https://bugs.eclipse.org/bugs/show_bug.cgi?id=52950
- */
- throw new RuntimeException(e);
- } finally {
- document.addDocumentListener(owner);
- fIsChanging= false;
- }
- }
-
- }
-
- /**
- * The document listener triggering the linked updating of positions
- * managed by this environment.
- */
- private class DocumentListener implements IDocumentListener {
-
- private DocumentEvent fLastEvent;
- private boolean fExit= false;
-
- /**
- * Checks whether <code>event</code> occurs within any of the positions
- * managed by this environment. If not, the linked mode is left.
- *
- * @param event {@inheritDoc}
- */
- public void documentAboutToBeChanged(DocumentEvent event) {
- // don't react on changes executed by the parent environment
- if (fParentEnvironment != null && fParentEnvironment.isChanging())
- return;
-
- fExit= false;
- fLastEvent= event;
-
- for (Iterator it= fGroups.iterator(); it.hasNext(); ) {
- LinkedPositionGroup group= (LinkedPositionGroup) it.next();
- if (group.isLegalEvent(event))
- // take the first hit - exlusion is guaranteed by enforcing
- // disjointness when adding positions
- return;
- }
-
- // the event describes a change that lies outside of any managed
- // position -> signal to exit
- // don't exit here already, since we want to make sure that the positions
- // are updated to the document event.
- // TODO we might not always want to exit, e.g. we want to stay
- // linked if code completion has inserted import statements
- fExit= true;
- }
-
- /**
- * Propagates a change to a linked position to all its sibling positions.
- *
- * @param event {@inheritDoc}
- */
- public void documentChanged(DocumentEvent event) {
- // don't react on changes executed by the parent environment
- if (fParentEnvironment != null && fParentEnvironment.isChanging())
- return;
-
- if (event.equals(fLastEvent) && fExit)
- LinkedEnvironment.this.exit(ILinkedListener.EXTERNAL_MODIFICATION);
-
- for (Iterator it= fGroups.iterator(); it.hasNext(); ) {
- LinkedPositionGroup group= (LinkedPositionGroup) it.next();
-
- Map result= group.handleEvent(event);
- if (result == null)
- continue;
-
- // edit all documents
- for (Iterator it2= result.keySet().iterator(); it2.hasNext(); ) {
- IDocument doc= (IDocument) it2.next();
- TextEdit edit= (TextEdit) result.get(doc);
- Replace replace= new Replace(edit);
-
- // apply the edition, either as post notification replace
- // on the calling document or directly on any other
- // document
- if (doc == event.getDocument()) {
- if (doc instanceof IDocumentExtension) {
- ((IDocumentExtension) doc).registerPostNotificationReplace(this, replace);
- } else {
- // ignore - there is no way we can log from jface text...
- }
- } else {
- replace.perform(doc, this);
- }
- }
-
- // take the first hit - exlusion is guaranteed by enforcing
- // disjointness when adding positions
- return;
- }
- }
-
- }
-
- /** The set of linked position groups. */
- private final List fGroups= new ArrayList();
- /** The set of documents spanned by this group. */
- private final Set fDocuments= new HashSet();
- /** The position updater for linked positions. */
- private final IPositionUpdater fUpdater= new InclusivePositionUpdater(getCategory());
- /** The document listener on the documents affected by this environment. */
- private final IDocumentListener fDocumentListener= new DocumentListener();
- /** The parent environment for a hierachical set up, or <code>null</code>. */
- private LinkedEnvironment fParentEnvironment;
- /**
- * The position in <code>fParentEnvironment</code> that includes all
- * positions in this object, or <code>null</code> if there is no parent
- * environment.
- */
- private LinkedPosition fParentPosition= null;
- /**
- * An environment is sealed once it has children - no more positions can be
- * added.
- */
- private boolean fIsSealed= false;
- /** <code>true</code> when this environment is changing documents. */
- private boolean fIsChanging= false;
- /** The linked listeners. */
- private final List fListeners= new ArrayList();
- /** Flag telling whether we have exited: */
- private boolean fIsActive= true;
- /**
- * The sequence of document positions as we are going to iterate through
- * them.
- */
- private List fPositionSequence= new ArrayList();
-
- /**
- * Whether we are in the process of editing documents (set by <code>Replace</code>,
- * read by <code>DocumentListener</code>.
- *
- * @return <code>true</code> if we are in the process of editing a
- * document, <code>false</code> otherwise
- */
- private boolean isChanging() {
- return fIsChanging || fParentEnvironment != null && fParentEnvironment.isChanging();
- }
-
- /**
- * Throws a <code>BadLocationException</code> if <code>group</code>
- * conflicts with this environment's groups.
- *
- * @param group the group being checked
- * @throws BadLocationException if <code>group</code> conflicts with this
- * environment's groups
- */
- private void enforceDisjoint(LinkedPositionGroup group) throws BadLocationException {
- for (Iterator it= fGroups.iterator(); it.hasNext(); ) {
- LinkedPositionGroup g= (LinkedPositionGroup) it.next();
- g.enforceDisjoint(group);
- }
- }
-
- /**
- * Causes this environment to exit. Called either if a document change
- * outside this enviroment is detected, or by the UI.
- *
- * <p>This method part of the private protocol between <code>LinkedUIControl</code> and <code>LinkedEnvironment</code>.</p>
- *
- * @param flags the exit flags.
- */
- public void exit(int flags) {
- if (!fIsActive)
- return;
- fIsActive= false;
-
- for (Iterator it= fDocuments.iterator(); it.hasNext(); ) {
- IDocument doc= (IDocument) it.next();
- try {
- doc.removePositionCategory(getCategory());
- } catch (BadPositionCategoryException e) {
- // won't happen
- Assert.isTrue(false);
- }
- doc.removePositionUpdater(fUpdater);
- doc.removeDocumentListener(fDocumentListener);
- }
-
- fDocuments.clear();
- fGroups.clear();
-
- for (Iterator it= fListeners.iterator(); it.hasNext(); ) {
- ILinkedListener listener= (ILinkedListener) it.next();
- listener.left(this, flags);
- }
-
- fListeners.clear();
-
- if (fParentEnvironment != null)
- fParentEnvironment.resume(flags);
- }
-
- /**
- * Puts <code>document</code> into the set of managed documents. This
- * involves registering the document listener and adding our position
- * category.
- *
- * @param document the new document
- */
- private void manageDocument(IDocument document) {
- if (!fDocuments.contains(document)) {
- fDocuments.add(document);
- document.addPositionCategory(getCategory());
- document.addPositionUpdater(fUpdater);
- document.addDocumentListener(fDocumentListener);
- }
-
- }
-
- /**
- * Returns the position category used by this environment.
- *
- * @return the position category used by this environment
- */
- private String getCategory() {
- return toString();
- }
-
- /**
- * Adds a position group to this <code>LinkedEnvironment</code>. This
- * method may not be called if the environment is already sealed, i.e. a
- * nested environment has been added to it. It is also not wise to add
- * groups once a UI has been established on top of this environment.
- *
- * <p>
- * If the positions in <code>group</code> conflict with any other groups
- * in this environment, a <code>BadLocationException</code> is thrown.
- * Also, if this environment is nested in another one, all positions in all
- * groups of the child environment have to lie in a single position in the
- * parent environment, otherwise a <code>BadLocationException</code> is
- * thrown.
- * </p>
- *
- * <p>
- * If <code>group</code> already exists, nothing happens.
- * </p>
- *
- * @param group the group to be added to this environment
- * @throws BadLocationException if the group conflicts with the other
- * groups in this environment or violates the nesting requirements.
- * @throws IllegalStateException if the method is called when the
- * environment is already sealed
- */
- public void addGroup(LinkedPositionGroup group) throws BadLocationException {
- if (group == null)
- throw new IllegalArgumentException("group may not be null"); //$NON-NLS-1$
- if (fIsSealed)
- throw new IllegalStateException("environment is already installed"); //$NON-NLS-1$
- if (fGroups.contains(group))
- // nothing happens
- return;
-
- enforceDisjoint(group);
- group.seal();
- fGroups.add(group);
- }
-
-
- /**
- * Installs this environment, which includes registering as document listener
- * on all involved documents and storing global information about this environment. If
- * an exception is thrown, the installation failed and the environment is unusable.
- *
- * @throws BadLocationException if some of the positions of this environment were not valid positions on their respective documents
- */
- public void forceInstall() throws BadLocationException {
- if (!install(true))
- Assert.isTrue(false);
- }
-
- /**
- * Installs this environment, which includes registering as document listener
- * on all involved documents and storing global information about this environment. The return
- * value states whether installation was successful; if not, the environment is not installed
- * and will not work.
- *
- * @return <code>true</code> if installation was successful, <code>false</code> otherwise
- * @throws BadLocationException if some of the positions of this environment were not valid positions on their respective documents
- */
- public boolean tryInstall() throws BadLocationException {
- return install(false);
- }
-
- /**
- * Installs this environment, which includes registering as document listener
- * on all involved documents and storing global information about this environment. The return
- * value states whether installation was successful; if not, the environment is not installed
- * and will not work. The return value can only then become <code>false</code> if <code>force</code>
- * was set to <code>false</code> as well.
- *
- * @param force if <code>true</code>, any other environment that cannot coexist
- * with this one is canceled; if <code>false</code>, install will fail when conflicts
- * occur and return false
- * @return <code>true</code> if installation was successful, <code>false</code> otherwise
- * @throws BadLocationException if some of the positions of this environment were not valid positions on their respective documents
- */
- private boolean install(boolean force) throws BadLocationException {
- if (fIsSealed)
- throw new IllegalStateException("environment is already installed"); //$NON-NLS-1$
- enforceNotEmpty();
-
- IDocument[] documents= getDocuments();
- LinkedManager manager= LinkedManager.getLinkedManager(documents, force);
- // if we force creation, we require a valid manager
- Assert.isTrue(!(force && manager == null));
- if (manager == null)
- return false;
-
- if (!manager.nestEnvironment(this, force))
- if (force)
- Assert.isTrue(false);
- else
- return false;
-
- // we set up successfully. After this point, exit has to be called to
- // remove registered listeners...
- fIsSealed= true;
- if (fParentEnvironment != null)
- fParentEnvironment.suspend();
-
- // register positions
- try {
- for (Iterator it= fGroups.iterator(); it.hasNext(); ) {
- LinkedPositionGroup group= (LinkedPositionGroup) it.next();
- group.register(this);
- }
- return true;
- } catch (BadLocationException e){
- // if we fail to add, make sure to release all listeners again
- exit(ILinkedListener.NONE);
- throw e;
- }
- }
-
- /**
- * Asserts that there is at least one linked position in this linked
- * environment, throws an IllegalStateException otherwise.
- */
- private void enforceNotEmpty() {
- boolean hasPosition= false;
- for (Iterator it= fGroups.iterator(); it.hasNext(); )
- if (!((LinkedPositionGroup) it.next()).isEmtpy()) {
- hasPosition= true;
- break;
- }
- if (!hasPosition)
- throw new IllegalStateException("must specify at least one linked position"); //$NON-NLS-1$
-
- }
-
- /**
- * Collects all the documents that contained positions are set upon.
- * @return the set of documents affected by this environment
- */
- private IDocument[] getDocuments() {
- Set docs= new HashSet();
- for (Iterator it= fGroups.iterator(); it.hasNext(); ) {
- LinkedPositionGroup group= (LinkedPositionGroup) it.next();
- docs.addAll(Arrays.asList(group.getDocuments()));
- }
- return (IDocument[]) docs.toArray(new IDocument[docs.size()]);
- }
-
- /**
- * Returns whether the receiver can be nested into the given <code>parent</code>
- * environment. If yes, the parent environment and its position that the receiver
- * fits in are remembered.
- *
- * @param parent the parent environment candidate
- * @return <code>true</code> if the receiver can be nested into <code>parent</code>, <code>false</code> otherwise
- */
- boolean canNestInto(LinkedEnvironment parent) {
- for (Iterator it= fGroups.iterator(); it.hasNext(); ) {
- LinkedPositionGroup group= (LinkedPositionGroup) it.next();
- if (!enforceNestability(group, parent)) {
- fParentPosition= null;
- return false;
- }
- }
-
- Assert.isNotNull(fParentPosition);
- fParentEnvironment= parent;
- return true;
- }
-
- /**
- * Called by nested environments when a group is added to them. All
- * positions in all groups of a nested environment have to fit inside a
- * single position in the parent environment.
- *
- * @param group the group of the nested environment to be adopted.
- * @param environment the environment to check against
- */
- private boolean enforceNestability(LinkedPositionGroup group, LinkedEnvironment environment) {
- Assert.isNotNull(environment);
- Assert.isNotNull(group);
-
- try {
- for (Iterator it= environment.fGroups.iterator(); it.hasNext(); ) {
- LinkedPositionGroup pg= (LinkedPositionGroup) it.next();
- LinkedPosition pos;
- pos= pg.adopt(group);
- if (pos != null && fParentPosition != null && fParentPosition != pos)
- return false; // group does not fit into one parent position, which is illegal
- else if (fParentPosition == null && pos != null)
- fParentPosition= pos;
- }
- } catch (BadLocationException e) {
- return false;
- }
-
- // group must fit into exactly one of the parent's positions
- return fParentPosition != null;
- }
-
- /**
- * Returns whether this environment is nested.
- *
- * <p>This method part of the private protocol between <code>LinkedUIControl</code> and <code>LinkedEnvironment</code>.</p>
- *
- * @return <code>true</code> if this environment is nested, <code>false</code>
- * otherwise
- */
- public boolean isNested() {
- return fParentEnvironment != null;
- }
-
- /**
- * Returns the positions in this environment that have a tab stop, in the
- * order they were added.
- *
- * <p>This method part of the private protocol between <code>LinkedUIControl</code> and <code>LinkedEnvironment</code>.</p>
- *
- * @return the positions in this environment that have a tab stop, in the
- * order they were added
- */
- public List getTabStopSequence() {
- return fPositionSequence;
- }
-
- /**
- * Adds <code>listener</code> to the set of listeners that are informed
- * upon state changes.
- *
- * @param listener the new listener
- */
- public void addLinkedListener(ILinkedListener listener) {
- Assert.isNotNull(listener);
- if (!fListeners.contains(listener))
- fListeners.add(listener);
- }
-
- /**
- * Removes <code>listener</code> from the set of listeners that are
- * informed upon state changes.
- *
- * @param listener the new listener
- */
- public void removeLinkedListener(ILinkedListener listener) {
- fListeners.remove(listener);
- }
-
- /**
- * Finds the position in this environment that is closest after <code>toFind</code>.
- * <code>toFind</code> needs not be a position in this environment and
- * serves merely as an offset.
- *
- * <p>This method part of the private protocol between <code>LinkedUIControl</code> and <code>LinkedEnvironment</code>.</p>
- *
- * @param toFind the position to search from
- * @return the closest position in the same document as <code>toFind</code>
- * after the offset of <code>toFind</code>, or <code>null</code>
- */
- public LinkedPosition findPosition(LinkedPosition toFind) {
- LinkedPosition position= null;
- for (Iterator it= fGroups.iterator(); it.hasNext(); ) {
- LinkedPositionGroup group= (LinkedPositionGroup) it.next();
- position= group.getPosition(toFind);
- if (position != null)
- break;
- }
- return position;
- }
-
- /**
- * Registers a <code>LinkedPosition</code> with this environment. Called
- * by <code>PositionGroup</code>.
- *
- * @param position the position to register
- * @throws BadLocationException if the position cannot be added to its
- * document
- */
- void register(LinkedPosition position) throws BadLocationException {
- Assert.isNotNull(position);
-
- IDocument document= position.getDocument();
- manageDocument(document);
- try {
- document.addPosition(getCategory(), position);
- } catch (BadPositionCategoryException e) {
- // won't happen as the category has been added by manageDocument()
- Assert.isTrue(false);
- }
- int seqNr= position.getSequenceNumber();
- if (seqNr != LinkedPositionGroup.NO_STOP) {
- fPositionSequence.add(position);
- }
- }
-
- /**
- * Suspends this environment.
- */
- private void suspend() {
- List l= new ArrayList(fListeners);
- for (Iterator it= l.iterator(); it.hasNext(); ) {
- ILinkedListener listener= (ILinkedListener) it.next();
- listener.suspend(this);
- }
- }
-
- /**
- * Resumes this environment. <code>flags</code> can be <code>NONE</code>
- * or <code>SELECT</code>.
- *
- * @param flags <code>NONE</code> or <code>SELECT</code>
- */
- private void resume(int flags) {
- List l= new ArrayList(fListeners);
- for (Iterator it= l.iterator(); it.hasNext(); ) {
- ILinkedListener listener= (ILinkedListener) it.next();
- listener.resume(this, flags);
- }
- }
-
- /**
- * Returns whether an offset is contained by any position in this
- * environment.
- *
- * @param offset the offset to check
- * @return <code>true</code> if <code>offset</code> is included by any
- * position (see {@link LinkedPosition#includes(int)}) in this
- * environment, <code>false</code> otherwise
- */
- public boolean anyPositionContains(int offset) {
- for (Iterator it= fGroups.iterator(); it.hasNext(); ) {
- LinkedPositionGroup group= (LinkedPositionGroup) it.next();
- if (group.contains(offset))
- // take the first hit - exlusion is guaranteed by enforcing
- // disjointness when adding positions
- return true;
- }
- return false;
- }
-
- /**
- * Returns the linked position group that contains <code>position</code>,
- * or <code>null</code> if <code>position</code> is not contained in
- * any group within this environment. Group containment is tested by
- * calling <code>group.contains(position)</code> for every <code>group</code>
- * in this environment.
- *
- * <p>
- * This method part of the private protocol between <code>LinkedUIControl</code>
- * and <code>LinkedEnvironment</code>.
- * </p>
- *
- * @param position the position the group of which is requested
- * @return the first group in this environment for which <code>group.contains(position)</code>
- * returns <code>true</code>, or <code>null</code> if no group
- * contains <code>position</code>
- */
- public LinkedPositionGroup getGroupForPosition(Position position) {
- for (Iterator it= fGroups.iterator(); it.hasNext(); ) {
- LinkedPositionGroup group= (LinkedPositionGroup) it.next();
- if (group.contains(position))
- return group;
- }
- return null;
- }
-
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/link/LinkedManager.java b/org.eclipse.text/src/org/eclipse/jface/text/link/LinkedManager.java
deleted file mode 100644
index 2bdeeae..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/link/LinkedManager.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.link;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.Stack;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.IDocument;
-
-
-/**
- * A linked manager ensures exclusive access of linked position infrastructures to documents. There
- * is at most one <code>LinkedManager</code> installed on the same document. The <code>getManager</code>
- * methods will return the existing instance if any of the specified documents already have an installed
- * manager.
- *
- * @since 3.0
- */
-class LinkedManager {
-
- /**
- * Our implementation of <code>ILinkedListener</code>.
- */
- private class Listener implements ILinkedListener {
-
- /*
- * @see org.eclipse.jdt.internal.ui.text.link2.LinkedEnvironment.ILinkedListener#left(org.eclipse.jdt.internal.ui.text.link2.LinkedEnvironment, int)
- */
- public void left(LinkedEnvironment environment, int flags) {
- LinkedManager.this.left(environment, flags);
- }
-
- /*
- * @see org.eclipse.jdt.internal.ui.text.link2.LinkedEnvironment.ILinkedListener#suspend(org.eclipse.jdt.internal.ui.text.link2.LinkedEnvironment)
- */
- public void suspend(LinkedEnvironment environment) {
- // not interested
- }
-
- /*
- * @see org.eclipse.jdt.internal.ui.text.link2.LinkedEnvironment.ILinkedListener#resume(org.eclipse.jdt.internal.ui.text.link2.LinkedEnvironment, int)
- */
- public void resume(LinkedEnvironment environment, int flags) {
- // not interested
- }
-
- }
-
- /** Global map from documents to managers. */
- private static Map fManagers= new HashMap();
-
- /**
- * Returns whether there exists a <code>LinkedManager</code> on <code>document</code>.
- *
- * @param document the document of interest
- * @return <code>true</code> if there exists a <code>LinkedManager</code> on <code>document</code>, <code>false</code> otherwise
- */
- public static boolean hasManager(IDocument document) {
- return fManagers.get(document) != null;
- }
-
- /**
- * Returns whether there exists a <code>LinkedManager</code> on any of the <code>documents</code>.
- *
- * @param documents the documents of interest
- * @return <code>true</code> if there exists a <code>LinkedManager</code> on any of the <code>documents</code>, <code>false</code> otherwise
- */
- public static boolean hasManager(IDocument[] documents) {
- for (int i= 0; i < documents.length; i++) {
- if (hasManager(documents[i]))
- return true;
- }
- return false;
- }
-
- /**
- * Returns the manager for the given documents. If <code>force</code> is
- * <code>true</code>, any existing conflicting managers are canceled, otherwise,
- * the method may return <code>null</code> if there are conflicts.
- *
- * @param documents the documents of interest
- * @param force whether to kill any conflicting managers
- * @return a manager able to cover the requested documents, or <code>null</code> if there is a conflict and <code>force</code> was set to <code>false</code>
- */
- public static LinkedManager getLinkedManager(IDocument[] documents, boolean force) {
- if (documents == null || documents.length == 0)
- return null;
-
- Set mgrs= new HashSet();
- LinkedManager mgr= null;
- for (int i= 0; i < documents.length; i++) {
- mgr= (LinkedManager) fManagers.get(documents[i]);
- if (mgr != null)
- mgrs.add(mgr);
- }
- if (mgrs.size() > 1)
- if (force) {
- for (Iterator it= mgrs.iterator(); it.hasNext(); ) {
- LinkedManager m= (LinkedManager) it.next();
- m.closeAllEnvironments();
- }
- } else {
- return null;
- }
-
- if (mgrs.size() == 0)
- mgr= new LinkedManager();
-
- for (int i= 0; i < documents.length; i++)
- fManagers.put(documents[i], mgr);
-
- return mgr;
- }
-
- /**
- * Cancels any linked manager for the specified document.
- *
- * @param document the document whose <code>LinkedManager</code> should be cancelled
- */
- public static void cancelManager(IDocument document) {
- LinkedManager mgr= (LinkedManager) fManagers.get(document);
- if (mgr != null)
- mgr.closeAllEnvironments();
- }
-
- /** The hierarchy of environments managed by this manager. */
- private Stack fEnvironments= new Stack();
- private Listener fListener= new Listener();
-
- /**
- * Notify the manager about a leaving environment.
- *
- * @param environment
- * @param flags
- */
- private void left(LinkedEnvironment environment, int flags) {
- if (!fEnvironments.contains(environment))
- return;
-
- while (!fEnvironments.isEmpty()) {
- LinkedEnvironment env= (LinkedEnvironment) fEnvironments.pop();
- if (env == environment)
- break;
- else
- env.exit(ILinkedListener.NONE);
- }
-
- if (fEnvironments.isEmpty()) {
- removeManager();
- }
- }
-
- private void closeAllEnvironments() {
- while (!fEnvironments.isEmpty()) {
- LinkedEnvironment env= (LinkedEnvironment) fEnvironments.pop();
- env.exit(ILinkedListener.NONE);
- }
-
- removeManager();
- }
-
- private void removeManager() {
- for (Iterator it= fManagers.keySet().iterator(); it.hasNext();) {
- IDocument doc= (IDocument) it.next();
- if (fManagers.get(doc) == this)
- it.remove();
- }
- }
-
- /**
- * Tries to nest the given <code>LinkedEnvironment</code> onto the top of
- * the stack of environments managed by the receiver. If <code>force</code>
- * is <code>true</code>, any environments on the stack that create a conflict
- * are killed.
- *
- * @param environment the environment to nest
- * @param force whether to force the addition of the environment
- * @return <code>true</code> if nesting was successful, <code>false</code> otherwise (only possible if <code>force</code> is <code>false</code>
- */
- public boolean nestEnvironment(LinkedEnvironment environment, boolean force) {
- Assert.isNotNull(environment);
-
- try {
- while (true) {
- if (fEnvironments.isEmpty()) {
- environment.addLinkedListener(fListener);
- fEnvironments.push(environment);
- return true;
- }
-
- LinkedEnvironment top= (LinkedEnvironment) fEnvironments.peek();
- if (environment.canNestInto(top)) {
- environment.addLinkedListener(fListener);
- fEnvironments.push(environment);
- return true;
- } else if (!force) {
- return false;
- } else { // force
- fEnvironments.pop();
- top.exit(ILinkedListener.NONE);
- // continue;
- }
- }
- } finally {
- // if we remove any, make sure the new one got inserted
- Assert.isTrue(fEnvironments.size() > 0);
- }
- }
-
- /**
- * @return
- */
- public LinkedEnvironment getTopEnvironment() {
- if (fEnvironments.isEmpty())
- return null;
- else
- return (LinkedEnvironment) fEnvironments.peek();
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/link/LinkedPosition.java b/org.eclipse.text/src/org/eclipse/jface/text/link/LinkedPosition.java
deleted file mode 100644
index be7f2a4..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/link/LinkedPosition.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.link;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.Position;
-
-/**
- * A <code>Position</code> on a document that knows which document it is
- * registered with and has a sequence number for tab stops.
- *
- * @since 3.0
- */
-public class LinkedPosition extends Position {
-
- /** The document this position belongs to. */
- private IDocument fDocument;
- private int fSequenceNumber;
-
- /**
- * Creates a new instance.
- *
- * @param document the document
- * @param offset the offset of the position
- * @param length the length of the position
- * @param sequence the iteration sequence rank
- */
- public LinkedPosition(IDocument document, int offset, int length, int sequence) {
- super(offset, length);
- Assert.isNotNull(document);
- fDocument= document;
- fSequenceNumber= sequence;
- }
-
- /**
- * Creates a new instance. Equivalent to calling
- * <code>LinkedPosition(document, offset, length, LinkedPositionGroup.NO_STOP)</code>
- *
- * @param document the document
- * @param offset the offset of the position
- * @param length the length of the position
- */
- public LinkedPosition(IDocument document, int offset, int length) {
- this(document, offset, length, LinkedPositionGroup.NO_STOP);
- }
-
- /**
- * @return Returns the document.
- */
- public IDocument getDocument() {
- return fDocument;
- }
-
- /*
- * @see org.eclipse.jface.text.Position#equals(java.lang.Object)
- */
- public boolean equals(Object other) {
- if (other instanceof LinkedPosition) {
- LinkedPosition p= (LinkedPosition) other;
- return p.offset == offset && p.length == length && p.fDocument == fDocument;
- }
- return false;
- }
-
- /**
- * Returns whether this position overlaps with <code>position</code>.
- *
- * @param position the position to check.
- * @return <code>true</code> if this position overlaps with <code>position</code>, <code>false</code> otherwise
- */
- public boolean overlapsWith(LinkedPosition position) {
- return position.getDocument() == fDocument && overlapsWith(position.getOffset(), position.getLength());
- }
-
- /**
- * Returns whether this position includes <code>event</code>.
- *
- * @param event the event to check.
- * @return <code>true</code> if this position includes <code>event</code>, <code>false</code> otherwise
- */
- public boolean includes(DocumentEvent event) {
- return includes(event.getDocument(), event.getOffset(), event.getLength());
- }
-
- /**
- * Returns whether this position includes <code>position</code>.
- *
- * @param position the position to check.
- * @return <code>true</code> if this position includes <code>position</code>, <code>false</code> otherwise
- */
- public boolean includes(LinkedPosition position) {
- return includes(position.getDocument(), position.getOffset(), position.getLength());
- }
-
- /**
- * Overrides {@link Position#includes(int)} so every offset is considered included that lies in
- * between the first and last offset of this position, and offsets that are right at the end
- * of the position.
- *
- * @param pOffset the offset to check
- * @return <code>true</code> if <code>pOffset</code> is in [offset, offset + length]
- */
- public boolean includes(int pOffset) {
- return this.offset <= pOffset && pOffset <= this.offset + this.length;
- }
-
- protected boolean includes(IDocument doc, int off, int len) {
- return doc == fDocument && off >= offset && len + off <= offset + length;
-
- }
-
- /**
- * Returns the content of this position on the referenced document.
- *
- * @return the content of the document at this position
- * @throws BadLocationException if the position is not valid
- */
- public String getContent() throws BadLocationException {
- return fDocument.get(offset, length);
- }
-
- /**
- * Returns the sequence number of this position.
- *
- * @return the sequence number of this position
- */
- public int getSequenceNumber() {
- return fSequenceNumber;
- }
-
- /**
- * Sets the sequence number of this position.
- *
- * @param sequence the new sequence number
- */
- public void setSequenceNumber(int sequence) {
- fSequenceNumber= sequence;
- }
-
- /*
- * @see org.eclipse.jface.text.Position#hashCode()
- */
- public int hashCode() {
- return fDocument.hashCode() | super.hashCode() | fSequenceNumber;
- }
-
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/link/LinkedPositionGroup.java b/org.eclipse.text/src/org/eclipse/jface/text/link/LinkedPositionGroup.java
deleted file mode 100644
index a3db48c..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/link/LinkedPositionGroup.java
+++ /dev/null
@@ -1,511 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.link;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.text.edits.MultiTextEdit;
-import org.eclipse.text.edits.ReplaceEdit;
-import org.eclipse.text.edits.TextEdit;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.Position;
-
-/**
- * A group of positions in multiple documents that are simultaneously modified -
- * if one gets edited, all other positions in a <code>PositionGroup</code>
- * are edited the same way. All linked positions in a group have the same
- * content.
- * <p>
- * Normally, new positions are given a tab stop weight which can be used by
- * clients, e.g. the UI. If no weight is given, a position will not be visited.
- * If no weights are used at all, the first position in a document is taken as
- * the only stop as to comply with the behaviour of the old linked position
- * infrastructure.
- * </p>
- *
- * @since 3.0
- */
-public class LinkedPositionGroup {
-
- /** Sequence constant declaring that a position should not be stopped by. */
- public static final int NO_STOP= -1;
-
- /* members */
-
- /** The linked positions of this group. */
- private final List fPositions= new LinkedList();
- /** Whether we are sealed or not. */
- private boolean fIsSealed= false;
-
- /*
- * iteration variables, set to communicate state between isLegalEvent and
- * handleEvent
- */
- /** The position including the most recent <code>DocumentEvent</code>. */
- private LinkedPosition fLastPosition;
- /** The offset of <code>fLastPosition</code>. */
- private int fLastPositionOffset;
- /**
- * <code>true</code> if there are custom iteration weights. For backward
- * compatibility.
- */
- private boolean fHasCustomIteration= false;
-
- /**
- * Adds a position to this group. If the position overlaps with another in
- * this group, or if the group is already part of an environment, an
- * exception is thrown.
- *
- * @param document the document of the position
- * @param offset the offset of the position
- * @param length the length of the position
- * @throws BadLocationException if the position is invalid or conflicts
- * with other positions in the group
- * @throws IllegalStateException if the group has alreay been added to an
- * environment
- */
- public void createPosition(IDocument document, int offset, int length) throws BadLocationException {
- createPosition(document, offset, length, LinkedPositionGroup.NO_STOP);
- }
-
- /**
- * Adds a position to this group. If the position overlaps with another in
- * this group, or if the group is already part of an environment, an
- * exception is thrown.
- *
- * @param document the document of the position
- * @param offset the offset of the position
- * @param length the length of the position
- * @param sequence the tab stop number of the position
- * @throws BadLocationException if the position is invalid or conflicts
- * with other positions in the group
- * @throws IllegalStateException if the group has alreay been added to an
- * environment
- */
- public void createPosition(IDocument document, int offset, int length, int sequence) throws BadLocationException {
- addPosition(new LinkedPosition(document, offset, length, sequence));
- }
-
- /**
- * Adds a position to this group. If the position overlaps with another in
- * this group, or if the group is already part of an environment, an
- * exception is thrown.
- *
- * @param document the document of the position
- * @param region a region describing the new position (it is not
- * stored, only its values are used)
- * @throws BadLocationException if the position is invalid or conflicts
- * with other positions in the group
- * @throws IllegalStateException if the group has alreay been added to an
- * environment
- */
- public void createPosition(IDocument document, IRegion region) throws BadLocationException {
- createPosition(document, region, LinkedPositionGroup.NO_STOP);
- }
-
- /**
- * Adds a position to this group. If the position overlaps with another in
- * this group, or if the group is already part of an environment, an
- * exception is thrown.
- *
- * @param document the document of the position
- * @param region a region describing the new position (it is not
- * stored, only its values are used)
- * @param sequence the tab stop number of the position
- * @throws BadLocationException if the position is invalid or conflicts
- * with other positions in the group
- * @throws IllegalStateException if the group has alreay been added to an
- * environment
- */
- public void createPosition(IDocument document, IRegion region, int sequence) throws BadLocationException {
- createPosition(document, region.getOffset(), region.getLength(), sequence);
- }
-
-// /**
-// * Adds a position to this group. If the position overlaps with another in
-// * this group, or if the group is already part of an environment, an
-// * exception is thrown.
-// *
-// * @param document the document of the position
-// * @param region a region describing the new position (it is not
-// * stored, only its values are used)
-// * @param proposals the completion proposals to be shown when a position of
-// * this type comes up
-// * @throws BadLocationException if the position is invalid or conflicts
-// * with other positions in the group
-// * @throws IllegalStateException if the group has alreay been added to an
-// * environment
-// */
-// public void createPosition(IDocument document, IRegion region, ICompletionProposal[] proposals) throws BadLocationException {
-// createPosition(document, region, LinkedPositionGroup.NO_STOP, proposals);
-// }
-//
-// /**
-// * Adds a position to this group. If the position overlaps with another in
-// * this group, or if the group is already part of an environment, an
-// * exception is thrown.
-// *
-// * @param document the document of the position
-// * @param offset the offset of the position
-// * @param length the length of the position
-// * @param proposals the completion proposals to be shown when a position of
-// * this type comes up
-// * @param sequence the tab stop number of the position
-// * @throws BadLocationException if the position is invalid or conflicts
-// * with other positions in the group
-// * @throws IllegalStateException if the group has alreay been added to an
-// * environment
-// */
-// public void createPosition(IDocument document, int offset, int length, int sequence, ICompletionProposal[] proposals) throws BadLocationException {
-// addPosition(new ProposalPosition(document, offset, length, sequence, proposals));
-// }
-//
-// /**
-// * Adds a position to this group. If the position overlaps with another in
-// * this group, or if the group is already part of an environment, an
-// * exception is thrown.
-// *
-// * @param document the document of the position
-// * @param offset the offset of the position
-// * @param length the length of the position
-// * @param proposals the completion proposals to be shown when a position of
-// * this type comes up
-// * @throws BadLocationException if the position is invalid or conflicts
-// * with other positions in the group
-// * @throws IllegalStateException if the group has alreay been added to an
-// * environment
-// */
-// public void createPosition(IDocument document, int offset, int length, ICompletionProposal[] proposals) throws BadLocationException {
-// createPosition(document, offset, length, LinkedPositionGroup.NO_STOP, proposals);
-// }
-//
-// /**
-// * Adds a position to this group. If the position overlaps with another in
-// * this group, or if the group is already part of an environment, an
-// * exception is thrown.
-// *
-// * @param document the document of the position
-// * @param region a region describing the new position (it is not
-// * stored, only its values are used)
-// * @param proposals the completion proposals to be shown when a position of
-// * this type comes up
-// * @param sequence the tab stop number of the position
-// * @throws BadLocationException if the position is invalid or conflicts
-// * with other positions in the group
-// * @throws IllegalStateException if the group has alreay been added to an
-// * environment
-// */
-// public void createPosition(IDocument document, IRegion region, int sequence, ICompletionProposal[] proposals) throws BadLocationException {
-// createPosition(document, region.getOffset(), region.getLength(), sequence, proposals);
-// }
-//
-// /**
-// * Adds a position to this group. If the position overlaps with another in
-// * this group, or if the group is already part of an environment, an
-// * exception is thrown.
-// * <p>
-// * This method is not implemented yet and will throw an <code>UnsupportedOperationException</code>.
-// *
-// * @param document the document of the position
-// * @param region a region describing the new position (it is not stored,
-// * only its values are used)
-// * @param sequence the tab stop number of the position
-// * @param processor the content assist processor that will be called to
-// * compute proposals for this position.
-// * @throws BadLocationException if the position is invalid or conflicts
-// * with other positions in the group
-// * @throws IllegalStateException if the group has alreay been added to an
-// * environment
-// */
-// public void createPosition(IDocument document, IRegion region, int sequence, IContentAssistProcessor processor) throws BadLocationException {
-// // TODO implement
-// throw new UnsupportedOperationException();
-// }
-//
- /**
- * Implementation of all the <code>createPosition</code> methods. Enforces
- * constraints and sets the custom iteration flag. If the position is
- * already in this group, nothing happens.
- * <p>
- * Positions added using this method are owned by this group afterwards any may
- * not be updated or modified thereafter.
- * </p>
- *
- * @param position the position to add
- * @throws BadLocationException if the position is invalid or conflicts
- * with other positions in the group
- * @throws IllegalStateException if the group has alreay been added to an
- * environment
- */
- public void addPosition(LinkedPosition position) throws BadLocationException {
- Assert.isNotNull(position);
- // don't add positions after it is installed.
- if (fIsSealed)
- throw new IllegalStateException("cannot add positions after the group is added to an environment"); //$NON-NLS-1$
-
- if (!fPositions.contains(position)) {
- enforceDisjoint(position);
- enforceEqualContent(position);
- fPositions.add(position);
- fHasCustomIteration |= position.getSequenceNumber() != LinkedPositionGroup.NO_STOP;
- } else
- return; // nothing happens
- }
-
- /**
- * Enforces the invariant that all positions must contain the same string.
- *
- * @param position the position to check
- * @throws BadLocationException if the equal content check fails
- */
- private void enforceEqualContent(LinkedPosition position) throws BadLocationException {
- if (fPositions.size() > 0) {
- String groupContent= ((LinkedPosition) fPositions.get(0)).getContent();
- String positionContent= position.getContent();
- if (!groupContent.equals(positionContent))
- throw new BadLocationException();
- }
- }
-
- /**
- * Enforces the invariant that all positions must be disjoint.
- *
- * @param position the position to check
- * @throws BadLocationException if the disjointness check fails
- */
- private void enforceDisjoint(LinkedPosition position) throws BadLocationException {
- for (Iterator it= fPositions.iterator(); it.hasNext(); ) {
- LinkedPosition p= (LinkedPosition) it.next();
- if (p.overlapsWith(position))
- throw new BadLocationException();
- }
- }
-
- /**
- * Enforces the disjointness for another group
- *
- * @param group the group to check
- * @throws BadLocationException if the disjointness check fails
- */
- void enforceDisjoint(LinkedPositionGroup group) throws BadLocationException {
- Assert.isNotNull(group);
- for (Iterator it= group.fPositions.iterator(); it.hasNext(); ) {
- LinkedPosition p= (LinkedPosition) it.next();
- enforceDisjoint(p);
- }
- }
-
- /**
- * Checks whether <code>event</code> fits in any of the positions of this
- * group.
- *
- * @param event the document event to check
- * @return <code>true</code> if <code>event</code> fits in any position
- */
- boolean isLegalEvent(DocumentEvent event) {
- for (Iterator it= fPositions.iterator(); it.hasNext(); ) {
- LinkedPosition pos= (LinkedPosition) it.next();
- if (pos.includes(event)) {
- fLastPosition= pos;
- fLastPositionOffset= pos.getOffset();
- return true;
- }
- }
- fLastPosition= null;
- fLastPositionOffset= -1;
- return false;
- }
-
- /**
- * Creates an edition of a document change that will forward any
- * modification in one position to all linked siblings. The return value is
- * a map from <code>IDocument</code> to <code>TextEdit</code>.
- *
- * @param event the document event to check
- * @return a map of edits, grouped by edited document
- */
- Map handleEvent(DocumentEvent event) {
-
- if (fLastPosition != null) {
-
- Map map= new HashMap();
-
- int relOffset= event.getOffset() - fLastPositionOffset;
- int length= event.getLength();
- String text= event.getText();
-
- for (Iterator it2= fPositions.iterator(); it2.hasNext(); ) {
- LinkedPosition p= (LinkedPosition) it2.next();
- if (p == fLastPosition)
- continue; // don't re-update the origin of the change
-
- List edits= (List) map.get(p.getDocument());
- if (edits == null) {
- edits= new ArrayList();
- map.put(p.getDocument(), edits);
- }
-
- edits.add(new ReplaceEdit(p.getOffset() + relOffset, length, text));
- }
-
- for (Iterator it2= map.keySet().iterator(); it2.hasNext(); ) {
- IDocument d= (IDocument) it2.next();
- TextEdit edit= new MultiTextEdit(0, d.getLength());
- edit.addChildren((TextEdit[]) ((List) map.get(d)).toArray(new TextEdit[0]));
- map.put(d, edit);
- }
-
- return map;
-
- }
-
- return null;
- }
-
- /**
- * Sets the environment of this group. Once an environment has been set, no
- * more positions can be added and the environment cannot be changed.
- *
- * @param environment the environment
- */
- void seal() {
- Assert.isTrue(!fIsSealed);
- fIsSealed= true;
-
- if (fHasCustomIteration == false && fPositions.size() > 0) {
- ((LinkedPosition) fPositions.get(0)).setSequenceNumber(0);
- }
- }
-
- IDocument[] getDocuments() {
- IDocument[] docs= new IDocument[fPositions.size()];
- int i= 0;
- for (Iterator it= fPositions.iterator(); it.hasNext(); i++) {
- LinkedPosition pos= (LinkedPosition) it.next();
- docs[i]= pos.getDocument();
- }
- return docs;
- }
-
- void register(LinkedEnvironment environment) throws BadLocationException {
- for (Iterator it= fPositions.iterator(); it.hasNext(); ) {
- LinkedPosition pos= (LinkedPosition) it.next();
- environment.register(pos);
- }
- }
-
- /**
- * Returns the position in this group that encompasses all positions in
- * <code>group</code>.
- *
- * @param group the group to be adopted
- * @return a position in the receiver that contains all positions in <code>group</code>,
- * or <code>null</code> if none can be found
- * @throws BadLocationException if more than one position are affected by
- * <code>group</code>
- */
- LinkedPosition adopt(LinkedPositionGroup group) throws BadLocationException {
- LinkedPosition found= null;
- for (Iterator it= group.fPositions.iterator(); it.hasNext(); ) {
- LinkedPosition pos= (LinkedPosition) it.next();
- LinkedPosition localFound= null;
- for (Iterator it2= fPositions.iterator(); it2.hasNext(); ) {
- LinkedPosition myPos= (LinkedPosition) it2.next();
- if (myPos.includes(pos)) {
- if (found == null)
- found= myPos;
- else if (found != myPos)
- throw new BadLocationException();
- if (localFound == null)
- localFound= myPos;
- }
- }
-
- if (localFound != found)
- throw new BadLocationException();
- }
- return found;
- }
-
- /**
- * Finds the closest position to <code>toFind</code>.
- */
- LinkedPosition getPosition(LinkedPosition toFind) {
- for (Iterator it= fPositions.iterator(); it.hasNext(); ) {
- LinkedPosition p= (LinkedPosition) it.next();
- if (p.includes(toFind))
- return p;
- }
- return null;
- }
-
- /**
- * Returns <code>true</code> if <code>offset</code> is contained in any
- * position in this group.
- *
- * @param offset the offset to check
- * @return <code>true</code> if offset is contained by this group
- */
- boolean contains(int offset) {
- for (Iterator it= fPositions.iterator(); it.hasNext(); ) {
- LinkedPosition pos= (LinkedPosition) it.next();
- if (pos.includes(offset)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Returns whether this group contains any positions.
- *
- * @return <code>true</code> if this group is empty, <code>false</code> if it is not
- */
- public boolean isEmtpy() {
- return fPositions.size() == 0;
- }
-
- /**
- * Returns the positions contained in the receiver as an array. The
- * positions are the actual positions and must not be modified; the array
- * is a copy of internal structures.
- *
- * @return the positions of this group in no particular order
- */
- public LinkedPosition[] getPositions() {
- return (LinkedPosition[]) fPositions.toArray(new LinkedPosition[0]);
- }
-
- /**
- * Returns <code>true</code> if the receiver contains <code>position</code>.
- *
- * @param position the position to check
- * @return <code>true</code> if the receiver contains <code>position</code>
- */
- boolean contains(Position position) {
- for (Iterator it= fPositions.iterator(); it.hasNext(); ) {
- LinkedPosition p= (LinkedPosition) it.next();
- if (position.equals(p))
- return true;
- }
- return false;
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/link/package.html b/org.eclipse.text/src/org/eclipse/jface/text/link/package.html
deleted file mode 100644
index aeab0f0..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/link/package.html
+++ /dev/null
@@ -1,74 +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">
- <meta content="Mozilla/4.75 [en] (Windows NT 5.0; U) [Netscape]"
- name="GENERATOR">
- <title>Linked Position Infrastructure</title>
-</head>
-<body>
-Application programming interfaces for interaction
-with the Eclipse Java User Interface text support.
-<h2>Linked Position Infrastructure</h2>
-<h3>package <span style="font-family: monospace;">org.eclipse.jface.text.link
-</span><span style="font-family: monospace;"></span></h3>
-<h3><code></code></h3>
-The Linked Position Infrastructure lets one set up a mode in an editor
-in which regions in a document (or several documents) are <em>linked</em>,
-i.e. editions
-of one linked position will be reflected in the others.
-<h4>Classes</h4>
-<ul>
- <li><code>LinkedPositionGroup</code>: a set of linked positions. Add
-positions to a group using the <code>addPosition</code> and <code>createPosition</code>
-methods, which
-also allow to specify an iteration order. See <span
- style="font-family: monospace;">ProposalPosition</span><code><span
- style="font-family: helvetica,arial,sans-serif;"> </span></code><span
- style="font-family: helvetica,arial,sans-serif;">for a position type
-that lets one attach </span><span style="font-family: monospace;">ICompletionProposals</span><span
- style="font-family: monospace;"></span><span
- style="font-family: helvetica,arial,sans-serif;"> </span><span
- style="font-family: helvetica,arial,sans-serif;">to</span>
-be shown when the position is hit.</li>
- <li><code>LinkedEnvironment</code>: umbrellas several <code>PositionGroup</code>s,
-e.g. in a template that has several groups of linked positions. Handles
-the forwarding of updates received via an IDocumentListener. Add <code>PositionGroup</code>s
-to
-an environment using the <code>addGroup</code> method. Existence of a <span
- style="font-family: monospace;">LinkedEnvironment </span>can be
-tested by one of the static methods.<br>
- </li>
- <li><code>LinkedUIControl</code>: The UI for linked mode (for one
-environment, to be precise). Monitors key etc. activity, monitors exit
-conditions, creates a painter etc. <br>
-Properties:
- <ul>
- <li><b>cycling mode</b> (whether to jump to the first position
-after the last): either of <code>CYCLE_ALWAYS</code>, <code>CYCLE_NEVER</code>
-and <code>CYCLE_WHEN_NO_PARENT</code> (default).</li>
- <li><b>exit position</b>: where to jump upon leaving the linked
-mode (e.g. using Enter, or Tab from the last position when not
-cycling). Set <code>isTabStop</code> to <code>true</code> if tabbing
-should stop over when cycling.</li>
- <li><span style="font-weight: bold;">position listener</span>:
-you can register a position listener which will get notified whenever
-the focus position changes. An example is <span
- style="font-family: monospace;">org.eclipse.ui.texteditor.link.EditorHistoryUpdater</span>
-which will store the edit location in the editor navigation history.<br>
- </li>
- </ul>
- </li>
-.
-</ul>
-<h4>Example</h4>
-<pre> IDocument doc1, doc2;<br> ITextViewer viewer1, viewer2;<br> <br> /* create groups - this step is independent of the linked mode */<br> PositionGroup group1= new PositionGroup();<br> group1.addPosition(doc1, 3,4);<br> group1.addPosition(doc1, 7,8);<br> <br> PositionGroup group2= newPositionGroup();<br> group2.addPosition(doc1, 15, 25);<br> group2.addPosition(doc2, 0, 10);<br> <br> /* set up linked mode */<br> LinkedEnvironment env= new LinkedEnvironment();<br> env.addGroup(group1);<br> env.addGroup(group2);<br> env.forceInstall();<br> <br> /* create UI */<br> LinkedUIControl ui= new LinkedUIControl(env, new ITextViewer[] { viewer1, viewer2 });<br> ui.enter();<br></pre>
-<h4>Todo</h4>
-<ul>
- <li>handle lazy computation of per-group proposals using a <code>IContentAssistProcessor</code>
-(see PositionGroup, ProposalPosition) .</li>
-</ul>
-</body>
-</html>
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/templates/ContextType.java b/org.eclipse.text/src/org/eclipse/jface/text/templates/ContextType.java
deleted file mode 100644
index ecca59e..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/templates/ContextType.java
+++ /dev/null
@@ -1,281 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.templates;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.text.edits.MalformedTreeException;
-import org.eclipse.text.edits.MultiTextEdit;
-import org.eclipse.text.edits.RangeMarker;
-import org.eclipse.text.edits.ReplaceEdit;
-import org.eclipse.text.edits.TextEdit;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-
-
-/**
- * A context type defines a context within which templates are resolved. It
- * stores a number of <code>TemplateVariableResolver</code>s. A
- * <code>TemplateBuffer</code> can be resolved in a
- * <code>TemplateContext</code> using the
- * {@link #resolve(TemplateBuffer, TemplateContext)} method.
- *
- * @since 3.0
- */
-public class ContextType {
-
- /** Name of the context type. */
- private /* final */ String fId= null;
-
- /** Variable resolvers used by this content type. */
- private final Map fResolvers= new HashMap();
-
- /** The name of the context type. */
- private String fName= null;
-
- /**
- * Creates a context type with an identifier. The identifier must be unique, a qualified name is suggested. The id is also used as name.
- *
- * @param id the unique identifier of the context type
- */
- public ContextType(String id) {
- this(id, id);
- }
-
- /**
- * Creates a context type with an identifier. The identifier must be unique, a qualified name is suggested.
- *
- * @param id the unique identifier of the context type
- * @param name the name of the context type
- */
- public ContextType(String id, String name) {
- Assert.isNotNull(id);
- Assert.isNotNull(name);
- fId= id;
- fName= name;
- }
-
- /**
- * Creates a context type with a <code>null</code> identifier.
- * <p>
- * This is a framework-only constructor that exists only so that context
- * types can be contributed via an extension point and that should not be
- * called in client code except for subclass constructors; use
- * {@link #ContextType(String)} instead.
- * </p>
- */
- public ContextType() {
- }
-
- /**
- * Sets the id of this context.
- * <p>
- * This is a framework-only method that exists solely so that context types
- * can be contributed via an extension point and that should not be called in
- * client code; use {@link #ContextType(String)} instead.
- * </p>
- *
- * @param id
- * @throws RuntimeException an unspecified exception if the id has already been set on this context type
- */
- public void setId(String id) throws RuntimeException {
- Assert.isNotNull(id);
- Assert.isTrue(fId == null); // may only be called once when the context is instantiated
- fId= id;
- }
-
- /**
- * Returns the name of the context type.
- *
- * @return the name of the receiver
- */
- public String getId() {
- return fId;
- }
-
- /**
- * Adds a variable resolver to the context type. If there already is a resolver
- * for the same type, the previous one gets replaced by <code>resolver</code>.
- *
- * @param resolver the resolver to be added under its name
- */
- public void addResolver(TemplateVariableResolver resolver) {
- fResolvers.put(resolver.getType(), resolver);
- }
-
- /**
- * Removes a template variable from the context type.
- *
- * @param resolver the varibable to be removed
- */
- public void removeResolver(TemplateVariableResolver resolver) {
- fResolvers.remove(resolver.getType());
- }
-
- /**
- * Removes all template variables from the context type.
- */
- public void removeAllResolvers() {
- fResolvers.clear();
- }
-
- /**
- * Returns an iterator for the variables known to the context type.
- *
- * @return an iterator over the variables in this context type
- */
- public Iterator resolvers() {
- return Collections.unmodifiableMap(fResolvers).values().iterator();
- }
-
- /**
- * Returns the resolver for the given type.
- *
- * @param type the type for which a resolver is needed
- * @return a resolver for the given type, or <code>null</code> if none is registered
- */
- protected TemplateVariableResolver getResolver(String type) {
- return (TemplateVariableResolver) fResolvers.get(type);
- }
-
- /**
- * Validates a pattern and returnes <code>null</code> if the validation was
- * a success or an error message if not.
- *
- * XXX subject to change - will throw an exception
- *
- * @param pattern the template pattern to validate
- * @return the translated pattern if successful, or an error message if not TODO what do we return there? throw an exception
- */
- public String validate(String pattern) {
- TemplateTranslator translator= new TemplateTranslator();
- TemplateBuffer buffer= translator.translate(pattern);
- if (buffer != null) {
- return validateVariables(buffer.getVariables());
- }
- return translator.getErrorMessage();
- }
-
- protected String validateVariables(TemplateVariable[] variables) {
- return null;
- }
-
- /**
- * Resolves the variables in <code>buffer</code> withing <code>context</code>
- * and edits the template buffer to reflect the resolved variables.
- *
- * @param buffer the template buffer
- * @param context the template context
- * @throws MalformedTreeException if the positions in the buffer overlap
- * @throws BadLocationException if the buffer cannot be successfully modified
- */
- public void resolve(TemplateBuffer buffer, TemplateContext context) throws MalformedTreeException, BadLocationException {
- TemplateVariable[] variables= buffer.getVariables();
-
- List positions= variablesToPositions(variables);
- List edits= new ArrayList(5);
-
- // iterate over all variables and try to resolve them
- for (int i= 0; i != variables.length; i++) {
- TemplateVariable variable= variables[i];
-
- if (variable.isUnambiguous())
- continue;
-
- // remember old values
- int[] oldOffsets= variable.getOffsets();
- int oldLength= variable.getLength();
- String oldValue= variable.getDefaultValue();
-
- String type= variable.getType();
- TemplateVariableResolver resolver= (TemplateVariableResolver) fResolvers.get(type);
- if (resolver == null)
- resolver= new TemplateVariableResolver(type, ""); //$NON-NLS-1$
- resolver.resolve(variable, context);
-
- String value= variable.getDefaultValue();
-
- if (!oldValue.equals(value))
- // update buffer to reflect new value
- for (int k= 0; k != oldOffsets.length; k++)
- edits.add(new ReplaceEdit(oldOffsets[k], oldLength, value));
-
- }
-
- IDocument document= new Document(buffer.getString());
- MultiTextEdit edit= new MultiTextEdit(0, document.getLength());
- edit.addChildren((TextEdit[]) positions.toArray(new TextEdit[positions.size()]));
- edit.addChildren((TextEdit[]) edits.toArray(new TextEdit[edits.size()]));
- edit.apply(document, TextEdit.UPDATE_REGIONS);
-
- positionsToVariables(positions, variables);
-
- buffer.setContent(document.get(), variables);
- }
-
- private static List variablesToPositions(TemplateVariable[] variables) {
- List positions= new ArrayList(5);
- for (int i= 0; i != variables.length; i++) {
- int[] offsets= variables[i].getOffsets();
- for (int j= 0; j != offsets.length; j++)
- positions.add(new RangeMarker(offsets[j], 0));
- }
-
- return positions;
- }
-
- private static void positionsToVariables(List positions, TemplateVariable[] variables) {
- Iterator iterator= positions.iterator();
-
- for (int i= 0; i != variables.length; i++) {
- TemplateVariable variable= variables[i];
-
- int[] offsets= new int[variable.getOffsets().length];
- for (int j= 0; j != offsets.length; j++)
- offsets[j]= ((TextEdit) iterator.next()).getOffset();
-
- variable.setOffsets(offsets);
- }
- }
-
- /**
- * Returns the name of the context type.
- *
- * @return the name of the context type
- */
- public String getName() {
- return fName;
- }
-
- /**
- * Sets the name of the context type.
- *
- * <p>
- * This is a framework-only method that exists solely so that context types
- * can be contributed via an extension point and that should not be called in
- * client code; use {@link #ContextType(String, String)} instead.
- * </p>
-
- * @param name the name of the context type
- */
- public void setName(String name) {
- Assert.isTrue(fName == null); // only initialized by extension code
- fName= name;
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/templates/DocumentTemplateContext.java b/org.eclipse.text/src/org/eclipse/jface/text/templates/DocumentTemplateContext.java
deleted file mode 100644
index b921d50..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/templates/DocumentTemplateContext.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.templates;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-
-/**
- * A typical text based document template context.
- *
- * @since 3.0
- */
-public class DocumentTemplateContext extends TemplateContext {
-
- /** The text of the document. */
- private final IDocument fDocument;
- /** The completion offset. */
- private int fCompletionOffset;
- /** The completion length. */
- private int fCompletionLength;
-
- /**
- * Creates a document template context.
- *
- * @param type the context type
- * @param document the document this context applies to
- * @param completionOffset the completion offset (for usage in content
- * assist)
- * @param completionLength the completion length
- */
- public DocumentTemplateContext(ContextType type, IDocument document, int completionOffset, int completionLength) {
- super(type);
-
- Assert.isNotNull(document);
- Assert.isTrue(completionOffset >= 0 && completionOffset <= document.getLength());
- Assert.isTrue(completionLength >= 0);
-
- fDocument= document;
- fCompletionOffset= completionOffset;
- fCompletionLength= completionLength;
- }
-
- /**
- * Returns the document.
- *
- * @return the document
- */
- public IDocument getDocument() {
- return fDocument;
- }
-
- /**
- * Returns the completion offset within the string of the context.
- *
- * @return the completion offset within the string of the context
- */
- public int getCompletionOffset() {
- return fCompletionOffset;
- }
-
- /**
- * Sets the completion offset.
- *
- * @param newOffset the new completion offset
- */
- protected void setCompletionOffset(int newOffset) {
- fCompletionOffset= newOffset;
- }
-
- /**
- * Returns the completion length within the string of the context.
- *
- * @return the completion length within the string of the context
- */
- public int getCompletionLength() {
- return fCompletionLength;
- }
-
- /**
- * Sets the completion length.
- *
- * @param newLength the new completion length
- */
- protected void setCompletionLength(int newLength) {
- fCompletionLength= newLength;
- }
-
- /**
- * Returns the keyword which triggered template insertion.
- *
- * @return the keyword which triggered template insertion
- */
- public String getKey() {
- int offset= getStart();
- int length= getEnd() - offset;
- try {
- return fDocument.get(offset, length);
- } catch (BadLocationException e) {
- return ""; //$NON-NLS-1$
- }
- }
-
- /**
- * Returns the beginning offset of the keyword.
- *
- * @return the beginning offset of the keyword
- */
- public int getStart() {
- return fCompletionOffset;
- }
-
- /**
- * Returns the end offset of the keyword.
- *
- * @return the end offset of the keyword
- */
- public int getEnd() {
- return fCompletionOffset + fCompletionLength;
- }
-
- /*
- * @see org.eclipse.jface.text.templates.TemplateContext#canEvaluate(org.eclipse.jface.text.templates.Template)
- */
- public boolean canEvaluate(Template template) {
- return true;
- }
-
- /*
- * @see org.eclipse.jface.text.templates.TemplateContext#evaluate(org.eclipse.jface.text.templates.Template)
- */
- public TemplateBuffer evaluate(Template template) throws BadLocationException {
- if (!canEvaluate(template))
- return null;
-
- TemplateTranslator translator= new TemplateTranslator();
- TemplateBuffer buffer= translator.translate(template);
-
- if (buffer == null)
- return buffer;
-
- getContextType().resolve(buffer, this);
-
- return buffer;
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/templates/GlobalVariables.java b/org.eclipse.text/src/org/eclipse/jface/text/templates/GlobalVariables.java
deleted file mode 100644
index 50b32bc..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/templates/GlobalVariables.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Sebastian Davids: sdavids@gmx.de - see bug 25376
- *******************************************************************************/
-package org.eclipse.jface.text.templates;
-
-import java.text.DateFormat;
-import java.util.Calendar;
-
-
-/**
- * Global variables which are available in any context.
- *
- * @since 3.0
- */
-public class GlobalVariables {
-
- /** The type of the selection variables. */
- public static final String SELECTION= "selection"; //$NON-NLS-1$
-
- /**
- * The cursor variable determines the cursor placement after template edition.
- */
- public static class Cursor extends SimpleVariableResolver {
-
- /** Name of the cursor variable, value= {@value} */
- public static final String NAME= "cursor"; //$NON-NLS-1$
-
- /**
- * Creates a new cursor variable
- */
- public Cursor() {
- super(NAME, TemplateMessages.getString("GlobalVariables.variable.description.cursor")); //$NON-NLS-1$
- setEvaluationString(""); //$NON-NLS-1$
- }
- }
-
- /**
- * The word selection variable determines templates that work on a full
- * lines selection.
- */
- public static class WordSelection extends SimpleVariableResolver {
-
- /** Name of the word selection variable, value= {@value} */
- public static final String NAME= "word_selection"; //$NON-NLS-1$
-
- /**
- * Creates a new word selection variable
- */
- public WordSelection() {
- super(NAME, TemplateMessages.getString("GlobalVariables.variable.description.selectedWord")); //$NON-NLS-1$
- }
- protected String resolve(TemplateContext context) {
- String selection= context.getVariable(SELECTION); //$NON-NLS-1$
- if (selection == null)
- return ""; //$NON-NLS-1$
- else
- return selection;
- }
- }
-
- /**
- * The line selection variable determines templates that work on selected
- * lines.
- */
- public static class LineSelection extends SimpleVariableResolver {
-
- /** Name of the line selection variable, value= {@value} */
- public static final String NAME= "line_selection"; //$NON-NLS-1$
-
- /**
- * Creates a new line selection variable
- */
- public LineSelection() {
- super(NAME, TemplateMessages.getString("GlobalVariables.variable.description.selectedLines")); //$NON-NLS-1$
- }
- protected String resolve(TemplateContext context) {
- String selection= context.getVariable(SELECTION); //$NON-NLS-1$
- if (selection == null)
- return ""; //$NON-NLS-1$
- else
- return selection;
- }
- }
-
- /**
- * The dollar variable inserts an escaped dollar symbol.
- */
- public static class Dollar extends SimpleVariableResolver {
- /**
- * Creates a new dollar variable
- */
- public Dollar() {
- super("dollar", TemplateMessages.getString("GlobalVariables.variable.description.dollar")); //$NON-NLS-1$ //$NON-NLS-2$
- setEvaluationString("$"); //$NON-NLS-1$
- }
- }
-
- /**
- * The date variable evaluates to the current date.
- */
- public static class Date extends SimpleVariableResolver {
- /**
- * Creates a new date variable
- */
- public Date() {
- super("date", TemplateMessages.getString("GlobalVariables.variable.description.date")); //$NON-NLS-1$ //$NON-NLS-2$
- }
- protected String resolve(TemplateContext context) {
- return DateFormat.getDateInstance().format(new java.util.Date());
- }
- }
-
- /**
- * The year variable evaluates to the current year.
- */
- public static class Year extends SimpleVariableResolver {
- /**
- * Creates a new year variable
- */
- public Year() {
- super("year", TemplateMessages.getString("GlobalVariables.variable.description.year")); //$NON-NLS-1$ //$NON-NLS-2$
- }
- protected String resolve(TemplateContext context) {
- return Integer.toString(Calendar.getInstance().get(Calendar.YEAR));
- }
- }
-
- /**
- * The time variable evaluates to the current time.
- */
- public static class Time extends SimpleVariableResolver {
- /**
- * Creates a new time variable
- */
- public Time() {
- super("time", TemplateMessages.getString("GlobalVariables.variable.description.time")); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * {@inheritDoc}
- */
- protected String resolve(TemplateContext context) {
- return DateFormat.getTimeInstance().format(new java.util.Date());
- }
- }
-
- /**
- * The user variable evaluates to the current user.
- */
- public static class User extends SimpleVariableResolver {
- /**
- * Creates a new user name variable
- */
- public User() {
- super("user", TemplateMessages.getString("GlobalVariables.variable.description.user")); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * {@inheritDoc}
- */
- protected String resolve(TemplateContext context) {
- return System.getProperty("user.name"); //$NON-NLS-1$
- }
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/templates/SimpleVariableResolver.java b/org.eclipse.text/src/org/eclipse/jface/text/templates/SimpleVariableResolver.java
deleted file mode 100644
index 2611316..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/templates/SimpleVariableResolver.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.templates;
-
-
-/**
- * A simple template variable, which always evaluates to a defined string.
- *
- * @since 3.0
- */
-public class SimpleVariableResolver extends TemplateVariableResolver {
-
- /** The string to which this variable evaluates. */
- private String fEvaluationString;
-
- /*
- * @see TemplateVariableResolver#TemplateVariableResolver(String, String)
- */
- protected SimpleVariableResolver(String type, String description) {
- super(type, description);
- }
-
- /**
- * Sets the string to which this variable evaluates.
- *
- * @param evaluationString the evaluation string, may be <code>null</code>.
- */
- public final void setEvaluationString(String evaluationString) {
- fEvaluationString= evaluationString;
- }
-
- /*
- * @see TemplateVariableResolver#evaluate(TemplateContext)
- */
- protected String resolve(TemplateContext context) {
- return fEvaluationString;
- }
-
-
- /**
- * Returns always <code>true</code>, since simple variables are normally
- * unambiguous.
- *
- * @param context {@inheritDoc}
- */
- protected boolean isUnambiguous(TemplateContext context) {
- return true;
- }
-
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/templates/Template.java b/org.eclipse.text/src/org/eclipse/jface/text/templates/Template.java
deleted file mode 100644
index eba82d7..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/templates/Template.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.templates;
-
-import org.eclipse.jface.text.Assert;
-
-/**
- * A template consisting of a name and a pattern.
- *
- * @since 3.0
- */
-public class Template {
-
- /** The name of this template */
- private String fName;
- /** A description of this template */
- private String fDescription;
- /** The name of the context type of this template */
- private String fContextTypeId;
- /** The template pattern. */
- private String fPattern;
-
- /**
- * Creates an empty template.
- */
- public Template() {
- this("", "", "", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- /**
- * Creates a copy of a template.
- *
- * @param template the template to copy
- */
- public Template(Template template) {
- this(template.getName(), template.getDescription(), template.getContextTypeId(), template.getPattern());
- }
-
- /**
- * Creates a template.
- *
- * @param name the name of the template
- * @param description the description of the template
- * @param contextTypeId the id of the context type in which the template can be applied
- * @param pattern the template pattern
- */
- public Template(String name, String description, String contextTypeId, String pattern) {
- setDescription(description);
- setName(name);
- setContextTypeId(contextTypeId);
- setPattern(pattern);
- }
-
- /*
- * @see Object#hashCode()
- */
- public int hashCode() {
- return fName.hashCode() ^ fPattern.hashCode() ^ fContextTypeId.hashCode();
- }
-
- /**
- * Sets the description of the template.
- *
- * @param description the new description
- */
- public void setDescription(String description) {
- Assert.isNotNull(description);
- fDescription= description;
- }
-
- /**
- * Returns the description of the template.
- *
- * @return the description of the template
- */
- public String getDescription() {
- return fDescription;
- }
-
- /**
- * Sets the name of the context type in which the template can be applied.
- *
- * @param contextTypeId the new context type name
- */
- public void setContextTypeId(String contextTypeId) {
- Assert.isNotNull(contextTypeId);
- fContextTypeId= contextTypeId;
- }
-
- /**
- * Returns the id of the context type in which the template can be applied.
- *
- * @return the id of the context type in which the template can be applied
- */
- public String getContextTypeId() {
- return fContextTypeId;
- }
-
- /**
- * Sets the name of the template.
- *
- * @param name the name of the template
- */
- public void setName(String name) {
- fName= name;
- }
-
- /**
- * Returns the name of the template.
- *
- * @return the name of the template
- */
- public String getName() {
- return fName;
- }
-
- /**
- * Sets the pattern of the template.
- *
- * @param pattern the new pattern of the template
- */
- public void setPattern(String pattern) {
- fPattern= pattern;
- }
-
- /**
- * Returns the template pattern.
- *
- * @return the template pattern
- */
- public String getPattern() {
- return fPattern;
- }
-
- /**
- * Returns <code>true</code> if template is enabled and matches the context,
- * <code>false</code> otherwise.
- *
- * @param prefix the prefix (e.g. inside a document) to match
- * @param contextTypeName the context type name to match
- * @return <code>true</code> if template is enabled and matches the context,
- * <code>false</code> otherwise
- */
- public boolean matches(String prefix, String contextTypeName) {
- return fContextTypeId.equals(contextTypeName);
- }
-
- /*
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object o) {
- if (!(o instanceof Template))
- return false;
-
- Template t= (Template) o;
- if (t == this)
- return true;
-
- return t.fName.equals(fName)
- && t.fPattern.equals(fPattern)
- && t.fContextTypeId.equals(fContextTypeId)
- && t.fDescription.equals(fDescription);
- }
-
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateBuffer.java b/org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateBuffer.java
deleted file mode 100644
index ddff685..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateBuffer.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.templates;
-
-import org.eclipse.jface.text.Assert;
-
-/**
- * A template buffer is a container for a string and variables.
- *
- * @since 3.0
- */
-public final class TemplateBuffer {
-
- /** The string of the template buffer */
- private String fString;
- /** The variable positions of the template buffer */
- private TemplateVariable[] fVariables;
-
- /**
- * Creates a template buffer.
- *
- * @param string the string
- * @param variables the variable positions
- */
- public TemplateBuffer(String string, TemplateVariable[] variables) {
- setContent(string, variables);
- }
-
- /**
- * Sets the content of the template buffer.
- *
- * @param string the string
- * @param variables the variable positions
- */
- public final void setContent(String string, TemplateVariable[] variables) {
- Assert.isNotNull(string);
- Assert.isNotNull(variables);
-
- // XXX assert non-overlapping variable properties
-
- fString= string;
- fVariables= variables;
- }
-
- /**
- * Returns the string of the template buffer.
- *
- * @return the string representation of the template buffer
- */
- public final String getString() {
- return fString;
- }
-
- /**
- * Returns the variable positions of the template buffer.
- *
- * @return the variable positions of the template buffer
- */
- public final TemplateVariable[] getVariables() {
- return fVariables;
- }
-
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateContext.java b/org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateContext.java
deleted file mode 100644
index 0b67ea9..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateContext.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.templates;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.jface.text.BadLocationException;
-
-/**
- * Provides the context for a <code>Template</code> being resolved. Keeps track
- * of resolved variables.
- *
- * @since 3.0
- */
-public abstract class TemplateContext {
-
- /** The context type of this context */
- private final ContextType fContextType;
- /** Additional variables. */
- private final Map fVariables= new HashMap();
- /** A flag to indicate that the context should not be modified. */
- private boolean fReadOnly;
-
- /**
- * Creates a template context of a particular context type.
- *
- * @param contextType the context type of this context
- */
- protected TemplateContext(ContextType contextType) {
- fContextType= contextType;
- fReadOnly= true;
- }
-
- /**
- * Returns the context type of this context.
- *
- * @return the context type of this context
- */
- public ContextType getContextType() {
- return fContextType;
- }
-
- /**
- * Sets or clears the read-only flag.
- *
- * @param readOnly the new read-only state
- */
- public void setReadOnly(boolean readOnly) {
- fReadOnly= readOnly;
- }
-
- /**
- * Returns <code>true</code> if the receiver is read-only, <code>false</code> otherwise.
- *
- * @return <code>true</code> if the receiver is read-only, <code>false</code> otherwise
- */
- public boolean isReadOnly() {
- return fReadOnly;
- }
-
- /**
- * Defines the value of a variable.
- *
- * @param name the name of the variable
- * @param value the value of the variable, <code>null</code> to undefine a variable
- */
- public void setVariable(String name, String value) {
- fVariables.put(name, value);
- }
-
- /**
- * Returns the value of a defined variable.
- *
- * @param name the name of the variable
- * @return returns the value of the variable, <code>null</code> if the variable was not defined
- */
- public String getVariable(String name) {
- return (String) fVariables.get(name);
- }
-
- /**
- * Evaluates the template in this context and returns a template buffer.
- * <p>
- * Evaluation means translating the template into a <code>TemplateBuffer</code>,
- * resolving the defined variables in this context and possibly formatting
- * the resolved buffer.</p>
- *
- * @param template the template to evaluate
- * @return returns the buffer with the evaluated template or <code>null</code> if the buffer could not be created
- * @throws BadLocationException if evaluation fails
- */
- public abstract TemplateBuffer evaluate(Template template) throws BadLocationException;
-
- /**
- * Tests if the specified template can be evaluated in this context.
- * <p>Examples are templates defined for a different context (e.g. a javadoc
- * template cannot be evaluated in Java context).</p>
- *
- * @param template the <code>Template</code> to check
- * @return <code>true</code> if <code>template</code> can be evaluated
- * in this context, <code>false</code> otherwise
- */
- public abstract boolean canEvaluate(Template template);
-
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateMessages.java b/org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateMessages.java
deleted file mode 100644
index 954fa91..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateMessages.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.templates;
-
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-/**
- * @since 3.0
- */
-public class TemplateMessages {
-
- private static final String RESOURCE_BUNDLE= TemplateMessages.class.getName();
- private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
-
- private TemplateMessages() {
- }
-
- /**
- * @param key
- * @return
- */
- public static String getString(String key) {
- try {
- return fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return '!' + key + '!';
- }
- }
-
- /**
- * Gets a string from the resource bundle and formats it with the argument
- *
- * @param key the string used to get the bundle value, must not be null
- * @param arg
- * @return
- */
- public static String getFormattedString(String key, Object arg) {
- return MessageFormat.format(getString(key), new Object[] { arg });
- }
-
-
- /**
- * Gets a string from the resource bundle and formats it with arguments
- * @param key
- * @param args
- * @return
- */
- public static String getFormattedString(String key, Object[] args) {
- return MessageFormat.format(getString(key), args);
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateMessages.properties b/org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateMessages.properties
deleted file mode 100644
index db21beb..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateMessages.properties
+++ /dev/null
@@ -1,158 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2003 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-# preference page
-TemplatePreferencePage.error.import=Failed to import templates.
-TemplatePreferencePage.error.export=Failed to export templates.
-TemplatePreferencePage.error.read.title=Reading Templates
-TemplatePreferencePage.error.write.title=Reading Templates
-TemplatePreferencePage.message=&Create, edit or remove templates:
-TemplatePreferencePage.title=Templates
-
-TemplatePreferencePage.new=&New...
-TemplatePreferencePage.edit=&Edit...
-TemplatePreferencePage.import=&Import...
-TemplatePreferencePage.export=E&xport...
-TemplatePreferencePage.export.all=Ex&port All...
-TemplatePreferencePage.remove=&Remove
-TemplatePreferencePage.enable.all=Ena&ble All
-TemplatePreferencePage.disable.all=Di&sable All
-TemplatePreferencePage.editor=Template
-
-TemplatePreferencePage.column.name=Name
-TemplatePreferencePage.column.context=Context
-TemplatePreferencePage.column.description=Description
-
-TemplatePreferencePage.use.code.formatter=Use code &formatter
-
-TemplatePreferencePage.import.title=Importing Templates
-TemplatePreferencePage.import.extension=*.xml
-
-TemplatePreferencePage.export.title=Exporting {0} Templates
-TemplatePreferencePage.export.filename=templates.xml
-TemplatePreferencePage.export.extension=*.xml
-
-TemplatePreferencePage.export.exists.title= Exporting Templates
-TemplatePreferencePage.export.exists.message= {0} already exists.\nDo you want to replace it?
-
-TemplatePreferencePage.export.error.title= Exporting Templates
-TemplatePreferencePage.export.error.hidden= Export failed.\n{0} is a hidden file.
-TemplatePreferencePage.export.error.canNotWrite= Export failed.\n{0} can not be modified.
-TemplatePreferencePage.export.error.fileNotFound= Export failed:\n{0}
-
-TemplatePreferencePage.error.parse.message= Failed to parse templates:\n{0}
-TemplatePreferencePage.error.read.message= Failed to read templates.
-
-TemplatePreferencePage.question.create.new.title= Edit Template
-TemplatePreferencePage.question.create.new.message= The name of the template has been changed. Click 'Yes' to create an additional template with the new name or 'No' to rename the existing one.
-
-TemplatePreferencePage.preview=Preview:
-
-# code template preference page
-CodeTemplatePreferencePage.error.import=Failed to import templates.
-CodeTemplatePreferencePage.error.export=Failed to export templates.
-CodeTemplatePreferencePage.error.read.title=Reading Templates
-CodeTemplatePreferencePage.error.write.title=Reading Templates
-CodeTemplatePreferencePage.message=&Templates used for code generation:
-CodeTemplatePreferencePage.title=Code Templates
-
-CodeTemplatePreferencePage.edit=&Edit...
-CodeTemplatePreferencePage.import=&Import...
-CodeTemplatePreferencePage.export=E&xport...
-CodeTemplatePreferencePage.export.all=Ex&port All...
-CodeTemplatePreferencePage.enable.all=Ena&ble All
-CodeTemplatePreferencePage.disable.all=Di&sable All
-CodeTemplatePreferencePage.editor=Template
-
-CodeTemplatePreferencePage.column.name=Name
-CodeTemplatePreferencePage.column.description=Description
-
-CodeTemplatePreferencePage.use.code.formatter=Use Code &Formatter
-
-CodeTemplatePreferencePage.import.title=Importing Templates
-CodeTemplatePreferencePage.import.extension=*.xml
-
-CodeTemplatePreferencePage.export.title=Exporting {0} Templates
-CodeTemplatePreferencePage.export.filename=codetemplates.xml
-CodeTemplatePreferencePage.export.extension=*.xml
-
-CodeTemplatePreferencePage.export.exists.title=Exporting Templates
-CodeTemplatePreferencePage.export.exists.message={0} already exists.\nDo you want to replace it?
-
-CodeTemplatePreferencePage.preview=Preview:
-
-
-# edit template dialog
-EditTemplateDialog.error.noname=Template name cannot be empty.
-EditTemplateDialog.error.adjacent.variables=Template pattern has adjacent variables.
-EditTemplateDialog.title.new=New Template
-EditTemplateDialog.title.edit=Edit Template
-
-EditTemplateDialog.name=&Name:
-EditTemplateDialog.description=&Description:
-EditTemplateDialog.context=&Context:
-EditTemplateDialog.pattern=&Pattern:
-EditTemplateDialog.insert.variable=Insert &Variable...
-
-EditTemplateDialog.undo=&Undo
-EditTemplateDialog.cut=Cu&t
-EditTemplateDialog.copy=&Copy
-EditTemplateDialog.paste=&Paste
-EditTemplateDialog.select.all=Select &All
-EditTemplateDialog.content.assist=Insert &Variable...
-
-# template variable dialog
-TemplateVariableDialog.title=Select a template variable.
-TemplateVariableDialog.column.name=Name
-TemplateVariableDialog.column.description=Description
-TemplateVariableDialog.insert=&Insert
-
-TemplateVariableProposal.error.title=Error applying template variable proposal
-TemplateVariableProcessor.error.title=Error creating template variable proposals
-
-# template set
-TemplateSet.error.read=Error occurred while reading templates.
-TemplateSet.error.write=Error occurred while writing templates.
-
-# templates
-Templates.error.title=Error accessing templates.
-Templates.error.read=Error occurred while reading templates.
-Templates.error.write=Error occurred while writing templates.
-
-# template engine
-TemplateEngine.error.title=Could not create template proposals.
-
-# template proposal
-TemplateProposal.delimiter=\ -
-
-# template evaluator
-TemplateEvaluator.error.title=Template Evaluation Error
-
-# template translator
-TemplateTranslator.error.incomplete.variable=Template has incomplete variables. Use '$' to escape.
-TemplateTranslator.error.invalid.identifier=Template has invalid variable identifiers.
-
-ContextType.error.multiple.cursor.variables=Template has multiple cursor variables.
-
-TemplateSet.error.missing.attribute=Missing required attribute
-
-
-GlobalVariables.variable.description.cursor=The cursor position after editing template variables
-GlobalVariables.variable.description.dollar=The dollar symbol
-GlobalVariables.variable.description.date=Current date
-GlobalVariables.variable.description.year=Current year
-GlobalVariables.variable.description.time=Current time
-GlobalVariables.variable.description.user=User name
-GlobalVariables.variable.description.selectedWord= The selected word
-GlobalVariables.variable.description.selectedLines= The selected lines
-
-# GlobalVariables.variable.description.line=Current line number
-
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateTranslator.java b/org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateTranslator.java
deleted file mode 100644
index 6ae821f..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateTranslator.java
+++ /dev/null
@@ -1,251 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.templates;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.Vector;
-
-/**
- * The template translator translates a string into a template buffer. Regions
- * marked as variables are translated into <code>TemplateVariable</code>s.
- * <p>
- * The EBNF grammer of a valid string is as follows:</p>
- * <p>
- * template := (text | escape)*. <br />
- * text := character - dollar. <br />
- * escape := dollar ('{' identifier '}' | dollar). <br />
- * dollar := '$'. <br />
- * </p>
- *
- * @since 3.0
- */
-public class TemplateTranslator {
-
- // states
- private static final int TEXT= 0;
- private static final int ESCAPE= 1;
- private static final int IDENTIFIER= 2;
-
- // tokens
- private static final char ESCAPE_CHARACTER= '$';
- private static final char IDENTIFIER_BEGIN= '{';
- private static final char IDENTIFIER_END= '}';
-
- /** a buffer for the translation result string */
- private final StringBuffer fBuffer= new StringBuffer();
- /** position offsets of variables */
- private final Vector fOffsets= new Vector();
- /** position lengths of variables */
- private final Vector fLengths= new Vector();
-
- /** the current parsing state */
- private int fState;
- /** the last translation error */
- private String fErrorMessage;
-
- /**
- * Returns an error message if an error occured for the last translation,
- * <code>null</code> otherwise.
- *
- * @return the error message if an error occurred during the most recent
- * translation, <code>null</code> otherwise
- */
- public String getErrorMessage() {
- return fErrorMessage;
- }
-
- /**
- * Translates a template to a <code>TemplateBuffer</code>. <code>null</code>
- * is returned if there was an error. <code>getErrorMessage()</code> retrieves the
- * associated error message.
- *
- * @param template the template to translate.
- * @return returns the template buffer corresponding to the string, <code>null</code>
- * if there was an error.
- * @see #getErrorMessage()
- */
- public TemplateBuffer translate(Template template) {
- return translate(template.getPattern());
- }
-
- /**
- * Translates a template string to <code>TemplateBuffer</code>. <code>null</code>
- * is returned if there was an error. <code>getErrorMessage()</code> retrieves the
- * associated error message.
- *
- * @param string the string to translate.
- * @return returns the template buffer corresponding to the string, <code>null</code>
- * if there was an error.
- * @see #getErrorMessage()
- */
- public TemplateBuffer translate(String string) {
-
- fBuffer.setLength(0);
- fOffsets.clear();
- fLengths.clear();
- fState= TEXT;
- fErrorMessage= null;
-
- if (!parse(string))
- return null;
-
- switch (fState) {
- case TEXT:
- break;
-
- // illegal
- case ESCAPE:
- fErrorMessage= TemplateMessages.getString("TemplateTranslator.error.incomplete.variable"); //$NON-NLS-1$
- fBuffer.append(ESCAPE_CHARACTER);
- return null;
-
- // illegal
- case IDENTIFIER:
- fErrorMessage= TemplateMessages.getString("TemplateTranslator.error.incomplete.variable"); //$NON-NLS-1$
- fBuffer.append(ESCAPE_CHARACTER);
- return null;
- }
-
- int[] offsets= new int[fOffsets.size()];
- int[] lengths= new int[fLengths.size()];
-
- for (int i= 0; i < fOffsets.size(); i++) {
- offsets[i]= ((Integer) fOffsets.get(i)).intValue();
- lengths[i]= ((Integer) fLengths.get(i)).intValue();
- }
-
- String translatedString= fBuffer.toString();
- TemplateVariable[] variables= findVariables(translatedString, offsets, lengths);
-
- return new TemplateBuffer(translatedString, variables);
- }
-
- private TemplateVariable[] findVariables(String string, int[] offsets, int[] lengths) {
-
- Map map= new HashMap();
-
- for (int i= 0; i != offsets.length; i++) {
- int offset= offsets[i];
- int length= lengths[i];
-
- String content= string.substring(offset, offset + length);
- Vector vector= (Vector) map.get(content);
- if (vector == null) {
- vector= new Vector();
- map.put(content, vector);
- }
- vector.add(new Integer(offset));
- }
-
- TemplateVariable[] variables= new TemplateVariable[map.size()];
- int k= 0;
-
- Set keys= map.keySet();
- for (Iterator i= keys.iterator(); i.hasNext(); ) {
- String name= (String) i.next();
- Vector vector= (Vector) map.get(name);
-
- int[] offsets_= new int[vector.size()];
- for (int j= 0; j != offsets_.length; j++)
- offsets_[j]= ((Integer) vector.get(j)).intValue();
-
- variables[k]= createVariable(name, name, offsets_);
- k++;
- }
-
- return variables;
- }
-
- /**
- * Hook method to create new variables. Subclasses may override to supply their
- * custom variable type.
- *
- * @param type the type of the new variable.
- * @param name the name of the new variable.
- * @param offsets the offsets where the variable occurs in the template
- * @return a new instance of <code>TemplateVariable</code>
- */
- protected TemplateVariable createVariable(String type, String name, int[] offsets) {
- return new TemplateVariable(type, name, offsets);
- }
-
- /** internal parser */
- private boolean parse(String string) {
-
- for (int i= 0; i != string.length(); i++) {
- char ch= string.charAt(i);
-
- switch (fState) {
- case TEXT:
- switch (ch) {
- case ESCAPE_CHARACTER:
- fState= ESCAPE;
- break;
-
- default:
- fBuffer.append(ch);
- break;
- }
- break;
-
- case ESCAPE:
- switch (ch) {
- case ESCAPE_CHARACTER:
- fBuffer.append(ch);
- fState= TEXT;
- break;
-
- case IDENTIFIER_BEGIN:
- fOffsets.add(new Integer(fBuffer.length()));
- fState= IDENTIFIER;
- break;
-
- default:
- // illegal single escape character, but be tolerant
- fErrorMessage= TemplateMessages.getString("TemplateTranslator.error.incomplete.variable"); //$NON-NLS-1$
- fBuffer.append(ESCAPE_CHARACTER);
- fBuffer.append(ch);
- fState= TEXT;
- return false;
- }
- break;
-
- case IDENTIFIER:
- switch (ch) {
- case IDENTIFIER_END:
- int offset = ((Integer) fOffsets.get(fOffsets.size() - 1)).intValue();
- fLengths.add(new Integer(fBuffer.length() - offset));
- fState= TEXT;
- break;
-
- default:
- if (!Character.isUnicodeIdentifierStart(ch) &&
- !Character.isUnicodeIdentifierPart(ch))
- {
- // illegal identifier character
- fErrorMessage= TemplateMessages.getString("TemplateTranslator.error.invalid.identifier"); //$NON-NLS-1$
- return false;
- }
-
- fBuffer.append(ch);
- break;
- }
- break;
- }
- }
-
- return true;
- }
-
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateVariable.java b/org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateVariable.java
deleted file mode 100644
index c9bf75e..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateVariable.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.templates;
-
-import org.eclipse.jface.text.Assert;
-
-/**
- * A <code>TemplateVariable</code> represents a set of positions into a
- * <code>TemplateBuffer</code> with identical content each. <code>TemplateVariableResolver</code>s
- * can be used to resolve a template variable to a symbol available from the
- * <code>TemplateContext</code>.
- *
- * @see TemplateVariableResolver
- * @see TemplateBuffer
- * @since 3.0
- */
-public class TemplateVariable {
-
- /** The type name of the variable */
- private final String fType;
- /** The name of the variable. */
- private final String fName;
- /** The offsets of the variable. */
- private int[] fOffsets;
- /** Flag indicating if the variable has been resolved umambiguously. */
- private boolean fIsUnambiguous;
- /**
- * The proposal strings available for this variable. The first string is
- * the default value.
- */
- private String[] fValues;
-
- /**
- * Creates a template variable. The type is used as the name of the
- * variable.
- *
- * @param type the type of the variable
- * @param defaultValue the default value of the variable
- * @param offsets the array of offsets of the variable
- */
- public TemplateVariable(String type, String defaultValue, int[] offsets) {
- this(type, new String[] { defaultValue }, offsets);
- }
-
- /**
- * Creates a template variable.
- *
- * @param type the type of the variable
- * @param name the name of the variable
- * @param defaultValue the default value of the variable
- * @param offsets the array of offsets of the variable
- */
- public TemplateVariable(String type, String name, String defaultValue, int[] offsets) {
- this(type, name, new String[] { defaultValue }, offsets);
- }
-
- /**
- * Creates a template variable with multiple possible values. The type is
- * used as the name of the template.
- *
- * @param type the type of the template variable
- * @param values the values available at this variable, non-empty
- * @param offsets the array of offsets of the variable
- */
- public TemplateVariable(String type, String[] values, int[] offsets) {
- this(type, type, values, offsets);
- }
-
- /**
- * Creates a template variable with multiple possible values.
- *
- * @param type the type of the variable
- * @param name the name of the variable
- * @param values the values available at this variable, non-empty
- * @param offsets the array of offsets of the variable
- */
- public TemplateVariable(String type, String name, String[] values, int[] offsets) {
- Assert.isNotNull(type);
- Assert.isNotNull(name);
- fType= type;
- fName= name;
- setValues(values);
- setOffsets(offsets);
- setUnambiguous(false);
- }
-
- /**
- * Returns the type of the variable.
- *
- * @return the type of the variable
- */
- public String getType() {
- return fType;
- }
-
- /**
- * Returns the name of the variable.
- *
- * @return the name of the variable
- */
- public String getName() {
- return fName;
- }
-
- /**
- * Returns the default value of the variable.
- *
- * @return the default value of the variable
- */
- public String getDefaultValue() {
- return getValues()[0];
- }
-
- /**
- * Returns the possible values for this variable. The returned array is
- * owned by this variable and must not be modified.
- *
- * @return the possible values for this variable
- */
- public String[] getValues() {
- return fValues;
- }
-
- /**
- * Returns the length of the variable.
- *
- * @return the length of the variable
- */
- public int getLength() {
- return getDefaultValue().length();
- }
-
- /**
- * Sets the offsets of the variable.
- *
- * @param offsets the new offsets of the variable
- */
- public void setOffsets(int[] offsets) {
- fOffsets= offsets;
- }
-
- /**
- * Returns the offsets of the variable.
- *
- * @return the length of the variable
- */
- public int[] getOffsets() {
- return fOffsets;
- }
-
- /**
- * Sets the default value for this variable. This is a shortcut for
- * <code>setValues(new String[] { value })</code>.
- *
- * @param value the new default value
- */
- public final void setValue(String value) {
- setValues(new String[] { value });
- }
-
- /**
- * Sets the possible values for this variable, with the first being the
- * default value.
- *
- * @param values a non-empty array of values
- */
- public void setValues(String[] values) {
- Assert.isTrue(values.length > 0);
- fValues= values;
- }
-
- /**
- * Sets the isUnambiguous flag of the variable.
- *
- * @param unambiguous the new umambiguous state of the variable
- */
- public void setUnambiguous(boolean unambiguous) {
- fIsUnambiguous= unambiguous;
- }
-
- /**
- * Returns <code>true</code> if the variable is unambiguously resolved, <code>false</code> otherwise.
- *
- * @return <code>true</code> if the variable is unambiguously resolved, <code>false</code> otherwise
- */
- public boolean isUnambiguous() {
- return fIsUnambiguous;
- }
-
-}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateVariableResolver.java b/org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateVariableResolver.java
deleted file mode 100644
index 8cc210f..0000000
--- a/org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateVariableResolver.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.templates;
-
-import org.eclipse.jface.text.Assert;
-
-/**
- * A <code>TemplateVariableResolver</code> resolves <code>TemplateVariables</code>
- * of a certain type inside a <code>TemplateContext</code>.
- *
- * @see TemplateVariable
- * @since 3.0
- */
-public class TemplateVariableResolver {
-
- /** Type of this resolver. */
- private String fType= null;
-
- /** Description of the type resolved by this resolver. */
- private String fDescription= null;
-
- /**
- * Creates an instance of <code>TemplateVariableResolver</code>.
- *
- * @param type the name of the type
- * @param description the description for the type
- */
- protected TemplateVariableResolver(String type, String description) {
- setType(type);
- setDescription(description);
- }
-
- /**
- * Creates an empty instance.
- * <p>
- * This is a framework-only constructor that exists only so that resolvers
- * can be contributed via an extension point and that should not be called
- * in client code except for subclass constructors; use
- * {@link #TemplateVariableResolver(String, String)} instead.
- * </p>
- */
- public TemplateVariableResolver() {
- }
-
- /**
- * Returns the type of this resolver.
- *
- * @return the type
- */
- public String getType() {
- return fType;
- }
-
- /**
- * Returns the description for the resolver.
- *
- * @return the description for the resolver
- */
- public String getDescription() {
- return fDescription;
- }
-
- /**
- * Returns an instance of the type resolved by the receiver available in <code>context</code>.
- * To resolve means to provide a binding to a concrete text object (a
- * <code>String</code>) in the given context.
- * <p>
- * The default implementation looks up the type in the context.</p>
- *
- * @param context the context in which to resolve the type
- * @return the name of the text object of this type, or <code>null</code> if not evaluatable
- */
- protected String resolve(TemplateContext context) {
- return context.getVariable(getType());
- }
-
- /**
- * Returns all possible bindings available in <code>context</code>. The default
- * implementation simply returns an array which contains the result of
- * {@link #resolve(TemplateContext)}, or an empty array if that call returns
- * <code>null</code>.
- *
- * @param context the context in which to resolve the type
- * @return an array of possible bindings of this type in <code>context</code>
- */
- protected String[] resolveAll(TemplateContext context) {
- String binding= resolve(context);
- if (binding == null)
- return new String[0];
- else
- return new String[] { binding };
- }
-
- /**
- * Resolves <code>variable</code> in <code>context</code>. To resolve
- * means to find a valid binding of the receiver's type in the given <code>TemplateContext</code>.
- * If the variable can be successfully resolved, its value is set using
- * {@link TemplateVariable#setValues(String[])}.
- *
- * @param context the context in which variable is resolved
- * @param variable the variable to resolve
- */
- public void resolve(TemplateVariable variable, TemplateContext context) {
- String[] bindings= resolveAll(context);
- if (bindings.length != 0)
- variable.setValues(bindings);
- if (bindings.length > 1)
- variable.setUnambiguous(false);
- else
- variable.setUnambiguous(isUnambiguous(context));
- }
-
- /**
- * Returns whether this resolver is able to resolve unambiguously. When
- * resolving a <code>TemplateVariable</code>, its <code>isUmambiguous</code>
- * state is set to the one of this resolver. By default, this method
- * returns <code>false</code>. Clients can overwrite this method to give
- * a hint about whether there should be e.g. prompting for input values for
- * ambiguous variables.
- *
- * @param context the context in which the resolved check should be
- * evaluated
- * @return <code>true</code> if the receiver is unambiguously resolveable
- * in <code>context</code>, <code>false</code> otherwise
- */
- protected boolean isUnambiguous(TemplateContext context) {
- return false;
- }
-
- /**
- * Sets the description.
- * <p>
- * This is a framework-only method that exists only so that resolvers
- * can be contributed via an extension point and that should not be called
- * in client code; use {@link #TemplateVariableResolver(String, String)} instead.
- * </p>
- *
- * @param description the description of this resolver
- */
- public final void setDescription(String description) {
- Assert.isNotNull(description);
- Assert.isTrue(fDescription == null); // may only be called once when initialized
- fDescription= description;
- }
-
- /**
- * Sets the type.
- * <p>
- * This is a framework-only method that exists only so that resolvers
- * can be contributed via an extension point and that should not be called
- * in client code; use {@link #TemplateVariableResolver(String, String)} instead.
- * </p>
- *
- * @param type the type of this resolver
- */
- public final void setType(String type) {
- Assert.isNotNull(type);
- Assert.isTrue(fType == null); // may only be called once when initialized
- fType= type;
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/text/edits/CopySourceEdit.java b/org.eclipse.text/src/org/eclipse/text/edits/CopySourceEdit.java
deleted file mode 100644
index d66c640..0000000
--- a/org.eclipse.text/src/org/eclipse/text/edits/CopySourceEdit.java
+++ /dev/null
@@ -1,309 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.text.edits;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-
-/**
- * A copy source edit denotes the source of a copy operation. Copy
- * source edits are only valid inside an edit tree if they have a
- * corresponding traget edit. Furthermore the corresponding
- * target edit can't be a direct or indirect child of the source
- * edit. Violating one of two requirements will result in a <code>
- * MalformedTreeException</code> when executing the edit tree.
- * <p>
- * A copy source edit can manange an optional source modifier. A
- * source modifier can provide a set of replace edits which will
- * to applied to the source before it gets inserted at the target
- * position.
- *
- * @see org.eclipse.text.edits.CopyTargetEdit
- *
- * @since 3.0
- */
-public final class CopySourceEdit extends TextEdit {
-
- private CopyTargetEdit fTarget;
- private ISourceModifier fModifier;
-
- private String fSourceContent;
- private TextEdit fSourceRoot;
-
- private static class PartialCopier extends TextEditVisitor {
- TextEdit fResult;
- List fParents= new ArrayList();
- TextEdit fCurrentParent;
-
- public static TextEdit perform(TextEdit source) {
- PartialCopier copier= new PartialCopier();
- source.accept(copier);
- return copier.fResult;
- }
- private void manageCopy(TextEdit copy) {
- if (fResult == null)
- fResult= copy;
- if (fCurrentParent != null) {
- fCurrentParent.addChild(copy);
- }
- fParents.add(fCurrentParent);
- fCurrentParent= copy;
- }
- public void postVisit(TextEdit edit) {
- fCurrentParent= (TextEdit)fParents.remove(fParents.size() - 1);
- }
- public boolean visitNode(TextEdit edit) {
- manageCopy(edit.doCopy());
- return true;
- }
- public boolean visit(CopySourceEdit edit) {
- manageCopy(new RangeMarker(edit.getOffset(), edit.getLength()));
- return true;
- }
- public boolean visit(CopyTargetEdit edit) {
- manageCopy(new InsertEdit(edit.getOffset(), edit.getSourceEdit().getContent()));
- return true;
- }
- public boolean visit(MoveSourceEdit edit) {
- manageCopy(new DeleteEdit(edit.getOffset(), edit.getLength()));
- return true;
- }
- public boolean visit(MoveTargetEdit edit) {
- manageCopy(new InsertEdit(edit.getOffset(), edit.getSourceEdit().getContent()));
- return true;
- }
- }
-
- /**
- * Constructs a new copy source edit.
- *
- * @param offset the edit's offset
- * @param length the edit's length
- */
- public CopySourceEdit(int offset, int length) {
- super(offset, length);
- }
-
- /**
- * Constructs a new copy source edit.
- *
- * @param offset the edit's offset
- * @param length the edit's length
- * @param target the edit's target
- */
- public CopySourceEdit(int offset, int length, CopyTargetEdit target) {
- this(offset, length);
- setTargetEdit(target);
- }
-
- /*
- * Copy Constructor
- */
- private CopySourceEdit(CopySourceEdit other) {
- super(other);
- if (other.fModifier != null)
- fModifier= other.fModifier.copy();
- }
-
- /**
- * Returns the associated traget edit or <code>null</code>
- * if no target edit is associated yet.
- *
- * @return the target edit or <code>null</code>
- */
- public CopyTargetEdit getTargetEdit() {
- return fTarget;
- }
-
- /**
- * Sets the target edit.
- *
- * @param edit the new target edit.
- *
- * @exception MalformedTreeException is thrown if the target edit
- * is a direct or indirect child of the source edit
- */
- public void setTargetEdit(CopyTargetEdit edit) throws MalformedTreeException {
- Assert.isNotNull(edit);
- if (fTarget != edit) {
- fTarget= edit;
- fTarget.setSourceEdit(this);
- }
- }
-
- /**
- * Returns the current source modifier or <code>null</code>
- * if no source modifier is set.
- *
- * @return the source modifier
- */
- public ISourceModifier getSourceModifier() {
- return fModifier;
- }
-
- /**
- * Sets the optional source modifier.
- *
- * @param modifier the source modifier or <code>null</code>
- * if no source modification is need.
- */
- public void setSourceModifier(ISourceModifier modifier) {
- fModifier= modifier;
- }
-
- /* non Java-doc
- * @see TextEdit#doCopy
- */
- protected TextEdit doCopy() {
- return new CopySourceEdit(this);
- }
-
- /* (non-Javadoc)
- * @see TextEdit#accept0
- */
- protected void accept0(TextEditVisitor visitor) {
- boolean visitChildren = visitor.visit(this);
- if (visitChildren) {
- acceptChildren(visitor);
- }
- }
-
- //---- API for CopyTargetEdit ------------------------------------------------
-
- /* package */ String getContent() {
- // The source content can be null if the edit wasn't executed
- // due to an exclusion list of the text edit processor. Return
- // the empty string which can be moved without any harm.
- if (fSourceContent == null)
- return ""; //$NON-NLS-1$
- return fSourceContent;
- }
-
- /* package */ void clearContent() {
- fSourceContent= null;
- }
-
- /* non Java-doc
- * @see TextEdit#postProcessCopy
- */
- protected void postProcessCopy(TextEditCopier copier) {
- if (fTarget != null) {
- CopySourceEdit source= (CopySourceEdit)copier.getCopy(this);
- CopyTargetEdit target= (CopyTargetEdit)copier.getCopy(fTarget);
- if (source != null && target != null)
- source.setTargetEdit(target);
- }
- }
-
- //---- consistency check ----------------------------------------------------
-
- /* package */ int traverseConsistencyCheck(TextEditProcessor processor, IDocument document, List sourceEdits) {
- int result= super.traverseConsistencyCheck(processor, document, sourceEdits);
- // Since source computation takes place in a recursive fashion (see
- // performSourceComputation) we only do something if we don't have a
- // computated source already.
- if (fSourceContent == null) {
- if (sourceEdits.size() <= result) {
- List list= new ArrayList();
- list.add(this);
- for (int i= sourceEdits.size(); i < result; i++)
- sourceEdits.add(null);
- sourceEdits.add(list);
- } else {
- List list= (List)sourceEdits.get(result);
- if (list == null) {
- list= new ArrayList();
- sourceEdits.add(result, list);
- }
- list.add(this);
- }
- }
- return result;
- }
-
- /* package */ void performConsistencyCheck(TextEditProcessor processor, IDocument document) throws MalformedTreeException {
- if (fTarget == null)
- throw new MalformedTreeException(getParent(), this, TextEditMessages.getString("CopySourceEdit.no_target")); //$NON-NLS-1$
- if (fTarget.getSourceEdit() != this)
- throw new MalformedTreeException(getParent(), this, TextEditMessages.getString("CopySourceEdit.different_source")); //$NON-NLS-1$
- }
-
- //---- source computation -------------------------------------------------------
-
- /* package */ void traverseSourceComputation(TextEditProcessor processor, IDocument document) {
- if (processor.considerEdit(this)) {
- performSourceComputation(processor, document);
- }
- }
-
- /* package */ void performSourceComputation(TextEditProcessor processor, IDocument document) {
- try {
- MultiTextEdit root= new MultiTextEdit(getOffset(), getLength());
- root.internalSetChildren(internalGetChildren());
- fSourceContent= document.get(getOffset(), getLength());
- fSourceRoot= PartialCopier.perform(root);
- fSourceRoot.moveTree(-getOffset());
- if (fSourceRoot.hasChildren()) {
- EditDocument subDocument= new EditDocument(fSourceContent);
- fSourceRoot.apply(subDocument, TextEdit.NONE);
- if (needsTransformation())
- applyTransformation(subDocument);
- fSourceContent= subDocument.get();
- fSourceRoot= null;
- } else {
- if (needsTransformation()) {
- EditDocument subDocument= new EditDocument(fSourceContent);
- applyTransformation(subDocument);
- fSourceContent= subDocument.get();
- }
- }
- } catch (BadLocationException cannotHappen) {
- Assert.isTrue(false);
- }
- }
-
- private boolean needsTransformation() {
- return fModifier != null;
- }
-
- private void applyTransformation(IDocument document) throws MalformedTreeException {
- TextEdit newEdit= new MultiTextEdit(0, document.getLength());
- ReplaceEdit[] replaces= fModifier.getModifications(document.get());
- for (int i= 0; i < replaces.length; i++) {
- newEdit.addChild(replaces[i]);
- }
- try {
- newEdit.apply(document, TextEdit.NONE);
- } catch (BadLocationException cannotHappen) {
- Assert.isTrue(false);
- }
- }
-
- //---- document updating ----------------------------------------------------------------
-
- /* package */ int performDocumentUpdating(IDocument document) throws BadLocationException {
- fDelta= 0;
- return fDelta;
- }
-
- //---- region updating ----------------------------------------------------------------
-
- /* non Java-doc
- * @see TextEdit#deleteChildren
- */
- /* package */ boolean deleteChildren() {
- return false;
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/text/edits/CopyTargetEdit.java b/org.eclipse.text/src/org/eclipse/text/edits/CopyTargetEdit.java
deleted file mode 100644
index ca12247..0000000
--- a/org.eclipse.text/src/org/eclipse/text/edits/CopyTargetEdit.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.text.edits;
-
-import java.util.List;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-
-/**
- * A copy target edit denotes the target of a copy operation. Copy
- * target edits are only valid inside an edit tree if they have a
- * corresponding source edit. Furthermore a target edit can't
- * can't be a direct or indirect child of the associated source edit.
- * Violating one of two requirements will result in a <code>
- * MalformedTreeException</code> when executing the edit tree.
- * <p>
- * Copy target edits can't be used as a parent for other edits.
- * Trying to add an edit to a copy target edit results in a <code>
- * MalformedTreeException</code> as well.
- *
- * @see org.eclipse.text.edits.CopySourceEdit
- *
- * @since 3.0
- */
-public final class CopyTargetEdit extends TextEdit {
-
- private CopySourceEdit fSource;
-
- /**
- * Constructs a new copy target edit
- *
- * @param offset the edit's offset
- */
- public CopyTargetEdit(int offset) {
- super(offset, 0);
- }
-
- /**
- * Constructs an new copy target edit
- *
- * @param offset the edit's offset
- * @param source the corresponding source edit
- */
- public CopyTargetEdit(int offset, CopySourceEdit source) {
- this(offset);
- setSourceEdit(source);
- }
-
- /*
- * Copy constructor
- */
- private CopyTargetEdit(CopyTargetEdit other) {
- super(other);
- }
-
- /**
- * Returns the associated source edit or <code>null</code>
- * if no source edit is associated yet.
- *
- * @return the source edit or <code>null</code>
- */
- public CopySourceEdit getSourceEdit() {
- return fSource;
- }
-
- /**
- * Sets the source edit.
- *
- * @param edit the source edit
- *
- * @exception MalformedTreeException is thrown if the target edit
- * is a direct or indirect child of the source edit
- */
- public void setSourceEdit(CopySourceEdit edit) throws MalformedTreeException {
- Assert.isNotNull(edit);
- if (fSource != edit) {
- fSource= edit;
- fSource.setTargetEdit(this);
- TextEdit parent= getParent();
- while (parent != null) {
- if (parent == fSource)
- throw new MalformedTreeException(parent, this, TextEditMessages.getString("CopyTargetEdit.wrong_parent")); //$NON-NLS-1$
- parent= parent.getParent();
- }
- }
- }
-
- /* non Java-doc
- * @see TextEdit#doCopy
- */
- protected TextEdit doCopy() {
- return new CopyTargetEdit(this);
- }
-
- /* non Java-doc
- * @see TextEdit#postProcessCopy
- */
- protected void postProcessCopy(TextEditCopier copier) {
- if (fSource != null) {
- CopyTargetEdit target= (CopyTargetEdit)copier.getCopy(this);
- CopySourceEdit source= (CopySourceEdit)copier.getCopy(fSource);
- if (target != null && source != null)
- target.setSourceEdit(source);
- }
- }
-
- /* (non-Javadoc)
- * @see TextEdit#accept0
- */
- protected void accept0(TextEditVisitor visitor) {
- boolean visitChildren = visitor.visit(this);
- if (visitChildren) {
- acceptChildren(visitor);
- }
- }
-
- /* non Java-doc
- * @see TextEdit#traverseConsistencyCheck
- */
- /* package */ int traverseConsistencyCheck(TextEditProcessor processor, IDocument document, List sourceEdits) {
- return super.traverseConsistencyCheck(processor, document, sourceEdits) + 1;
- }
-
- /* non Java-doc
- * @see TextEdit#performConsistencyCheck
- */
- /* package */ void performConsistencyCheck(TextEditProcessor processor, IDocument document) throws MalformedTreeException {
- if (fSource == null)
- throw new MalformedTreeException(getParent(), this, TextEditMessages.getString("CopyTargetEdit.no_source")); //$NON-NLS-1$
- if (fSource.getTargetEdit() != this)
- throw new MalformedTreeException(getParent(), this, TextEditMessages.getString("CopyTargetEdit.different_target")); //$NON-NLS-1$
- }
-
- /* non Java-doc
- * @see TextEdit#performDocumentUpdating
- */
- /* package */ int performDocumentUpdating(IDocument document) throws BadLocationException {
- String source= fSource.getContent();
- document.replace(getOffset(), getLength(), source);
- fDelta= source.length() - getLength();
- fSource.clearContent();
- return fDelta;
- }
-
- /* non Java-doc
- * @see TextEdit#deleteChildren
- */
- /* package */ boolean deleteChildren() {
- return false;
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/text/edits/CopyingRangeMarker.java b/org.eclipse.text/src/org/eclipse/text/edits/CopyingRangeMarker.java
deleted file mode 100644
index ccf99f6..0000000
--- a/org.eclipse.text/src/org/eclipse/text/edits/CopyingRangeMarker.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.text.edits;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-
-/**
- * A <code>CopyingRangeMarker</code> can be used to track positions when executing
- * text edits. Additionally a copying range marker stores a local copy of the
- * text it captures when it gets executed.
- *
- * @since 3.0
- */
-public final class CopyingRangeMarker extends TextEdit {
-
- private String fText;
-
- /**
- * Creates a new <tt>CopyRangeMarker</tt> for the given
- * offset and length.
- *
- * @param offset the marker's offset
- * @param length the marker's length
- */
- public CopyingRangeMarker(int offset, int length) {
- super(offset, length);
- }
-
- /*
- * Copy constructor
- */
- private CopyingRangeMarker(CopyingRangeMarker other) {
- super(other);
- fText= other.fText;
- }
-
- /* non Java-doc
- * @see TextEdit#doCopy
- */
- protected TextEdit doCopy() {
- return new CopyingRangeMarker(this);
- }
-
- /*
- * @see TextEdit#accept0
- */
- protected void accept0(TextEditVisitor visitor) {
- boolean visitChildren = visitor.visit(this);
- if (visitChildren) {
- acceptChildren(visitor);
- }
- }
-
- /* non Java-doc
- * @see TextEdit#performDocumentUpdating
- */
- /* package */ int performDocumentUpdating(IDocument document) throws BadLocationException {
- fText= document.get(getOffset(), getLength());
- fDelta= 0;
- return fDelta;
- }
-
- /* non Java-doc
- * @see TextEdit#deleteChildren
- */
- /* package */ boolean deleteChildren() {
- return false;
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/text/edits/DeleteEdit.java b/org.eclipse.text/src/org/eclipse/text/edits/DeleteEdit.java
deleted file mode 100644
index cb0f8ed..0000000
--- a/org.eclipse.text/src/org/eclipse/text/edits/DeleteEdit.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.text.edits;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-
-/**
- * Text edit to delete a range in a document.
- * <p>
- * A delete edit is equivalent to <code>ReplaceEdit(
- * offset, length, "")</code>.
- *
- * @since 3.0
- */
-public final class DeleteEdit extends TextEdit {
-
- /**
- * Constructs a new delete edit.
- *
- * @param offset the offset of the range to replace
- * @param length the length of the range to replace
- */
- public DeleteEdit(int offset, int length) {
- super(offset, length);
- }
-
- /*
- * Copy constructor
- */
- private DeleteEdit(DeleteEdit other) {
- super(other);
- }
-
- /* non Java-doc
- * @see TextEdit#doCopy
- */
- protected TextEdit doCopy() {
- return new DeleteEdit(this);
- }
-
- /* (non-Javadoc)
- * @see TextEdit#accept0
- */
- protected void accept0(TextEditVisitor visitor) {
- boolean visitChildren = visitor.visit(this);
- if (visitChildren) {
- acceptChildren(visitor);
- }
- }
-
- /* non Java-doc
- * @see TextEdit#performDocumentUpdating
- */
- /* package */ int performDocumentUpdating(IDocument document) throws BadLocationException {
- document.replace(getOffset(), getLength(), ""); //$NON-NLS-1$
- fDelta= -getLength();
- return fDelta;
- }
-
- /* non Java-doc
- * @see TextEdit#deleteChildren
- */
- /* package */ boolean deleteChildren() {
- return true;
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/text/edits/EditDocument.java b/org.eclipse.text/src/org/eclipse/text/edits/EditDocument.java
deleted file mode 100644
index ef599db..0000000
--- a/org.eclipse.text/src/org/eclipse/text/edits/EditDocument.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.text.edits;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentListener;
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.jface.text.IDocumentPartitioningListener;
-import org.eclipse.jface.text.IPositionUpdater;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.Position;
-
-/* package */ class EditDocument implements IDocument {
-
- private StringBuffer fBuffer;
-
- public EditDocument(String content) {
- fBuffer= new StringBuffer(content);
- }
-
- public void addDocumentListener(IDocumentListener listener) {
- throw new UnsupportedOperationException();
- }
-
- public void addDocumentPartitioningListener(IDocumentPartitioningListener listener) {
- throw new UnsupportedOperationException();
- }
-
- public void addPosition(Position position) throws BadLocationException {
- throw new UnsupportedOperationException();
- }
-
- public void addPosition(String category, Position position) throws BadLocationException, BadPositionCategoryException {
- throw new UnsupportedOperationException();
- }
-
- public void addPositionCategory(String category) {
- throw new UnsupportedOperationException();
- }
-
- public void addPositionUpdater(IPositionUpdater updater) {
- throw new UnsupportedOperationException();
- }
-
- public void addPrenotifiedDocumentListener(IDocumentListener documentAdapter) {
- throw new UnsupportedOperationException();
- }
-
- public int computeIndexInCategory(String category, int offset) throws BadLocationException, BadPositionCategoryException {
- throw new UnsupportedOperationException();
- }
-
- public int computeNumberOfLines(String text) {
- throw new UnsupportedOperationException();
- }
-
- public ITypedRegion[] computePartitioning(int offset, int length) throws BadLocationException {
- throw new UnsupportedOperationException();
- }
-
- public boolean containsPosition(String category, int offset, int length) {
- throw new UnsupportedOperationException();
- }
-
- public boolean containsPositionCategory(String category) {
- throw new UnsupportedOperationException();
- }
-
- public String get() {
- return fBuffer.toString();
- }
-
- public String get(int offset, int length) throws BadLocationException {
- char[] result= new char[length];
- fBuffer.getChars(offset, offset + length, result, 0);
- return new String(result);
- }
-
- public char getChar(int offset) throws BadLocationException {
- throw new UnsupportedOperationException();
- }
-
- public String getContentType(int offset) throws BadLocationException {
- throw new UnsupportedOperationException();
- }
-
- public IDocumentPartitioner getDocumentPartitioner() {
- throw new UnsupportedOperationException();
- }
-
- public String[] getLegalContentTypes() {
- throw new UnsupportedOperationException();
- }
-
- public String[] getLegalLineDelimiters() {
- throw new UnsupportedOperationException();
- }
-
- public int getLength() {
- return fBuffer.length();
- }
-
- public String getLineDelimiter(int line) throws BadLocationException {
- throw new UnsupportedOperationException();
- }
-
- public IRegion getLineInformation(int line) throws BadLocationException {
- throw new UnsupportedOperationException();
- }
-
- public IRegion getLineInformationOfOffset(int offset) throws BadLocationException {
- throw new UnsupportedOperationException();
- }
-
- public int getLineLength(int line) throws BadLocationException {
- throw new UnsupportedOperationException();
- }
-
- public int getLineOffset(int line) throws BadLocationException {
- throw new UnsupportedOperationException();
- }
-
- public int getLineOfOffset(int offset) throws BadLocationException {
- throw new UnsupportedOperationException();
- }
-
- public int getNumberOfLines() {
- throw new UnsupportedOperationException();
- }
-
- public int getNumberOfLines(int offset, int length) throws BadLocationException {
- throw new UnsupportedOperationException();
- }
-
- public ITypedRegion getPartition(int offset) throws BadLocationException {
- throw new UnsupportedOperationException();
- }
-
- public String[] getPositionCategories() {
- throw new UnsupportedOperationException();
- }
-
- public Position[] getPositions(String category) throws BadPositionCategoryException {
- throw new UnsupportedOperationException();
- }
-
- public IPositionUpdater[] getPositionUpdaters() {
- throw new UnsupportedOperationException();
- }
-
- public void insertPositionUpdater(IPositionUpdater updater, int index) {
- throw new UnsupportedOperationException();
- }
-
- public void removeDocumentListener(IDocumentListener listener) {
- throw new UnsupportedOperationException();
- }
-
- public void removeDocumentPartitioningListener(IDocumentPartitioningListener listener) {
- throw new UnsupportedOperationException();
- }
-
- public void removePosition(Position position) {
- throw new UnsupportedOperationException();
- }
-
- public void removePosition(String category, Position position) throws BadPositionCategoryException {
- throw new UnsupportedOperationException();
- }
-
- public void removePositionCategory(String category) throws BadPositionCategoryException {
- throw new UnsupportedOperationException();
- }
-
- public void removePositionUpdater(IPositionUpdater updater) {
- throw new UnsupportedOperationException();
- }
-
- public void removePrenotifiedDocumentListener(IDocumentListener documentAdapter) {
- throw new UnsupportedOperationException();
- }
-
- public void replace(int offset, int length, String text) throws BadLocationException {
- fBuffer.replace(offset, offset + length, text);
- }
-
- public int search(int startOffset, String findString, boolean forwardSearch, boolean caseSensitive, boolean wholeWord) throws BadLocationException {
- throw new UnsupportedOperationException();
- }
-
- public void set(String text) {
- throw new UnsupportedOperationException();
- }
-
- public void setDocumentPartitioner(IDocumentPartitioner partitioner) {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/text/edits/ISourceModifier.java b/org.eclipse.text/src/org/eclipse/text/edits/ISourceModifier.java
deleted file mode 100644
index bab1fcc..0000000
--- a/org.eclipse.text/src/org/eclipse/text/edits/ISourceModifier.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.text.edits;
-
-/**
- * A source modifier can be used to modify the source of
- * a move or copy edit before it gets inserted at the target
- * position. This is useful if the text to be copied has to
- * be modified before it is inserted without changing the
- * original source.
- *
- * @since 3.0
- */
-public interface ISourceModifier {
- /**
- * Returns the modification to be done to the passed
- * string in form of replace edits. The set of returned
- * replace edits must modify disjoint text regions.
- * Violating this requirement will result in a <code>
- * BadLocationException</code> while executing the
- * associated move or copy edit.
- * <p>
- * The caller of this method is responsible to apply
- * the returned edits to the passed source.
- *
- * @param source the source to be copied or moved
- * @return an array of <code>ReplaceEdits</code>
- * describing the modifications.
- */
- public ReplaceEdit[] getModifications(String source);
-
- /**
- * Creates a copy of this source modifier object. The copy will
- * be used in a different text edit object. So it should be
- * created in a way that is doesn't conflict with other text edits
- * refering to this source modifier.
- *
- * @return the copy of the source modifier
- */
- public ISourceModifier copy();
-}
diff --git a/org.eclipse.text/src/org/eclipse/text/edits/InsertEdit.java b/org.eclipse.text/src/org/eclipse/text/edits/InsertEdit.java
deleted file mode 100644
index 6fd662d..0000000
--- a/org.eclipse.text/src/org/eclipse/text/edits/InsertEdit.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.text.edits;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-
-/**
- * Text edit to insert a text at a given position in a
- * document.
- * <p>
- * An insert edit is equivalent to <code>ReplaceEdit(offset, 0, text)
- * </code>
- *
- * @since 3.0
- */
-public final class InsertEdit extends TextEdit {
-
- private String fText;
-
- /**
- * Constructs a new insert edit.
- *
- * @param offset the insertion offset
- * @param text the text to insert
- */
- public InsertEdit(int offset, String text) {
- super(offset, 0);
- fText= text;
- }
-
- /*
- * Copy constructor
- */
- private InsertEdit(InsertEdit other) {
- super(other);
- fText= other.fText;
- }
-
- /**
- * Returns the text to be inserted.
- *
- * @return the edit's text.
- */
- public String getText() {
- return fText;
- }
-
- /* non Java-doc
- * @see TextEdit#doCopy
- */
- protected TextEdit doCopy() {
- return new InsertEdit(this);
- }
-
- /* (non-Javadoc)
- * @see TextEdit#accept0
- */
- protected void accept0(TextEditVisitor visitor) {
- boolean visitChildren = visitor.visit(this);
- if (visitChildren) {
- acceptChildren(visitor);
- }
- }
-
- /* non Java-doc
- * @see TextEdit#performDocumentUpdating
- */
- /* package */ int performDocumentUpdating(IDocument document) throws BadLocationException {
- document.replace(getOffset(), getLength(), fText);
- fDelta= fText.length() - getLength();
- return fDelta;
- }
-
- /* non Java-doc
- * @see TextEdit#deleteChildren
- */
- /* package */ boolean deleteChildren() {
- return false;
- }
-
- /* non Java-doc
- * @see java.lang.Object#toString()
- */
- public String toString() {
- return super.toString() + " <<" + fText; //$NON-NLS-1$
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/text/edits/MalformedTreeException.java b/org.eclipse.text/src/org/eclipse/text/edits/MalformedTreeException.java
deleted file mode 100644
index f5baec9..0000000
--- a/org.eclipse.text/src/org/eclipse/text/edits/MalformedTreeException.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.text.edits;
-
-/**
- * Thrown to indicate that an edit got added to a parent edit
- * but the child edit somehow conflicts with the parent or
- * one of it siblings.
- *
- * @see TextEdit#add(TextEdit)
- *
- * @since 3.0
- */
-public class MalformedTreeException extends RuntimeException {
-
- private TextEdit fParent;
- private TextEdit fChild;
-
- /**
- * Constructs a new malformed tree exception.
- *
- * @param parent the parent edit
- * @param child the child edit
- * @param message the detail message
- */
- public MalformedTreeException(TextEdit parent, TextEdit child, String message) {
- super(message);
- fParent= parent;
- fChild= child;
- }
-
- /**
- * Returns the parent edit that caused the exception.
- *
- * @return the parent edit
- */
- public TextEdit getParent() {
- return fParent;
- }
-
- /**
- * Returns the child edit that caused the exception.
- *
- * @return the child edit
- */
- public TextEdit getChild() {
- return fChild;
- }
-
- /* package */ void setParent(TextEdit parent) {
- fParent= parent;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.text/src/org/eclipse/text/edits/Messages.properties b/org.eclipse.text/src/org/eclipse/text/edits/Messages.properties
deleted file mode 100644
index 486880f..0000000
--- a/org.eclipse.text/src/org/eclipse/text/edits/Messages.properties
+++ /dev/null
@@ -1,33 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2003 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-TextEdit.range_outside= Range of child edit lies outside of parent edit
-TextEdit.overlapping= Overlapping text edits
-TextEdit.deleted_edit= Cannot add deleted edit
-
-CopySourceEdit.no_target= No target edit provided.
-CopySourceEdit.different_source= Target edit has different source edit.
-
-CopyTargetEdit.no_source= No source edit provided.
-CopyTargetEdit.different_target= Source edit has different target edit.
-CopyTargetEdit.wrong_parent=Source edit must not be the parent of the target.
-
-MoveSourceEdit.no_target= No target edit provided.
-MoveSourceEdit.different_source= Target edit has different source edit.
-
-MoveTargetEdit.no_source= No source edit provided.
-MoveTargetEdit.different_target= Source edit has different target edit.
-MoveTargetEdit.wrong_parent=Source edit must not be the parent of the target.
-
-TextEditProcessor.invalid_length=End position lies outside of document range
-
-UndoEdit.no_children=Can\'t add children to an undo edit
-UndoEdit.can_not_be_added=Can\'t add an undo edit to another edit
diff --git a/org.eclipse.text/src/org/eclipse/text/edits/MoveSourceEdit.java b/org.eclipse.text/src/org/eclipse/text/edits/MoveSourceEdit.java
deleted file mode 100644
index 3c2fcc1..0000000
--- a/org.eclipse.text/src/org/eclipse/text/edits/MoveSourceEdit.java
+++ /dev/null
@@ -1,419 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.text.edits;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.Region;
-
-/**
- * A move source edit denotes the source of a move operation. Move
- * source edits are only valid inside an edit tree if they have a
- * corresponding traget edit. Furthermore the corresponding target
- * edit can't be a direct or indirect child of the source edit.
- * Violating one of two requirements will result in a <code>
- * MalformedTreeException</code> when executing the edit tree.
- * <p>
- * A move source edit can manange an optional source modifier. A
- * source modifier can provide a set of replace edits which will
- * to applied to the source before it gets inserted at the target
- * position.
- *
- * @see org.eclipse.text.edits.MoveTargetEdit
- * @see org.eclipse.text.edits.CopySourceEdit
- *
- * @since 3.0
- */
-public final class MoveSourceEdit extends TextEdit {
-
- private MoveTargetEdit fTarget;
- private ISourceModifier fModifier;
-
- private String fSourceContent;
- private MultiTextEdit fSourceRoot;
-
- /**
- * Constructs a new move source edit.
- *
- * @param offset the edit's offset
- * @param length the edit's length
- */
- public MoveSourceEdit(int offset, int length) {
- super(offset, length);
- }
-
- /**
- * Constructs a new copy source edit.
- *
- * @param offset the edit's offset
- * @param length the edit's length
- * @param target the edit's target
- */
- public MoveSourceEdit(int offset, int length, MoveTargetEdit target) {
- this(offset, length);
- setTargetEdit(target);
- }
-
- /*
- * Copy constructor
- */
- private MoveSourceEdit(MoveSourceEdit other) {
- super(other);
- if (other.fModifier != null)
- fModifier= other.fModifier.copy();
- }
-
- /**
- * Returns the associated traget edit or <code>null</code>
- * if no target edit is associated yet.
- *
- * @return the target edit or <code>null</code>
- */
- public MoveTargetEdit getTargetEdit() {
- return fTarget;
- }
-
- /**
- * Sets the target edit.
- *
- * @param edit the new target edit.
- *
- * @exception MalformedTreeException is thrown if the target edit
- * is a direct or indirect child of the source edit
- */
- public void setTargetEdit(MoveTargetEdit edit) {
- fTarget= edit;
- fTarget.setSourceEdit(this);
- }
-
- /**
- * Returns the current source modifier or <code>null</code>
- * if no source modifier is set.
- *
- * @return the source modifier
- */
- public ISourceModifier getSourceModifier() {
- return fModifier;
- }
-
- /**
- * Sets the optional source modifier.
- *
- * @param modifier the source modifier or <code>null</code>
- * if no source modification is need.
- */
- public void setSourceModifier(ISourceModifier modifier) {
- fModifier= modifier;
- }
-
- //---- API for MoveTargetEdit ---------------------------------------------
-
- /* package */ String getContent() {
- // The source content can be null if the edit wasn't executed
- // due to an exclusion list of the text edit processor. Return
- // the empty string which can be moved without any harm.
- if (fSourceContent == null)
- return ""; //$NON-NLS-1$
- return fSourceContent;
- }
-
- /* package */ MultiTextEdit getRoot() {
- return fSourceRoot;
- }
-
- /* package */ void clearContent() {
- fSourceContent= null;
- fSourceRoot= null;
- }
-
- //---- Copying -------------------------------------------------------------
-
- /* non Java-doc
- * @see TextEdit#doCopy
- */
- protected TextEdit doCopy() {
- return new MoveSourceEdit(this);
- }
-
- /* non Java-doc
- * @see TextEdit#postProcessCopy
- */
- protected void postProcessCopy(TextEditCopier copier) {
- if (fTarget != null) {
- MoveSourceEdit source= (MoveSourceEdit)copier.getCopy(this);
- MoveTargetEdit target= (MoveTargetEdit)copier.getCopy(fTarget);
- if (source != null && target != null)
- source.setTargetEdit(target);
- }
- }
-
- //---- Visitor -------------------------------------------------------------
-
- /* (non-Javadoc)
- * @see TextEdit#accept0
- */
- protected void accept0(TextEditVisitor visitor) {
- boolean visitChildren = visitor.visit(this);
- if (visitChildren) {
- acceptChildren(visitor);
- }
- }
-
- //---- consistency check ----------------------------------------------------------------
-
- /* package */ int traverseConsistencyCheck(TextEditProcessor processor, IDocument document, List sourceEdits) {
- int result= super.traverseConsistencyCheck(processor, document, sourceEdits);
- // Since source computation takes place in a recursive fashion (see
- // performSourceComputation) we only do something if we don't have a
- // computated source already.
- if (fSourceContent == null) {
- if (sourceEdits.size() <= result) {
- List list= new ArrayList();
- list.add(this);
- for (int i= sourceEdits.size(); i < result; i++)
- sourceEdits.add(null);
- sourceEdits.add(list);
- } else {
- List list= (List)sourceEdits.get(result);
- if (list == null) {
- list= new ArrayList();
- sourceEdits.add(result, list);
- }
- list.add(this);
- }
- }
- return result;
- }
-
- /* package */ void performConsistencyCheck(TextEditProcessor processor, IDocument document) throws MalformedTreeException {
- if (fTarget == null)
- throw new MalformedTreeException(getParent(), this, TextEditMessages.getString("MoveSourceEdit.no_target")); //$NON-NLS-1$
- if (fTarget.getSourceEdit() != this)
- throw new MalformedTreeException(getParent(), this, TextEditMessages.getString("MoveSourceEdit.different_source")); //$NON-NLS-1$
- }
-
- //---- source computation --------------------------------------------------------------
-
- /* package */ void traverseSourceComputation(TextEditProcessor processor, IDocument document) {
- if (processor.considerEdit(this)) {
- performSourceComputation(processor, document);
- }
- }
-
- /* package */ void performSourceComputation(TextEditProcessor processor, IDocument document) {
- try {
- TextEdit[] children= removeChildren();
- if (children.length > 0) {
- String content= document.get(getOffset(), getLength());
- EditDocument subDocument= new EditDocument(content);
- fSourceRoot= new MultiTextEdit(getOffset(), getLength());
- fSourceRoot.addChildren(children);
- fSourceRoot.moveTree(-getOffset());
- int processingStyle= getStyle(processor);
- fSourceRoot.apply(subDocument, processingStyle);
- if (needsTransformation())
- applyTransformation(subDocument, processingStyle);
- fSourceContent= subDocument.get();
- } else {
- fSourceContent= document.get(getOffset(), getLength());
- if (needsTransformation()) {
- EditDocument subDocument= new EditDocument(fSourceContent);
- applyTransformation(subDocument, getStyle(processor));
- fSourceContent= subDocument.get();
- }
- }
- } catch (BadLocationException cannotHappen) {
- Assert.isTrue(false);
- }
- }
-
- private int getStyle(TextEditProcessor processor) {
- // we never need undo while performing local edits.
- if ((processor.getStyle() & TextEdit.UPDATE_REGIONS) != 0)
- return TextEdit.UPDATE_REGIONS;
- return TextEdit.NONE;
- }
-
- //---- document updating ----------------------------------------------------------------
-
- /* package */ int performDocumentUpdating(IDocument document) throws BadLocationException {
- document.replace(getOffset(), getLength(), ""); //$NON-NLS-1$
- fDelta= -getLength();
- return fDelta;
- }
-
- //---- region updating --------------------------------------------------------------
-
- /* non Java-doc
- * @see TextEdit#deleteChildren
- */
- /* package */ boolean deleteChildren() {
- return false;
- }
-
- //---- content transformation --------------------------------------------------
-
- private boolean needsTransformation() {
- return fModifier != null;
- }
-
- private void applyTransformation(IDocument document, int style) throws MalformedTreeException {
- if ((style & TextEdit.UPDATE_REGIONS) != 0 && fSourceRoot != null) {
- Map editMap= new HashMap();
- TextEdit newEdit= createEdit(editMap);
- List replaces= new ArrayList(Arrays.asList(fModifier.getModifications(document.get())));
- insertEdits(newEdit, replaces);
- try {
- newEdit.apply(document, style);
- } catch (BadLocationException cannotHappen) {
- Assert.isTrue(false);
- }
- restorePositions(editMap);
- } else {
- MultiTextEdit newEdit= new MultiTextEdit(0, document.getLength());
- TextEdit[] replaces= fModifier.getModifications(document.get());
- for (int i= 0; i < replaces.length; i++) {
- newEdit.addChild(replaces[i]);
- }
- try {
- newEdit.apply(document, style);
- } catch (BadLocationException cannotHappen) {
- Assert.isTrue(false);
- }
- }
- }
-
- private TextEdit createEdit(Map editMap) {
- MultiTextEdit result= new MultiTextEdit(0, fSourceRoot.getLength());
- editMap.put(result, fSourceRoot);
- createEdit(fSourceRoot, result, editMap);
- return result;
- }
-
- private static void createEdit(TextEdit source, TextEdit target, Map editMap) {
- TextEdit[] children= source.getChildren();
- for (int i= 0; i < children.length; i++) {
- TextEdit child= children[i];
- // a deleted child remains deleted even if the temporary buffer
- // gets modified.
- if (child.isDeleted())
- continue;
- RangeMarker marker= new RangeMarker(child.getOffset(), child.getLength());
- target.addChild(marker);
- editMap.put(marker, child);
- createEdit(child, marker, editMap);
- }
- }
-
- private void insertEdits(TextEdit root, List edits) {
- while(edits.size() > 0) {
- ReplaceEdit edit= (ReplaceEdit)edits.remove(0);
- insert(root, edit, edits);
- }
- }
- private static void insert(TextEdit parent, ReplaceEdit edit, List edits) {
- if (!parent.hasChildren()) {
- parent.addChild(edit);
- return;
- }
- TextEdit[] children= parent.getChildren();
- // First dive down to find the right parent.
- for (int i= 0; i < children.length; i++) {
- TextEdit child= children[i];
- if (child.covers(edit)) {
- insert(child, edit, edits);
- return;
- } else if (edit.covers(child)) {
- parent.removeChild(i);
- edit.addChild(child);
- } else {
- IRegion intersect= intersect(edit, child);
- if (intersect != null) {
- ReplaceEdit[] splits= splitEdit(edit, intersect);
- insert(child, splits[0], edits);
- edits.add(splits[1]);
- }
- }
- }
- parent.addChild(edit);
- }
-
- public static IRegion intersect(TextEdit op1, TextEdit op2) {
- int offset1= op1.getOffset();
- int length1= op1.getLength();
- int end1= offset1 + length1 - 1;
- int offset2= op2.getOffset();
- if (end1 < offset2)
- return null;
- int length2= op2.getLength();
- int end2= offset2 + length2 - 1;
- if (end2 < offset1)
- return null;
- if (offset1 < offset2) {
- int end= Math.max(end1, end2);
- return new Region(offset2, end - offset2 + 1);
- } else {
- int end= Math.max(end1, end2);
- return new Region(offset1, end - offset1 + 1);
- }
- }
-
- private static ReplaceEdit[] splitEdit(ReplaceEdit edit, IRegion intersect) {
- if (edit.getOffset() != intersect.getOffset()) {
- return splitIntersectRight(edit, intersect);
- } else {
- return splitIntersectLeft(edit, intersect);
- }
- }
-
- private static ReplaceEdit[] splitIntersectRight(ReplaceEdit edit, IRegion intersect) {
- ReplaceEdit[] result= new ReplaceEdit[2];
- // this is the actual delete. We use replace to only deal with one type
- result[0]= new ReplaceEdit(intersect.getOffset(), intersect.getLength(), ""); //$NON-NLS-1$
- result[1]= new ReplaceEdit(
- edit.getOffset(),
- intersect.getOffset() - edit.getOffset(),
- edit.getText());
- return result;
- }
-
- private static ReplaceEdit[] splitIntersectLeft(ReplaceEdit edit, IRegion intersect) {
- ReplaceEdit[] result= new ReplaceEdit[2];
- result[0]= new ReplaceEdit(intersect.getOffset(), intersect.getLength(), edit.getText());
- result[1]= new ReplaceEdit( // this is the actual delete. We use replace to only deal with one type
- intersect.getOffset() + intersect.getLength(),
- edit.getLength() - intersect.getLength(),
- ""); //$NON-NLS-1$
- return result;
- }
-
- private static void restorePositions(Map editMap) {
- for (Iterator iter= editMap.keySet().iterator(); iter.hasNext();) {
- TextEdit marker= (TextEdit)iter.next();
- TextEdit edit= (TextEdit)editMap.get(marker);
- if (marker.isDeleted()) {
- edit.markAsDeleted();
- } else {
- edit.adjustOffset(marker.getOffset() - edit.getOffset());
- edit.adjustLength(marker.getLength() - edit.getLength());
- }
- }
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/text/edits/MoveTargetEdit.java b/org.eclipse.text/src/org/eclipse/text/edits/MoveTargetEdit.java
deleted file mode 100644
index a9da7e2..0000000
--- a/org.eclipse.text/src/org/eclipse/text/edits/MoveTargetEdit.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.text.edits;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-
-/**
- * A move target edit denotes the target of a move operation. Move
- * target edits are only valid inside an edit tree if they have a
- * corresponding source edit. Furthermore a target edit can't
- * can't be a direct or indirect child of its associated source edit.
- * Violating one of two requirements will result in a <code>
- * MalformedTreeException</code> when executing the edit tree.
- * <p>
- * Move target edits can't be used as a parent for other edits.
- * Trying to add an edit to a move target edit results in a <code>
- * MalformedTreeException</code> as well.
- *
- * @see org.eclipse.text.edits.MoveSourceEdit
- * @see org.eclipse.text.edits.CopyTargetEdit
- *
- * @since 3.0
- */
-public final class MoveTargetEdit extends TextEdit {
-
- private MoveSourceEdit fSource;
-
- /**
- * Constructs a new move target edit
- *
- * @param offset the edit's offset
- */
- public MoveTargetEdit(int offset) {
- super(offset, 0);
- }
-
- /**
- * Constructs an new move target edit
- *
- * @param offset the edit's offset
- * @param source the corresponding source edit
- */
- public MoveTargetEdit(int offset, MoveSourceEdit source) {
- this(offset);
- setSourceEdit(source);
- }
-
- /*
- * Copy constructor
- */
- private MoveTargetEdit(MoveTargetEdit other) {
- super(other);
- }
-
- /**
- * Returns the associated source edit or <code>null</code>
- * if no source edit is associated yet.
- *
- * @return the source edit or <code>null</code>
- */
- public MoveSourceEdit getSourceEdit() {
- return fSource;
- }
-
- /**
- * Sets the source edit.
- *
- * @param edit the source edit
- *
- * @exception MalformedTreeException is thrown if the target edit
- * is a direct or indirect child of the source edit
- */
- public void setSourceEdit(MoveSourceEdit edit) {
- if (fSource != edit) {
- fSource= edit;
- fSource.setTargetEdit(this);
- TextEdit parent= getParent();
- while (parent != null) {
- if (parent == fSource)
- throw new MalformedTreeException(parent, this, TextEditMessages.getString("MoveTargetEdit.wrong_parent")); //$NON-NLS-1$
- parent= parent.getParent();
- }
- }
- }
-
- /* non Java-doc
- * @see TextEdit#doCopy
- */
- protected TextEdit doCopy() {
- return new MoveTargetEdit(this);
- }
-
- /* non Java-doc
- * @see TextEdit#postProcessCopy
- */
- protected void postProcessCopy(TextEditCopier copier) {
- if (fSource != null) {
- MoveTargetEdit target= (MoveTargetEdit)copier.getCopy(this);
- MoveSourceEdit source= (MoveSourceEdit)copier.getCopy(fSource);
- if (target != null && source != null)
- target.setSourceEdit(source);
- }
- }
-
- /* (non-Javadoc)
- * @see TextEdit#accept0
- */
- protected void accept0(TextEditVisitor visitor) {
- boolean visitChildren = visitor.visit(this);
- if (visitChildren) {
- acceptChildren(visitor);
- }
- }
-
- //---- consistency check ----------------------------------------------------------
-
- /* non Java-doc
- * @see TextEdit#traverseConsistencyCheck
- */
- /* package */ int traverseConsistencyCheck(TextEditProcessor processor, IDocument document, List sourceEdits) {
- return super.traverseConsistencyCheck(processor, document, sourceEdits) + 1;
- }
-
- /* non Java-doc
- * @see TextEdit#performConsistencyCheck
- */
- /* package */ void performConsistencyCheck(TextEditProcessor processor, IDocument document) throws MalformedTreeException {
- if (fSource == null)
- throw new MalformedTreeException(getParent(), this, TextEditMessages.getString("MoveTargetEdit.no_source")); //$NON-NLS-1$
- if (fSource.getTargetEdit() != this)
- throw new MalformedTreeException(getParent(), this, TextEditMessages.getString("MoveTargetEdit.different_target")); //$NON-NLS-1$
- }
-
- //---- document updating ----------------------------------------------------------------
-
- /* non Java-doc
- * @see TextEdit#performDocumentUpdating
- */
- /* package */ int performDocumentUpdating(IDocument document) throws BadLocationException {
- String source= fSource.getContent();
- document.replace(getOffset(), getLength(), source);
- fDelta= source.length() - getLength();
-
- MultiTextEdit sourceRoot= fSource.getRoot();
- if (sourceRoot != null) {
- sourceRoot.moveTree(getOffset());
- TextEdit[] sourceChildren= sourceRoot.removeChildren();
- List children= new ArrayList(sourceChildren.length);
- for (int i= 0; i < sourceChildren.length; i++) {
- TextEdit child= sourceChildren[i];
- child.internalSetParent(this);
- children.add(child);
- }
- internalSetChildren(children);
- }
- fSource.clearContent();
- return fDelta;
- }
-
- //---- region updating --------------------------------------------------------------
-
- /* (non-Javadoc)
- * @see org.eclipse.text.edits.TextEdit#traversePassThree
- */
- /* package */ int traverseRegionUpdating(TextEditProcessor processor, IDocument document, int accumulatedDelta, boolean delete) {
- // the children got already updated / normalized while they got removed
- // from the source edit. So we only have to adjust the offset computed to
- // far.
- if (delete) {
- deleteTree();
- } else {
- moveTree(accumulatedDelta);
- }
- return accumulatedDelta + fDelta;
- }
-
- /* package */ boolean deleteChildren() {
- return false;
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/text/edits/MultiTextEdit.java b/org.eclipse.text/src/org/eclipse/text/edits/MultiTextEdit.java
deleted file mode 100644
index b1eaa0f..0000000
--- a/org.eclipse.text/src/org/eclipse/text/edits/MultiTextEdit.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.text.edits;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-
-/**
- * A multi text edit can be used to aggregate several edits into
- * one edit. The edit itself doesn't modify a document.
- * <p>
- * Clients are allowed to implement subclasses of a multi text
- * edit.Subclasses must implement <code>doCopy()</code> to ensure
- * the a copy of the right type is created. Not implementing
- * <code>doCopy()</code> in subclasses will result in an assertion
- * failure during copying.
- *
- * @since 3.0
- */
-public class MultiTextEdit extends TextEdit {
-
- private boolean fDefined;
-
- /**
- * Creates a new <code>MultiTextEdit</code>. The range
- * of the edit is determined by the range of its children.
- *
- * Adding this edit to a parent edit sets its range to the
- * range covered by its children. If the edit doesn't have
- * any children its offset is set to the parent's offset
- * and its length is set to 0.
- */
- public MultiTextEdit() {
- super(0, Integer.MAX_VALUE);
- fDefined= false;
- }
-
- /**
- * Creates a new </code>MultiTextEdit</code> for the given
- * range. Adding a child to this edit which isn't covered
- * by the given range will result in an exception.
- *
- * @param offset the edit's offset
- * @param length the edit's length.
- * @see TextEdit#add(TextEdit)
- */
- public MultiTextEdit(int offset, int length) {
- super(offset, length);
- fDefined= true;
- }
-
- /*
- * Copy constructor.
- */
- protected MultiTextEdit(MultiTextEdit other) {
- super(other);
- }
-
- /**
- * Checks the edit's integrity.
- * <p>
- * Note that this method <b>should only be called</b> by the edit
- * framework and not by normal clients.</p>
- *<p>
- * This default implementation does nothing. Subclasses may override
- * if needed.</p>
- *
- * @exception MalformedTreeException if the edit isn't in a valid state
- * and can therefore not be executed
- */
- protected void checkIntegrity() throws MalformedTreeException {
- // does nothing
- }
-
- /* non Java-doc
- * @see TextEdit#copy
- */
- protected TextEdit doCopy() {
- Assert.isTrue(MultiTextEdit.class == getClass(), "Subclasses must reimplement copy0"); //$NON-NLS-1$
- return new MultiTextEdit(this);
- }
-
- /* (non-Javadoc)
- * @see TextEdit#accept0
- */
- protected void accept0(TextEditVisitor visitor) {
- boolean visitChildren = visitor.visit(this);
- if (visitChildren) {
- acceptChildren(visitor);
- }
- }
-
- /* non Java-doc
- * @see TextEdit#performConsistencyCheck
- */
- /* package */ void performConsistencyCheck(TextEditProcessor processor, IDocument document) throws MalformedTreeException {
- checkIntegrity();
- }
-
- /* non Java-doc
- * @see TextEdit#performDocumentUpdating
- */
- /* package */ int performDocumentUpdating(IDocument document) throws BadLocationException {
- fDelta= 0;
- return fDelta;
- }
-
- /* non Java-doc
- * @see TextEdit#deleteChildren
- */
- /* package */ boolean deleteChildren() {
- return false;
- }
-
- /* package */ void aboutToBeAdded(TextEdit parent) {
- defineRegion(parent.getOffset());
- }
-
- /* package */ void defineRegion(int parentOffset) {
- if (fDefined)
- return;
- if (hasChildren()) {
- IRegion region= getCoverage(getChildren());
- internalSetOffset(region.getOffset());
- internalSetLength(region.getLength());
- } else {
- internalSetOffset(parentOffset);
- internalSetLength(0);
- }
- fDefined= true;
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/text/edits/RangeMarker.java b/org.eclipse.text/src/org/eclipse/text/edits/RangeMarker.java
deleted file mode 100644
index 248fe2a..0000000
--- a/org.eclipse.text/src/org/eclipse/text/edits/RangeMarker.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.text.edits;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-
-/**
- * A range marker can be used to track positions when executing
- * text edits.
- *
- * @since 3.0
- */
-public final class RangeMarker extends TextEdit {
-
- /**
- * Creates a new range marker for the given offset and length.
- *
- * @param offset the marker's offset
- * @param length the marker's length
- */
- public RangeMarker(int offset, int length) {
- super(offset, length);
- }
-
- /*
- * Copy constructor
- */
- private RangeMarker(RangeMarker other) {
- super(other);
- }
-
- /* non Java-doc
- * @see TextEdit#copy
- */
- protected TextEdit doCopy() {
- return new RangeMarker(this);
- }
-
- /* (non-Javadoc)
- * @see TextEdit#accept0
- */
- protected void accept0(TextEditVisitor visitor) {
- boolean visitChildren = visitor.visit(this);
- if (visitChildren) {
- acceptChildren(visitor);
- }
- }
-
- /* non Java-doc
- * @see TextEdit#performDocumentUpdating
- */
- /* package */ int performDocumentUpdating(IDocument document) throws BadLocationException {
- fDelta= 0;
- return fDelta;
- }
-
- /* non Java-doc
- * @see TextEdit#deleteChildren
- */
- /* package */ boolean deleteChildren() {
- return false;
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/text/edits/ReplaceEdit.java b/org.eclipse.text/src/org/eclipse/text/edits/ReplaceEdit.java
deleted file mode 100644
index b693351..0000000
--- a/org.eclipse.text/src/org/eclipse/text/edits/ReplaceEdit.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.text.edits;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-
-/**
- * Text edit to replace a range in a document with a different
- * string.
- *
- * @since 3.0
- */
-public final class ReplaceEdit extends TextEdit {
-
- private String fText;
-
- /**
- * Constructs a new replace edit.
- *
- * @param offset the offset of the range to replace
- * @param length the length of the range to replace
- * @param text the new text
- */
- public ReplaceEdit(int offset, int length, String text) {
- super(offset, length);
- Assert.isNotNull(text);
- fText= text;
- }
-
- /*
- * Copy constructor
- *
- * @param other the edit to copy from
- */
- private ReplaceEdit(ReplaceEdit other) {
- super(other);
- fText= other.fText;
- }
-
- /**
- * Returns the new text replacing the text denoted
- * by the edit.
- *
- * @return the edit's text.
- */
- public String getText() {
- return fText;
- }
-
- /* non Java-doc
- * @see TextEdit#doCopy
- */
- protected TextEdit doCopy() {
- return new ReplaceEdit(this);
- }
-
- /* (non-Javadoc)
- * @see TextEdit#accept0
- */
- protected void accept0(TextEditVisitor visitor) {
- boolean visitChildren = visitor.visit(this);
- if (visitChildren) {
- acceptChildren(visitor);
- }
- }
-
- /* non Java-doc
- * @see TextEdit#performDocumentUpdating
- */
- /* package */ int performDocumentUpdating(IDocument document) throws BadLocationException {
- document.replace(getOffset(), getLength(), fText);
- fDelta= fText.length() - getLength();
- return fDelta;
- }
-
- /* non Java-doc
- * @see TextEdit#deleteChildren
- */
- /* package */ boolean deleteChildren() {
- return true;
- }
-
- /* non Java-doc
- * @see java.lang.Object#toString()
- */
- public String toString() {
- return super.toString() + " <<" + fText; //$NON-NLS-1$
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/text/edits/TextEdit.java b/org.eclipse.text/src/org/eclipse/text/edits/TextEdit.java
deleted file mode 100644
index 64fee93..0000000
--- a/org.eclipse.text/src/org/eclipse/text/edits/TextEdit.java
+++ /dev/null
@@ -1,833 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.text.edits;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.Region;
-
-/**
- * A text edit describes an elementary text manipulation operation. Edits are
- * executed by applying them to a document (e.g. an instance of <code>IDocument
- * </code>).
- * <p>
- * Text edits form a tree. Clients can navigate the tree upwards, from child to
- * parent, as well as downwards. Newly created edits are unparented. New edits
- * are added to the tree by calling one of the <code>add</code> methods on a parent
- * edit.
- * </p>
- * <p>
- * An edit tree is well formed in the following sense:
- * <ul>
- * <li>a parent edit covers all its children</li>
- * <li>children don't overlap</li>
- * <li>an edit with length 0 can't have any children</li>
- * </ul>
- * Any manipulation of the tree that violates one of the above requirements results
- * in a <code>MalformedTreeException</code>.
- * </p>
- * <p>
- * Insert edits are represented by an edit of length 0. If more than one insert
- * edit exists at the same offset then the edits are executed in the order in which
- * they have been added to a parent. The following code example:
- * <pre>
- * IDocument document= new Document("org");
- * MultiEdit edit= new MultiEdit();
- * edit.add(new InsertEdit(0, "www.");
- * edit.add(new InsertEdit(0, "eclipse.");
- * edit.apply(document);
- * </pre>
- * therefore results in string: "www.eclipse.org".
- * </p>
- * <p>
- * Text edits can be executed in a mode where the edit's region is updated to
- * reflect the edit's position in the changed document. Region updating is enabled
- * by default or can be requested by passing <code>UPDATE_REGIONS</code> to the
- * {@link #apply(IDocument, int) apply(IDocument, int)} method. In the above example
- * the region of the <code>InsertEdit(0, "eclipse.")</code> edit after executing
- * the root edit is <code>[3, 8]</code>. If the region of an edit got deleted during
- * change execution the region is set to <code>[-1, -1]</code> and the method {@link
- * #isDeleted() isDeleted} returns <code>true</code>.
- * </p>
- * This class isn't intended to be subclassed outside of the edit framework. Clients
- * are only allowed to subclass <code>MultiTextEdit</code>.
- *
- * @see TextBufferEditor
- *
- * @since 3.0
- */
-public abstract class TextEdit {
-
- /**
- * Flags indicating that either <code>CREATE_UNDO</code> nor
- * <code>UPDATE_REGIONS</code> is set.
- */
- public static final int NONE= 0;
-
- /**
- * Flags indicating that applying an edit tree to a document
- * is supposed to create a corresponding undo edit. If not
- * specified <code>null</code> is returned from method <code>
- * apply</code>.
- */
- public static final int CREATE_UNDO= 1 << 0;
-
- /**
- * Flag indicating that the edit's region will be updated to
- * reflect its position in the changed document. If not specified
- * when applying an edit tree to a document the edit's region will
- * be arbitrary. It is even not guaranteed that the tree is still
- * well formed.
- */
- public static final int UPDATE_REGIONS= 1 << 1;
-
- private static class InsertionComparator implements Comparator {
- public int compare(Object o1, Object o2) {
- TextEdit edit1 = (TextEdit) o1;
- TextEdit edit2 = (TextEdit) o2;
-
- int offset1 = edit1.getOffset();
- int length1 = edit1.getLength();
-
- int offset2 = edit2.getOffset();
- int length2 = edit2.getLength();
-
- // make sure that a duplicate insertion point at the same offet is
- // inserted last. Have to double check with the spec. It says the
- // with identical values there is no guarantee which one will be
- // found.
- if (offset1 == offset2 && length1 == 0 && length2 == 0) {
- return -1;
- }
- if (offset1 + length1 - 1 < offset2) {
- return -1;
- }
- if (offset2 + length2 - 1 < offset1) {
- return 1;
- }
- throw new MalformedTreeException(
- null, edit1,
- TextEditMessages.getString("TextEdit.overlapping")); //$NON-NLS-1$
- }
- }
-
- private static final TextEdit[] EMPTY_ARRAY= new TextEdit[0];
- private static final InsertionComparator INSERTION_COMPARATOR= new InsertionComparator();
-
- private static final int DELETED_VALUE= -1;
-
- private int fOffset;
- private int fLength;
-
- /* package */ TextEdit fParent;
- /* package */ List fChildren;
-
- /* package */ int fDelta;
-
- /**
- * Create a new text edit. Parent is initialized to <code>
- * null<code> and the edit doesn't have any children.
- */
- protected TextEdit(int offset, int length) {
- Assert.isTrue(offset >= 0 && length >= 0);
- fOffset= offset;
- fLength= length;
- fDelta= 0;
- }
-
- /**
- * Copy constrcutor
- *
- * @param source the source to copy form
- */
- protected TextEdit(TextEdit source) {
- fOffset= source.fOffset;
- fLength= source.fLength;
- fDelta= 0;
- }
-
- //---- Region management -----------------------------------------------
-
- /**
- * Returns the range that this edit is manipulating. The returned
- * <code>IRegion</code> contains the edit's offset and length at
- * the point in time when this call is made. Any subsequent changes
- * to the edit's offset and length aren't reflected in the returned
- * region object.
- * <p>
- * Creating a region for a deleted edit will result in an assertion
- * failure.
- *
- * @return the manipulated region
- */
- public final IRegion getRegion() {
- return new Region(fOffset, fLength);
- }
-
- /**
- * Returns the offset of the edit. An offset is a 0-based
- * character index. Returns <code>-1</code> if the edit
- * is marked as deleted
- *
- * @return the offset of the edit
- */
- public final int getOffset() {
- return fOffset;
- }
-
- /**
- * Returns the length of the edit. Returns <code>-1</code>
- * if the edit is marked as deleted.
- *
- * @return the length of the edit
- */
- public final int getLength() {
- return fLength;
- }
-
- /**
- * Returns the inclusive end position of this edit. The inclusive end
- * position denotes the last character of the region manipulated by
- * this edit. The returned value is the result of the following
- * calculation:
- * <pre>
- * getOffset() + getLength() - 1;
- * <pre>
- *
- * @return the inclusive end position
- */
- public final int getInclusiveEnd() {
- return fOffset + fLength - 1;
- }
-
- /**
- * Returns the exclusive end position of this edit. The exclusive end
- * position denotes the next character of the region manipulated by
- * this edit. The returned value is the result of the following
- * calculation:
- * <pre>
- * getOffset() + getLength();
- * </pre>
- *
- * @return the exclusive end position
- */
- public final int getExclusiveEnd() {
- return fOffset + fLength;
- }
-
- /**
- * Returns whether this edit has been deleted or not.
- *
- * @return <code>true</code> if the edit has been
- * deleted; otherwise <code>false</code> is returned.
- */
- public final boolean isDeleted() {
- return fOffset == DELETED_VALUE && fLength == DELETED_VALUE;
- }
-
- /**
- * Returns <code>true</code> if the edit covers the given edit
- * <code>other</code>. If the length of the edit is zero <code>
- * false</code> is returned. An insert edit can't cover any other
- * edit, even if the other edit has the same offset and length.
- *
- * @param other the other edit
- * @return <code>true<code> if the edit covers the other edit;
- * otherwise <code>false</code> is returned.
- * @see Regions#covers(IRegion, IRegion)
- */
- public final boolean covers(TextEdit other) {
- if (fLength == 0) { // an insert edit can't cover anything
- return false;
- } else {
- int otherOffset= other.fOffset;
- return fOffset <= otherOffset && otherOffset + other.fLength <= fOffset + fLength;
- }
- }
-
- //---- parent and children management -----------------------------
-
- /**
- * Returns the edit's parent. The method returns <code>null</code>
- * if this edit hasn't been add to another edit.
- *
- * @return the edit's parent
- */
- public final TextEdit getParent() {
- return fParent;
- }
-
- /**
- * Adds the given edit <code>child</code> to this edit.
- *
- * @param child the child edit to add
- * @exception <code>MalformedTreeException<code> is thrown if the child
- * edit can't be added to this edit. This is the case if the child
- * overlaps with one of its siblings or if the child edit's region
- * isn't fully covered by this edit.
- */
- public final void addChild(TextEdit child) throws MalformedTreeException {
- internalAdd(child);
- }
-
- /**
- * Adds all edits in <code>edits</code> to this edit.
- *
- * @param edits the text edits to add
- * @exception <code>MalformedTreeException</code> is thrown if one of
- * the given edits can't be added to this edit.
- *
- * @see #addChild(TextEdit)
- */
- public final void addChildren(TextEdit[] edits) throws MalformedTreeException {
- for (int i= 0; i < edits.length; i++) {
- internalAdd(edits[i]);
- }
- }
-
- /**
- * Removes the edit specified by the given index from the list
- * of children. Returns the child edit that was removed from
- * the list of children. The parent of the returned edit is
- * set to <code>null</code>.
- *
- * @param index the index of the edit to remove
- * @return the removed edit
- * @exception <code>IndexOutOfBoundsException</code> if the index
- * is out of range
- */
- public final TextEdit removeChild(int index) {
- if (fChildren == null)
- throw new IndexOutOfBoundsException("Index: " + index + " Size: 0"); //$NON-NLS-1$//$NON-NLS-2$
- TextEdit result= (TextEdit)fChildren.remove(index);
- result.internalSetParent(null);
- if (fChildren.isEmpty())
- fChildren= null;
- return result;
- }
-
- /**
- * Removes the first occurrence of the given child from the list
- * of children.
- *
- * @param child the child to be removed
- * @return <code>true</code> if the edit contained the given
- * child; otherwise <code>false</code> is returned
- */
- public final boolean removeChild(TextEdit child) {
- Assert.isNotNull(child);
- if (fChildren == null)
- return false;
- boolean result= fChildren.remove(child);
- if (result) {
- child.internalSetParent(null);
- if (fChildren.isEmpty())
- fChildren= null;
- }
- return result;
- }
-
- /**
- * Removes all child edits from and returns them. The parent
- * of the removed edits is set to <code>null</code>.
- *
- * @return an array of the removed edits
- */
- public final TextEdit[] removeChildren() {
- if (fChildren == null)
- return EMPTY_ARRAY;
- int size= fChildren.size();
- TextEdit[] result= new TextEdit[size];
- for (int i= 0; i < size; i++) {
- result[i]= (TextEdit)fChildren.get(i);
- result[i].internalSetParent(null);
- }
- fChildren= null;
- return result;
- }
-
- /**
- * Returns <code>true</code> if this edit has children. Otherwise
- * <code>false</code> is returned.
- *
- * @return <code>true</code> if this edit has children; otherwise
- * <code>false</code> is returned
- */
- public final boolean hasChildren() {
- return fChildren != null && ! fChildren.isEmpty();
- }
-
- /**
- * Returns the edit's children. If the edit doesn't have any
- * children an empty array is returned.
- *
- * @return the edit's children
- */
- public final TextEdit[] getChildren() {
- if (fChildren == null)
- return EMPTY_ARRAY;
- return (TextEdit[])fChildren.toArray(new TextEdit[fChildren.size()]);
- }
-
- /**
- * Returns the size of the managed children.
- *
- * @return the size of the children
- */
- public final int getChildrenSize() {
- if (fChildren == null)
- return 0;
- return fChildren.size();
- }
-
- /**
- * Returns the text range spawned by the given array of text edits.
- * The method requires that the given array contains at least one
- * edit. If all edits passed are deleted the method returns <code>
- * null</code>.
- *
- * @param edits an array of edits
- * @return the text range spawned by the given array of edits or
- * <code>null</code> if all edits are marked as deleted
- */
- public static IRegion getCoverage(TextEdit[] edits) {
- Assert.isTrue(edits != null && edits.length > 0);
-
- int offset= Integer.MAX_VALUE;
- int end= Integer.MIN_VALUE;
- int deleted= 0;
- for (int i= 0; i < edits.length; i++) {
- TextEdit edit= edits[i];
- if (edit.isDeleted()) {
- deleted++;
- } else {
- offset= Math.min(offset, edit.getOffset());
- end= Math.max(end, edit.getExclusiveEnd());
- }
- }
- if (edits.length == deleted) {
- return null;
- } else {
- return new Region(offset, end - offset);
- }
- }
-
- /*
- * Hook called before this edit gets added to the passed
- * parent.
- */
- /* package */ void aboutToBeAdded(TextEdit parent) {
- }
-
- //---- Object methods ------------------------------------------------------
-
- /**
- * The <code>Edit</code> implementation of this <code>Object</code>
- * method uses object identity (==).
- *
- * @param obj the other object
- * @return <code>true</code> iff <code>this == obj</code>; otherwise
- * <code>false</code> is returned
- *
- * @see Object#equals(java.lang.Object)
- */
- public final boolean equals(Object obj) {
- return this == obj; // equivalent to Object.equals
- }
-
- /**
- * The <code>Edit</code> implementation of this <code>Object</code>
- * method calls uses <code>Object#hashCode()</code> to compute its
- * hash code.
- *
- * @return the object's hash code value
- *
- * @see Object#hashCode()
- */
- public final int hashCode() {
- return super.hashCode();
- }
-
- /* non Java-doc
- * @see java.lang.Object#toString()
- */
- public String toString() {
- StringBuffer buffer= new StringBuffer("{"); //$NON-NLS-1$
- String name= getClass().getName();
- int index= name.lastIndexOf('.');
- if (index != -1) {
- buffer.append(name.substring(index + 1));
- } else {
- buffer.append(name);
- }
- buffer.append(" } "); //$NON-NLS-1$
- if (isDeleted()) {
- buffer.append("[deleted]"); //$NON-NLS-1$
- } else {
- buffer.append("["); //$NON-NLS-1$
- buffer.append(fOffset);
- buffer.append(","); //$NON-NLS-1$
- buffer.append(fLength);
- buffer.append("]"); //$NON-NLS-1$
- }
- return buffer.toString();
- }
-
- //---- Copying -------------------------------------------------------------
-
- /**
- * Creates a deep copy of the edit tree rooted at this
- * edit.
- *
- * @return a deep copy of the edit tree
- * @see #doCopy()
- */
- public final TextEdit copy() {
- TextEditCopier copier= new TextEditCopier(this);
- return copier.perform();
- }
-
- /**
- * Creates and returns a copy of this edit. The copy method should be
- * implemented in a way so that the copy can executed without causing
- * any harm to the original edit. Implementors of this method are
- * responsible for creating deep or shallow copies of referenced
- * object to fullfil this requirement.
- * <p>
- * Implementers of this method should use the copy constructor <code>
- * Edit#Edit(Edit source) to initialize the edit part of the copy.
- * Implementors aren't responsible to actually copy the children or
- * to set the right parent.
- * <p>
- * This method <b>should not be called</b> from outside the framework.
- * Please use <code>copy</code> to create a copy of a edit tree.
- *
- * @return a copy of this edit.
- * @see #copy()
- * @see #postProcessCopy(TextEditCopier)
- * @see TextEditCopier
- */
- protected abstract TextEdit doCopy();
-
- /**
- * This method is called on every edit of the copied tree to do some
- * postprocessing like connected an edit to a different edit in the tree.
- * <p>
- * This default implementation does nothing
- *
- * @param copier the copier that manages a map between original and
- * copied edit.
- * @see TextEditCopier
- */
- protected void postProcessCopy(TextEditCopier copier) {
- }
-
- //---- Visitor support -------------------------------------------------
-
- /**
- * Accepts the given visitor on a visit of the current edit.
- *
- * @param visitor the visitor object
- * @exception IllegalArgumentException if the visitor is null
- */
- public final void accept(TextEditVisitor visitor) {
- Assert.isNotNull(visitor);
- // begin with the generic pre-visit
- visitor.preVisit(this);
- // dynamic dispatch to internal method for type-specific visit/endVisit
- accept0(visitor);
- // end with the generic post-visit
- visitor.postVisit(this);
- }
-
- /**
- * Accepts the given visitor on a type-specific visit of the current edit.
- * This method must be implemented in all concrete text edits.
- * <p>
- * General template for implementation on each concrete TextEdit class:
- * <pre>
- * <code>
- * boolean visitChildren = visitor.visit(this);
- * if (visitChildren) {
- * acceptChildren(visitor);
- * }
- * </code>
- * </pre>
- * Note that the caller (<code>accept</code>) takes care of invoking
- * <code>visitor.preVisit(this)</code> and <code>visitor.postVisit(this)</code>.
- * </p>
- *
- * @param visitor the visitor object
- */
- protected abstract void accept0(TextEditVisitor visitor);
-
-
- /**
- * Accepts the given visitor on the edits children.
- * <p>
- * This method must be used by the concrete implementations of
- * <code>accept</code> to traverse list-values properties; it
- * encapsulates the proper handling of on-the-fly changes to the list.
- * </p>
- *
- * @param visitor the visitor object
- */
- protected final void acceptChildren(TextEditVisitor visitor) {
- if (fChildren == null)
- return;
- Iterator iterator= fChildren.iterator();
- while (iterator.hasNext()) {
- TextEdit curr= (TextEdit) iterator.next();
- curr.accept(visitor);
- }
- }
-
- //---- Execution -------------------------------------------------------
-
- /**
- * Applies the edit tree rooted by this edit to the given document. To check
- * if the edit tree can be applied to the document either catch <code>
- * MalformedTreeException</code> or use <code>TextEditProcessor</code> to
- * execute an edit tree.
- *
- * @param document the document to be manipulated
- * @param style flags controlling the execution of the edit tree. Valid
- * flags are: <code>CREATE_UNDO</code> and </code>UPDATE_REGIONS</code>.
- * @return a undo edit, if <code>CREATE_UNDO</code> is specified. Otherwise
- * <code>null</code> is returned.
- *
- * @exception MalformedTreeException is thrown if the tree isn't
- * in a valid state. This exception is thrown before any edit
- * is executed. So the document is still in its original state.
- * @exception BadLocationException is thrown if one of the edits
- * in the tree can't be executed. The state of the document is
- * undefined if this exception is thrown.
- *
- * @see #checkIntegrity()
- * @see #perform(IDocument)
- * @see TextEditProcessor#performEdits()
- */
- public final UndoEdit apply(IDocument document, int style) throws MalformedTreeException, BadLocationException {
- try {
- TextEditProcessor processor= new TextEditProcessor(document, this, style);
- return processor.performEdits();
- } finally {
- // unconnect from text edit processor
- fParent= null;
- }
- }
-
- /**
- * Applies the edit tree rooted by this edit to the given document. This
- * method is a convenience method for <code>apply(document, CREATE_UNDO | UPDATE_REGIONS)
- * </code>
- *
- * @see #apply(IDocument, int)
- */
- public final UndoEdit apply(IDocument document) throws MalformedTreeException, BadLocationException {
- return apply(document, CREATE_UNDO | UPDATE_REGIONS);
- }
-
- /* package */ UndoEdit dispatchPerformEdits(TextEditProcessor processor) throws BadLocationException {
- return processor.executeDo();
- }
-
- /* package */ void dispatchCheckIntegrity(TextEditProcessor processor) throws MalformedTreeException {
- processor.checkIntegrityDo();
- }
-
- //---- internal state accessors ----------------------------------------------------------
-
- /* package */ void internalSetParent(TextEdit parent) {
- if (parent != null)
- Assert.isTrue(fParent == null);
- fParent= parent;
- }
-
- /* package */ void internalSetOffset(int offset) {
- Assert.isTrue(offset >= 0);
- fOffset= offset;
- }
-
- /* package */ void internalSetLength(int length) {
- Assert.isTrue(length >= 0);
- fLength= length;
- }
-
- /* package */ List internalGetChildren() {
- return fChildren;
- }
-
- /* package */ void internalSetChildren(List children) {
- fChildren= children;
- }
-
- /* package */ void internalAdd(TextEdit child) throws MalformedTreeException {
- child.aboutToBeAdded(this);
- if (child.isDeleted())
- throw new MalformedTreeException(this, child, TextEditMessages.getString("TextEdit.deleted_edit")); //$NON-NLS-1$
- if (!covers(child))
- throw new MalformedTreeException(this, child, TextEditMessages.getString("TextEdit.range_outside")); //$NON-NLS-1$
- if (fChildren == null) {
- fChildren= new ArrayList(2);
- }
- int index= computeInsertionIndex(child);
- fChildren.add(index, child);
- child.internalSetParent(this);
- }
-
- private int computeInsertionIndex(TextEdit edit) {
- int size= fChildren.size();
- if (size == 0)
- return 0;
- TextEdit last= (TextEdit)fChildren.get(size - 1);
- if (last.getExclusiveEnd() <= edit.getOffset())
- return size;
- try {
- return -Collections.binarySearch(fChildren, edit,INSERTION_COMPARATOR) -1;
- } catch(MalformedTreeException e) {
- e.setParent(this);
- throw e;
- }
- }
-
- //---- Offset & Length updating -------------------------------------------------
-
- /**
- * Adjusts the edits offset according to the given
- * delta. This method doesn't update any children.
- *
- * @param delta the delta of the text replace operation
- */
- /* package */ void adjustOffset(int delta) {
- if (isDeleted())
- return;
- fOffset+= delta;
- Assert.isTrue(fOffset >= 0);
- }
-
- /**
- * Adjusts the edits length according to the given
- * delta. This method doesn't update any children.
- *
- * @param delta the delta of the text replace operation
- */
- /* package */ void adjustLength(int delta) {
- if (isDeleted())
- return;
- fLength+= delta;
- Assert.isTrue(fLength >= 0);
- }
-
- /**
- * Marks the edit as deleted. This method doesn't update
- * any children.
- */
- /* package */ void markAsDeleted() {
- fOffset= DELETED_VALUE;
- fLength= DELETED_VALUE;
- }
-
- //---- Edit processing ----------------------------------------------
-
- /* package */ int traverseConsistencyCheck(TextEditProcessor processor, IDocument document, List sourceEdits) {
- int result= 0;
- if (fChildren != null) {
- for (int i= fChildren.size() - 1; i >= 0; i--) {
- TextEdit child= (TextEdit)fChildren.get(i);
- result= Math.max(result, child.traverseConsistencyCheck(processor, document, sourceEdits));
- }
- }
- if (processor.considerEdit(this)) {
- performConsistencyCheck(processor, document);
- }
- return result;
- }
-
- /* package */ void performConsistencyCheck(TextEditProcessor processor, IDocument document) {
- }
-
- /* package */ void traverseSourceComputation(TextEditProcessor processor, IDocument document) {
- }
-
- /* package */ void performSourceComputation(TextEditProcessor processor, IDocument document) {
- }
-
- /* package */ int traverseDocumentUpdating(TextEditProcessor processor, IDocument document) throws BadLocationException {
- int delta= 0;
- if (fChildren != null) {
- for (int i= fChildren.size() - 1; i >= 0; i--) {
- TextEdit child= (TextEdit)fChildren.get(i);
- delta+= child.traverseDocumentUpdating(processor, document);
- }
- }
- if (processor.considerEdit(this)) {
- if (delta != 0)
- adjustLength(delta);
- int r= performDocumentUpdating(document);
- if (r != 0)
- adjustLength(r);
- delta+= r;
- }
- return delta;
- }
-
- /* package */ abstract int performDocumentUpdating(IDocument document) throws BadLocationException;
-
- /* package */ int traverseRegionUpdating(TextEditProcessor processor, IDocument document, int accumulatedDelta, boolean delete) {
- performRegionUpdating(accumulatedDelta, delete);
- if (fChildren != null) {
- boolean childDelete= delete || deleteChildren();
- for (Iterator iter= fChildren.iterator(); iter.hasNext();) {
- TextEdit child= (TextEdit)iter.next();
- accumulatedDelta= child.traverseRegionUpdating(processor, document, accumulatedDelta, childDelete);
- }
- }
- return accumulatedDelta + fDelta;
- }
-
- /* package */ void performRegionUpdating(int accumulatedDelta, boolean delete) {
- if (delete)
- markAsDeleted();
- else
- adjustOffset(accumulatedDelta);
- }
-
- /* package */ abstract boolean deleteChildren();
-
- /* package */ void moveTree(int delta) {
- adjustOffset(delta);
- if (fChildren != null) {
- for (Iterator iter= fChildren.iterator(); iter.hasNext();) {
- ((TextEdit)iter.next()).moveTree(delta);
- }
- }
- }
-
- /* package */ void deleteTree() {
- markAsDeleted();
- if (fChildren != null) {
- for (Iterator iter= fChildren.iterator(); iter.hasNext();) {
- TextEdit child= (TextEdit)iter.next();
- child.deleteTree();
- }
- }
- }
-}
-
diff --git a/org.eclipse.text/src/org/eclipse/text/edits/TextEditCopier.java b/org.eclipse.text/src/org/eclipse/text/edits/TextEditCopier.java
deleted file mode 100644
index af542e4..0000000
--- a/org.eclipse.text/src/org/eclipse/text/edits/TextEditCopier.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.text.edits;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.jface.text.Assert;
-
-/**
- * Copies a tree of text edits. A text edit copier keeps a map
- * between original and new text edits. It can be used to map
- * a copy back to its original edit.
- *
- * @since 3.0
- */
-public final class TextEditCopier {
-
- private TextEdit fEdit;
- private Map fCopies;
-
- /**
- * Constructs a new <code>TextEditCopier</code> for the
- * given edit. The actual copy is done by calling <code>
- * perform</code>.
- *
- * @param edit the edit to copy
- *
- * @see #perform()
- */
- public TextEditCopier(TextEdit edit) {
- super();
- Assert.isNotNull(edit);
- fEdit= edit;
- fCopies= new HashMap();
- }
-
- /**
- * Performs the actual copying.
- *
- * @return the copy
- */
- public TextEdit perform() {
- TextEdit result= doCopy(fEdit);
- if (result != null) {
- for (Iterator iter= fCopies.keySet().iterator(); iter.hasNext();) {
- TextEdit edit= (TextEdit)iter.next();
- edit.postProcessCopy(this);
- }
- }
- return result;
- }
-
- /**
- * Returns the copy for the original text edit.
- *
- * @param original the original for which the copy
- * is requested
- * @return the copy of the original edit or <code>null</code>
- * if the original isn't managed by this copier
- */
- public TextEdit getCopy(TextEdit original) {
- Assert.isNotNull(original);
- return (TextEdit)fCopies.get(original);
- }
-
- //---- helper methods --------------------------------------------
-
- private TextEdit doCopy(TextEdit edit) {
- TextEdit result= edit.doCopy();
- List children= edit.internalGetChildren();
- if (children != null) {
- List newChildren= new ArrayList(children.size());
- for (Iterator iter= children.iterator(); iter.hasNext();) {
- TextEdit childCopy= doCopy((TextEdit)iter.next());
- childCopy.internalSetParent(result);
- newChildren.add(childCopy);
- }
- result.internalSetChildren(newChildren);
- }
- addCopy(edit, result);
- return result;
- }
-
- private void addCopy(TextEdit original, TextEdit copy) {
- fCopies.put(original, copy);
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/text/edits/TextEditGroup.java b/org.eclipse.text/src/org/eclipse/text/edits/TextEditGroup.java
deleted file mode 100644
index 749ed80..0000000
--- a/org.eclipse.text/src/org/eclipse/text/edits/TextEditGroup.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.text.edits;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.IRegion;
-
-
-/**
- * A text edit group combines a list of {@link TextEdit}s
- * and a name into a single object. The name must be a human
- * readable string use to persent the text edit group in the
- * user interface.
- *
- * @since 3.0
- */
-public class TextEditGroup {
-
- private String fDescription;
- private List fEdits;
-
- /**
- * Creates a new text edit group with the given name.
- *
- * @param name the name of the text edit group. Must be
- * a human readable string
- */
- public TextEditGroup(String name) {
- super();
- Assert.isNotNull(name);
- fDescription= name;
- fEdits= new ArrayList(3);
- }
-
- /**
- * Creates a new text edit group with a name and a single
- * {@link TextEdit}.
- *
- * @param name the name of the text edit group. Must be
- * a human readable string
- * @param edit the edit to manage
- */
- public TextEditGroup(String name, TextEdit edit) {
- Assert.isNotNull(name);
- Assert.isNotNull(edit);
- fDescription= name;
- fEdits= new ArrayList(1);
- fEdits.add(edit);
- }
-
- /**
- * Creates a new text edit group with the given name and
- * array of edits.
- *
- * @param name the name of the text edit group. Must be
- * a human readable string
- * @param edits the array of edits
- */
- public TextEditGroup(String name, TextEdit[] edits) {
- super();
- Assert.isNotNull(name);
- Assert.isNotNull(edits);
- fDescription= name;
- fEdits= new ArrayList(Arrays.asList(edits));
- }
-
- /**
- * Returns the edit group's name.
- *
- * @return the edit group's name
- */
- public String getName() {
- return fDescription;
- }
-
- /**
- * Adds the given {@link TextEdit} to this group.
- *
- * @param edit the edit to add
- */
- public void addTextEdit(TextEdit edit) {
- fEdits.add(edit);
- }
-
- /**
- * Returns <code>true</code> if the list of managed
- * {@link TextEdit}s is empty; otherwise <code>false
- * </code> is returned.
- *
- * @return whether the list of managed text edits is
- * empty or not
- */
- public boolean isEmpty() {
- return fEdits.isEmpty();
- }
-
- /**
- * Returns an array of {@link TextEdit}s containing
- * the edits managed by this group.
- *
- * @return the managed text edits
- */
- public TextEdit[] getTextEdits() {
- return (TextEdit[]) fEdits.toArray(new TextEdit[fEdits.size()]);
- }
-
- /**
- * Returns the text region covered by the edits managed via this
- * edit group. If the group doesn't manage any edits <code>null
- * </code> is returned.
- *
- * @return the text region covered by this edit group or <code>
- * null</code> if no edits are managed
- */
- public IRegion getRegion() {
- int size= fEdits.size();
- if (size == 0) {
- return null;
- } else if (size == 1) {
- return ((TextEdit)fEdits.get(0)).getRegion();
- } else {
- return TextEdit.getCoverage((TextEdit[])fEdits.toArray(new TextEdit[fEdits.size()]));
- }
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/text/edits/TextEditMessages.java b/org.eclipse.text/src/org/eclipse/text/edits/TextEditMessages.java
deleted file mode 100644
index 1b9c1f7..0000000
--- a/org.eclipse.text/src/org/eclipse/text/edits/TextEditMessages.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.text.edits;
-
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-/* package */ class TextEditMessages {
-
- private static final String BUNDLE_NAME= "org.eclipse.text.edits.Messages"; //$NON-NLS-1$
-
- private static final ResourceBundle RESOURCE_BUNDLE= ResourceBundle.getBundle(BUNDLE_NAME);
-
- private TextEditMessages() {
- }
-
- public static String getString(String key) {
- try {
- return RESOURCE_BUNDLE.getString(key);
- } catch (MissingResourceException e) {
- return '!' + key + '!';
- }
- }
-
- public static String getFormattedString(String key, Object arg) {
- return getFormattedString(key, new Object[] { arg });
- }
-
- public static String getFormattedString(String key, Object[] args) {
- return MessageFormat.format(getString(key), args);
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/text/edits/TextEditProcessor.java b/org.eclipse.text/src/org/eclipse/text/edits/TextEditProcessor.java
deleted file mode 100644
index 47b7678..0000000
--- a/org.eclipse.text/src/org/eclipse/text/edits/TextEditProcessor.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.text.edits;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-
-/**
- * A <code>TextEditProcessor</code> manages a set of edits and applies
- * them as a whole to an <code>IDocument</code>.
- * <p>
- * This class isn't intended to be subclassed.
- *
- * @see org.eclipse.text.edits.TextEdit#apply(IDocument)
- *
- * @since 3.0
- */
-public class TextEditProcessor {
-
- private IDocument fDocument;
- private TextEdit fRoot;
- private int fStyle;
-
- private boolean fChecked;
- private MalformedTreeException fException;
-
- private List fSourceEdits;
-
- /**
- * Constructs a new edit processor for the given
- * document.
- *
- * @param document the document to manipulate
- * @param root the root of the text edit tree describing
- * the modifications. By passing a text edit a a text edit
- * processor the ownership of the edit is transfered to the
- * text edit processors. Clients must not modify the edit
- * (e.g adding new children) any longer.
- */
- public TextEditProcessor(IDocument document, TextEdit root, int style) {
- Assert.isNotNull(document);
- Assert.isNotNull(root);
- fDocument= document;
- fRoot= root;
- if (fRoot instanceof MultiTextEdit)
- ((MultiTextEdit)fRoot).defineRegion(0);
- fStyle= style;
- }
-
- /**
- * Returns the document to be manipulated.
- *
- * @return the document
- */
- public IDocument getDocument() {
- return fDocument;
- }
-
- /**
- * Returns the edit processor's root edit.
- *
- * @return the processor's root edit
- */
- public TextEdit getRoot() {
- return fRoot;
- }
-
- /**
- * Returns the style bits of the text edit processor
- *
- * @return the style bits
- * @see TextEdit#CREATE_UNDO
- * @see TextEdit#UPDATE_POSITIONS
- */
- public int getStyle() {
- return fStyle;
- }
-
- /**
- * Checks if the processor can execute all its edits.
- *
- * @return <code>true</code> if the edits can be executed. Return <code>false
- * </code>otherwise. One major reason why edits cannot be executed are wrong
- * offset or length values of edits. Calling perform in this case will very
- * likely end in a <code>BadLocationException</code>.
- */
- public boolean canPerformEdits() {
- try {
- fRoot.dispatchCheckIntegrity(this);
- fChecked= true;
- } catch (MalformedTreeException e) {
- fException= e;
- return false;
- }
- return true;
- }
-
- /**
- * Executes the text edits.
- *
- * @return an object representing the undo of the executed edits
- * @exception MalformedTreeException is thrown if the edit tree isn't
- * in a valid state. This exception is thrown before any edit is executed.
- * So the document is still in its original state.
- * @exception BadLocationException is thrown if one of the edits in the
- * tree can't be executed. The state of the document is undefined if this
- * exception is thrown.
- */
- public UndoEdit performEdits() throws MalformedTreeException, BadLocationException {
- if (!fChecked) {
- fRoot.dispatchCheckIntegrity(this);
- } else {
- if (fException != null)
- throw fException;
- }
- return fRoot.dispatchPerformEdits(this);
- }
-
- /* non Java-doc
- * Class isn't intended to be sublcassed
- */
- protected boolean considerEdit(TextEdit edit) {
- return true;
- }
-
- //---- checking --------------------------------------------------------------------
-
- /* package */ void checkIntegrityDo() throws MalformedTreeException {
- fSourceEdits= new ArrayList();
- fRoot.traverseConsistencyCheck(this, fDocument, fSourceEdits);
- if (fRoot.getExclusiveEnd() > fDocument.getLength())
- throw new MalformedTreeException(null, fRoot, TextEditMessages.getString("TextEditProcessor.invalid_length")); //$NON-NLS-1$
- }
-
- /* package */ void checkIntegrityUndo() {
- if (fRoot.getExclusiveEnd() > fDocument.getLength())
- throw new MalformedTreeException(null, fRoot, TextEditMessages.getString("TextEditProcessor.invalid_length")); //$NON-NLS-1$
- }
-
- //---- execution --------------------------------------------------------------------
-
- /* package */ UndoEdit executeDo() throws BadLocationException {
- UndoCollector collector= new UndoCollector(fRoot);
- try {
- if (createUndo())
- collector.connect(fDocument);
- computeSources();
- fRoot.traverseDocumentUpdating(this, fDocument);
- if (updateRegions()) {
- fRoot.traverseRegionUpdating(this, fDocument, 0, false);
- }
- } finally {
- collector.disconnect(fDocument);
- }
- return collector.undo;
- }
-
- private void computeSources() {
- for (Iterator iter= fSourceEdits.iterator(); iter.hasNext();) {
- List list= (List)iter.next();
- if (list != null) {
- for (Iterator edits= list.iterator(); edits.hasNext();) {
- TextEdit edit= (TextEdit)edits.next();
- edit.traverseSourceComputation(this, fDocument);
- }
- }
- }
- }
-
- /* package */ UndoEdit executeUndo() throws BadLocationException {
- UndoCollector collector= new UndoCollector(fRoot);
- try {
- if (createUndo())
- collector.connect(fDocument);
- TextEdit[] edits= fRoot.getChildren();
- for (int i= edits.length - 1; i >= 0; i--) {
- edits[i].performDocumentUpdating(fDocument);
- }
- } finally {
- collector.disconnect(fDocument);
- }
- return collector.undo;
- }
-
- private boolean createUndo() {
- return (fStyle & TextEdit.CREATE_UNDO) != 0;
- }
-
- private boolean updateRegions() {
- return (fStyle & TextEdit.UPDATE_REGIONS) != 0;
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/text/edits/TextEditVisitor.java b/org.eclipse.text/src/org/eclipse/text/edits/TextEditVisitor.java
deleted file mode 100644
index 3146561..0000000
--- a/org.eclipse.text/src/org/eclipse/text/edits/TextEditVisitor.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.text.edits;
-
-/**
- * A visitor for text edits.
- * <p>
- * For each different concrete text edit type <it>T</it> there is a method:
- * <ul>
- * <li><code>public boolean visit(<it>T</it> node)</code> - Visits the given edit to
- * perform some arbitrary operation. If <code>true </code> is returned, the given edit's
- * child edits will be visited next; however, if <code>false</code> is returned, the
- * given edit's child edits will not be visited. The default implementation provided by
- * this class calls a generic method <code>visitNode(<it>Testedit</it> node)</code>.
- * Subclasses may reimplement these method as needed.</li>
- * </ul>
- * </p>
- * <p>
- * In addition, there are methods for visiting text edits in the
- * abstract, regardless of node type:
- * <ul>
- * <li><code>public void preVisit(TextEdit edit)</code> - Visits
- * the given edit to perform some arbitrary operation.
- * This method is invoked prior to the appropriate type-specific
- * <code>visit</code> method.
- * The default implementation of this method does nothing.
- * Subclasses may reimplement this method as needed.</li>
- *
- * <li><code>public void postVisit(TextEdit edit)</code> - Visits
- * the given edit to perform some arbitrary operation.
- * This method is invoked after the appropriate type-specific
- * <code>endVisit</code> method.
- * The default implementation of this method does nothing.
- * Subclasses may reimplement this method as needed.</li>
- * </ul>
- * </p>
- * <p>
- * For edits with chldren, the child nodes are visited in increasing order.
- * </p>
- *
- * @see TextEdit#accept
- * @since 3.0
- */
-public class TextEditVisitor {
-
- /**
- * Visits the given text edit prior to the type-specific visit.
- * (before <code>visit</code>).
- * <p>
- * The default implementation does nothing. Subclasses may reimplement.
- * </p>
- *
- * @param node the node to visit
- */
- public void preVisit(TextEdit edit) {
- // default implementation: do nothing
- }
-
- /**
- * Visits the given text edit following the type-specific visit
- * (after <code>endVisit</code>).
- * <p>
- * The default implementation does nothing. Subclasses may reimplement.
- * </p>
- *
- * @param node the node to visit
- */
- public void postVisit(TextEdit edit) {
- // default implementation: do nothing
- }
-
- /**
- * Visits the given text edit. This method is called by default from
- * type-specific visits. It is not called by a edit's accept method.
- * The default implementation returns <code>true</code>.
- *
- * @return If <code>true</code> is returned, the given node's child
- * nodes will be visited next; however, if <code>false</code> is
- * returned, the given node's child nodes will not be visited.
- */
- public boolean visitNode(TextEdit edit) {
- return true;
- }
-
- /**
- * Visists a <code>CopySourceEdit</code> instance.
- *
- * @return If <code>true</code> is returned, the given node's child
- * nodes will be visited next; however, if <code>false</code> is
- * returned, the given node's child nodes will not be visited.
- */
- public boolean visit(CopySourceEdit edit) {
- return visitNode(edit);
- }
-
- /**
- * Visists a <code>CopyTargetEdit</code> instance.
- *
- * @return If <code>true</code> is returned, the given node's child
- * nodes will be visited next; however, if <code>false</code> is
- * returned, the given node's child nodes will not be visited.
- */
- public boolean visit(CopyTargetEdit edit) {
- return visitNode(edit);
- }
-
- /**
- * Visists a <code>MoveSourceEdit</code> instance.
- *
- * @return If <code>true</code> is returned, the given node's child
- * nodes will be visited next; however, if <code>false</code> is
- * returned, the given node's child nodes will not be visited.
- */
- public boolean visit(MoveSourceEdit edit) {
- return visitNode(edit);
- }
-
- /**
- * Visists a <code>MoveTargetEdit</code> instance.
- *
- * @return If <code>true</code> is returned, the given node's child
- * nodes will be visited next; however, if <code>false</code> is
- * returned, the given node's child nodes will not be visited.
- */
- public boolean visit(MoveTargetEdit edit) {
- return visitNode(edit);
- }
-
- /**
- * Visists a <code>RangeMarker</code> instance.
- *
- * @return If <code>true</code> is returned, the given node's child
- * nodes will be visited next; however, if <code>false</code> is
- * returned, the given node's child nodes will not be visited.
- */
- public boolean visit(RangeMarker edit) {
- return visitNode(edit);
- }
-
- /**
- * Visists a <code>CopyingRangeMarker</code> instance.
- *
- * @return If <code>true</code> is returned, the given node's child
- * nodes will be visited next; however, if <code>false</code> is
- * returned, the given node's child nodes will not be visited.
- */
- public boolean visit(CopyingRangeMarker edit) {
- return visitNode(edit);
- }
-
- /**
- * Visists a <code>DeleteEdit</code> instance.
- *
- * @return If <code>true</code> is returned, the given node's child
- * nodes will be visited next; however, if <code>false</code> is
- * returned, the given node's child nodes will not be visited.
- */
- public boolean visit(DeleteEdit edit) {
- return visitNode(edit);
- }
-
- /**
- * Visists a <code>InsertEdit</code> instance.
- *
- * @return If <code>true</code> is returned, the given node's child
- * nodes will be visited next; however, if <code>false</code> is
- * returned, the given node's child nodes will not be visited.
- */
- public boolean visit(InsertEdit edit) {
- return visitNode(edit);
- }
-
- /**
- * Visists a <code>ReplaceEdit</code> instance.
- *
- * @return If <code>true</code> is returned, the given node's child
- * nodes will be visited next; however, if <code>false</code> is
- * returned, the given node's child nodes will not be visited.
- */
- public boolean visit(ReplaceEdit edit) {
- return visitNode(edit);
- }
-
- /**
- * Visists a <code>UndoEdit</code> instance.
- *
- * @return If <code>true</code> is returned, the given node's child
- * nodes will be visited next; however, if <code>false</code> is
- * returned, the given node's child nodes will not be visited.
- */
- public boolean visit(UndoEdit edit) {
- return visitNode(edit);
- }
-
- /**
- * Visists a <code>MultiTextEdit</code> instance.
- *
- * @return If <code>true</code> is returned, the given node's child
- * nodes will be visited next; however, if <code>false</code> is
- * returned, the given node's child nodes will not be visited.
- */
- public boolean visit(MultiTextEdit edit) {
- return visitNode(edit);
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/text/edits/TreeIterationInfo.java b/org.eclipse.text/src/org/eclipse/text/edits/TreeIterationInfo.java
deleted file mode 100644
index 2cf0873..0000000
--- a/org.eclipse.text/src/org/eclipse/text/edits/TreeIterationInfo.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.text.edits;
-
-import org.eclipse.jface.text.Assert;
-
-
-/* package */ class TreeIterationInfo {
-
- public static interface Visitor {
- public void visit(TextEdit edit);
- }
-
- private int fMark= -1;
- private TextEdit[][] fEditStack= new TextEdit[10][];
- private int[] fIndexStack= new int[10];
-
- public int getSize() {
- return fMark + 1;
- }
- public void push(TextEdit[] edits) {
- if (++fMark == fEditStack.length) {
- TextEdit[][] t1= new TextEdit[fEditStack.length * 2][];
- System.arraycopy(fEditStack, 0, t1, 0, fEditStack.length);
- fEditStack= t1;
- int[] t2= new int[fEditStack.length];
- System.arraycopy(fIndexStack, 0, t2, 0, fIndexStack.length);
- fIndexStack= t2;
- }
- fEditStack[fMark]= edits;
- fIndexStack[fMark]= -1;
- }
- public void setIndex(int index) {
- fIndexStack[fMark]= index;
- }
- public void pop() {
- fEditStack[fMark]= null;
- fIndexStack[fMark]= -1;
- fMark--;
- }
- public void accept(Visitor visitor) {
- for (int i= fMark; i >= 0; i--) {
- Assert.isTrue(fIndexStack[i] >= 0);
- int start= fIndexStack[i] + 1;
- TextEdit[] edits= fEditStack[i];
- for (int s= start; s < edits.length; s++) {
- visitor.visit(edits[s]);
- }
- }
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/text/edits/UndoCollector.java b/org.eclipse.text/src/org/eclipse/text/edits/UndoCollector.java
deleted file mode 100644
index dd4b58f..0000000
--- a/org.eclipse.text/src/org/eclipse/text/edits/UndoCollector.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.text.edits;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentListener;
-
-
-/* package */ class UndoCollector implements IDocumentListener {
-
- protected UndoEdit undo;
- private int fOffset;
- private int fLength;
-
- public UndoCollector(TextEdit root) {
- fOffset= root.getOffset();
- fLength= root.getLength();
- }
-
- public void connect(IDocument document) {
- document.addDocumentListener(this);
- undo= new UndoEdit();
- }
-
- public void disconnect(IDocument document) {
- if (undo != null) {
- document.removeDocumentListener(this);
- undo.defineRegion(fOffset, fLength);
- }
- }
-
- public void documentChanged(DocumentEvent event) {
- fLength+= getDelta(event);
- }
-
- private static int getDelta(DocumentEvent event) {
- String text= event.getText();
- return (text == null ? -event.getLength() : text.length()) - event.getLength();
- }
-
- public void documentAboutToBeChanged(DocumentEvent event) {
- int offset= event.getOffset();
- int currentLength= event.getLength();
- String currentText= null;
- try {
- currentText= event.getDocument().get(offset, currentLength);
- } catch (BadLocationException cannotHappen) {
- Assert.isTrue(false, "Can't happen"); //$NON-NLS-1$
- }
-
- undo.add(new ReplaceEdit(offset, event.getText().length(), currentText));
- }
-}
diff --git a/org.eclipse.text/src/org/eclipse/text/edits/UndoEdit.java b/org.eclipse.text/src/org/eclipse/text/edits/UndoEdit.java
deleted file mode 100644
index 584f610..0000000
--- a/org.eclipse.text/src/org/eclipse/text/edits/UndoEdit.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.text.edits;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-
-/**
- * This class encapsulates the reverse changes of an executed text
- * edit tree. To apply an undo memento to a document use method
- * <code>apply(IDocument)</code>.
- * <p>
- * Clients can add additional children to an undo edit nor can they
- * add an undo edit as a child to another edit. Doing so results in
- * both cases in a <code>MalformedTreeException<code>.
- *
- * @since 3.0
- */
-public final class UndoEdit extends TextEdit {
-
- /* package */ UndoEdit() {
- super(0, Integer.MAX_VALUE);
- }
-
- private UndoEdit(UndoEdit other) {
- super(other);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.text.edits.TextEdit#internalAdd(org.eclipse.text.edits.TextEdit)
- */
- /* package */ void internalAdd(TextEdit child) throws MalformedTreeException {
- throw new MalformedTreeException(null, this, TextEditMessages.getString("UndoEdit.no_children")); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.text.edits.MultiTextEdit#aboutToBeAdded(org.eclipse.text.edits.TextEdit)
- */
- /* package */ void aboutToBeAdded(TextEdit parent) {
- throw new MalformedTreeException(parent, this, TextEditMessages.getString("UndoEdit.can_not_be_added")); //$NON-NLS-1$
- }
-
- /* package */ UndoEdit dispatchPerformEdits(TextEditProcessor processor) throws BadLocationException {
- return processor.executeUndo();
- }
-
- /* package */ void dispatchCheckIntegrity(TextEditProcessor processor) throws MalformedTreeException {
- processor.checkIntegrityUndo();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.text.edits.TextEdit#doCopy()
- */
- protected TextEdit doCopy() {
- return new UndoEdit(this);
- }
-
- /* (non-Javadoc)
- * @see TextEdit#accept0
- */
- protected void accept0(TextEditVisitor visitor) {
- boolean visitChildren = visitor.visit(this);
- if (visitChildren) {
- acceptChildren(visitor);
- }
- }
-
- /* (non-Javadoc)
- * @see TextEdit#performDocumentUpdating
- */
- /* package */ int performDocumentUpdating(IDocument document) throws BadLocationException {
- fDelta= 0;
- return fDelta;
- }
-
- /* package */ void add(ReplaceEdit edit) {
- List children= internalGetChildren();
- if (children == null) {
- children= new ArrayList(2);
- internalSetChildren(children);
- }
- children.add(edit);
- }
-
- /* package */ void defineRegion(int offset, int length) {
- internalSetOffset(offset);
- internalSetLength(length);
- }
-
- /* package */ boolean deleteChildren() {
- return false;
- }
-}
-
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/SelectMarkerRulerAction.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/SelectMarkerRulerAction.java
index 3c13a48..6b49e11 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/SelectMarkerRulerAction.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/SelectMarkerRulerAction.java
@@ -13,11 +13,12 @@
package org.eclipse.ui.texteditor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ResourceBundle;
-
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
@@ -26,12 +27,10 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
-
import org.eclipse.swt.widgets.Shell;
-
import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
-
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.Position;
@@ -41,12 +40,11 @@
import org.eclipse.jface.text.source.IAnnotationModel;
import org.eclipse.jface.text.source.IVerticalRuler;
import org.eclipse.jface.text.source.IVerticalRulerInfo;
-
import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.views.tasklist.TaskList;
/**
@@ -112,19 +110,35 @@
public void run() {
IMarker marker= chooseMarker(fMarkers);
- if (MarkerUtilities.isMarkerType(marker, IMarker.TASK) || MarkerUtilities.isMarkerType(marker, IMarker.PROBLEM)) {
+ boolean isProblemMarker= MarkerUtilities.isMarkerType(marker, IMarker.PROBLEM);
+ boolean isTaskMarker= MarkerUtilities.isMarkerType(marker, IMarker.TASK);
+ if (isProblemMarker || isTaskMarker) {
IWorkbenchPage page= fTextEditor.getSite().getPage();
- IViewPart view= view= page.findView("org.eclipse.ui.views.TaskList"); //$NON-NLS-1$
- if (view instanceof TaskList) {
- StructuredSelection ss= new StructuredSelection(marker);
- ((TaskList) view).setSelection(ss, true);
- } else {
- int offset= MarkerUtilities.getCharStart(marker);
- int endOffset= MarkerUtilities.getCharEnd(marker);
- if (offset > -1 && endOffset > -1)
- fTextEditor.selectAndReveal(offset, endOffset - offset);
+ IViewPart view= page.findView(isProblemMarker ? IPageLayout.ID_PROBLEM_VIEW: IPageLayout.ID_TASK_LIST); //$NON-NLS-1$ //$NON-NLS-2$
+ if (view != null) {
+ boolean selectionSet= false;
+ try {
+ Method method= view.getClass().getMethod("setSelection", new Class[] { IStructuredSelection.class, boolean.class}); //$NON-NLS-1$
+ method.invoke(view, new Object[] {new StructuredSelection(marker), Boolean.TRUE });
+ selectionSet= true;
+ } catch (NoSuchMethodException x) {
+ selectionSet= false;
+ } catch (IllegalAccessException x) {
+ selectionSet= false;
+ } catch (InvocationTargetException x) {
+ selectionSet= false;
+ }
+
+ if (selectionSet)
+ return;
}
}
+ // Select and reveal in editor
+ int offset= MarkerUtilities.getCharStart(marker);
+ int endOffset= MarkerUtilities.getCharEnd(marker);
+ if (offset > -1 && endOffset > -1)
+ fTextEditor.selectAndReveal(offset, endOffset - offset);
+
}
/**
diff --git a/org.eclipse.ui.examples.javaeditor/.classpath b/org.eclipse.ui.examples.javaeditor/.classpath
deleted file mode 100644
index 81b25ea..0000000
--- a/org.eclipse.ui.examples.javaeditor/.classpath
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="Eclipse Java Editor Example"/>
- <classpathentry kind="src" path="Template Editor Example"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/org.eclipse.ui.examples.javaeditor/.cvsignore b/org.eclipse.ui.examples.javaeditor/.cvsignore
deleted file mode 100644
index c5e82d7..0000000
--- a/org.eclipse.ui.examples.javaeditor/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
\ No newline at end of file
diff --git a/org.eclipse.ui.examples.javaeditor/.project b/org.eclipse.ui.examples.javaeditor/.project
deleted file mode 100644
index 55e75ae..0000000
--- a/org.eclipse.ui.examples.javaeditor/.project
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.ui.examples.javaeditor</name>
- <comment></comment>
- <projects>
- <project>org.eclipse.core.filebuffers</project>
- <project>org.eclipse.core.runtime.compatibility</project>
- <project>org.eclipse.jface.text</project>
- <project>org.eclipse.ui</project>
- <project>org.eclipse.ui.editors</project>
- <project>org.eclipse.ui.views</project>
- <project>org.eclipse.ui.workbench.texteditor</project>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.eclipse.pde.PluginNature</nature>
- </natures>
-</projectDescription>
diff --git a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaActionContributor.java b/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaActionContributor.java
deleted file mode 100644
index 6c9f577..0000000
--- a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaActionContributor.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.examples.javaeditor;
-
-
-import org.eclipse.jface.action.*;
-import org.eclipse.ui.*;
-import org.eclipse.ui.editors.text.TextEditorActionContributor;
-import org.eclipse.ui.texteditor.*;
-
-/**
- * Contributes interesting Java actions to the desktop's Edit menu and the toolbar.
- */
-public class JavaActionContributor extends TextEditorActionContributor {
-
- protected RetargetTextEditorAction fContentAssistProposal;
- protected RetargetTextEditorAction fContentAssistTip;
- protected TextEditorAction fTogglePresentation;
-
- /**
- * Default constructor.
- */
- public JavaActionContributor() {
- super();
- fContentAssistProposal= new RetargetTextEditorAction(JavaEditorMessages.getResourceBundle(), "ContentAssistProposal."); //$NON-NLS-1$
- fContentAssistProposal.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
- fContentAssistTip= new RetargetTextEditorAction(JavaEditorMessages.getResourceBundle(), "ContentAssistTip."); //$NON-NLS-1$
- fContentAssistTip.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_CONTEXT_INFORMATION);
- fTogglePresentation= new PresentationAction();
- }
-
- /*
- * @see IEditorActionBarContributor#init(IActionBars)
- */
- public void init(IActionBars bars) {
- super.init(bars);
-
- IMenuManager menuManager= bars.getMenuManager();
- IMenuManager editMenu= menuManager.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
- if (editMenu != null) {
- editMenu.add(new Separator());
- editMenu.add(fContentAssistProposal);
- editMenu.add(fContentAssistTip);
- }
-
- IToolBarManager toolBarManager= bars.getToolBarManager();
- if (toolBarManager != null) {
- toolBarManager.add(new Separator());
- toolBarManager.add(fTogglePresentation);
- }
- }
-
- private void doSetActiveEditor(IEditorPart part) {
- super.setActiveEditor(part);
-
- ITextEditor editor= null;
- if (part instanceof ITextEditor)
- editor= (ITextEditor) part;
-
- fContentAssistProposal.setAction(getAction(editor, "ContentAssistProposal")); //$NON-NLS-1$
- fContentAssistTip.setAction(getAction(editor, "ContentAssistTip")); //$NON-NLS-1$
-
- fTogglePresentation.setEditor(editor);
- fTogglePresentation.update();
- }
-
- /*
- * @see IEditorActionBarContributor#setActiveEditor(IEditorPart)
- */
- public void setActiveEditor(IEditorPart part) {
- super.setActiveEditor(part);
- doSetActiveEditor(part);
- }
-
- /*
- * @see IEditorActionBarContributor#dispose()
- */
- public void dispose() {
- doSetActiveEditor(null);
- super.dispose();
- }
-}
diff --git a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaAnnotationHover.java b/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaAnnotationHover.java
deleted file mode 100644
index 3ef3d17..0000000
--- a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaAnnotationHover.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.examples.javaeditor;
-
-
-import org.eclipse.jface.text.*;
-import org.eclipse.jface.text.source.IAnnotationHover;
-import org.eclipse.jface.text.source.ISourceViewer;
-
-/**
- * The JavaAnnotationHover provides the hover support for java editors.
- */
-
-public class JavaAnnotationHover implements IAnnotationHover {
-
- /* (non-Javadoc)
- * Method declared on IAnnotationHover
- */
- public String getHoverInfo(ISourceViewer sourceViewer, int lineNumber) {
- IDocument document= sourceViewer.getDocument();
-
- try {
- IRegion info= document.getLineInformation(lineNumber);
- return document.get(info.getOffset(), info.getLength());
- } catch (BadLocationException x) {
- }
-
- return null;
- }
-}
diff --git a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaContentOutlinePage.java b/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaContentOutlinePage.java
deleted file mode 100644
index 748d1b0..0000000
--- a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaContentOutlinePage.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.examples.javaeditor;
-
-
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.text.*;
-import org.eclipse.jface.viewers.*;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
-
-/**
- * A content outline page which always represents the content of the
- * connected editor in 10 segments.
- */
-public class JavaContentOutlinePage extends ContentOutlinePage {
-
- /**
- * A segment element.
- */
- protected static class Segment {
- public String name;
- public Position position;
-
- public Segment(String name, Position position) {
- this.name= name;
- this.position= position;
- }
-
- public String toString() {
- return name;
- }
- }
-
- /**
- * Divides the editor's document into ten segments and provides elements for them.
- */
- protected class ContentProvider implements ITreeContentProvider {
-
- protected final static String SEGMENTS= "__java_segments"; //$NON-NLS-1$
- protected IPositionUpdater fPositionUpdater= new DefaultPositionUpdater(SEGMENTS);
- protected List fContent= new ArrayList(10);
-
- protected void parse(IDocument document) {
-
- int lines= document.getNumberOfLines();
- int increment= Math.max(Math.round(lines / 10), 10);
-
- for (int line= 0; line < lines; line += increment) {
-
- int length= increment;
- if (line + increment > lines)
- length= lines - line;
-
- try {
-
- int offset= document.getLineOffset(line);
- int end= document.getLineOffset(line + length);
- length= end - offset;
- Position p= new Position(offset, length);
- document.addPosition(SEGMENTS, p);
- fContent.add(new Segment(MessageFormat.format(JavaEditorMessages.getString("OutlinePage.segment.title_pattern"), new Object[] { new Integer(offset) }), p)); //$NON-NLS-1$
-
- } catch (BadPositionCategoryException x) {
- } catch (BadLocationException x) {
- }
- }
- }
-
- /*
- * @see IContentProvider#inputChanged(Viewer, Object, Object)
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- if (oldInput != null) {
- IDocument document= fDocumentProvider.getDocument(oldInput);
- if (document != null) {
- try {
- document.removePositionCategory(SEGMENTS);
- } catch (BadPositionCategoryException x) {
- }
- document.removePositionUpdater(fPositionUpdater);
- }
- }
-
- fContent.clear();
-
- if (newInput != null) {
- IDocument document= fDocumentProvider.getDocument(newInput);
- if (document != null) {
- document.addPositionCategory(SEGMENTS);
- document.addPositionUpdater(fPositionUpdater);
-
- parse(document);
- }
- }
- }
-
- /*
- * @see IContentProvider#dispose
- */
- public void dispose() {
- if (fContent != null) {
- fContent.clear();
- fContent= null;
- }
- }
-
- /*
- * @see IContentProvider#isDeleted(Object)
- */
- public boolean isDeleted(Object element) {
- return false;
- }
-
- /*
- * @see IStructuredContentProvider#getElements(Object)
- */
- public Object[] getElements(Object element) {
- return fContent.toArray();
- }
-
- /*
- * @see ITreeContentProvider#hasChildren(Object)
- */
- public boolean hasChildren(Object element) {
- return element == fInput;
- }
-
- /*
- * @see ITreeContentProvider#getParent(Object)
- */
- public Object getParent(Object element) {
- if (element instanceof Segment)
- return fInput;
- return null;
- }
-
- /*
- * @see ITreeContentProvider#getChildren(Object)
- */
- public Object[] getChildren(Object element) {
- if (element == fInput)
- return fContent.toArray();
- return new Object[0];
- }
- }
-
- protected Object fInput;
- protected IDocumentProvider fDocumentProvider;
- protected ITextEditor fTextEditor;
-
- /**
- * Creates a content outline page using the given provider and the given editor.
- */
- public JavaContentOutlinePage(IDocumentProvider provider, ITextEditor editor) {
- super();
- fDocumentProvider= provider;
- fTextEditor= editor;
- }
-
- /* (non-Javadoc)
- * Method declared on ContentOutlinePage
- */
- public void createControl(Composite parent) {
-
- super.createControl(parent);
-
- TreeViewer viewer= getTreeViewer();
- viewer.setContentProvider(new ContentProvider());
- viewer.setLabelProvider(new LabelProvider());
- viewer.addSelectionChangedListener(this);
-
- if (fInput != null)
- viewer.setInput(fInput);
- }
-
- /* (non-Javadoc)
- * Method declared on ContentOutlinePage
- */
- public void selectionChanged(SelectionChangedEvent event) {
-
- super.selectionChanged(event);
-
- ISelection selection= event.getSelection();
- if (selection.isEmpty())
- fTextEditor.resetHighlightRange();
- else {
- Segment segment= (Segment) ((IStructuredSelection) selection).getFirstElement();
- int start= segment.position.getOffset();
- int length= segment.position.getLength();
- try {
- fTextEditor.setHighlightRange(start, length, true);
- } catch (IllegalArgumentException x) {
- fTextEditor.resetHighlightRange();
- }
- }
- }
-
- /**
- * Sets the input of the outline page
- */
- public void setInput(Object input) {
- fInput= input;
- update();
- }
-
- /**
- * Updates the outline page.
- */
- public void update() {
- TreeViewer viewer= getTreeViewer();
-
- if (viewer != null) {
- Control control= viewer.getControl();
- if (control != null && !control.isDisposed()) {
- control.setRedraw(false);
- viewer.setInput(fInput);
- viewer.expandAll();
- control.setRedraw(true);
- }
- }
- }
-}
diff --git a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaDocumentSetupParticipant.java b/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaDocumentSetupParticipant.java
deleted file mode 100644
index 45d4bf0..0000000
--- a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaDocumentSetupParticipant.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**********************************************************************
-Copyright (c) 2000, 2003 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-
-Contributors:
- IBM Corporation - Initial implementation
-**********************************************************************/
-package org.eclipse.ui.examples.javaeditor;
-
-import org.eclipse.core.filebuffers.IDocumentSetupParticipant;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentExtension3;
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.jface.text.rules.DefaultPartitioner;
-
-/**
- *
- */
-public class JavaDocumentSetupParticipant implements IDocumentSetupParticipant {
-
- /**
- */
- public JavaDocumentSetupParticipant() {
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IDocumentSetupParticipant#setup(org.eclipse.jface.text.IDocument)
- */
- public void setup(IDocument document) {
- if (document instanceof IDocumentExtension3) {
- IDocumentExtension3 extension3= (IDocumentExtension3) document;
- IDocumentPartitioner partitioner= new DefaultPartitioner(JavaEditorExamplePlugin.getDefault().getJavaPartitionScanner(), JavaPartitionScanner.JAVA_PARTITION_TYPES);
- extension3.setDocumentPartitioner(JavaEditorExamplePlugin.JAVA_PARTITIONING, partitioner);
- partitioner.connect(document);
- }
- }
-}
diff --git a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaEditor.java b/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaEditor.java
deleted file mode 100644
index bc4b055..0000000
--- a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaEditor.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.examples.javaeditor;
-
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.MenuManager;
-
-import org.eclipse.jface.text.source.ISourceViewer;
-
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.editors.text.TextEditor;
-import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
-import org.eclipse.ui.texteditor.TextOperationAction;
-import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
-
-
-/**
- * Java specific text editor.
- */
-public class JavaEditor extends TextEditor {
-
- /** The outline page */
- private JavaContentOutlinePage fOutlinePage;
-
- /**
- * Default constructor.
- */
- public JavaEditor() {
- super();
- }
-
- /** The <code>JavaEditor</code> implementation of this
- * <code>AbstractTextEditor</code> method extend the
- * actions to add those specific to the receiver
- */
- protected void createActions() {
- super.createActions();
-
- IAction a= new TextOperationAction(JavaEditorMessages.getResourceBundle(), "ContentAssistProposal.", this, ISourceViewer.CONTENTASSIST_PROPOSALS); //$NON-NLS-1$
- a.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
- setAction("ContentAssistProposal", a); //$NON-NLS-1$
-
- a= new TextOperationAction(JavaEditorMessages.getResourceBundle(), "ContentAssistTip.", this, ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION); //$NON-NLS-1$
- a.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_CONTEXT_INFORMATION);
- setAction("ContentAssistTip", a); //$NON-NLS-1$
- }
-
- /** The <code>JavaEditor</code> implementation of this
- * <code>AbstractTextEditor</code> method performs any extra
- * disposal actions required by the java editor.
- */
- public void dispose() {
- if (fOutlinePage != null)
- fOutlinePage.setInput(null);
- super.dispose();
- }
-
- /** The <code>JavaEditor</code> implementation of this
- * <code>AbstractTextEditor</code> method performs any extra
- * revert behavior required by the java editor.
- */
- public void doRevertToSaved() {
- super.doRevertToSaved();
- if (fOutlinePage != null)
- fOutlinePage.update();
- }
-
- /** The <code>JavaEditor</code> implementation of this
- * <code>AbstractTextEditor</code> method performs any extra
- * save behavior required by the java editor.
- */
- public void doSave(IProgressMonitor monitor) {
- super.doSave(monitor);
- if (fOutlinePage != null)
- fOutlinePage.update();
- }
-
- /** The <code>JavaEditor</code> implementation of this
- * <code>AbstractTextEditor</code> method performs any extra
- * save as behavior required by the java editor.
- */
- public void doSaveAs() {
- super.doSaveAs();
- if (fOutlinePage != null)
- fOutlinePage.update();
- }
-
- /** The <code>JavaEditor</code> implementation of this
- * <code>AbstractTextEditor</code> method performs sets the
- * input of the outline page after AbstractTextEditor has set input.
- */
- public void doSetInput(IEditorInput input) throws CoreException {
- super.doSetInput(input);
- if (fOutlinePage != null)
- fOutlinePage.setInput(input);
- }
-
- /** The <code>JavaEditor</code> implementation of this
- * <code>AbstractTextEditor</code> method adds any
- * JavaEditor specific entries.
- */
- public void editorContextMenuAboutToShow(MenuManager menu) {
- super.editorContextMenuAboutToShow(menu);
- addAction(menu, "ContentAssistProposal"); //$NON-NLS-1$
- addAction(menu, "ContentAssistTip"); //$NON-NLS-1$
- }
-
- /** The <code>JavaEditor</code> implementation of this
- * <code>AbstractTextEditor</code> method performs gets
- * the java content outline page if request is for a an
- * outline page.
- */
- public Object getAdapter(Class required) {
- if (IContentOutlinePage.class.equals(required)) {
- if (fOutlinePage == null) {
- fOutlinePage= new JavaContentOutlinePage(getDocumentProvider(), this);
- if (getEditorInput() != null)
- fOutlinePage.setInput(getEditorInput());
- }
- return fOutlinePage;
- }
- return super.getAdapter(required);
- }
-
- /* (non-Javadoc)
- * Method declared on AbstractTextEditor
- */
- protected void initializeEditor() {
- super.initializeEditor();
- setSourceViewerConfiguration(new JavaSourceViewerConfiguration());
-// setEditorContextMenuId("#JavaEditorContext"); //$NON-NLS-1$
-// setRulerContextMenuId("#JavaRulerContext"); //$NON-NLS-1$
- }
-}
diff --git a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaEditorExamplePlugin.java b/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaEditorExamplePlugin.java
deleted file mode 100644
index 8eb40a0..0000000
--- a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaEditorExamplePlugin.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/**********************************************************************
-Copyright (c) 2000, 2003 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-
-Contributors:
- IBM Corporation - Initial implementation
-**********************************************************************/
-package org.eclipse.ui.examples.javaeditor;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPluginDescriptor;
-
-import org.eclipse.jface.text.rules.RuleBasedScanner;
-
-import org.eclipse.ui.examples.javaeditor.java.JavaCodeScanner;
-import org.eclipse.ui.examples.javaeditor.javadoc.JavaDocScanner;
-import org.eclipse.ui.examples.javaeditor.util.JavaColorProvider;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-
-/**
- * The example java editor plugin class.
- *
- * @since 3.0
- */
-public class JavaEditorExamplePlugin extends AbstractUIPlugin {
-
- public final static String JAVA_PARTITIONING= "__java_example_partitioning"; //$NON-NLS-1$
-
- private static JavaEditorExamplePlugin fgInstance;
- private JavaPartitionScanner fPartitionScanner;
- private JavaColorProvider fColorProvider;
- private JavaCodeScanner fCodeScanner;
- private JavaDocScanner fDocScanner;
-
- /**
- * Creates a new plugin instance.
- *
- * @param descriptor
- */
- public JavaEditorExamplePlugin(IPluginDescriptor descriptor) {
- super(descriptor);
- fgInstance= this;
- }
-
- /**
- * Returns the default plugin instance.
- *
- * @return the default plugin instance
- */
- public static JavaEditorExamplePlugin getDefault() {
- return fgInstance;
- }
-
- /*
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#shutdown()
- */
- public void shutdown() throws CoreException {
- super.shutdown();
- }
-
- /**
- * Return a scanner for creating java partitions.
- */
- public JavaPartitionScanner getJavaPartitionScanner() {
- if (fPartitionScanner == null)
- fPartitionScanner= new JavaPartitionScanner();
- return fPartitionScanner;
- }
-
- /**
- * Returns the singleton scanner.
- */
- public RuleBasedScanner getJavaCodeScanner() {
- if (fCodeScanner == null)
- fCodeScanner= new JavaCodeScanner(getJavaColorProvider());
- return fCodeScanner;
- }
-
- /**
- * Returns the singleton color provider.
- */
- public JavaColorProvider getJavaColorProvider() {
- if (fColorProvider == null)
- fColorProvider= new JavaColorProvider();
- return fColorProvider;
- }
-
- /**
- * Returns the singleton document scanner.
- */
- public RuleBasedScanner getJavaDocScanner() {
- if (fDocScanner == null)
- fDocScanner= new JavaDocScanner(fColorProvider);
- return fDocScanner;
- }
-}
diff --git a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaEditorMessages.java b/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaEditorMessages.java
deleted file mode 100644
index c037d22..0000000
--- a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaEditorMessages.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.examples.javaeditor;
-
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-public class JavaEditorMessages {
-
- private static final String RESOURCE_BUNDLE= "org.eclipse.ui.examples.javaeditor.JavaEditorMessages";//$NON-NLS-1$
-
- private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
-
- private JavaEditorMessages() {
- }
-
- public static String getString(String key) {
- try {
- return fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- }
-
- public static ResourceBundle getResourceBundle() {
- return fgResourceBundle;
- }
-}
diff --git a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaEditorMessages.properties b/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaEditorMessages.properties
deleted file mode 100644
index 441a4a4..0000000
--- a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaEditorMessages.properties
+++ /dev/null
@@ -1,39 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2003 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-## Actions ##
-
-ContentAssistProposal.label=Content Assist@Ctrl+SPACE
-ContentAssistProposal.tooltip=Content Assist
-ContentAssistProposal.image=
-ContentAssistProposal.description=Content Assist
-
-ContentAssistTip.label=Content Tip@Ctrl+SHIFT+SPACE
-ContentAssistTip.tooltip=Content Tip
-ContentAssistTip.image=
-ContentAssistTip.description=Content Tip
-
-TogglePresentation.label=Change Presentation
-TogglePresentation.tooltip=Enable/Disable Segmented Source Viewer
-TogglePresentation.image=togglepresentation.gif
-TogglePresentation.description=Enable/Disable Segmented Source Viewer
-
-OutlinePage.segment.title_pattern=position {0}
-
-AutoIndent.error.bad_location_1=JavaAutoIndentStrategy.getAutoIndentString: BadLocationException
-AutoIndent.error.bad_location_2=JavaAutoIndentStrategy.calcShiftBackReplace: BadLocationException
-
-CompletionProcessor.ContextInfo.display.pattern=proposal {0} at position {1}
-CompletionProcessor.ContextInfo.value.pattern=proposal {0} valid from {1} to {2}
-CompletionProcessor.Proposal.ContextInfo.pattern={0} valid 5 characters around insertion point
-CompletionProcessor.Proposal.hoverinfo.pattern=Java keyword: {0}
-
-JavaTextHover.emptySelection=empty selection
diff --git a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaPartitionScanner.java b/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaPartitionScanner.java
deleted file mode 100644
index 54bb2ed..0000000
--- a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaPartitionScanner.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.examples.javaeditor;
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.text.rules.*;
-
-/**
- * This scanner recognizes the JavaDoc comments and Java multi line comments.
- */
-public class JavaPartitionScanner extends RuleBasedPartitionScanner {
-
- public final static String JAVA_MULTILINE_COMMENT= "__java_multiline_comment"; //$NON-NLS-1$
- public final static String JAVA_DOC= "__java_javadoc"; //$NON-NLS-1$
- public final static String[] JAVA_PARTITION_TYPES= new String[] { JAVA_MULTILINE_COMMENT, JAVA_DOC };
-
- /**
- * Detector for empty comments.
- */
- static class EmptyCommentDetector implements IWordDetector {
-
- /* (non-Javadoc)
- * Method declared on IWordDetector
- */
- public boolean isWordStart(char c) {
- return (c == '/');
- }
-
- /* (non-Javadoc)
- * Method declared on IWordDetector
- */
- public boolean isWordPart(char c) {
- return (c == '*' || c == '/');
- }
- }
-
- /**
- *
- */
- static class WordPredicateRule extends WordRule implements IPredicateRule {
-
- private IToken fSuccessToken;
-
- public WordPredicateRule(IToken successToken) {
- super(new EmptyCommentDetector());
- fSuccessToken= successToken;
- addWord("/**/", fSuccessToken); //$NON-NLS-1$
- }
-
- /*
- * @see org.eclipse.jface.text.rules.IPredicateRule#evaluate(ICharacterScanner, boolean)
- */
- public IToken evaluate(ICharacterScanner scanner, boolean resume) {
- return super.evaluate(scanner);
- }
-
- /*
- * @see org.eclipse.jface.text.rules.IPredicateRule#getSuccessToken()
- */
- public IToken getSuccessToken() {
- return fSuccessToken;
- }
- }
-
- /**
- * Creates the partitioner and sets up the appropriate rules.
- */
- public JavaPartitionScanner() {
- super();
-
- IToken javaDoc= new Token(JAVA_DOC);
- IToken comment= new Token(JAVA_MULTILINE_COMMENT);
-
- List rules= new ArrayList();
-
- // Add rule for single line comments.
- rules.add(new EndOfLineRule("//", Token.UNDEFINED)); //$NON-NLS-1$
-
- // Add rule for strings and character constants.
- rules.add(new SingleLineRule("\"", "\"", Token.UNDEFINED, '\\')); //$NON-NLS-2$ //$NON-NLS-1$
- rules.add(new SingleLineRule("'", "'", Token.UNDEFINED, '\\')); //$NON-NLS-2$ //$NON-NLS-1$
-
- // Add special case word rule.
- rules.add(new WordPredicateRule(comment));
-
- // Add rules for multi-line comments and javadoc.
- rules.add(new MultiLineRule("/**", "*/", javaDoc, (char) 0, true)); //$NON-NLS-1$ //$NON-NLS-2$
- rules.add(new MultiLineRule("/*", "*/", comment, (char) 0, true)); //$NON-NLS-1$ //$NON-NLS-2$
-
- IPredicateRule[] result= new IPredicateRule[rules.size()];
- rules.toArray(result);
- setPredicateRules(result);
- }
-}
diff --git a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaSourceViewerConfiguration.java b/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaSourceViewerConfiguration.java
deleted file mode 100644
index 5df2a87..0000000
--- a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaSourceViewerConfiguration.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.examples.javaeditor;
-
-
-import org.eclipse.swt.graphics.RGB;
-
-import org.eclipse.jface.text.DefaultAutoIndentStrategy;
-import org.eclipse.jface.text.IAutoIndentStrategy;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextDoubleClickStrategy;
-import org.eclipse.jface.text.ITextHover;
-import org.eclipse.jface.text.TextAttribute;
-import org.eclipse.jface.text.contentassist.ContentAssistant;
-import org.eclipse.jface.text.contentassist.IContentAssistant;
-import org.eclipse.jface.text.presentation.IPresentationReconciler;
-import org.eclipse.jface.text.presentation.PresentationReconciler;
-import org.eclipse.jface.text.rules.BufferedRuleBasedScanner;
-import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
-import org.eclipse.jface.text.rules.Token;
-import org.eclipse.jface.text.source.IAnnotationHover;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.text.source.SourceViewerConfiguration;
-
-import org.eclipse.ui.examples.javaeditor.java.JavaAutoIndentStrategy;
-import org.eclipse.ui.examples.javaeditor.java.JavaCompletionProcessor;
-import org.eclipse.ui.examples.javaeditor.java.JavaDoubleClickSelector;
-import org.eclipse.ui.examples.javaeditor.javadoc.JavaDocCompletionProcessor;
-import org.eclipse.ui.examples.javaeditor.util.JavaColorProvider;
-
-/**
- * Example configuration for an <code>SourceViewer</code> which shows Java code.
- */
-public class JavaSourceViewerConfiguration extends SourceViewerConfiguration {
-
-
- /**
- * Single token scanner.
- */
- static class SingleTokenScanner extends BufferedRuleBasedScanner {
- public SingleTokenScanner(TextAttribute attribute) {
- setDefaultReturnToken(new Token(attribute));
- }
- }
-
-
- /**
- * Default constructor.
- */
- public JavaSourceViewerConfiguration() {
- }
-
- /* (non-Javadoc)
- * Method declared on SourceViewerConfiguration
- */
- public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
- return new JavaAnnotationHover();
- }
-
- /* (non-Javadoc)
- * Method declared on SourceViewerConfiguration
- */
- public IAutoIndentStrategy getAutoIndentStrategy(ISourceViewer sourceViewer, String contentType) {
- return (IDocument.DEFAULT_CONTENT_TYPE.equals(contentType) ? new JavaAutoIndentStrategy() : new DefaultAutoIndentStrategy());
- }
-
- /*
- * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getConfiguredDocumentPartitioning(org.eclipse.jface.text.source.ISourceViewer)
- */
- public String getConfiguredDocumentPartitioning(ISourceViewer sourceViewer) {
- return JavaEditorExamplePlugin.JAVA_PARTITIONING;
- }
-
- /* (non-Javadoc)
- * Method declared on SourceViewerConfiguration
- */
- public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
- return new String[] { IDocument.DEFAULT_CONTENT_TYPE, JavaPartitionScanner.JAVA_DOC, JavaPartitionScanner.JAVA_MULTILINE_COMMENT };
- }
-
- /* (non-Javadoc)
- * Method declared on SourceViewerConfiguration
- */
- public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
-
- ContentAssistant assistant= new ContentAssistant();
- assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
- assistant.setContentAssistProcessor(new JavaCompletionProcessor(), IDocument.DEFAULT_CONTENT_TYPE);
- assistant.setContentAssistProcessor(new JavaDocCompletionProcessor(), JavaPartitionScanner.JAVA_DOC);
-
- assistant.enableAutoActivation(true);
- assistant.setAutoActivationDelay(500);
- assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
- assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
- assistant.setContextInformationPopupBackground(JavaEditorExamplePlugin.getDefault().getJavaColorProvider().getColor(new RGB(150, 150, 0)));
-
- return assistant;
- }
-
- /* (non-Javadoc)
- * Method declared on SourceViewerConfiguration
- */
- public String getDefaultPrefix(ISourceViewer sourceViewer, String contentType) {
- return (IDocument.DEFAULT_CONTENT_TYPE.equals(contentType) ? "//" : null); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * Method declared on SourceViewerConfiguration
- */
- public ITextDoubleClickStrategy getDoubleClickStrategy(ISourceViewer sourceViewer, String contentType) {
- return new JavaDoubleClickSelector();
- }
-
- /* (non-Javadoc)
- * Method declared on SourceViewerConfiguration
- */
- public String[] getIndentPrefixes(ISourceViewer sourceViewer, String contentType) {
- return new String[] { "\t", " " }; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /* (non-Javadoc)
- * Method declared on SourceViewerConfiguration
- */
- public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
-
- JavaColorProvider provider= JavaEditorExamplePlugin.getDefault().getJavaColorProvider();
- PresentationReconciler reconciler= new PresentationReconciler();
- reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
-
- DefaultDamagerRepairer dr= new DefaultDamagerRepairer(JavaEditorExamplePlugin.getDefault().getJavaCodeScanner());
- reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
- reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
-
- dr= new DefaultDamagerRepairer(new SingleTokenScanner(new TextAttribute(provider.getColor(JavaColorProvider.JAVADOC_DEFAULT))));
- reconciler.setDamager(dr, JavaPartitionScanner.JAVA_DOC);
- reconciler.setRepairer(dr, JavaPartitionScanner.JAVA_DOC);
-
- dr= new DefaultDamagerRepairer(new SingleTokenScanner(new TextAttribute(provider.getColor(JavaColorProvider.MULTI_LINE_COMMENT))));
- reconciler.setDamager(dr, JavaPartitionScanner.JAVA_MULTILINE_COMMENT);
- reconciler.setRepairer(dr, JavaPartitionScanner.JAVA_MULTILINE_COMMENT);
-
- return reconciler;
- }
-
- /* (non-Javadoc)
- * Method declared on SourceViewerConfiguration
- */
- public int getTabWidth(ISourceViewer sourceViewer) {
- return 4;
- }
-
- /* (non-Javadoc)
- * Method declared on SourceViewerConfiguration
- */
- public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) {
- return new JavaTextHover();
- }
-}
diff --git a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaTextHover.java b/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaTextHover.java
deleted file mode 100644
index f4f55e8..0000000
--- a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaTextHover.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.examples.javaeditor;
-
-
-import org.eclipse.jface.text.*;
-import org.eclipse.swt.graphics.Point;
-
-/**
- * Example implementation for an <code>ITextHover</code> which hovers over Java code.
- */
-public class JavaTextHover implements ITextHover {
-
- /* (non-Javadoc)
- * Method declared on ITextHover
- */
- public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
- if (hoverRegion != null) {
- try {
- if (hoverRegion.getLength() > -1)
- return textViewer.getDocument().get(hoverRegion.getOffset(), hoverRegion.getLength());
- } catch (BadLocationException x) {
- }
- }
- return JavaEditorMessages.getString("JavaTextHover.emptySelection"); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * Method declared on ITextHover
- */
- public IRegion getHoverRegion(ITextViewer textViewer, int offset) {
- Point selection= textViewer.getSelectedRange();
- if (selection.x <= offset && offset < selection.x + selection.y)
- return new Region(selection.x, selection.y);
- return new Region(offset, 0);
- }
-}
diff --git a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/PresentationAction.java b/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/PresentationAction.java
deleted file mode 100644
index fcdb150..0000000
--- a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/PresentationAction.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.examples.javaeditor;
-
-
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.TextEditorAction;
-
-/**
- * A toolbar action which toggles the presentation model of the
- * connected text editor. The editor shows either the highlight range
- * only or always the whole document.
- */
-public class PresentationAction extends TextEditorAction {
-
- /**
- * Constructs and updates the action.
- */
- public PresentationAction() {
- super(JavaEditorMessages.getResourceBundle(), "TogglePresentation.", null); //$NON-NLS-1$
- update();
- }
-
- /* (non-Javadoc)
- * Method declared on IAction
- */
- public void run() {
-
- ITextEditor editor= getTextEditor();
-
- editor.resetHighlightRange();
- boolean show= editor.showsHighlightRangeOnly();
- setChecked(!show);
- editor.showHighlightRangeOnly(!show);
- }
-
- /* (non-Javadoc)
- * Method declared on TextEditorAction
- */
- public void update() {
- setChecked(getTextEditor() != null && getTextEditor().showsHighlightRangeOnly());
- setEnabled(true);
- }
-}
diff --git a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/java/JavaAutoIndentStrategy.java b/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/java/JavaAutoIndentStrategy.java
deleted file mode 100644
index cf459d9..0000000
--- a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/java/JavaAutoIndentStrategy.java
+++ /dev/null
@@ -1,263 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.examples.javaeditor.java;
-
-
-import org.eclipse.jface.text.*;
-
-/**
- * Auto indent strategy sensitive to brackets.
- */
-public class JavaAutoIndentStrategy extends DefaultAutoIndentStrategy {
-
- public JavaAutoIndentStrategy() {
- }
-
- /* (non-Javadoc)
- * Method declared on IAutoIndentStrategy
- */
- public void customizeDocumentCommand(IDocument d, DocumentCommand c) {
- if (c.length == 0 && c.text != null && endsWithDelimiter(d, c.text))
- smartIndentAfterNewLine(d, c);
- else if ("}".equals(c.text)) { //$NON-NLS-1$
- smartInsertAfterBracket(d, c);
- }
- }
-
- /**
- * Returns whether or not the text ends with one of the given search strings.
- */
- private boolean endsWithDelimiter(IDocument d, String txt) {
- String[] delimiters= d.getLegalLineDelimiters();
- if (delimiters != null)
- return TextUtilities.endsWith(delimiters, txt) > -1;
- return false;
- }
-
- /**
- * Returns the line number of the next bracket after end.
- * @returns the line number of the next matching bracket after end
- * @param document - the document being parsed
- * @param line - the line to start searching back from
- * @param end - the end position to search back from
- * @param closingBracketIncrease - the number of brackets to skip
- */
- protected int findMatchingOpenBracket(IDocument document, int line, int end, int closingBracketIncrease) throws BadLocationException {
-
- int start= document.getLineOffset(line);
- int brackcount= getBracketCount(document, start, end, false) - closingBracketIncrease;
-
- // sum up the brackets counts of each line (closing brackets count negative,
- // opening positive) until we find a line the brings the count to zero
- while (brackcount < 0) {
- line--;
- if (line < 0) {
- return -1;
- }
- start= document.getLineOffset(line);
- end= start + document.getLineLength(line) - 1;
- brackcount += getBracketCount(document, start, end, false);
- }
- return line;
- }
-
- /**
- * Returns the bracket value of a section of text. Closing brackets have a value of -1 and
- * open brackets have a value of 1.
- * @returns the line number of the next matching bracket after end
- * @param document - the document being parsed
- * @param start - the start position for the search
- * @param end - the end position for the search
- * @param ignoreCloseBrackets - whether or not to ignore closing brackets in the count
- */
- private int getBracketCount(IDocument document, int start, int end, boolean ignoreCloseBrackets) throws BadLocationException {
-
- int begin = start;
- int bracketcount= 0;
- while (begin < end) {
- char curr= document.getChar(begin);
- begin++;
- switch (curr) {
- case '/' :
- if (begin < end) {
- char next= document.getChar(begin);
- if (next == '*') {
- // a comment starts, advance to the comment end
- begin= getCommentEnd(document, begin + 1, end);
- } else if (next == '/') {
- // '//'-comment: nothing to do anymore on this line
- begin= end;
- }
- }
- break;
- case '*' :
- if (begin < end) {
- char next= document.getChar(begin);
- if (next == '/') {
- // we have been in a comment: forget what we read before
- bracketcount= 0;
- begin++;
- }
- }
- break;
- case '{' :
- bracketcount++;
- ignoreCloseBrackets= false;
- break;
- case '}' :
- if (!ignoreCloseBrackets) {
- bracketcount--;
- }
- break;
- case '"' :
- case '\'' :
- begin= getStringEnd(document, begin, end, curr);
- break;
- default :
- }
- }
- return bracketcount;
- }
-
- /**
- * Returns the end position a comment starting at pos.
- * @returns the end position a comment starting at pos
- * @param document - the document being parsed
- * @param position - the start position for the search
- * @param end - the end position for the search
- */
- private int getCommentEnd(IDocument document, int position, int end) throws BadLocationException {
- int currentPosition = position;
- while (currentPosition < end) {
- char curr= document.getChar(currentPosition);
- currentPosition++;
- if (curr == '*') {
- if (currentPosition < end && document.getChar(currentPosition) == '/') {
- return currentPosition + 1;
- }
- }
- }
- return end;
- }
-
- /**
- * Returns the String at line with the leading whitespace removed.
- * @returns the String at line with the leading whitespace removed.
- * @param document - the document being parsed
- * @param line - the line being searched
- */
- protected String getIndentOfLine(IDocument document, int line) throws BadLocationException {
- if (line > -1) {
- int start= document.getLineOffset(line);
- int end= start + document.getLineLength(line) - 1;
- int whiteend= findEndOfWhiteSpace(document, start, end);
- return document.get(start, whiteend - start);
- } else {
- return ""; //$NON-NLS-1$
- }
- }
-
- /**
- * Returns the position of the character in the document after position.
- * @returns the next location of character.
- * @param document - the document being parsed
- * @param position - the position to start searching from
- * @param end - the end of the document
- * @param character - the character you are trying to match
- */
- private int getStringEnd(IDocument document, int position, int end, char character) throws BadLocationException {
- int currentPosition = position;
- while (currentPosition < end) {
- char currentCharacter= document.getChar(currentPosition);
- currentPosition++;
- if (currentCharacter == '\\') {
- // ignore escaped characters
- currentPosition++;
- } else if (currentCharacter == character) {
- return currentPosition;
- }
- }
- return end;
- }
-
- /**
- * Set the indent of a new line based on the command provided in the supplied document.
- * @param document - the document being parsed
- * @param command - the command being performed
- */
- protected void smartIndentAfterNewLine(IDocument document, DocumentCommand command) {
-
- int docLength= document.getLength();
- if (command.offset == -1 || docLength == 0)
- return;
-
- try {
- int p= (command.offset == docLength ? command.offset - 1 : command.offset);
- int line= document.getLineOfOffset(p);
-
- StringBuffer buf= new StringBuffer(command.text);
- if (command.offset < docLength && document.getChar(command.offset) == '}') {
- int indLine= findMatchingOpenBracket(document, line, command.offset, 0);
- if (indLine == -1) {
- indLine= line;
- }
- buf.append(getIndentOfLine(document, indLine));
- } else {
- int start= document.getLineOffset(line);
- int whiteend= findEndOfWhiteSpace(document, start, command.offset);
- buf.append(document.get(start, whiteend - start));
- if (getBracketCount(document, start, command.offset, true) > 0) {
- buf.append('\t');
- }
- }
- command.text= buf.toString();
-
- } catch (BadLocationException excp) {
- System.out.println(JavaEditorMessages.getString("AutoIndent.error.bad_location_1")); //$NON-NLS-1$
- }
- }
-
- /**
- * Set the indent of a bracket based on the command provided in the supplied document.
- * @param document - the document being parsed
- * @param command - the command being performed
- */
- protected void smartInsertAfterBracket(IDocument document, DocumentCommand command) {
- if (command.offset == -1 || document.getLength() == 0)
- return;
-
- try {
- int p= (command.offset == document.getLength() ? command.offset - 1 : command.offset);
- int line= document.getLineOfOffset(p);
- int start= document.getLineOffset(line);
- int whiteend= findEndOfWhiteSpace(document, start, command.offset);
-
- // shift only when line does not contain any text up to the closing bracket
- if (whiteend == command.offset) {
- // evaluate the line with the opening bracket that matches out closing bracket
- int indLine= findMatchingOpenBracket(document, line, command.offset, 1);
- if (indLine != -1 && indLine != line) {
- // take the indent of the found line
- StringBuffer replaceText= new StringBuffer(getIndentOfLine(document, indLine));
- // add the rest of the current line including the just added close bracket
- replaceText.append(document.get(whiteend, command.offset - whiteend));
- replaceText.append(command.text);
- // modify document command
- command.length= command.offset - start;
- command.offset= start;
- command.text= replaceText.toString();
- }
- }
- } catch (BadLocationException excp) {
- System.out.println(JavaEditorMessages.getString("AutoIndent.error.bad_location_2")); //$NON-NLS-1$
- }
- }
-}
diff --git a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/java/JavaCodeScanner.java b/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/java/JavaCodeScanner.java
deleted file mode 100644
index 3b9535e..0000000
--- a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/java/JavaCodeScanner.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.examples.javaeditor.java;
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.text.TextAttribute;
-import org.eclipse.jface.text.rules.*;
-import org.eclipse.ui.examples.javaeditor.util.*;
-
-/**
- * A Java code scanner.
- */
-public class JavaCodeScanner extends RuleBasedScanner {
-
- private static String[] fgKeywords= { "abstract", "break", "case", "catch", "class", "continue", "default", "do", "else", "extends", "final", "finally", "for", "if", "implements", "import", "instanceof", "interface", "native", "new", "package", "private", "protected", "public", "return", "static", "super", "switch", "synchronized", "this", "throw", "throws", "transient", "try", "volatile", "while" }; //$NON-NLS-36$ //$NON-NLS-35$ //$NON-NLS-34$ //$NON-NLS-33$ //$NON-NLS-32$ //$NON-NLS-31$ //$NON-NLS-30$ //$NON-NLS-29$ //$NON-NLS-28$ //$NON-NLS-27$ //$NON-NLS-26$ //$NON-NLS-25$ //$NON-NLS-24$ //$NON-NLS-23$ //$NON-NLS-22$ //$NON-NLS-21$ //$NON-NLS-20$ //$NON-NLS-19$ //$NON-NLS-18$ //$NON-NLS-17$ //$NON-NLS-16$ //$NON-NLS-15$ //$NON-NLS-14$ //$NON-NLS-13$ //$NON-NLS-12$ //$NON-NLS-11$ //$NON-NLS-10$ //$NON-NLS-9$ //$NON-NLS-8$ //$NON-NLS-7$ //$NON-NLS-6$ //$NON-NLS-5$ //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$
-
- private static String[] fgTypes= { "void", "boolean", "char", "byte", "short", "int", "long", "float", "double" }; //$NON-NLS-1$ //$NON-NLS-5$ //$NON-NLS-7$ //$NON-NLS-6$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-2$
-
- private static String[] fgConstants= { "false", "null", "true" }; //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$
-
- /**
- * Creates a Java code scanner
- */
- public JavaCodeScanner(JavaColorProvider provider) {
-
- IToken keyword= new Token(new TextAttribute(provider.getColor(JavaColorProvider.KEYWORD)));
- IToken type= new Token(new TextAttribute(provider.getColor(JavaColorProvider.TYPE)));
- IToken string= new Token(new TextAttribute(provider.getColor(JavaColorProvider.STRING)));
- IToken comment= new Token(new TextAttribute(provider.getColor(JavaColorProvider.SINGLE_LINE_COMMENT)));
- IToken other= new Token(new TextAttribute(provider.getColor(JavaColorProvider.DEFAULT)));
-
- List rules= new ArrayList();
-
- // Add rule for single line comments.
- rules.add(new EndOfLineRule("//", comment)); //$NON-NLS-1$
-
- // Add rule for strings and character constants.
- rules.add(new SingleLineRule("\"", "\"", string, '\\')); //$NON-NLS-2$ //$NON-NLS-1$
- rules.add(new SingleLineRule("'", "'", string, '\\')); //$NON-NLS-2$ //$NON-NLS-1$
-
- // Add generic whitespace rule.
- rules.add(new WhitespaceRule(new JavaWhitespaceDetector()));
-
- // Add word rule for keywords, types, and constants.
- WordRule wordRule= new WordRule(new JavaWordDetector(), other);
- for (int i= 0; i < fgKeywords.length; i++)
- wordRule.addWord(fgKeywords[i], keyword);
- for (int i= 0; i < fgTypes.length; i++)
- wordRule.addWord(fgTypes[i], type);
- for (int i= 0; i < fgConstants.length; i++)
- wordRule.addWord(fgConstants[i], type);
- rules.add(wordRule);
-
- IRule[] result= new IRule[rules.size()];
- rules.toArray(result);
- setRules(result);
- }
-}
diff --git a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/java/JavaCompletionProcessor.java b/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/java/JavaCompletionProcessor.java
deleted file mode 100644
index 1059d44..0000000
--- a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/java/JavaCompletionProcessor.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.examples.javaeditor.java;
-
-
-import java.text.MessageFormat;
-
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.TextPresentation;
-import org.eclipse.jface.text.contentassist.*;
-
-/**
- * Example Java completion processor.
- */
-public class JavaCompletionProcessor implements IContentAssistProcessor {
-
- /**
- * Simple content assist tip closer. The tip is valid in a range
- * of 5 characters around its popup location.
- */
- protected static class Validator implements IContextInformationValidator, IContextInformationPresenter {
-
- protected int fInstallOffset;
-
- /*
- * @see IContextInformationValidator#isContextInformationValid(int)
- */
- public boolean isContextInformationValid(int offset) {
- return Math.abs(fInstallOffset - offset) < 5;
- }
-
- /*
- * @see IContextInformationValidator#install(IContextInformation, ITextViewer, int)
- */
- public void install(IContextInformation info, ITextViewer viewer, int offset) {
- fInstallOffset= offset;
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContextInformationPresenter#updatePresentation(int, TextPresentation)
- */
- public boolean updatePresentation(int documentPosition, TextPresentation presentation) {
- return false;
- }
- }
-
- protected final static String[] fgProposals=
- { "abstract", "boolean", "break", "byte", "case", "catch", "char", "class", "continue", "default", "do", "double", "else", "extends", "false", "final", "finally", "float", "for", "if", "implements", "import", "instanceof", "int", "interface", "long", "native", "new", "null", "package", "private", "protected", "public", "return", "short", "static", "super", "switch", "synchronized", "this", "throw", "throws", "transient", "true", "try", "void", "volatile", "while" }; //$NON-NLS-48$ //$NON-NLS-47$ //$NON-NLS-46$ //$NON-NLS-45$ //$NON-NLS-44$ //$NON-NLS-43$ //$NON-NLS-42$ //$NON-NLS-41$ //$NON-NLS-40$ //$NON-NLS-39$ //$NON-NLS-38$ //$NON-NLS-37$ //$NON-NLS-36$ //$NON-NLS-35$ //$NON-NLS-34$ //$NON-NLS-33$ //$NON-NLS-32$ //$NON-NLS-31$ //$NON-NLS-30$ //$NON-NLS-29$ //$NON-NLS-28$ //$NON-NLS-27$ //$NON-NLS-26$ //$NON-NLS-25$ //$NON-NLS-24$ //$NON-NLS-23$ //$NON-NLS-22$ //$NON-NLS-21$ //$NON-NLS-20$ //$NON-NLS-19$ //$NON-NLS-18$ //$NON-NLS-17$ //$NON-NLS-16$ //$NON-NLS-15$ //$NON-NLS-14$ //$NON-NLS-13$ //$NON-NLS-12$ //$NON-NLS-11$ //$NON-NLS-10$ //$NON-NLS-9$ //$NON-NLS-8$ //$NON-NLS-7$ //$NON-NLS-6$ //$NON-NLS-5$ //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$
-
- protected IContextInformationValidator fValidator= new Validator();
-
- /* (non-Javadoc)
- * Method declared on IContentAssistProcessor
- */
- public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) {
- ICompletionProposal[] result= new ICompletionProposal[fgProposals.length];
- for (int i= 0; i < fgProposals.length; i++) {
- IContextInformation info= new ContextInformation(fgProposals[i], MessageFormat.format(JavaEditorMessages.getString("CompletionProcessor.Proposal.ContextInfo.pattern"), new Object[] { fgProposals[i] })); //$NON-NLS-1$
- result[i]= new CompletionProposal(fgProposals[i], documentOffset, 0, fgProposals[i].length(), null, fgProposals[i], info, MessageFormat.format(JavaEditorMessages.getString("CompletionProcessor.Proposal.hoverinfo.pattern"), new Object[] { fgProposals[i]})); //$NON-NLS-1$
- }
- return result;
- }
-
- /* (non-Javadoc)
- * Method declared on IContentAssistProcessor
- */
- public IContextInformation[] computeContextInformation(ITextViewer viewer, int documentOffset) {
- IContextInformation[] result= new IContextInformation[5];
- for (int i= 0; i < result.length; i++)
- result[i]= new ContextInformation(
- MessageFormat.format(JavaEditorMessages.getString("CompletionProcessor.ContextInfo.display.pattern"), new Object[] { new Integer(i), new Integer(documentOffset) }), //$NON-NLS-1$
- MessageFormat.format(JavaEditorMessages.getString("CompletionProcessor.ContextInfo.value.pattern"), new Object[] { new Integer(i), new Integer(documentOffset - 5), new Integer(documentOffset + 5)})); //$NON-NLS-1$
- return result;
- }
-
- /* (non-Javadoc)
- * Method declared on IContentAssistProcessor
- */
- public char[] getCompletionProposalAutoActivationCharacters() {
- return new char[] { '.', '(' };
- }
-
- /* (non-Javadoc)
- * Method declared on IContentAssistProcessor
- */
- public char[] getContextInformationAutoActivationCharacters() {
- return new char[] { '#' };
- }
-
- /* (non-Javadoc)
- * Method declared on IContentAssistProcessor
- */
- public IContextInformationValidator getContextInformationValidator() {
- return fValidator;
- }
-
- /* (non-Javadoc)
- * Method declared on IContentAssistProcessor
- */
- public String getErrorMessage() {
- return null;
- }
-}
diff --git a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/java/JavaDoubleClickSelector.java b/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/java/JavaDoubleClickSelector.java
deleted file mode 100644
index ace486e..0000000
--- a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/java/JavaDoubleClickSelector.java
+++ /dev/null
@@ -1,240 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.examples.javaeditor.java;
-
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextDoubleClickStrategy;
-import org.eclipse.jface.text.ITextViewer;
-
-/**
- * Double click strategy aware of Java identifier syntax rules.
- */
-public class JavaDoubleClickSelector implements ITextDoubleClickStrategy {
-
- protected ITextViewer fText;
- protected int fPos;
- protected int fStartPos;
- protected int fEndPos;
-
- protected static char[] fgBrackets= { '{', '}', '(', ')', '[', ']', '"', '"' };
-
- /*
- * Create a JavaDoubleClickSelector.
- */
- public JavaDoubleClickSelector() {
- super();
- }
-
- /* (non-Javadoc)
- * Method declared on ITextDoubleClickStrategy
- */
- public void doubleClicked(ITextViewer text) {
-
- fPos= text.getSelectedRange().x;
-
- if (fPos < 0)
- return;
-
- fText= text;
-
- if (!selectBracketBlock())
- selectWord();
- }
-
- /**
- * Match the brackets at the current selection. Return true if successful,
- * false otherwise.
- */
- protected boolean matchBracketsAt() {
-
- char prevChar, nextChar;
-
- int i;
- int bracketIndex1= fgBrackets.length;
- int bracketIndex2= fgBrackets.length;
-
- fStartPos= -1;
- fEndPos= -1;
-
- // get the chars preceding and following the start position
- try {
-
- IDocument doc= fText.getDocument();
-
- prevChar= doc.getChar(fPos - 1);
- nextChar= doc.getChar(fPos);
-
- // is the char either an open or close bracket?
- for (i= 0; i < fgBrackets.length; i= i + 2) {
- if (prevChar == fgBrackets[i]) {
- fStartPos= fPos - 1;
- bracketIndex1= i;
- }
- }
- for (i= 1; i < fgBrackets.length; i= i + 2) {
- if (nextChar == fgBrackets[i]) {
- fEndPos= fPos;
- bracketIndex2= i;
- }
- }
-
- if (fStartPos > -1 && bracketIndex1 < bracketIndex2) {
- fEndPos= searchForClosingBracket(fStartPos, prevChar, fgBrackets[bracketIndex1 + 1], doc);
- if (fEndPos > -1)
- return true;
- else
- fStartPos= -1;
- } else if (fEndPos > -1) {
- fStartPos= searchForOpenBracket(fEndPos, fgBrackets[bracketIndex2 - 1], nextChar, doc);
- if (fStartPos > -1)
- return true;
- else
- fEndPos= -1;
- }
-
- } catch (BadLocationException x) {
- }
-
- return false;
- }
-
- /**
- * Select the word at the current selection. Return true if successful,
- * false otherwise.
- */
- protected boolean matchWord() {
-
- IDocument doc= fText.getDocument();
-
- try {
-
- int pos= fPos;
- char c;
-
- while (pos >= 0) {
- c= doc.getChar(pos);
- if (!Character.isJavaIdentifierPart(c))
- break;
- --pos;
- }
-
- fStartPos= pos;
-
- pos= fPos;
- int length= doc.getLength();
-
- while (pos < length) {
- c= doc.getChar(pos);
- if (!Character.isJavaIdentifierPart(c))
- break;
- ++pos;
- }
-
- fEndPos= pos;
-
- return true;
-
- } catch (BadLocationException x) {
- }
-
- return false;
- }
-
- /**
- * Returns the position of the closing bracket after startPosition.
- * @returns the location of the closing bracket.
- * @param startPosition - the beginning position
- * @param openBracket - the character that represents the open bracket
- * @param closeBracket - the character that represents the close bracket
- * @param document - the document being searched
- */
- protected int searchForClosingBracket(int startPosition, char openBracket, char closeBracket, IDocument document) throws BadLocationException {
- int stack= 1;
- int closePosition= startPosition + 1;
- int length= document.getLength();
- char nextChar;
-
- while (closePosition < length && stack > 0) {
- nextChar= document.getChar(closePosition);
- if (nextChar == openBracket && nextChar != closeBracket)
- stack++;
- else if (nextChar == closeBracket)
- stack--;
- closePosition++;
- }
-
- if (stack == 0)
- return closePosition - 1;
- else
- return -1;
-
- }
-
- /**
- * Returns the position of the open bracket before startPosition.
- * @returns the location of the starting bracket.
- * @param startPosition - the beginning position
- * @param openBracket - the character that represents the open bracket
- * @param closeBracket - the character that represents the close bracket
- * @param document - the document being searched
- */
- protected int searchForOpenBracket(int startPosition, char openBracket, char closeBracket, IDocument document) throws BadLocationException {
- int stack= 1;
- int openPos= startPosition - 1;
- char nextChar;
-
- while (openPos >= 0 && stack > 0) {
- nextChar= document.getChar(openPos);
- if (nextChar == closeBracket && nextChar != openBracket)
- stack++;
- else if (nextChar == openBracket)
- stack--;
- openPos--;
- }
-
- if (stack == 0)
- return openPos + 1;
- else
- return -1;
- }
-
- /**
- * Select the area between the selected bracket and the closing bracket. Return
- * true if successful.
- */
- protected boolean selectBracketBlock() {
- if (matchBracketsAt()) {
-
- if (fStartPos == fEndPos)
- fText.setSelectedRange(fStartPos, 0);
- else
- fText.setSelectedRange(fStartPos + 1, fEndPos - fStartPos - 1);
-
- return true;
- }
- return false;
- }
-
- /**
- * Select the word at the current selection.
- */
- protected void selectWord() {
- if (matchWord()) {
-
- if (fStartPos == fEndPos)
- fText.setSelectedRange(fStartPos, 0);
- else
- fText.setSelectedRange(fStartPos + 1, fEndPos - fStartPos - 1);
- }
- }
-}
diff --git a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/java/JavaEditorMessages.java b/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/java/JavaEditorMessages.java
deleted file mode 100644
index 3b1937f..0000000
--- a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/java/JavaEditorMessages.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.examples.javaeditor.java;
-
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-public class JavaEditorMessages {
-
- private static final String RESOURCE_BUNDLE= "org.eclipse.ui.examples.javaeditor.JavaEditorMessages";//$NON-NLS-1$
-
- private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
-
- private JavaEditorMessages() {
- }
-
- 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.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/javadoc/JavaDocCompletionProcessor.java b/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/javadoc/JavaDocCompletionProcessor.java
deleted file mode 100644
index ffd4d21..0000000
--- a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/javadoc/JavaDocCompletionProcessor.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.examples.javaeditor.javadoc;
-
-
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.contentassist.*;
-
-/**
- * Example Java doc completion processor.
- */
-public class JavaDocCompletionProcessor implements IContentAssistProcessor {
-
- protected final static String[] fgProposals= { "@author", "@deprecated", "@exception", "@param", "@return", "@see", "@serial", "@serialData", "@serialField", "@since", "@throws", "@version" }; //$NON-NLS-12$ //$NON-NLS-11$ //$NON-NLS-10$ //$NON-NLS-7$ //$NON-NLS-9$ //$NON-NLS-8$ //$NON-NLS-6$ //$NON-NLS-5$ //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$
-
- /* (non-Javadoc)
- * Method declared on IContentAssistProcessor
- */
- public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) {
- ICompletionProposal[] result= new ICompletionProposal[fgProposals.length];
- for (int i= 0; i < fgProposals.length; i++)
- result[i]= new CompletionProposal(fgProposals[i], documentOffset, 0, fgProposals[i].length());
- return result;
- }
-
- /* (non-Javadoc)
- * Method declared on IContentAssistProcessor
- */
- public IContextInformation[] computeContextInformation(ITextViewer viewer, int documentOffset) {
- return null;
- }
-
- /* (non-Javadoc)
- * Method declared on IContentAssistProcessor
- */
- public char[] getCompletionProposalAutoActivationCharacters() {
- return null;
- }
-
- /* (non-Javadoc)
- * Method declared on IContentAssistProcessor
- */
- public char[] getContextInformationAutoActivationCharacters() {
- return null;
- }
-
- /* (non-Javadoc)
- * Method declared on IContentAssistProcessor
- */
- public IContextInformationValidator getContextInformationValidator() {
- return null;
- }
-
- /* (non-Javadoc)
- * Method declared on IContentAssistProcessor
- */
- public String getErrorMessage() {
- return null;
- }
-}
diff --git a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/javadoc/JavaDocScanner.java b/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/javadoc/JavaDocScanner.java
deleted file mode 100644
index c101cf0..0000000
--- a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/javadoc/JavaDocScanner.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.examples.javaeditor.javadoc;
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.text.TextAttribute;
-import org.eclipse.jface.text.rules.*;
-import org.eclipse.ui.examples.javaeditor.util.JavaColorProvider;
-import org.eclipse.ui.examples.javaeditor.util.JavaWhitespaceDetector;
-
-/**
- * A rule based JavaDoc scanner.
- */
-public class JavaDocScanner extends RuleBasedScanner {
-
- /**
- * A key word detector.
- */
- static class JavaDocWordDetector implements IWordDetector {
-
- /* (non-Javadoc)
- * Method declared on IWordDetector
- */
- public boolean isWordStart(char c) {
- return (c == '@');
- }
-
- /* (non-Javadoc)
- * Method declared on IWordDetector
- */
- public boolean isWordPart(char c) {
- return Character.isLetter(c);
- }
- }
-
- private static String[] fgKeywords= { "@author", "@deprecated", "@exception", "@param", "@return", "@see", "@serial", "@serialData", "@serialField", "@since", "@throws", "@version" }; //$NON-NLS-12$ //$NON-NLS-11$ //$NON-NLS-10$ //$NON-NLS-7$ //$NON-NLS-9$ //$NON-NLS-8$ //$NON-NLS-6$ //$NON-NLS-5$ //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$
-
- /**
- * Create a new java doc scanner.
- */
- public JavaDocScanner(JavaColorProvider provider) {
- super();
-
- IToken keyword= new Token(new TextAttribute(provider.getColor(JavaColorProvider.JAVADOC_KEYWORD)));
- IToken tag= new Token(new TextAttribute(provider.getColor(JavaColorProvider.JAVADOC_TAG)));
- IToken link= new Token(new TextAttribute(provider.getColor(JavaColorProvider.JAVADOC_LINK)));
-
- List list= new ArrayList();
-
- // Add rule for tags.
- list.add(new SingleLineRule("<", ">", tag)); //$NON-NLS-2$ //$NON-NLS-1$
-
- // Add rule for links.
- list.add(new SingleLineRule("{", "}", link)); //$NON-NLS-2$ //$NON-NLS-1$
-
- // Add generic whitespace rule.
- list.add(new WhitespaceRule(new JavaWhitespaceDetector()));
-
- // Add word rule for keywords.
- WordRule wordRule= new WordRule(new JavaDocWordDetector());
- for (int i= 0; i < fgKeywords.length; i++)
- wordRule.addWord(fgKeywords[i], keyword);
- list.add(wordRule);
-
- IRule[] result= new IRule[list.size()];
- list.toArray(result);
- setRules(result);
- }
-}
diff --git a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/togglepresentation.gif b/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/togglepresentation.gif
deleted file mode 100644
index a0831f0..0000000
--- a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/togglepresentation.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/util/JavaColorProvider.java b/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/util/JavaColorProvider.java
deleted file mode 100644
index d96551b..0000000
--- a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/util/JavaColorProvider.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.examples.javaeditor.util;
-
-
-import java.util.*;
-
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Display;
-
-/**
- * Manager for colors used in the Java editor
- */
-public class JavaColorProvider {
-
- public static final RGB MULTI_LINE_COMMENT= new RGB(128, 0, 0);
- public static final RGB SINGLE_LINE_COMMENT= new RGB(128, 128, 0);
- public static final RGB KEYWORD= new RGB(0, 0, 128);
- public static final RGB TYPE= new RGB(0, 0, 128);
- public static final RGB STRING= new RGB(0, 128, 0);
- public static final RGB DEFAULT= new RGB(0, 0, 0);
- public static final RGB JAVADOC_KEYWORD= new RGB(0, 128, 0);
- public static final RGB JAVADOC_TAG= new RGB(128, 128, 128);
- public static final RGB JAVADOC_LINK= new RGB(128, 128, 128);
- public static final RGB JAVADOC_DEFAULT= new RGB(0, 128, 128);
-
- protected Map fColorTable= new HashMap(10);
-
- /**
- * Release all of the color resources held onto by the receiver.
- */
- public void dispose() {
- Iterator e= fColorTable.values().iterator();
- while (e.hasNext())
- ((Color) e.next()).dispose();
- }
-
- /**
- * Return the Color that is stored in the Color table as rgb.
- */
- public Color getColor(RGB rgb) {
- Color color= (Color) fColorTable.get(rgb);
- if (color == null) {
- color= new Color(Display.getCurrent(), rgb);
- fColorTable.put(rgb, color);
- }
- return color;
- }
-}
diff --git a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/util/JavaWhitespaceDetector.java b/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/util/JavaWhitespaceDetector.java
deleted file mode 100644
index 1b5bc95..0000000
--- a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/util/JavaWhitespaceDetector.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.examples.javaeditor.util;
-
-
-import org.eclipse.jface.text.rules.IWhitespaceDetector;
-
-/**
- * A java aware white space detector.
- */
-public class JavaWhitespaceDetector implements IWhitespaceDetector {
-
- /* (non-Javadoc)
- * Method declared on IWhitespaceDetector
- */
- public boolean isWhitespace(char character) {
- return Character.isWhitespace(character);
- }
-}
diff --git a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/util/JavaWordDetector.java b/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/util/JavaWordDetector.java
deleted file mode 100644
index e79a1b9..0000000
--- a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/util/JavaWordDetector.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.examples.javaeditor.util;
-
-
-import org.eclipse.jface.text.rules.IWordDetector;
-
-/**
- * A Java aware word detector.
- */
-public class JavaWordDetector implements IWordDetector {
-
- /* (non-Javadoc)
- * Method declared on IWordDetector.
- */
- public boolean isWordPart(char character) {
- return Character.isJavaIdentifierPart(character);
- }
-
- /* (non-Javadoc)
- * Method declared on IWordDetector.
- */
- public boolean isWordStart(char character) {
- return Character.isJavaIdentifierStart(character);
- }
-}
diff --git a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/ColorManager.java b/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/ColorManager.java
deleted file mode 100644
index 54b46c1..0000000
--- a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/ColorManager.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.eclipse.ui.examples.templateeditor.editors;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Display;
-
-public class ColorManager {
-
- protected Map fColorTable = new HashMap(10);
-
- public void dispose() {
- Iterator e = fColorTable.values().iterator();
- while (e.hasNext())
- ((Color) e.next()).dispose();
- }
- public Color getColor(RGB rgb) {
- Color color = (Color) fColorTable.get(rgb);
- if (color == null) {
- color = new Color(Display.getCurrent(), rgb);
- fColorTable.put(rgb, color);
- }
- return color;
- }
-}
diff --git a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/IXMLColorConstants.java b/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/IXMLColorConstants.java
deleted file mode 100644
index dfb35ee..0000000
--- a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/IXMLColorConstants.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.eclipse.ui.examples.templateeditor.editors;
-
-import org.eclipse.swt.graphics.RGB;
-
-public interface IXMLColorConstants {
- RGB XML_COMMENT = new RGB(128, 0, 0);
- RGB PROC_INSTR = new RGB(128, 128, 128);
- RGB STRING = new RGB(0, 128, 0);
- RGB DEFAULT = new RGB(0, 0, 0);
- RGB TAG = new RGB(0, 0, 128);
-}
diff --git a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/NonRuleBasedDamagerRepairer.java b/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/NonRuleBasedDamagerRepairer.java
deleted file mode 100644
index b0d4d13..0000000
--- a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/NonRuleBasedDamagerRepairer.java
+++ /dev/null
@@ -1,138 +0,0 @@
-package org.eclipse.ui.examples.templateeditor.editors;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextAttribute;
-import org.eclipse.jface.text.TextPresentation;
-import org.eclipse.jface.text.presentation.IPresentationDamager;
-import org.eclipse.jface.text.presentation.IPresentationRepairer;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.swt.custom.StyleRange;
-
-public class NonRuleBasedDamagerRepairer
- implements IPresentationDamager, IPresentationRepairer {
-
- /** The document this object works on */
- protected IDocument fDocument;
- /** The default text attribute if non is returned as data by the current token */
- protected TextAttribute fDefaultTextAttribute;
-
- /**
- * Constructor for NonRuleBasedDamagerRepairer.
- */
- public NonRuleBasedDamagerRepairer(TextAttribute defaultTextAttribute) {
- Assert.isNotNull(defaultTextAttribute);
-
- fDefaultTextAttribute = defaultTextAttribute;
- }
-
- /**
- * @see IPresentationRepairer#setDocument(IDocument)
- */
- public void setDocument(IDocument document) {
- fDocument = document;
- }
-
- /**
- * Returns the end offset of the line that contains the specified offset or
- * if the offset is inside a line delimiter, the end offset of the next line.
- *
- * @param offset the offset whose line end offset must be computed
- * @return the line end offset for the given offset
- * @exception BadLocationException if offset is invalid in the current document
- */
- protected int endOfLineOf(int offset) throws BadLocationException {
-
- IRegion info = fDocument.getLineInformationOfOffset(offset);
- if (offset <= info.getOffset() + info.getLength())
- return info.getOffset() + info.getLength();
-
- int line = fDocument.getLineOfOffset(offset);
- try {
- info = fDocument.getLineInformation(line + 1);
- return info.getOffset() + info.getLength();
- } catch (BadLocationException x) {
- return fDocument.getLength();
- }
- }
-
- /**
- * @see IPresentationDamager#getDamageRegion(ITypedRegion, DocumentEvent, boolean)
- */
- public IRegion getDamageRegion(
- ITypedRegion partition,
- DocumentEvent event,
- boolean documentPartitioningChanged) {
- if (!documentPartitioningChanged) {
- try {
-
- IRegion info =
- fDocument.getLineInformationOfOffset(event.getOffset());
- int start = Math.max(partition.getOffset(), info.getOffset());
-
- int end =
- event.getOffset()
- + (event.getText() == null
- ? event.getLength()
- : event.getText().length());
-
- if (info.getOffset() <= end
- && end <= info.getOffset() + info.getLength()) {
- // optimize the case of the same line
- end = info.getOffset() + info.getLength();
- } else
- end = endOfLineOf(end);
-
- end =
- Math.min(
- partition.getOffset() + partition.getLength(),
- end);
- return new Region(start, end - start);
-
- } catch (BadLocationException x) {
- }
- }
-
- return partition;
- }
-
- /**
- * @see IPresentationRepairer#createPresentation(TextPresentation, ITypedRegion)
- */
- public void createPresentation(
- TextPresentation presentation,
- ITypedRegion region) {
- addRange(
- presentation,
- region.getOffset(),
- region.getLength(),
- fDefaultTextAttribute);
- }
-
- /**
- * Adds style information to the given text presentation.
- *
- * @param presentation the text presentation to be extended
- * @param offset the offset of the range to be styled
- * @param length the length of the range to be styled
- * @param attr the attribute describing the style of the range to be styled
- */
- protected void addRange(
- TextPresentation presentation,
- int offset,
- int length,
- TextAttribute attr) {
- if (attr != null)
- presentation.addStyleRange(
- new StyleRange(
- offset,
- length,
- attr.getForeground(),
- attr.getBackground(),
- attr.getStyle()));
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/TagRule.java b/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/TagRule.java
deleted file mode 100644
index a824a7e..0000000
--- a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/TagRule.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.eclipse.ui.examples.templateeditor.editors;
-
-import org.eclipse.jface.text.rules.*;
-
-public class TagRule extends MultiLineRule {
-
- public TagRule(IToken token) {
- super("<", ">", token); //$NON-NLS-1$//$NON-NLS-2$
- }
- protected boolean sequenceDetected(
- ICharacterScanner scanner,
- char[] sequence,
- boolean eofAllowed) {
- int c = scanner.read();
- if (sequence[0] == '<') {
- if (c == '?') {
- // processing instruction - abort
- scanner.unread();
- return false;
- }
- if (c == '!') {
- scanner.unread();
- // comment - abort
- return false;
- }
- } else if (sequence[0] == '>') {
- scanner.unread();
- }
- return super.sequenceDetected(scanner, sequence, eofAllowed);
- }
-}
diff --git a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/TemplateEditor.java b/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/TemplateEditor.java
deleted file mode 100644
index 019ae2f..0000000
--- a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/TemplateEditor.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.examples.templateeditor.editors;
-
-import org.eclipse.jface.action.IAction;
-
-import org.eclipse.jface.text.source.ISourceViewer;
-
-import org.eclipse.ui.texteditor.ExtendedTextEditor;
-import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
-import org.eclipse.ui.texteditor.TextOperationAction;
-
-/**
- * A simple xml editor with template capabilities.
- */
-public class TemplateEditor extends ExtendedTextEditor {
-
- private static final String TEMPLATE_PROPOSALS= "template_proposals_action"; //$NON-NLS-1$
- private ColorManager colorManager;
-
- /**
- * Creates a new template editor.
- */
- public TemplateEditor() {
- super();
- colorManager = new ColorManager();
- setSourceViewerConfiguration(new XMLConfiguration(colorManager));
- setDocumentProvider(new XMLDocumentProvider());
- }
-
- public void dispose() {
- colorManager.dispose();
- super.dispose();
- }
-
- protected void createActions() {
- super.createActions();
-
- IAction action= new TextOperationAction(
- TemplateMessages.getResourceBundle(),
- "Editor." + TEMPLATE_PROPOSALS + ".", //$NON-NLS-1$ //$NON-NLS-2$
- this,
- ISourceViewer.CONTENTASSIST_PROPOSALS);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
- setAction(TEMPLATE_PROPOSALS, action);
- markAsStateDependentAction(TEMPLATE_PROPOSALS, true);
- }
-
-}
diff --git a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/TemplateEditorUI.java b/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/TemplateEditorUI.java
deleted file mode 100644
index 5752826..0000000
--- a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/TemplateEditorUI.java
+++ /dev/null
@@ -1,96 +0,0 @@
-package org.eclipse.ui.examples.templateeditor.editors;
-
-
-import java.io.IOException;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.resource.ImageRegistry;
-
-import org.eclipse.jface.text.templates.ContextTypeRegistry;
-import org.eclipse.jface.text.templates.persistence.TemplateStore;
-
-import org.eclipse.ui.examples.javaeditor.JavaEditorExamplePlugin;
-import org.eclipse.ui.examples.templateeditor.template.XMLContextType;
-
-/**
- * The main plugin class to be used in the desktop.
- */
-public class TemplateEditorUI {
- /** Key to store custom templates. */
- private static final String CUSTOM_TEMPLATES_KEY= "org.eclipse.ui.examples.templateeditor.customtemplates"; //$NON-NLS-1$
-
- /** The shared instance. */
- private static TemplateEditorUI fInstance;
-
- /** The template store. */
- private TemplateStore fStore;
- /** The context type registry. */
- private ContextTypeRegistry fRegistry;
-
- private TemplateEditorUI() {
- }
-
- /**
- * Returns the shared instance.
- *
- * @return the shared instance
- */
- public static TemplateEditorUI getDefault() {
- if (fInstance == null)
- fInstance= new TemplateEditorUI();
- return fInstance;
- }
-
- /**
- * Returns this plug-in's template store.
- *
- * @return the template store of this plug-in instance
- */
- public TemplateStore getTemplateStore() {
- if (fStore == null) {
- fStore= new TemplateStore(getContextTypeRegistry(), JavaEditorExamplePlugin.getDefault().getPreferenceStore(), CUSTOM_TEMPLATES_KEY);
- try {
- fStore.load();
- } catch (IOException e) {
- JavaEditorExamplePlugin.getDefault().getLog().log(new Status(IStatus.ERROR, "org.eclipse.ui.examples.javaeditor", IStatus.OK, "", e)); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- return fStore;
- }
-
- /**
- * Returns this plug-in's context type registry.
- *
- * @return the context type registry for this plug-in instance
- */
- public ContextTypeRegistry getContextTypeRegistry() {
- if (fRegistry == null) {
- // create an configure the contexts available in the template editor
- fRegistry= new ContextTypeRegistry();
- fRegistry.addContextType(XMLContextType.XML_CONTEXT_TYPE);
- }
- return fRegistry;
- }
-
- /* Forward plug-in methods to javaeditor example plugin default instance */
- public ImageRegistry getImageRegistry() {
- return JavaEditorExamplePlugin.getDefault().getImageRegistry();
- }
-
- public static ImageDescriptor imageDescriptorFromPlugin(String string, String default_image) {
- return JavaEditorExamplePlugin.imageDescriptorFromPlugin(string, default_image);
- }
-
- public IPreferenceStore getPreferenceStore() {
- return JavaEditorExamplePlugin.getDefault().getPreferenceStore();
- }
-
- public void savePluginPreferences() {
- JavaEditorExamplePlugin.getDefault().savePluginPreferences();
- }
-
-}
diff --git a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/TemplateMessages.java b/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/TemplateMessages.java
deleted file mode 100644
index 2497adc..0000000
--- a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/TemplateMessages.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.examples.templateeditor.editors;
-
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-class TemplateMessages {
-
- private static final String RESOURCE_BUNDLE= TemplateMessages.class.getName();
- private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
-
- private TemplateMessages() {
- }
-
- /**
- * @param key
- * @return
- */
- public static String getString(String key) {
- try {
- return fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return '!' + key + '!';
- }
- }
-
- /**
- * Gets a string from the resource bundle and formats it with the argument
- *
- * @param key the string used to get the bundle value, must not be null
- * @param arg
- * @return
- */
- public static String getFormattedString(String key, Object arg) {
- return MessageFormat.format(getString(key), new Object[] { arg });
- }
-
-
- /**
- * Gets a string from the resource bundle and formats it with arguments
- * @param key
- * @param args
- * @return
- */
- public static String getFormattedString(String key, Object[] args) {
- return MessageFormat.format(getString(key), args);
- }
-
- /**
- * @return
- */
- public static ResourceBundle getResourceBundle() {
- return fgResourceBundle;
- }
-}
diff --git a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/TemplateMessages.properties b/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/TemplateMessages.properties
deleted file mode 100644
index 244f3f2..0000000
--- a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/TemplateMessages.properties
+++ /dev/null
@@ -1,3 +0,0 @@
-Editor.template_proposals_action.label= Template Assist
-Editor.template_proposals_action.description= Shows the available templates
-Editor.template_proposals_action.tooltip= Show Template Proposals
diff --git a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/XMLConfiguration.java b/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/XMLConfiguration.java
deleted file mode 100644
index d1ebe99..0000000
--- a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/XMLConfiguration.java
+++ /dev/null
@@ -1,91 +0,0 @@
-package org.eclipse.ui.examples.templateeditor.editors;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextDoubleClickStrategy;
-import org.eclipse.jface.text.TextAttribute;
-import org.eclipse.jface.text.contentassist.ContentAssistant;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.text.contentassist.IContentAssistant;
-import org.eclipse.jface.text.presentation.IPresentationReconciler;
-import org.eclipse.jface.text.presentation.PresentationReconciler;
-import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
-import org.eclipse.jface.text.rules.Token;
-import org.eclipse.jface.text.source.ISourceViewer;
-
-import org.eclipse.ui.editors.text.TextSourceViewerConfiguration;
-import org.eclipse.ui.examples.templateeditor.template.XMLCompletionProcessor;
-
-public class XMLConfiguration extends TextSourceViewerConfiguration {
-
- private XMLDoubleClickStrategy doubleClickStrategy;
- private XMLTagScanner tagScanner;
- private XMLScanner scanner;
- private ColorManager colorManager;
-
- public XMLConfiguration(ColorManager colorManager) {
- this.colorManager= colorManager;
- }
-
- public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
- return new String[]{IDocument.DEFAULT_CONTENT_TYPE, XMLPartitionScanner.XML_COMMENT,
- XMLPartitionScanner.XML_TAG};
- }
-
- public ITextDoubleClickStrategy getDoubleClickStrategy(ISourceViewer sourceViewer, String contentType) {
- if (doubleClickStrategy == null)
- doubleClickStrategy= new XMLDoubleClickStrategy();
- return doubleClickStrategy;
- }
-
- protected XMLScanner getXMLScanner() {
- if (scanner == null) {
- scanner= new XMLScanner(colorManager);
- scanner.setDefaultReturnToken(new Token(
- new TextAttribute(colorManager.getColor(IXMLColorConstants.DEFAULT))));
- }
- return scanner;
- }
-
- protected XMLTagScanner getXMLTagScanner() {
- if (tagScanner == null) {
- tagScanner= new XMLTagScanner(colorManager);
- tagScanner
- .setDefaultReturnToken(new Token(new TextAttribute(colorManager.getColor(IXMLColorConstants.TAG))));
- }
- return tagScanner;
- }
-
- public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
- PresentationReconciler reconciler= new PresentationReconciler();
-
- DefaultDamagerRepairer dr= new DefaultDamagerRepairer(getXMLTagScanner());
- reconciler.setDamager(dr, XMLPartitionScanner.XML_TAG);
- reconciler.setRepairer(dr, XMLPartitionScanner.XML_TAG);
-
- dr= new DefaultDamagerRepairer(getXMLScanner());
- reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
- reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
-
- NonRuleBasedDamagerRepairer ndr= new NonRuleBasedDamagerRepairer(new TextAttribute(colorManager
- .getColor(IXMLColorConstants.XML_COMMENT)));
- reconciler.setDamager(ndr, XMLPartitionScanner.XML_COMMENT);
- reconciler.setRepairer(ndr, XMLPartitionScanner.XML_COMMENT);
-
- return reconciler;
- }
-
- public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
- ContentAssistant assistant= new ContentAssistant();
- assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
-
- IContentAssistProcessor processor= new XMLCompletionProcessor();
- assistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
- assistant.setContentAssistProcessor(processor, XMLPartitionScanner.XML_TAG);
-
- assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
- assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));
-
- return assistant;
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/XMLDocumentProvider.java b/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/XMLDocumentProvider.java
deleted file mode 100644
index cca6b53..0000000
--- a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/XMLDocumentProvider.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.eclipse.ui.examples.templateeditor.editors;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.jface.text.rules.DefaultPartitioner;
-import org.eclipse.ui.editors.text.FileDocumentProvider;
-
-public class XMLDocumentProvider extends FileDocumentProvider {
-
- protected IDocument createDocument(Object element) throws CoreException {
- IDocument document = super.createDocument(element);
- if (document != null) {
- IDocumentPartitioner partitioner =
- new DefaultPartitioner(
- new XMLPartitionScanner(),
- new String[] {
- XMLPartitionScanner.XML_TAG,
- XMLPartitionScanner.XML_COMMENT });
- partitioner.connect(document);
- document.setDocumentPartitioner(partitioner);
- }
- return document;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/XMLDoubleClickStrategy.java b/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/XMLDoubleClickStrategy.java
deleted file mode 100644
index 474cad3..0000000
--- a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/XMLDoubleClickStrategy.java
+++ /dev/null
@@ -1,112 +0,0 @@
-package org.eclipse.ui.examples.templateeditor.editors;
-
-import org.eclipse.jface.text.*;
-
-public class XMLDoubleClickStrategy implements ITextDoubleClickStrategy {
- protected ITextViewer fText;
-
- public void doubleClicked(ITextViewer part) {
- int pos = part.getSelectedRange().x;
-
- if (pos < 0)
- return;
-
- fText = part;
-
- if (!selectComment(pos)) {
- selectWord(pos);
- }
- }
- protected boolean selectComment(int caretPos) {
- IDocument doc = fText.getDocument();
- int startPos, endPos;
-
- try {
- int pos = caretPos;
- char c = ' ';
-
- while (pos >= 0) {
- c = doc.getChar(pos);
- if (c == '\\') {
- pos -= 2;
- continue;
- }
- if (c == Character.LINE_SEPARATOR || c == '\"')
- break;
- --pos;
- }
-
- if (c != '\"')
- return false;
-
- startPos = pos;
-
- pos = caretPos;
- int length = doc.getLength();
- c = ' ';
-
- while (pos < length) {
- c = doc.getChar(pos);
- if (c == Character.LINE_SEPARATOR || c == '\"')
- break;
- ++pos;
- }
- if (c != '\"')
- return false;
-
- endPos = pos;
-
- int offset = startPos + 1;
- int len = endPos - offset;
- fText.setSelectedRange(offset, len);
- return true;
- } catch (BadLocationException x) {
- }
-
- return false;
- }
- protected boolean selectWord(int caretPos) {
-
- IDocument doc = fText.getDocument();
- int startPos, endPos;
-
- try {
-
- int pos = caretPos;
- char c;
-
- while (pos >= 0) {
- c = doc.getChar(pos);
- if (!Character.isJavaIdentifierPart(c))
- break;
- --pos;
- }
-
- startPos = pos;
-
- pos = caretPos;
- int length = doc.getLength();
-
- while (pos < length) {
- c = doc.getChar(pos);
- if (!Character.isJavaIdentifierPart(c))
- break;
- ++pos;
- }
-
- endPos = pos;
- selectRange(startPos, endPos);
- return true;
-
- } catch (BadLocationException x) {
- }
-
- return false;
- }
-
- private void selectRange(int startPos, int stopPos) {
- int offset = startPos + 1;
- int length = stopPos - offset;
- fText.setSelectedRange(offset, length);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/XMLPartitionScanner.java b/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/XMLPartitionScanner.java
deleted file mode 100644
index 8d975ba..0000000
--- a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/XMLPartitionScanner.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package org.eclipse.ui.examples.templateeditor.editors;
-
-import org.eclipse.jface.text.rules.*;
-
-public class XMLPartitionScanner extends RuleBasedPartitionScanner {
- public final static String XML_DEFAULT = "__xml_default"; //$NON-NLS-1$
- public final static String XML_COMMENT = "__xml_comment"; //$NON-NLS-1$
- public final static String XML_TAG = "__xml_tag"; //$NON-NLS-1$
-
- public XMLPartitionScanner() {
-
- IToken xmlComment = new Token(XML_COMMENT);
- IToken tag = new Token(XML_TAG);
-
- IPredicateRule[] rules = new IPredicateRule[2];
-
- rules[0] = new MultiLineRule("<!--", "-->", xmlComment); //$NON-NLS-1$//$NON-NLS-2$
- rules[1] = new TagRule(tag);
-
- setPredicateRules(rules);
- }
-}
diff --git a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/XMLScanner.java b/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/XMLScanner.java
deleted file mode 100644
index 1225160..0000000
--- a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/XMLScanner.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package org.eclipse.ui.examples.templateeditor.editors;
-
-import org.eclipse.jface.text.rules.*;
-import org.eclipse.jface.text.*;
-
-public class XMLScanner extends RuleBasedScanner {
-
- public XMLScanner(ColorManager manager) {
- IToken procInstr =
- new Token(
- new TextAttribute(
- manager.getColor(IXMLColorConstants.PROC_INSTR)));
-
- IRule[] rules = new IRule[2];
- //Add rule for processing instructions
- rules[0] = new SingleLineRule("<?", "?>", procInstr); //$NON-NLS-1$//$NON-NLS-2$
- // Add generic whitespace rule.
- rules[1] = new WhitespaceRule(new XMLWhitespaceDetector());
-
- setRules(rules);
- }
-}
diff --git a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/XMLTagScanner.java b/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/XMLTagScanner.java
deleted file mode 100644
index eecd7fe..0000000
--- a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/XMLTagScanner.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package org.eclipse.ui.examples.templateeditor.editors;
-
-import org.eclipse.jface.text.*;
-import org.eclipse.jface.text.rules.*;
-
-public class XMLTagScanner extends RuleBasedScanner {
-
- public XMLTagScanner(ColorManager manager) {
- IToken string =
- new Token(
- new TextAttribute(manager.getColor(IXMLColorConstants.STRING)));
-
- IRule[] rules = new IRule[3];
-
- // Add rule for double quotes
- rules[0] = new SingleLineRule("\"", "\"", string, '\\'); //$NON-NLS-1$//$NON-NLS-2$
- // Add a rule for single quotes
- rules[1] = new SingleLineRule("'", "'", string, '\\'); //$NON-NLS-1$//$NON-NLS-2$
- // Add generic whitespace rule.
- rules[2] = new WhitespaceRule(new XMLWhitespaceDetector());
-
- setRules(rules);
- }
-}
diff --git a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/XMLWhitespaceDetector.java b/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/XMLWhitespaceDetector.java
deleted file mode 100644
index d8c5be4..0000000
--- a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/XMLWhitespaceDetector.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.eclipse.ui.examples.templateeditor.editors;
-
-import org.eclipse.jface.text.rules.IWhitespaceDetector;
-
-public class XMLWhitespaceDetector implements IWhitespaceDetector {
-
- public boolean isWhitespace(char c) {
- return (c == ' ' || c == '\t' || c == '\n' || c == '\r');
- }
-}
diff --git a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/preferences/TemplatesPreferencePage.java b/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/preferences/TemplatesPreferencePage.java
deleted file mode 100644
index c4e3329..0000000
--- a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/preferences/TemplatesPreferencePage.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.examples.templateeditor.preferences;
-
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.examples.templateeditor.editors.TemplateEditorUI;
-import org.eclipse.ui.texteditor.templates.TemplatePreferencePage;
-
-/**
- * @see org.eclipse.jface.preference.PreferencePage
- */
-public class TemplatesPreferencePage extends TemplatePreferencePage implements IWorkbenchPreferencePage {
-
- public TemplatesPreferencePage() {
- setPreferenceStore(TemplateEditorUI.getDefault().getPreferenceStore());
- setTemplateStore(TemplateEditorUI.getDefault().getTemplateStore());
- setContextTypeRegistry(TemplateEditorUI.getDefault().getContextTypeRegistry());
- }
-
- protected boolean isShowFormatterSetting() {
- return false;
- }
-
-
- public boolean performOk() {
- boolean ok= super.performOk();
-
- TemplateEditorUI.getDefault().savePluginPreferences();
-
- return ok;
- }
-}
diff --git a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/template/AntVariableResolver.java b/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/template/AntVariableResolver.java
deleted file mode 100644
index 6f73dbc..0000000
--- a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/template/AntVariableResolver.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.examples.templateeditor.template;
-
-import java.util.Arrays;
-import java.util.Comparator;
-
-import org.eclipse.jface.text.templates.TemplateContext;
-import org.eclipse.jface.text.templates.TemplateVariableResolver;
-
-/**
- * Looks up existing ant variables and proposes them. The proposals are sorted by
- * their prefix-likeness with the variable type.
- */
-public class AntVariableResolver extends TemplateVariableResolver {
- /*
- * @see org.eclipse.jface.text.templates.TemplateVariableResolver#resolveAll(org.eclipse.jface.text.templates.TemplateContext)
- */
- protected String[] resolveAll(TemplateContext context) {
- String[] proposals= new String[] { "${srcDir}", "${dstDir}" }; //$NON-NLS-1$ //$NON-NLS-2$
-
- Arrays.sort(proposals, new Comparator() {
-
- public int compare(Object o1, Object o2) {
- return getCommonPrefixLength(getType(), (String) o2) - getCommonPrefixLength(getType(), (String) o1);
- }
-
- private int getCommonPrefixLength(String type, String var) {
- int i= 0;
- CharSequence vSeq= var.subSequence(2, var.length() - 1); // strip away ${}
- while (i < type.length() && i < vSeq.length())
- if (Character.toLowerCase(type.charAt(i)) == Character.toLowerCase(vSeq.charAt(i)))
- i++;
- else
- break;
- return i;
- }
- });
-
- return proposals;
- }
-}
diff --git a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/template/XMLCompletionProcessor.java b/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/template/XMLCompletionProcessor.java
deleted file mode 100644
index b691e58..0000000
--- a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/template/XMLCompletionProcessor.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.examples.templateeditor.template;
-
-import org.eclipse.swt.graphics.Image;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.resource.ImageRegistry;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.templates.ContextType;
-import org.eclipse.jface.text.templates.Template;
-import org.eclipse.jface.text.templates.TemplateCompletionProcessor;
-
-import org.eclipse.ui.examples.templateeditor.editors.TemplateEditorUI;
-
-
-/**
- * A completion processor for XML templates.
- */
-public class XMLCompletionProcessor extends TemplateCompletionProcessor {
- private static final String DEFAULT_IMAGE= "icons/template.gif"; //$NON-NLS-1$
-
- /**
- * We watch for angular brackets since those are often part of XML
- * templates.
- */
- protected String extractPrefix(ITextViewer viewer, int offset) {
- IDocument document= viewer.getDocument();
- int i= offset;
- if (i > document.getLength())
- return ""; //$NON-NLS-1$
-
- try {
- while (i > 0) {
- char ch= document.getChar(i - 1);
- if (ch != '<' && !Character.isJavaIdentifierPart(ch))
- break;
- i--;
- }
-
- return document.get(i, offset - i);
- } catch (BadLocationException e) {
- return ""; //$NON-NLS-1$
- }
- }
-
- /**
- * Cut out angular brackets for relevance sorting, since the template name
- * does not contain the brackets.
- */
- protected int getRelevance(Template template, String prefix) {
- if (prefix.startsWith("<")) //$NON-NLS-1$
- prefix= prefix.substring(1);
- if (template.getName().startsWith(prefix))
- return 90;
- return 0;
- }
-
- /**
- * Simply return all templates.
- */
- protected Template[] getTemplates(String contextTypeId) {
- return TemplateEditorUI.getDefault().getTemplateStore().getTemplates();
- }
-
- /**
- * Return the XML context type that is supported by this plugin.
- */
- protected ContextType getContextType(ITextViewer viewer, IRegion region) {
- return TemplateEditorUI.getDefault().getContextTypeRegistry().getContextType(XMLContextType.XML_CONTEXT_TYPE);
- }
-
- /**
- * Always return the default image.
- */
- protected Image getImage(Template template) {
- ImageRegistry registry= TemplateEditorUI.getDefault().getImageRegistry();
- Image image= registry.get(DEFAULT_IMAGE);
- if (image == null) {
- ImageDescriptor desc= TemplateEditorUI.imageDescriptorFromPlugin("org.eclipse.ui.examples.javaeditor", DEFAULT_IMAGE); //$NON-NLS-1$
- registry.put(DEFAULT_IMAGE, desc);
- image= registry.get(DEFAULT_IMAGE);
- }
- return image;
- }
-
-}
diff --git a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/template/XMLContextType.java b/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/template/XMLContextType.java
deleted file mode 100644
index 01a6484..0000000
--- a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/template/XMLContextType.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.examples.templateeditor.template;
-
-import org.eclipse.jface.text.templates.ContextType;
-import org.eclipse.jface.text.templates.GlobalVariables;
-
-
-/**
- * A very simple context type.
- */
-public class XMLContextType extends ContextType {
-
- /** This context's id */
- public static final String XML_CONTEXT_TYPE= "org.eclipse.ui.examples.templateeditor.xml"; //$NON-NLS-1$
-
- /**
- * Creates a new XML context type.
- */
- public XMLContextType() {
- addGlobalResolvers();
- }
-
- private void addGlobalResolvers() {
- addResolver(new GlobalVariables.Cursor());
- addResolver(new GlobalVariables.WordSelection());
- addResolver(new GlobalVariables.LineSelection());
- addResolver(new GlobalVariables.Dollar());
- addResolver(new GlobalVariables.Date());
- addResolver(new GlobalVariables.Year());
- addResolver(new GlobalVariables.Time());
- addResolver(new GlobalVariables.User());
- }
-
-}
diff --git a/org.eclipse.ui.examples.javaeditor/about.html b/org.eclipse.ui.examples.javaeditor/about.html
deleted file mode 100644
index 9db411a..0000000
--- a/org.eclipse.ui.examples.javaeditor/about.html
+++ /dev/null
@@ -1,30 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<html>
-<head>
-<title>About</title>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</head>
-<body lang="EN-US">
-<h2>About This Content</h2>
-
-<p>20th June, 2002</p>
-<h3>License</h3>
-<p>Eclipse.org makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
-Common Public License Version 1.0 ("CPL"). A copy of the CPL is available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>.
-For purposes of the CPL, "Program" will mean the Content.</p>
-
-<h3>Contributions</h3>
-
-<p>If this Content is licensed to you under the terms and conditions of the CPL, any Contributions, as defined in the CPL, uploaded, submitted, or otherwise
-made available to Eclipse.org, members of Eclipse.org and/or the host of Eclipse.org web site, by you that relate to such
-Content are provided under the terms and conditions of the CPL and can be made available to others under the terms of the CPL.</p>
-
-<p>If this Content is licensed to you under license terms and conditions other than the CPL ("Other License"), any modifications, enhancements and/or
-other code and/or documentation ("Modifications") uploaded, submitted, or otherwise made available to Eclipse.org, members of Eclipse.org and/or the
-host of Eclipse.org, by you that relate to such Content are provided under terms and conditions of the Other License and can be made available
-to others under the terms of the Other License. In addition, with regard to Modifications for which you are the copyright holder, you are also
-providing the Modifications under the terms and conditions of the CPL and such Modifications can be made available to others under the terms of
-the CPL.</p>
-
-</body>
-</html>
\ No newline at end of file
diff --git a/org.eclipse.ui.examples.javaeditor/build.properties b/org.eclipse.ui.examples.javaeditor/build.properties
deleted file mode 100644
index cace593..0000000
--- a/org.eclipse.ui.examples.javaeditor/build.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2003 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-source.javaeditorexample.jar = Eclipse Java Editor Example/
-source.templateeditorexample.jar = Template Editor Example/
-
-bin.includes = doc-html/,\
- icons/,\
- templates/,\
- .options,\
- about.html,\
- plugin.properties,\
- plugin.xml,\
- *.jar
-
-src.includes = about.html
diff --git a/org.eclipse.ui.examples.javaeditor/doc-html/hglegal.htm b/org.eclipse.ui.examples.javaeditor/doc-html/hglegal.htm
deleted file mode 100644
index c598113..0000000
--- a/org.eclipse.ui.examples.javaeditor/doc-html/hglegal.htm
+++ /dev/null
@@ -1,14 +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="GENERATOR" content="Mozilla/4.73 [en] (Win98; U) [Netscape]">
- <title>Legal Notices</title>
-</head>
-<body>
-
-<h3>
-<a NAME="Notices"></a>Notices</h3>
-(c) Copyright IBM Corp. 2000, 2001. All Rights Reserved.
-</body>
-</html>
diff --git a/org.eclipse.ui.examples.javaeditor/doc-html/hglegal2002.htm b/org.eclipse.ui.examples.javaeditor/doc-html/hglegal2002.htm
deleted file mode 100644
index 3c86467..0000000
--- a/org.eclipse.ui.examples.javaeditor/doc-html/hglegal2002.htm
+++ /dev/null
@@ -1,13 +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">
- <title>Legal Notices</title>
-</head>
-<body>
-
-<h3>
-<a NAME="Notices"></a>Notices</h3>
-(c) Copyright IBM Corp. and others 2000, 2002. All Rights Reserved.
-</body>
-</html>
diff --git a/org.eclipse.ui.examples.javaeditor/doc-html/hglegal2003.htm b/org.eclipse.ui.examples.javaeditor/doc-html/hglegal2003.htm
deleted file mode 100644
index f5871b7..0000000
--- a/org.eclipse.ui.examples.javaeditor/doc-html/hglegal2003.htm
+++ /dev/null
@@ -1,14 +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">
- <LINK REL="stylesheet" HREF="../../../book.css" CHARSET="ISO-8859-1" TYPE="text/css">
- <title>Legal Notices</title>
-</head>
-<body>
-
-<h3>
-<a NAME="Notices"></a>Notices</h3>
-(c) Copyright (c) 2000, 2003 IBM Corporation and others. All Rights Reserved.
-</body>
-</html>
diff --git a/org.eclipse.ui.examples.javaeditor/doc-html/ngibmcpy.gif b/org.eclipse.ui.examples.javaeditor/doc-html/ngibmcpy.gif
deleted file mode 100644
index 360f8e9..0000000
--- a/org.eclipse.ui.examples.javaeditor/doc-html/ngibmcpy.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.ui.examples.javaeditor/doc-html/ngibmcpy2002.gif b/org.eclipse.ui.examples.javaeditor/doc-html/ngibmcpy2002.gif
deleted file mode 100644
index 61cef48..0000000
--- a/org.eclipse.ui.examples.javaeditor/doc-html/ngibmcpy2002.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.ui.examples.javaeditor/doc-html/ngibmcpy2003.gif b/org.eclipse.ui.examples.javaeditor/doc-html/ngibmcpy2003.gif
deleted file mode 100644
index c786e43..0000000
--- a/org.eclipse.ui.examples.javaeditor/doc-html/ngibmcpy2003.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.ui.examples.javaeditor/doc-html/ui_javaeditor_ex.html b/org.eclipse.ui.examples.javaeditor/doc-html/ui_javaeditor_ex.html
deleted file mode 100644
index 3302957..0000000
--- a/org.eclipse.ui.examples.javaeditor/doc-html/ui_javaeditor_ex.html
+++ /dev/null
@@ -1,237 +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="GENERATOR" content="Mozilla/4.76 [en] (Windows NT 5.0; U) [Netscape]">
- <title>Desktop - Java Editor Example</title>
-</head>
-<body>
-
-<h2>
-<b>Example - Java Editor</b></h2>
-
-<h3>
-Introduction</h3>
-The Java Editor example demonstrates the standard features available for
-custom text editors. It also shows how to register an editor
-for a file extension (in this case .jav) and how to define a custom Document
-provider for use by that editor. This example is only for demonstration
-purposes. Java editing support is provided by the Eclipse Java Tooling.
-<h3>
-<b>Features demonstrated in the example editor</b></h3>
-
-<ul>
-<li>
-syntax highlighting</li>
-
-<li>
-content type sensitive content assist (JavaDoc and Java code)</li>
-
-<li>
-communication between content outliner and editor, i.e. content outliner
-selection feeds the highlight range of the editor</li>
-
-<li>
-two different presentation modes</li>
-
-<ul>
-<li>
- marking the highlight range using a visual range indicator</li>
-
-<li>
-confining the editor to show only text within the highlight range (e.g.
-show a single method of a Java class)</li>
-</ul>
-
-<li>
-marker handling</li>
-
-<li>
-document sharing</li>
-</ul>
-
-<h3>
-Features not demonstrated</h3>
-
-<ul>
-<li>
-content formatting</li>
-
-<li>
-dynamic reconciling of content outline page</li>
-</ul>
-
-<h3>
-Running the example editor</h3>
-
-<ol>
-<li>
-Create a project</li>
-
-<li>
-Create a file with the file extension ".jav" in the newly created project.
-The Java example editor opens automatically.</li>
-
-<li>
-Insert Java code. The Java code is dynamically colored. The example editor
-presents the following language elements in different colors: multi-line
-comments, single line comments, Java language reserved words, string and
-character constants, regular Java code, as well as multi-line comments
-following the JavaDoc guidelines. Inside those JavaDoc comments, JavaDoc
-keywords and tags are differently colored.</li>
-
-<li>
-Open a new Java multi-line comment by inserting "/*" outside a Java comment.
-All the text between the inserted "/*" and the first occurrence of "*/"
-or the end of the text changes its color to red. Append another "*". The
-red range changes color to green as the regular multi-line comment now
-is considered containing JavaDoc. Invoke code assist using CTRL-SPACE.
-The function of content assist is to support the user in writing code.
-So on invocation, content assist should list all possible valid completions
-at the invocation location. Inside JavaDoc, the example editor always proposes
-all JavaDoc keywords.</li>
-
-<li>
-Outside a Java comment invoke content tip using CTRL+SHIFT+SPACE. Five
-proposals are listed. Select one and press ENTER. A small floating red
-window appears above the current line displaying the selected proposal.
-The anticipated use of content tips is to let the user express her intention,
-e.g. to enter a method call and to present contextual information which
-guides the user by doing so. In the example editor, the proposal is considered
-valid five characters around the initial invocation location. While the
-content tip is visible, invoke content assist using CTRL+SPACE. Content
-assist invoked in this situation should help the user to accomplish her
-stated intention visible in the content tip. Inside regular Java code,
-the example editor always proposes all Java keywords.</li>
-
-<li>
-Save the Java code. Saving updates the content outliner. The content outliner
-contains ten entries each of them representing one of ten equally sized
-segments of the Java code in the editor. This style of content outline
-has been chosen to show that the semantics of highlight ranges can arbitrarily
-be defined. (See next steps.)</li>
-
-<li>
-Select one of the entries in the content outliner. The corresponding lines
-are marked with a blue bar in the editor's left vertical ruler.</li>
-
-<li>
-Now switch to the segmented presentation mode of the Java editor. For that
-make sure that the editor has the focus and press that button in the desktop's
-toolbar whose hover help says "Enable/Disable segmented source viewer".
-This functionality is anticipated to be used, e.g., for single method views.</li>
-
-<li>
-Select a different entry in the content outliner. Now the editor only shows
-the selected segment. By deselecting the entry in the content outliner,
-the complete Java code is shown again.</li>
-
-<li>
-Select an entry in the content outliner, select a fraction of the visible
-text, and add a task for the selection. The task shows up in the task list.
-Modify the visible code. In the task list, select the previously created
-task and press the "Go to file" button. The task is selected in the visible
-area, correctly taking the previously applied modifications into account.</li>
-
-<li>
-Select another entry in the content outliner. Reveal the previously added
-task from the task list. The editor's highlight range is automatically
-enlarged to enclose the range of the revealed task.</li>
-
-<li>
-Open a new workspace. In the new workspace, open a Java editor for the
-same file as in the original workspace. Modify the editor content. Switch
-back to the original workspace. The editor shows the changes made in the
-other workspace. The two editors showing the same file are lively linked.</li>
-</ol>
-
-<h3>
-Principles for creating custom text editors</h3>
-The following steps are usually necessary do develop a custom text editor.
-<ol>
-<li>
-Create a document provider. A document provider (see IDocumentProvider)
-produces and manages documents (see IDocument) containing a textual representation
-of editor input elements. It is important to decide how the translation
-between element and textual representation looks like and whether the document
-provider should be shared between multiple editors or not. See the class
-FileDocumentProvider in the Java example editor.</li>
-
-<li>
-Create a document partitioner. A document partitioner (see IDocumentPartitioner)
-divides a document into disjoint regions. The partitioner assigns each
-region one content type out of a set of content types predefined by the
-partitioner. On each document change the document's partitioning must be
-updated. See the class JavaPartitioner in the Java example editor. The
-JavaPartitioner determines regions of the types multi-line comments, JavaDoc
-comments, and everything else. It must be ensured that the document provider
-is set on each document produced by the document provider.</li>
-
-<li>
-Determine which of the source viewer plugins should be provided. Among
-other supported plugins are auto indent strategies, double click strategies,
-content formatter, and text presentation reconciler. The subsequent description
-will be restricted to the text presentation reconciler (see IPresentationReconciler).
-In the Java example editor, the text presentation reconciler is utilized
-to implement syntax highlighting.</li>
-
-<li>
-Create for all source viewer plugins the appropriate extensions for each
-supported content type. As seen above, the document partitioner defines
-the supported content types. The default implementation of IPresentationReconciler
-supports IPresentationDamagers and IPresentationRepairers as extensions.
-Those extensions are considered being specific for a particular content
-type. Thus, for a custom editor, the user must first select a subset of
-the supported content types. Regions of a type being a member of the selected
-subset will, e.g., be syntax highlighted. For each of those types the extensions
-must be implemented. See JavaDamagerRepairer and JavaDocDamagerRepairer
-in the example editor.</li>
-
-<li>
-Build a source viewer configuration using the previously created plugins
-and extensions. See JavaSourceViewerConfiguration in the example editor.</li>
-
-<li>
-Customize the class TextEditor or AbstractTextEditor with the developed
-document partitioner and source viewer configuration. Add or replace actions
-and adapt the construction of the editor's context menu. In the actual
-version, this customization must be done in a subclass. See JavaEditor
-in the example editor.</li>
-
-<li>
-Set up an appropriate action bar contributor who contributes editor-related
-actions to the desktop's toolbar and menus. See JavaActionContributor in
-the example editor.</li>
-
-<li>
-Extend the XML configuration file of the editor's plugin, so that the editor
-registers at the predefined editor extension point for a specific set of
-file extensions. Also set up the action bar contributor in the XML file.
-See plugin.xml of this example.</li>
-</ol>
-
-<h3>
-Code organization of the example</h3>
-The example code is organized in four packages:
-<ul>
-<li>
-<tt>org.eclipse.ui.examples.javaeditor </tt>contains all the editor specific
-classes.</li>
-
-<li>
-<tt>org.eclipse.ui.examples.javaeditor.java</tt> contains all Java specific
-source viewer plugins such as the JavaDamagerRepairer as well as the Java
-specific document partitioner.</li>
-
-<li>
-<tt>org.eclipse.ui.examples.javaeditor.javadoc </tt>contains all JavaDoc
-specific source viewer plugins such as the JavaDocDamagerRepairer.</li>
-
-<br><tt>org.eclipse.ui.examples.javaeditor.util</tt> contains convenience
-classes shared by the three other packages.</ul>
-
-<br>
-<p><a href="hglegal2003.htm"><img src="ngibmcpy2003.gif" alt="Copyright IBM Corporation and others 2000, 2003" border="0" width="324" height="14"></a>
-</p>
-</body>
-</html>
diff --git a/org.eclipse.ui.examples.javaeditor/doc-html/ui_templateeditor_ex.html b/org.eclipse.ui.examples.javaeditor/doc-html/ui_templateeditor_ex.html
deleted file mode 100644
index 68ed57d..0000000
--- a/org.eclipse.ui.examples.javaeditor/doc-html/ui_templateeditor_ex.html
+++ /dev/null
@@ -1,69 +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="GENERATOR" content="Mozilla/4.76 [en] (Windows NT 5.0; U) [Netscape]">
- <title>Desktop - Template Editor Example</title>
-</head>
-<body>
-
-<h2>
-<b>Example - Template Editor</b></h2>
-
-<h3>
-Introduction</h3>
-The Template Editor example demonstrates how to add template support to an editor. The example is
-based on the PDE example editor project that can be created using the new project wizard. The editor
-is a simple XML editor; it is only for demonstration purposes.
-<h3>
-<b>Features demonstrated in the template editor</b></h3>
-
-<ul>
-<li>
-creating a template context for an editor</li>
-
-<li>
-setting up a content assist processor that will propose template completions</li>
-
-<li>
-contributing a context type and variable resolvers to an editor via plugin.xml</li>
-
-<li>
-contributing templates to a context type via plugin.xml</li>
-
-<li>
-adding a preference page for handling templates, both contributed and user-added</li>
-
-</ul>
-
-<h3>
-Features not demonstrated</h3>
-
-<ul>
-<li>
-template formatting</li>
-</ul>
-
-<h3>
-Code organization of the template editor example</h3>
-The example code is organized in three packages:
-<ul>
-<li>
-<tt>org.eclipse.ui.examples.templateeditor.editors</tt> contains all the editor specific
-classes. See <code>XMLConfiguration</code> to see how the <code>TemplateCompletionProcessor</code>
-is added in the <code>getContentAssistant</code> method.</li>
-
-<li>
-<tt>org.eclipse.ui.examples.templateeditor.preferences</tt> contains the contributed template
-preference page.</li>
-
-<li>
-<tt>org.eclipse.ui.examples.templateeditor.template</tt> contains the example context type, the
-completion processor and the variable resolver that is contributed via plugin.xml.</li>
-</ul>
-
-<br>
-<p><a href="hglegal2003.htm"><img src="ngibmcpy2003.gif" alt="Copyright IBM Corporation and others 2000, 2003" border="0" width="324" height="14"></a>
-</p>
-</body>
-</html>
diff --git a/org.eclipse.ui.examples.javaeditor/icons/obj16/java.gif b/org.eclipse.ui.examples.javaeditor/icons/obj16/java.gif
deleted file mode 100644
index 83de817..0000000
--- a/org.eclipse.ui.examples.javaeditor/icons/obj16/java.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.ui.examples.javaeditor/icons/resolver.gif b/org.eclipse.ui.examples.javaeditor/icons/resolver.gif
deleted file mode 100644
index 34fb3c9..0000000
--- a/org.eclipse.ui.examples.javaeditor/icons/resolver.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.ui.examples.javaeditor/icons/sample.gif b/org.eclipse.ui.examples.javaeditor/icons/sample.gif
deleted file mode 100644
index 34fb3c9..0000000
--- a/org.eclipse.ui.examples.javaeditor/icons/sample.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.ui.examples.javaeditor/icons/template.gif b/org.eclipse.ui.examples.javaeditor/icons/template.gif
deleted file mode 100644
index 65c2632..0000000
--- a/org.eclipse.ui.examples.javaeditor/icons/template.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.ui.examples.javaeditor/plugin.properties b/org.eclipse.ui.examples.javaeditor/plugin.properties
deleted file mode 100644
index 7bb6717..0000000
--- a/org.eclipse.ui.examples.javaeditor/plugin.properties
+++ /dev/null
@@ -1,38 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2003 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-#
-# Resource strings for Java Example Editor
-#
-pluginName=JFace Text Example
-providerName = Eclipse.org
-
-#
-# Java Example Editor
-#
-javaEditorName=Example Java Editor
-javaFileExtensions=jav
-documentSetupParticipantName=Example Java Document Setup Participant
-
-#
-# XML / Template Editor
-#
-xml.editor.name= Template Editor
-xml.editor.extensions= xml
-
-xml.contextType.name= Ant Script
-
-ant.tasks.copy.name= copy
-ant.tasks.copy.description= Copy task
-
-ant.resolvers.src= Source Fileset
-ant.resolvers.src.description= A source fileset
-ant.resolvers.dst= Destination Fileset
-ant.resolvers.dst.description= An output fileset
diff --git a/org.eclipse.ui.examples.javaeditor/plugin.xml b/org.eclipse.ui.examples.javaeditor/plugin.xml
deleted file mode 100644
index 229ee97..0000000
--- a/org.eclipse.ui.examples.javaeditor/plugin.xml
+++ /dev/null
@@ -1,119 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
-<plugin
- id="org.eclipse.ui.examples.javaeditor"
- name="%pluginName"
- version="3.0.0"
- provider-name="%providerName"
- class="org.eclipse.ui.examples.javaeditor.JavaEditorExamplePlugin">
-
- <runtime>
- <library name="javaeditorexample.jar">
- <export name="*"/>
- </library>
- <library name="templateeditorexample.jar">
- <export name="*"/>
- </library>
- </runtime>
- <requires>
- <import plugin="org.eclipse.core.runtime.compatibility"/>
- <import plugin="org.eclipse.ui"/>
- <import plugin="org.eclipse.core.filebuffers"/>
- <import plugin="org.eclipse.jface.text"/>
- <import plugin="org.eclipse.ui.workbench.texteditor"/>
- <import plugin="org.eclipse.ui.editors"/>
- <import plugin="org.eclipse.ui.views"/>
- </requires>
-
-
-<!-- =========================================================================== -->
-<!-- Java Editor Example -->
-<!-- =========================================================================== -->
-
- <extension
- point="org.eclipse.ui.editors">
- <editor
- name="%javaEditorName"
- icon="icons/obj16/java.gif"
- extensions="%javaFileExtensions"
- contributorClass="org.eclipse.ui.examples.javaeditor.JavaActionContributor"
- class="org.eclipse.ui.examples.javaeditor.JavaEditor"
- id="org.eclipse.ui.JavaEditor">
- </editor>
- </extension>
-
- <extension
- id="ExampleJavaDocumentSetupParticipant"
- name="%documentSetupParticipantName"
- point="org.eclipse.core.filebuffers.documentSetup">
- <participant
- extensions="%javaFileExtensions"
- class="org.eclipse.ui.examples.javaeditor.JavaDocumentSetupParticipant">
- </participant>
- </extension>
-
-<!-- =========================================================================== -->
-<!-- Template Editor Example -->
-<!-- =========================================================================== -->
-
- <extension
- point="org.eclipse.ui.editors">
- <editor
- name="%xml.editor.name"
- icon="icons/sample.gif"
- extensions="%xml.editor.extensions"
- contributorClass="org.eclipse.ui.texteditor.BasicTextEditorActionContributor"
- class="org.eclipse.ui.examples.templateeditor.editors.TemplateEditor"
- id="org.eclipse.ui.examples.templateeditor.editors.TemplateEditor">
- </editor>
- </extension>
-
- <extension
- point="org.eclipse.ui.preferencePages">
- <page
- name="Template Editor"
- class="org.eclipse.ui.examples.templateeditor.preferences.TemplatesPreferencePage"
- id="org.eclipse.ui.examples.templateeditor.preferencepage">
- </page>
- </extension>
-
- <extension
- point="org.eclipse.ui.editors.templates">
- <contextType
- name="%xml.contextType.name"
- class="org.eclipse.ui.examples.templateeditor.template.XMLContextType"
- id="org.eclipse.ui.examples.templateeditor.xml">
- </contextType>
- <template
- name="%ant.tasks.copy.name"
- icon="icons/template.gif"
- description="%ant.tasks.copy.description"
- contextTypeId="org.eclipse.ui.examples.templateeditor.xml"
- id="org.eclipse.ui.examples.templateeditor.ant.copy">
- <pattern><copy todir="${dst}">
- <fileset dir="${src}"/>
-</copy></pattern>
- </template>
- <resolver
- name="%ant.resolvers.src"
- type="src"
- icon="icons/resolver.gif"
- description="%ant.resolvers.src.description"
- contextTypeId="org.eclipse.ui.examples.templateeditor.xml"
- class="org.eclipse.ui.examples.templateeditor.template.AntVariableResolver">
- </resolver>
- <resolver
- name="%ant.resolvers.dst"
- type="dst"
- icon="icons/resolver.gif"
- description="%ant.resolvers.dst.description"
- contextTypeId="org.eclipse.ui.examples.templateeditor.xml"
- class="org.eclipse.ui.examples.templateeditor.template.AntVariableResolver">
- </resolver>
- <include
- file="templates/ant.xml"
- translations="templates/ant.properties">
- </include>
- </extension>
-
-</plugin>
diff --git a/org.eclipse.ui.examples.javaeditor/templates/ant.properties b/org.eclipse.ui.examples.javaeditor/templates/ant.properties
deleted file mode 100644
index fc7e0e9..0000000
--- a/org.eclipse.ui.examples.javaeditor/templates/ant.properties
+++ /dev/null
@@ -1,2 +0,0 @@
-ant.tasks.javac.name= javac
-ant.tasks.javac.desc= Add a javac task
diff --git a/org.eclipse.ui.examples.javaeditor/templates/ant.xml b/org.eclipse.ui.examples.javaeditor/templates/ant.xml
deleted file mode 100644
index 025cf7a..0000000
--- a/org.eclipse.ui.examples.javaeditor/templates/ant.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<templates>
-
-<template
- context="org.eclipse.ui.examples.templateeditor.xml"
- description="%ant.tasks.javac.desc"
- id="org.eclipse.ui.examples.templateeditor.ant.javac1"
- name="%ant.tasks.javac.name"><javac srcdir="${src}"
- destdir="${dst}"
- classpath="${jarfile}"
- debug="${on}"
-/>${cursor}</template>
-
-</templates>
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ResourceAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ResourceAction.java
index 68b128b..e626bce 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ResourceAction.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ResourceAction.java
@@ -125,7 +125,7 @@
* @param prefix a prefix to be prepended to the various resource keys, or <code>null</code> if none
* @since 2.1
*/
- private void initialize(ResourceBundle bundle, String prefix) {
+ protected void initialize(ResourceBundle bundle, String prefix) {
String labelKey= "label"; //$NON-NLS-1$
String tooltipKey= "tooltip"; //$NON-NLS-1$
String imageKey= "image"; //$NON-NLS-1$