diff options
author | cvs2svn | 2004-09-07 08:58:49 +0000 |
---|---|---|
committer | cvs2svn | 2004-09-07 08:58:49 +0000 |
commit | 7c16254a32d3e5ef62c9d7835f9cd0301e7d3b09 (patch) | |
tree | 10a63a8e0c9b6a168a72547dc065c2535b714172 /org.eclipse.ui.workbench.texteditor | |
parent | d6e189e884be8b74de32491a4638780c2b44e73f (diff) | |
download | eclipse.platform.text-7c16254a32d3e5ef62c9d7835f9cd0301e7d3b09.tar.gz eclipse.platform.text-7c16254a32d3e5ef62c9d7835f9cd0301e7d3b09.tar.xz eclipse.platform.text-7c16254a32d3e5ef62c9d7835f9cd0301e7d3b09.zip |
This commit was manufactured by cvs2svn to create branch 'perf_30'.
Sprout from master 2004-06-23 19:42:46 UTC Dani Megert <dmegert> 'Copyright fix - automated changes with releng tool'
Cherrypick from master 2004-09-07 08:58:47 UTC Dani Megert <dmegert> 'Settting org.eclipse.jdt.core.compiler.problem.specialParameterHidingField to "disabled"':
org.eclipse.core.filebuffers.tests/.settings/org.eclipse.jdt.core.prefs
org.eclipse.text.tests/src/org/eclipse/text/tests/Accessor.java
org.eclipse.ui.editors.tests/.settings/org.eclipse.jdt.core.prefs
org.eclipse.ui.editors.tests/test.xml
org.eclipse.ui.workbench.texteditor.tests/.settings/org.eclipse.jdt.core.prefs
org.eclipse.ui.workbench.texteditor.tests/test.xml
Cherrypick from master 2004-04-14 15:46:14 UTC Dani Megert <dmegert> 'Initial Release - work in progress':
org.eclipse.ui.editors.tests/.classpath
org.eclipse.ui.editors.tests/build.properties
org.eclipse.ui.workbench.texteditor.tests/.classpath
org.eclipse.ui.workbench.texteditor.tests/build.properties
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/annotationModelCreation.exsd
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/IAnnotationModelFactory.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/IPersistableAnnotationModel.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/filebuffers/package.html
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/FileBuffersMessages.java
org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/FileBuffersMessages.properties
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/projection/AnnotationBag.java
org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/IProjectionListener.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/ProjectionSummary.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/projection/org/eclipse/jface/text/source/projection/images/collapsed.gif
org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/images/expanded.gif
org.eclipse.jface.text/scripts/exportplugin.xml
org.eclipse.jface.text/src/org/eclipse/jface/contentassist/AbstractControlContentAssistSubjectAdapter.java
org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ComboContentAssistSubjectAdapter.java
org.eclipse.jface.text/src/org/eclipse/jface/contentassist/IContentAssistSubjectControl.java
org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ISubjectControlContentAssistProcessor.java
org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ISubjectControlContentAssistant.java
org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ISubjectControlContextInformationPresenter.java
org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ISubjectControlContextInformationValidator.java
org.eclipse.jface.text/src/org/eclipse/jface/contentassist/SubjectControlContentAssistant.java
org.eclipse.jface.text/src/org/eclipse/jface/contentassist/SubjectControlContextInformationValidator.java
org.eclipse.jface.text/src/org/eclipse/jface/contentassist/TextContentAssistSubjectAdapter.java
org.eclipse.jface.text/src/org/eclipse/jface/contentassist/images/content_assist_cue.gif
org.eclipse.jface.text/src/org/eclipse/jface/contentassist/package.html
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/ContentAssistMessages.java
org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistMessages.properties
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/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/DefaultDocumentAdapter.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/DocumentClone.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/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/AdditionalInfoController.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/ContentAssistSubjectControlAdapter.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/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/IContextInformationValidator.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/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/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/LinkedModeUI.java
org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedPositionAnnotations.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/DirtyRegion.java
org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/DirtyRegionQueue.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/AnnotationBarHoverManager.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationColumn.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/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/ILineRange.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/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/IVerticalRulerListener.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/ImageUtilities.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/LineRange.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/VerticalRuler.java
org.eclipse.jface.text/src/org/eclipse/jface/text/source/VerticalRulerEvent.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/InclusivePositionUpdater.java
org.eclipse.jface.text/src/org/eclipse/jface/text/templates/JFaceTextTemplateMessages.java
org.eclipse.jface.text/src/org/eclipse/jface/text/templates/JFaceTextTemplateMessages.properties
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/package.html
org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplatePersistenceData.java
org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplatePersistenceMessages.java
org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplatePersistenceMessages.properties
org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateReaderWriter.java
org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateStore.java
org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/package.html
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/LineConversionTest.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/AnnotationManagerSetup.java
org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/AnnotationManagerTest.java
org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/JUnitSetup.java
org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/LineAnnotationManagerTest.java
org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/LineBasedFileSearch.java
org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/PositionTrackerTest.java
org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/ResultUpdaterTest.java
org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SearchResultPageTest.java
org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SortingTest.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/dlcl16/collapseall.gif
org.eclipse.search/icons/full/dlcl16/expandall.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/dlcl16/tsearch_obj.gif
org.eclipse.search/icons/full/dtool16/group_by_file.gif
org.eclipse.search/icons/full/dtool16/group_by_folder.gif
org.eclipse.search/icons/full/dtool16/group_by_project.gif
org.eclipse.search/icons/full/dtool16/search.gif
org.eclipse.search/icons/full/elcl16/collapseall.gif
org.eclipse.search/icons/full/elcl16/expandall.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/elcl16/tsearch_obj.gif
org.eclipse.search/icons/full/etool16/group_by_file.gif
org.eclipse.search/icons/full/etool16/group_by_folder.gif
org.eclipse.search/icons/full/etool16/group_by_project.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/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/IEditorMatchAdapter.java
org.eclipse.search/new search/org/eclipse/search/ui/text/IFileMatchAdapter.java
org.eclipse.search/new search/org/eclipse/search/ui/text/ISearchEditorAccess.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/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/SearchesDialog.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/CollapseAllAction.java
org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/ExpandAllAction.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/RemoveAllMatchesAction.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/RemoveSelectedMatchesAction.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/basic/views/TableViewerNavigator.java
org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/TreeViewerNavigator.java
org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/AnnotationHighlighter.java
org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/AnnotationManagers.java
org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/EditorAccessHighlighter.java
org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/EditorAnnotationManager.java
org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/Highlighter.java
org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/MarkerHighlighter.java
org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/PositionTracker.java
org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/WindowAnnotationManager.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/WorkingSetComparator.java
org.eclipse.search/search/org/eclipse/search/internal/ui/text/EditorOpener.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/RegExContentAssistProcessor.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/SearchResultUpdater.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/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/projection/org/eclipse/jface/text/projection/package.html
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/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/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/ISynchronizable.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/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/ILinkedModeListener.java
org.eclipse.text/src/org/eclipse/jface/text/link/InclusivePositionUpdater.java
org.eclipse.text/src/org/eclipse/jface/text/link/LinkedModeManager.java
org.eclipse.text/src/org/eclipse/jface/text/link/LinkedModeModel.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/package.html
org.eclipse.text/src/org/eclipse/jface/text/source/Annotation.java
org.eclipse.text/src/org/eclipse/jface/text/source/AnnotationMap.java
org.eclipse.text/src/org/eclipse/jface/text/source/AnnotationModel.java
org.eclipse.text/src/org/eclipse/jface/text/source/AnnotationModelEvent.java
org.eclipse.text/src/org/eclipse/jface/text/source/IAnnotationMap.java
org.eclipse.text/src/org/eclipse/jface/text/source/IAnnotationModel.java
org.eclipse.text/src/org/eclipse/jface/text/source/IAnnotationModelExtension.java
org.eclipse.text/src/org/eclipse/jface/text/source/IAnnotationModelListener.java
org.eclipse.text/src/org/eclipse/jface/text/source/IAnnotationModelListenerExtension.java
org.eclipse.text/src/org/eclipse/jface/text/source/package.html
org.eclipse.text/src/org/eclipse/jface/text/templates/DocumentTemplateContext.java
org.eclipse.text/src/org/eclipse/jface/text/templates/GlobalTemplateVariables.java
org.eclipse.text/src/org/eclipse/jface/text/templates/SimpleTemplateVariableResolver.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/TemplateContextType.java
org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateException.java
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/jface/text/templates/TextTemplateMessages.java
org.eclipse.text/src/org/eclipse/jface/text/templates/TextTemplateMessages.properties
org.eclipse.text/src/org/eclipse/jface/text/templates/package.html
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.editors.tests/src/org/eclipse/ui/editors/tests/EditorsTestSuite.java
org.eclipse.ui.editors/.classpath
org.eclipse.ui.editors/.cvsignore
org.eclipse.ui.editors/.project
org.eclipse.ui.editors/_buildnotes_text_2_0.html
org.eclipse.ui.editors/_buildnotes_text_2_1.html
org.eclipse.ui.editors/about.html
org.eclipse.ui.editors/build.properties
org.eclipse.ui.editors/buildnotes_text.html
org.eclipse.ui.editors/icons/full/ctool16/last_edit_pos.gif
org.eclipse.ui.editors/icons/full/ctool16/next_nav.gif
org.eclipse.ui.editors/icons/full/ctool16/prev_nav.gif
org.eclipse.ui.editors/icons/full/dtool16/last_edit_pos.gif
org.eclipse.ui.editors/icons/full/dtool16/next_nav.gif
org.eclipse.ui.editors/icons/full/dtool16/prev_nav.gif
org.eclipse.ui.editors/icons/full/etool16/last_edit_pos.gif
org.eclipse.ui.editors/icons/full/etool16/next_nav.gif
org.eclipse.ui.editors/icons/full/etool16/prev_nav.gif
org.eclipse.ui.editors/icons/full/obj16/file_obj.gif
org.eclipse.ui.editors/migration_guidelines.html
org.eclipse.ui.editors/plugin.properties
org.eclipse.ui.editors/plugin.xml
org.eclipse.ui.editors/schema/annotationTypes.exsd
org.eclipse.ui.editors/schema/documentProviders.exsd
org.eclipse.ui.editors/schema/markerAnnotationSpecification.exsd
org.eclipse.ui.editors/schema/markerUpdaters.exsd
org.eclipse.ui.editors/schema/templates.exsd
org.eclipse.ui.editors/scripts/exportplugin.xml
org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/DefaultEncodingSupport.java
org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/EditorsUI.java
org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/EncodingActionGroup.java
org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/FileDocumentProvider.java
org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/ForwardingDocumentProvider.java
org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/IEncodingActionsConstants.java
org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/IEncodingActionsDefinitionIds.java
org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/IEncodingActionsHelpContextIds.java
org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/IEncodingSupport.java
org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/IFoldingCommandIds.java
org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/ILocationProvider.java
org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/IStorageDocumentProvider.java
org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/ITextEditorHelpContextIds.java
org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/StorageDocumentProvider.java
org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditor.java
org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditorActionContributor.java
org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditorMessages.java
org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditorMessages.properties
org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditorPreferenceConstants.java
org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditorPreferencePage.java
org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextFileDocumentProvider.java
org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextSourceViewerConfiguration.java
org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/package.html
org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionContextTypeRegistry.java
org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionTemplateMessages.java
org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionTemplateMessages.properties
org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionTemplateStore.java
org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/package.html
org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/quickdiff/LastSaveReferenceProvider.java
org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/quickdiff/QuickDiffMessages.java
org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/quickdiff/QuickDiffMessages.properties
org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AbstractConfigurationBlockPreferencePage.java
org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AnnotationsConfigurationBlock.java
org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AnnotationsPreferencePage.java
org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/ColorEditor.java
org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/EditorsPlugin.java
org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/FileEditorInputAdapterFactory.java
org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/IEditorsStatusConstants.java
org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/IPreferenceConfigurationBlock.java
org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/JavaFileEditorInput.java
org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/NextPreviousPulldownActionDelegate.java
org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/NextPulldownActionDelegate.java
org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/OpenExternalFileAction.java
org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/OverlayPreferenceStore.java
org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/PixelConverter.java
org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/PreviousPulldownActionDelegate.java
org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/QuickDiffConfigurationBlock.java
org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/QuickDiffPreferencePage.java
org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SharedTextColors.java
org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/StatusInfo.java
org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TabFolderLayout.java
org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.java
org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.properties
org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorPreferencePage2.java
org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/UISynchronizationContext.java
org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/WorkspaceOperationRunner.java
org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/AnnotationType.java
org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/AnnotationTypeHierarchy.java
org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/DelegatingAnnotationPreference.java
org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/SourceViewerInformationControl.java
org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/TextChangeHover.java
org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditor.java
org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditorPreferenceConstants.java
org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractMarkerAnnotationModel.java
org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AddMarkerAction.java
org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AddTaskAction.java
org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationPreferenceLookup.java
org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationTypeLookup.java
org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/BasicMarkerUpdater.java
org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/BookmarkRulerAction.java
org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ChainedPreferenceStore.java
org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DefaultMarkerAnnotationAccess.java
org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DocumentProviderRegistry.java
org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/IMarkerUpdater.java
org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ImageUtilities.java
org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotation.java
org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotationPreferences.java
org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerRulerAction.java
org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerRulerInfoAction.java
org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerUpdater.java
org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerUtilities.java
org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ResourceMarkerAnnotationModel.java
org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ResourceMarkerAnnotationModelFactory.java
org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/SelectMarkerRulerAction.java
org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/SelectMarkerRulerInfoAction.java
org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/SelectRulerAction.java
org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/SimpleMarkerAnnotation.java
org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/TaskRulerAction.java
org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/TextEditorMessages.java
org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/TextEditorMessages.properties
org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/package.html
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
org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/WorkbenchTextEditorTestSuite.java
org.eclipse.ui.workbench.texteditor/.classpath
org.eclipse.ui.workbench.texteditor/.cvsignore
org.eclipse.ui.workbench.texteditor/.project
org.eclipse.ui.workbench.texteditor/about.html
org.eclipse.ui.workbench.texteditor/build.properties
org.eclipse.ui.workbench.texteditor/icons/full/ctool16/segment_edit.gif
org.eclipse.ui.workbench.texteditor/icons/full/dtool16/segment_edit.gif
org.eclipse.ui.workbench.texteditor/icons/full/etool16/segment_edit.gif
org.eclipse.ui.workbench.texteditor/plugin.properties
org.eclipse.ui.workbench.texteditor/plugin.xml
org.eclipse.ui.workbench.texteditor/schema/quickDiffReferenceProvider.exsd
org.eclipse.ui.workbench.texteditor/scripts/exportplugin.xml
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/contentassist/ContentAssistHandler.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/contentassist/ContentAssistMessages.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/contentassist/ContentAssistMessages.properties
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/AnnotationExpandHover.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/AnnotationExpansionControl.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/EditPosition.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/EditorMessages.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/EditorMessages.properties
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/GotoLastEditPositionAction.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/LinearLayouter.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/TextEditorPlugin.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DiffRegion.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DocumentLineDiffer.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffExtensionsRegistry.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffMessages.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffMessages.properties
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffRestoreAction.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/ReferenceSelectionAction.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/RestoreAction.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/RevertBlockAction.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/RevertLineAction.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/RevertSelectionAction.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/DifferencesIterator.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/DocLineComparator.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/IRangeComparator.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/ITokenComparator.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/LinkedRangeDifference.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/LinkedRangeFactory.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/RangeDifference.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/RangeDifferencer.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/package.html
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/package.html
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractDocumentProvider.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractRulerActionDelegate.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AnnotationPreference.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/BasicTextEditorActionContributor.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/CaseAction.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConfigurationElementSorter.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ContentAssistAction.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConvertLineDelimitersAction.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/DefaultRangeIndicator.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/DeleteLineAction.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/DeleteLineTarget.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/EditorMessages.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/EditorMessages.properties
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/EditorStatusLine.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindNextAction.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceAction.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceDialog.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceTarget.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/GotoLineAction.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IAbstractTextEditorHelpContextIds.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IAnnotationImageProvider.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IDocumentProvider.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IDocumentProviderExtension.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IDocumentProviderExtension2.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IDocumentProviderExtension3.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IEditorStatusLine.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IElementStateListener.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IElementStateListenerExtension.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IFindReplaceTargetExtension2.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IReadOnlyDependent.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ISchedulingRuleProvider.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IStatusField.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IStatusFieldExtension.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditor.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorActionConstants.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorActionDefinitionIds.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorDropTargetListener.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorExtension.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorExtension2.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorExtension3.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IUpdate.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IWorkbenchActionDefinitionIds.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IncrementalFindAction.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IncrementalFindTarget.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/InfoForm.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/InsertLineAction.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/MarkAction.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/MarkRegionTarget.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/MoveLinesAction.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/PropagatingFontFieldEditor.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/RegExContentAssistProcessor.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ResourceAction.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/RetargetTextEditorAction.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/RevertToSavedAction.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SaveAction.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SelectAnnotationRulerAction.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ShiftAction.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SourceViewerDecorationSupport.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/StatusLineContributionItem.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/StatusTextEditor.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/TextEditorAction.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/TextNavigationAction.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/TextOperationAction.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/TextSelectionNavigationLocation.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ValidateStateException.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/WorkbenchChainedTextFontFieldEditor.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/link/EditorLinkedModeUI.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/package.html
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/IQuickDiffReferenceProvider.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/QuickDiff.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/QuickDiffToggleAction.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/ReferenceProviderDescriptor.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/package.html
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/EditTemplateDialog.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/MessageLine.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/StatusDialog.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/StatusInfo.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplateContentProvider.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplateVariableProcessor.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplateVariableProposal.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TextEditorTemplateMessages.java
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TextEditorTemplateMessages.properties
org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/package.html
Diffstat (limited to 'org.eclipse.ui.workbench.texteditor')
129 files changed, 0 insertions, 31437 deletions
diff --git a/org.eclipse.ui.workbench.texteditor/.classpath b/org.eclipse.ui.workbench.texteditor/.classpath deleted file mode 100644 index 065ac06e197..00000000000 --- a/org.eclipse.ui.workbench.texteditor/.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.ui.workbench.texteditor/.cvsignore b/org.eclipse.ui.workbench.texteditor/.cvsignore deleted file mode 100644 index c5e82d74585..00000000000 --- a/org.eclipse.ui.workbench.texteditor/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -bin
\ No newline at end of file diff --git a/org.eclipse.ui.workbench.texteditor/.project b/org.eclipse.ui.workbench.texteditor/.project deleted file mode 100644 index ba6f6a3796a..00000000000 --- a/org.eclipse.ui.workbench.texteditor/.project +++ /dev/null @@ -1,31 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>org.eclipse.ui.workbench.texteditor</name> - <comment></comment> - <projects> - <project>org.eclipse.core.runtime.compatibility</project> - <project>org.eclipse.jface.text</project> - <project>org.eclipse.ui</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.ui.workbench.texteditor/about.html b/org.eclipse.ui.workbench.texteditor/about.html deleted file mode 100644 index 9db411aab99..00000000000 --- a/org.eclipse.ui.workbench.texteditor/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.workbench.texteditor/build.properties b/org.eclipse.ui.workbench.texteditor/build.properties deleted file mode 100644 index ddb08d5fb07..00000000000 --- a/org.eclipse.ui.workbench.texteditor/build.properties +++ /dev/null @@ -1,18 +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 -############################################################################### -bin.includes = *.jar,\ - plugin.xml,\ - plugin.properties,\ - icons/,\ - about.html -src.includes = about.html,\ - schema/ -source.texteditor.jar = src/ diff --git a/org.eclipse.ui.workbench.texteditor/icons/full/ctool16/segment_edit.gif b/org.eclipse.ui.workbench.texteditor/icons/full/ctool16/segment_edit.gif Binary files differdeleted file mode 100644 index 1b50ff8d67b..00000000000 --- a/org.eclipse.ui.workbench.texteditor/icons/full/ctool16/segment_edit.gif +++ /dev/null diff --git a/org.eclipse.ui.workbench.texteditor/icons/full/dtool16/segment_edit.gif b/org.eclipse.ui.workbench.texteditor/icons/full/dtool16/segment_edit.gif Binary files differdeleted file mode 100644 index e55a884d6a1..00000000000 --- a/org.eclipse.ui.workbench.texteditor/icons/full/dtool16/segment_edit.gif +++ /dev/null diff --git a/org.eclipse.ui.workbench.texteditor/icons/full/etool16/segment_edit.gif b/org.eclipse.ui.workbench.texteditor/icons/full/etool16/segment_edit.gif Binary files differdeleted file mode 100644 index 1b50ff8d67b..00000000000 --- a/org.eclipse.ui.workbench.texteditor/icons/full/etool16/segment_edit.gif +++ /dev/null diff --git a/org.eclipse.ui.workbench.texteditor/plugin.properties b/org.eclipse.ui.workbench.texteditor/plugin.properties deleted file mode 100644 index c3b6c951af9..00000000000 --- a/org.eclipse.ui.workbench.texteditor/plugin.properties +++ /dev/null @@ -1,158 +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 -############################################################################### -pluginName= Text Editor Framework -providerName= Eclipse.org - -category.textEditor.name= Text Editing -category.textEditor.description= Text Editing Commands - -ExtPoint.referenceProvider= Reference Provider - -textEditorPresentationActionSet.label= Editor Presentation - -onlyShowSelectedElement.label= Show Selected Element Only -onlyShowSelectedElement.tooltip= Show Selected Element Only -onlyShowSelectedElement.description= Show Selected Element Only - -smartEnter.label= Insert Line Below Current Line -smartEnter.description= Adds a new line below the current line -smartEnterInverse.label= Insert Line Above Current Line -smartEnterInverse.description= Adds a new line above the current line -moveLineUp.label= Move Lines Up -moveLineUp.description= Moves the selected lines up -moveLineDown.label= Move Lines Down -moveLineDown.description= Moves the selected lines down -copyLineUp.label= Duplicate Lines -copyLineUp.description= Duplicates the selected lines and leaves the selection unchanged -copyLineDown.label= Copy Lines -copyLineDown.description= Duplicates the selected lines and moves the selection to the copy -upperCase.description= Changes the selection to upper case -upperCase.label= To Upper Case -lowerCase.description= Changes the selection to lower case -lowerCase.label= To Lower Case - -goToLastEditPosition.label= Last Edit Location -goToLastEditPosition.description= Last edit location - -command.clearMark.description = Clear the mark -command.clearMark.name = Clear Mark -command.contentAssistContextInformation.description= Show Context Information -command.contentAssistContextInformation.name= Context Information -command.contentAssistProposals.description= Content Assist -command.contentAssistProposals.name= Content Assist -command.deleteLine.description = Delete a line of text -command.deleteLine.name = Delete Line -command.cutLine.description = Cut a line of text -command.cutLine.name = Cut Line -command.deleteLineBeginning.description = Delete to the beginning of a line of text -command.deleteLineBeginning.name = Delete to Beginning of Line -command.cutLineBeginning.description = Cut to the beginning of a line of text -command.cutLineBeginning.name = Cut to Beginning of Line -command.deleteLineEnd.description = Delete to the end of a line of text -command.deleteLineEnd.name = Delete to End of Line -command.cutLineEnd.description = Cut to the end of a line of text -command.cutLineEnd.name = Cut to End of Line -command.deleteNext.description = Delete the next character -command.deleteNext.name = Delete Next -command.deletePreviousWord.description = Delete the previous word -command.deletePreviousWord.name = Delete Previous Word -command.deleteNextWord.description = Delete the next word -command.deleteNextWord.name = Delete Next Word -command.deletePrevious.description = Delete the previous character -command.deletePrevious.name = Delete Previous -command.findIncremental.description = Incremental find -command.findIncremental.name = Incremental Find -command.findIncrementalReverse.description = Incremental find reverse -command.findIncrementalReverse.name = Incremental Find Reverse -command.findNext.description = Find next item -command.findNext.name = Find Next -command.findPrevious.description = Find previous item -command.findPrevious.name = Find Previous -command.goToLine.description = Go to a specified line of text -command.goToLine.name = Go to Line -command.lineDown.description = Go down one line of text -command.lineDown.name = Line Down -command.lineEnd.description = Go to the end of the line of text -command.lineEnd.name = Line End -command.lineStart.description = Go to the start of the line of text -command.lineStart.name = Line Start -command.lineUp.description = Go up one line of text -command.lineUp.name = Line Up -command.nextColumn.description = Go to the next column -command.nextColumn.name = Next Column -command.nextWord.description = Go to the next word -command.nextWord.name = Next Word -command.pageDown.description = Go down one page -command.pageDown.name = Page Down -command.pageUp.description = Go up one page -command.pageUp.name = Page Up -command.previousColumn.description = Go to the previous column -command.previousColumn.name = Previous Column -command.previousWord.description = Go to the previous word -command.previousWord.name = Previous Word -command.revertToSaved.description = Revert to the last saved state -command.revertToSaved.name = Revert to Saved -command.scrollLineDown.description = Scroll down one line of text -command.scrollLineDown.name = Scroll Line Down -command.scrollLineUp.description = Scroll up one line of text -command.scrollLineUp.name = Scroll Line Up -command.selectAll.description = Select all -command.selectAll.name = Select All -command.selectLineDown.description = Extend the selection to the next line of text -command.selectLineDown.name = Select Line Down -command.selectLineEnd.description = Select to the end of the line of text -command.selectLineEnd.name = Select Line End -command.selectLineStart.description = Select to the beginning of the line of text -command.selectLineStart.name = Select Line Start -command.selectLineUp.description = Extend the selection to the previous line of text -command.selectLineUp.name = Select Line Up -command.selectNextColumn.description = Select the next column -command.selectNextColumn.name = Select Next Column -command.selectPageDown.description = Select to the bottom of the page -command.selectPageDown.name = Select Page Down -command.selectPageUp.description = Select to the top of the page -command.selectPageUp.name = Select Page Up -command.selectPreviousColumn.description = Select the previous column -command.selectPreviousColumn.name = Select Previous Column -command.selectTextEnd.description = Select to the end of the text -command.selectTextEnd.name = Select Text End -command.selectTextStart.description = Select to the beginning of the text -command.selectTextStart.name = Select Text Start -command.selectWindowEnd.description = Select to the end of the window -command.selectWindowEnd.name = Select Window End -command.selectWindowStart.description = Select to the start of the window -command.selectWindowStart.name = Select Window Start -command.selectWordNext.description = Select the next word -command.selectWordNext.name = Select Next Word -command.selectWordPrevious.description = Select the previous word -command.selectWordPrevious.name = Select Previous Word -command.setMark.description = Set the mark -command.setMark.name = Set Mark -command.shiftLeft.description = Shift a block of text to the left -command.shiftLeft.name = Shift Left -command.shiftRight.description = Shift a block of text to the right -command.shiftRight.name = Shift Right -command.showRulerContextMenu.description = Show the context menu for the ruler -command.showRulerContextMenu.name = Show Ruler Context Menu -command.swapMark.description = Swap the mark with the cursor position -command.swapMark.name = Swap Mark -command.textEnd.description = Go to the end of the text -command.textEnd.name = Text End -command.textStart.description = Go to the beginning of the text -command.textStart.name = Text Start -command.toggleOverwrite.description = Toggle overwrite mode -command.toggleOverwrite.name = Toggle Overwrite -command.toggleInsertMode.description = Toggle insert mode -command.toggleInsertMode.name = Toggle Insert Mode -command.windowEnd.description = Go to the end of the window -command.windowEnd.name = Window End -command.windowStart.description = Go to the start of the window -command.windowStart.name = Window Start diff --git a/org.eclipse.ui.workbench.texteditor/plugin.xml b/org.eclipse.ui.workbench.texteditor/plugin.xml deleted file mode 100644 index 987ab3d47ea..00000000000 --- a/org.eclipse.ui.workbench.texteditor/plugin.xml +++ /dev/null @@ -1,1079 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<?eclipse version="3.0"?> -<plugin - id="org.eclipse.ui.workbench.texteditor" - name="%pluginName" - version="3.0.0" - provider-name="%providerName" - class="org.eclipse.ui.internal.texteditor.TextEditorPlugin"> - - <runtime> - <library name="texteditor.jar"> - <export name="*"/> - </library> - </runtime> - <requires> - <import plugin="org.eclipse.core.runtime"/> - <import plugin="org.eclipse.jface.text"/> - <import plugin="org.eclipse.ui"/> - </requires> - - - <extension-point id="quickDiffReferenceProvider" name="%ExtPoint.referenceProvider" schema="schema/quickDiffReferenceProvider.exsd"/> - - - <extension - point="org.eclipse.ui.commands"> - <category - name="%category.textEditor.name" - description="%category.textEditor.description" - id="org.eclipse.ui.category.textEditor"> - </category> - <command - name="%command.deleteLine.name" - description="%command.deleteLine.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.delete.line"> - </command> - <command - name="%command.cutLine.name" - description="%command.cutLine.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.cut.line"> - </command> - <command - name="%command.deleteLineBeginning.name" - description="%command.deleteLineBeginning.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.delete.line.to.beginning"> - </command> - <command - name="%command.cutLineBeginning.name" - description="%command.cutLineBeginning.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.cut.line.to.beginning"> - </command> - <command - name="%command.deleteLineEnd.name" - description="%command.deleteLineEnd.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.delete.line.to.end"> - </command> - <command - name="%command.cutLineEnd.name" - description="%command.cutLineEnd.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.cut.line.to.end"> - </command> - <command - name="%command.setMark.name" - description="%command.setMark.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.set.mark"> - </command> - <command - name="%command.clearMark.name" - description="%command.clearMark.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.clear.mark"> - </command> - <command - name="%command.swapMark.name" - description="%command.swapMark.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.swap.mark"> - </command> - <command - name="%command.findNext.name" - description="%command.findNext.description" - categoryId="org.eclipse.ui.category.edit" - id="org.eclipse.ui.edit.findNext"> - </command> - <command - name="%command.findPrevious.name" - description="%command.findPrevious.description" - categoryId="org.eclipse.ui.category.edit" - id="org.eclipse.ui.edit.findPrevious"> - </command> - <command - name="%command.findIncremental.name" - description="%command.findIncremental.description" - categoryId="org.eclipse.ui.category.edit" - id="org.eclipse.ui.edit.findIncremental"> - </command> - <command - name="%command.findIncrementalReverse.name" - description="%command.findIncrementalReverse.description" - categoryId="org.eclipse.ui.category.edit" - id="org.eclipse.ui.edit.findIncrementalReverse"> - </command> - <command - name="%command.revertToSaved.name" - description="%command.revertToSaved.description" - categoryId="org.eclipse.ui.category.edit" - id="org.eclipse.ui.edit.revertToSaved"> - </command> - <command - name="%command.lineUp.name" - description="%command.lineUp.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.goto.lineUp"> - </command> - <command - name="%command.lineDown.name" - description="%command.lineDown.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.goto.lineDown"> - </command> - <command - name="%command.lineStart.name" - description="%command.lineStart.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.goto.lineStart"> - </command> - <command - name="%command.lineEnd.name" - description="%command.lineEnd.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.goto.lineEnd"> - </command> - <command - name="%command.goToLine.name" - description="%command.goToLine.description" - categoryId="org.eclipse.ui.category.navigate" - id="org.eclipse.ui.edit.text.goto.line"> - </command> - <command - name="%command.previousColumn.name" - description="%command.previousColumn.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.goto.columnPrevious"> - </command> - <command - name="%command.nextColumn.name" - description="%command.nextColumn.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.goto.columnNext"> - </command> - <command - name="%command.pageUp.name" - description="%command.pageUp.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.goto.pageUp"> - </command> - <command - name="%command.pageDown.name" - description="%command.pageDown.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.goto.pageDown"> - </command> - <command - name="%command.previousWord.name" - description="%command.previousWord.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.goto.wordPrevious"> - </command> - <command - name="%command.nextWord.name" - description="%command.nextWord.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.goto.wordNext"> - </command> - <command - name="%command.textStart.name" - description="%command.textStart.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.goto.textStart"> - </command> - <command - name="%command.textEnd.name" - description="%command.textEnd.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.goto.textEnd"> - </command> - <command - name="%command.windowStart.name" - description="%command.windowStart.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.goto.windowStart"> - </command> - <command - name="%command.windowEnd.name" - description="%command.windowEnd.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.goto.windowEnd"> - </command> - <command - name="%command.scrollLineUp.name" - description="%command.scrollLineUp.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.scroll.lineUp"> - </command> - <command - name="%command.scrollLineDown.name" - description="%command.scrollLineDown.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.scroll.lineDown"> - </command> - <command - name="%command.selectLineUp.name" - description="%command.selectLineUp.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.select.lineUp"> - </command> - <command - name="%command.selectLineDown.name" - description="%command.selectLineDown.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.select.lineDown"> - </command> - <command - name="%command.selectLineStart.name" - description="%command.selectLineStart.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.select.lineStart"> - </command> - <command - name="%command.selectLineEnd.name" - description="%command.selectLineEnd.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.select.lineEnd"> - </command> - <command - name="%command.selectPreviousColumn.name" - description="%command.selectPreviousColumn.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.select.columnPrevious"> - </command> - <command - name="%command.selectNextColumn.name" - description="%command.selectNextColumn.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.select.columnNext"> - </command> - <command - name="%command.selectPageUp.name" - description="%command.selectPageUp.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.select.pageUp"> - </command> - <command - name="%command.selectPageDown.name" - description="%command.selectPageDown.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.select.pageDown"> - </command> - <command - name="%command.selectWordPrevious.name" - description="%command.selectWordPrevious.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.select.wordPrevious"> - </command> - <command - name="%command.selectWordNext.name" - description="%command.selectWordNext.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.select.wordNext"> - </command> - <command - name="%command.selectTextStart.name" - description="%command.selectTextStart.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.select.textStart"> - </command> - <command - name="%command.selectTextEnd.name" - description="%command.selectTextEnd.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.select.textEnd"> - </command> - <command - name="%command.selectWindowStart.name" - description="%command.selectWindowStart.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.select.windowStart"> - </command> - <command - name="%command.selectWindowEnd.name" - description="%command.selectWindowEnd.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.select.windowEnd"> - </command> - <command - name="%command.deletePrevious.name" - description="%command.deletePrevious.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.deletePrevious"> - </command> - <command - name="%command.deleteNext.name" - description="%command.deleteNext.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.deleteNext"> - </command> - <command - name="%command.deletePreviousWord.name" - description="%command.deletePreviousWord.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.deletePreviousWord"> - </command> - <command - name="%command.deleteNextWord.name" - description="%command.deleteNextWord.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.deleteNextWord"> - </command> - <command - name="%command.shiftRight.name" - description="%command.shiftRight.description" - categoryId="org.eclipse.ui.category.edit" - id="org.eclipse.ui.edit.text.shiftRight"> - </command> - <command - name="%command.shiftLeft.name" - description="%command.shiftLeft.description" - categoryId="org.eclipse.ui.category.edit" - id="org.eclipse.ui.edit.text.shiftLeft"> - </command> - <command - name="%command.toggleOverwrite.name" - description="%command.toggleOverwrite.description" - categoryId="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.toggleOverwrite"> - </command> - <command - name="%command.showRulerContextMenu.name" - description="%command.showRulerContextMenu.description" - categoryId="org.eclipse.ui.category.window" - id="org.eclipse.ui.edit.text.showRulerContextMenu"> - </command> - <command - name="%goToLastEditPosition.label" - description="%goToLastEditPosition.description" - category="org.eclipse.ui.category.navigate" - id="org.eclipse.ui.edit.text.gotoLastEditPosition"> - </command> - <command - name="%smartEnter.label" - description="%smartEnter.description" - category="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.smartEnter"> - </command> - <command - name="%smartEnterInverse.label" - description="%smartEnterInverse.description" - category="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.smartEnterInverse"> - </command> - <command - name="%moveLineUp.label" - description="%moveLineUp.description" - category="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.moveLineUp"> - </command> - <command - name="%moveLineDown.label" - description="%moveLineDown.description" - category="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.moveLineDown"> - </command> - <command - name="%copyLineUp.label" - description="%copyLineUp.description" - category="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.copyLineUp"> - </command> - <command - name="%copyLineDown.label" - description="%copyLineDown.description" - category="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.copyLineDown"> - </command> - <command - name="%upperCase.label" - description="%upperCase.description" - category="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.upperCase"> - </command> - <command - name="%lowerCase.label" - description="%lowerCase.description" - category="org.eclipse.ui.category.textEditor" - id="org.eclipse.ui.edit.text.lowerCase"> - </command> - <command - name="%onlyShowSelectedElement.label" - description="%onlyShowSelectedElement.description" - category="org.eclipse.ui.category.window" - id="org.eclipse.ui.edit.text.toggleShowSelectedElementOnly"> - </command> - <command - name="%command.contentAssistProposals.name" - description="%command.contentAssistProposals.description" - categoryId="org.eclipse.ui.category.edit" - id="org.eclipse.ui.edit.text.contentAssist.proposals"> - </command> - <command - name="%command.contentAssistContextInformation.name" - description="%command.contentAssistContextInformation.description" - categoryId="org.eclipse.ui.category.edit" - id="org.eclipse.ui.edit.text.contentAssist.contextInformation"> - </command> - <command - name="%command.toggleInsertMode.name" - description="%command.toggleInsertMode.description" - categoryId="org.eclipse.ui.category.edit" - id="org.eclipse.ui.edit.text.toggleInsertMode"> - </command> - - <keyBinding - commandId="org.eclipse.ui.edit.text.delete.line" - contextId="org.eclipse.ui.textEditorScope" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration" - keySequence="Ctrl+D"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.delete.line.to.end" - contextId="org.eclipse.ui.textEditorScope" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration" - keySequence="Ctrl+Shift+Delete"> - </keyBinding> - <keyBinding - platform="gtk" - contextId="org.eclipse.ui.textEditorScope" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration" - keySequence="Ctrl+Shift+Delete"> - </keyBinding> - <keyBinding - platform="gtk" - commandId="org.eclipse.ui.edit.text.delete.line.to.end" - contextId="org.eclipse.ui.textEditorScope" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration" - keySequence="Esc Ctrl+Delete"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.findNext" - contextId="org.eclipse.ui.textEditorScope" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration" - keySequence="Ctrl+K"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.findPrevious" - contextId="org.eclipse.ui.textEditorScope" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration" - keySequence="Ctrl+Shift+K"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.findIncremental" - contextId="org.eclipse.ui.textEditorScope" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration" - keySequence="Ctrl+J"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.findIncrementalReverse" - contextId="org.eclipse.ui.textEditorScope" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration" - keySequence="Ctrl+Shift+J"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.goto.line" - contextId="org.eclipse.ui.textEditorScope" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration" - keySequence="Ctrl+L"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.scroll.lineUp" - contextId="org.eclipse.ui.textEditorScope" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration" - keySequence="Ctrl+Arrow_Up"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.scroll.lineDown" - contextId="org.eclipse.ui.textEditorScope" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration" - keySequence="Ctrl+Arrow_Down"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.toggleOverwrite" - contextId="org.eclipse.ui.textEditorScope" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration" - keySequence="Insert"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.showRulerContextMenu" - contextId="org.eclipse.ui.textEditorScope" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration" - keySequence="Ctrl+F10"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.contentAssist.proposals" - contextId="org.eclipse.ui.contexts.dialogAndWindow" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration" - keySequence="Ctrl+Space"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.contentAssist.contextInformation" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration" - keySequence="Ctrl+Shift+Space"> - </keyBinding> - <keyBinding - string="Ctrl+Q" - scope="org.eclipse.ui.globalScope" - command="org.eclipse.ui.edit.text.gotoLastEditPosition" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"> - </keyBinding> - <keyBinding - string="Shift+ENTER" - scope="org.eclipse.ui.textEditorScope" - command="org.eclipse.ui.edit.text.smartEnter" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"> - </keyBinding> - <keyBinding - string="Ctrl+Shift+ENTER" - scope="org.eclipse.ui.textEditorScope" - command="org.eclipse.ui.edit.text.smartEnterInverse" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"> - </keyBinding> - <keyBinding - string="Alt+ARROW_UP" - scope="org.eclipse.ui.textEditorScope" - command="org.eclipse.ui.edit.text.moveLineUp" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"> - </keyBinding> - <keyBinding - string="Alt+ARROW_DOWN" - scope="org.eclipse.ui.textEditorScope" - command="org.eclipse.ui.edit.text.moveLineDown" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"> - </keyBinding> - <keyBinding - string="Alt+Ctrl+ARROW_UP" - scope="org.eclipse.ui.textEditorScope" - command="org.eclipse.ui.edit.text.copyLineUp" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"> - </keyBinding> - <keyBinding - string="Alt+Ctrl+ARROW_DOWN" - scope="org.eclipse.ui.textEditorScope" - command="org.eclipse.ui.edit.text.copyLineDown" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"> - </keyBinding> - <keyBinding - string="Ctrl+Shift+X" - scope="org.eclipse.ui.textEditorScope" - command="org.eclipse.ui.edit.text.upperCase" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"> - </keyBinding> - <keyBinding - string="Ctrl+Shift+Y" - scope="org.eclipse.ui.textEditorScope" - command="org.eclipse.ui.edit.text.lowerCase" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"> - </keyBinding> - <keyBinding - string="" - scope="org.eclipse.ui.textEditorScope" - command="org.eclipse.ui.edit.text.toggleShowSelectedElementOnly" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"> - </keyBinding> - <keyBinding - string="Ctrl+Arrow_Right" - scope="org.eclipse.ui.textEditorScope" - command="org.eclipse.ui.edit.text.goto.wordNext" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"> - </keyBinding> - <keyBinding - string="Ctrl+Arrow_Left" - scope="org.eclipse.ui.textEditorScope" - command="org.eclipse.ui.edit.text.goto.wordPrevious" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"> - </keyBinding> - <keyBinding - string="Ctrl+Delete" - scope="org.eclipse.ui.textEditorScope" - command="org.eclipse.ui.edit.text.deleteNextWord" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"> - </keyBinding> - <keyBinding - string="Ctrl+Backspace" - scope="org.eclipse.ui.textEditorScope" - command="org.eclipse.ui.edit.text.deletePreviousWord" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"> - </keyBinding> - <keyBinding - string="Ctrl+Shift+Arrow_Right" - scope="org.eclipse.ui.textEditorScope" - command="org.eclipse.ui.edit.text.select.wordNext" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"> - </keyBinding> - <keyBinding - string="Ctrl+Shift+Arrow_Left" - scope="org.eclipse.ui.textEditorScope" - command="org.eclipse.ui.edit.text.select.wordPrevious" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"> - </keyBinding> - <keyBinding - locale="zh" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration" - keySequence="Ctrl+Space"> - </keyBinding> - <keyBinding - locale="zh" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration" - keySequence="Ctrl+Shift+Space"> - </keyBinding> - <keyBinding - locale="zh" - commandId="org.eclipse.ui.edit.text.contentAssist.proposals" - contextId="org.eclipse.ui.contexts.dialogAndWindow" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration" - keySequence="Alt+/"> - </keyBinding> - <keyBinding - locale="zh" - commandId="org.eclipse.ui.edit.text.contentAssist.contextInformation" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration" - keySequence="Alt+?"> - </keyBinding> - <keyBinding - locale="zh" - commandId="org.eclipse.ui.edit.text.contentAssist.contextInformation" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration" - keySequence="Alt+Shift+?"> - </keyBinding> - <keyBinding - platform="carbon" - contextId="org.eclipse.ui.textEditorScope" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration" - keySequence="Ctrl+D"> - </keyBinding> - <keyBinding - platform="carbon" - contextId="org.eclipse.ui.textEditorScope" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration" - keySequence="Ctrl+Shift+Delete"> - </keyBinding> - <keyBinding - platform="carbon" - contextId="org.eclipse.ui.textEditorScope" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration" - keySequence="Ctrl+K"> - </keyBinding> - <keyBinding - platform="carbon" - contextId="org.eclipse.ui.textEditorScope" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration" - keySequence="Ctrl+Shift+K"> - </keyBinding> - <keyBinding - platform="carbon" - contextId="org.eclipse.ui.textEditorScope" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration" - keySequence="Ctrl+J"> - </keyBinding> - <keyBinding - platform="carbon" - contextId="org.eclipse.ui.textEditorScope" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration" - keySequence="Ctrl+Shift+J"> - </keyBinding> - <keyBinding - platform="carbon" - contextId="org.eclipse.ui.textEditorScope" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration" - keySequence="Ctrl+L"> - </keyBinding> - <keyBinding - platform="carbon" - contextId="org.eclipse.ui.textEditorScope" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration" - keySequence="Ctrl+Arrow_Up"> - </keyBinding> - <keyBinding - platform="carbon" - contextId="org.eclipse.ui.textEditorScope" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration" - keySequence="Ctrl+Arrow_Down"> - </keyBinding> - <keyBinding - platform="carbon" - contextId="org.eclipse.ui.textEditorScope" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration" - keySequence="Ctrl+F10"> - </keyBinding> - <keyBinding - platform="carbon" - commandId="org.eclipse.ui.edit.text.showRulerContextMenu" - contextId="org.eclipse.ui.textEditorScope" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration" - keySequence="Command+F10"> - </keyBinding> - <keyBinding - platform="carbon" - commandId="org.eclipse.ui.edit.text.delete.line" - contextId="org.eclipse.ui.textEditorScope" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration" - keySequence="Command+D"> - </keyBinding> - <keyBinding - platform="carbon" - commandId="org.eclipse.ui.edit.text.delete.line.to.end" - contextId="org.eclipse.ui.textEditorScope" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration" - keySequence="Command+Shift+Delete"> - </keyBinding> - <keyBinding - platform="carbon" - commandId="org.eclipse.ui.edit.findNext" - contextId="org.eclipse.ui.textEditorScope" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration" - keySequence="Command+K"> - </keyBinding> - <keyBinding - platform="carbon" - commandId="org.eclipse.ui.edit.findPrevious" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration" - contextId="org.eclipse.ui.textEditorScope" - keySequence="Command+Shift+K"> - </keyBinding> - <keyBinding - platform="carbon" - commandId="org.eclipse.ui.edit.findIncremental" - contextId="org.eclipse.ui.textEditorScope" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration" - keySequence="Command+J"> - </keyBinding> - <keyBinding - platform="carbon" - commandId="org.eclipse.ui.edit.findIncrementalReverse" - contextId="org.eclipse.ui.textEditorScope" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration" - keySequence="Command+Shift+J"> - </keyBinding> - <keyBinding - platform="carbon" - commandId="org.eclipse.ui.edit.text.goto.line" - contextId="org.eclipse.ui.textEditorScope" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration" - keySequence="Command+L"> - </keyBinding> - <keyBinding - platform="carbon" - commandId="org.eclipse.ui.edit.text.scroll.lineUp" - contextId="org.eclipse.ui.textEditorScope" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration" - keySequence="Command+Arrow_Up"> - </keyBinding> - <keyBinding - platform="carbon" - commandId="org.eclipse.ui.edit.text.scroll.lineDown" - contextId="org.eclipse.ui.textEditorScope" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration" - keySequence="Command+Arrow_Down"> - </keyBinding> - <keyBinding - platform="carbon" - commandId="org.eclipse.ui.edit.text.contentAssist.proposals" - contextId="org.eclipse.ui.contexts.dialogAndWindow" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration" - keySequence="Command+Space"> - </keyBinding> - <keyBinding - platform="carbon" - commandId="org.eclipse.ui.edit.text.contentAssist.contextInformation" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration" - keySequence="Command+Shift+Space"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.toggleInsertMode" - contextId="org.eclipse.ui.textEditorScope" - keySequence="Ctrl+Shift+Insert" - keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.cut.line.to.beginning" - contextId="org.eclipse.ui.textEditorScope" - keySequence="Alt+0 Ctrl+K" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.cut.line.to.beginning" - contextId="org.eclipse.ui.textEditorScope" - keySequence="Esc 0 Ctrl+K" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.cut.line.to.end" - contextId="org.eclipse.ui.textEditorScope" - keySequence="Ctrl+K" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.set.mark" - contextId="org.eclipse.ui.textEditorScope" - keySequence="Ctrl+Space" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.set.mark" - contextId="org.eclipse.ui.textEditorScope" - keySequence="Ctrl+2" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.clear.mark" - contextId="org.eclipse.ui.textEditorScope" - keySequence="Ctrl+G" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.swap.mark" - contextId="org.eclipse.ui.textEditorScope" - keySequence="Ctrl+X Ctrl+X" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.findIncremental" - contextId="org.eclipse.ui.textEditorScope" - keySequence="Ctrl+S" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.findIncrementalReverse" - contextId="org.eclipse.ui.textEditorScope" - keySequence="Ctrl+R" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.goto.lineUp" - contextId="org.eclipse.ui.textEditorScope" - keySequence="Ctrl+P" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.goto.lineDown" - contextId="org.eclipse.ui.textEditorScope" - keySequence="Ctrl+N" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.goto.lineStart" - contextId="org.eclipse.ui.textEditorScope" - keySequence="Ctrl+A" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.goto.lineEnd" - contextId="org.eclipse.ui.textEditorScope" - keySequence="Ctrl+E" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.goto.line" - contextId="org.eclipse.ui.textEditorScope" - keySequence="Ctrl+X G" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.goto.columnPrevious" - contextId="org.eclipse.ui.textEditorScope" - keySequence="Ctrl+B" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.goto.columnNext" - contextId="org.eclipse.ui.textEditorScope" - keySequence="Ctrl+F" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.goto.pageUp" - contextId="org.eclipse.ui.textEditorScope" - keySequence="Alt+V" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.goto.pageUp" - contextId="org.eclipse.ui.textEditorScope" - keySequence="Esc V" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.goto.pageDown" - contextId="org.eclipse.ui.textEditorScope" - keySequence="Ctrl+V" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.goto.wordPrevious" - contextId="org.eclipse.ui.textEditorScope" - keySequence="Alt+B" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.goto.wordPrevious" - contextId="org.eclipse.ui.textEditorScope" - keySequence="Esc B" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.goto.wordNext" - contextId="org.eclipse.ui.textEditorScope" - keySequence="Alt+F" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.goto.wordNext" - contextId="org.eclipse.ui.textEditorScope" - keySequence="Esc F" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.goto.textStart" - contextId="org.eclipse.ui.textEditorScope" - keySequence="Alt+<" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.goto.textStart" - contextId="org.eclipse.ui.textEditorScope" - keySequence="Alt+Shift+<" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.goto.textStart" - contextId="org.eclipse.ui.textEditorScope" - keySequence="Esc <" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.goto.textStart" - contextId="org.eclipse.ui.textEditorScope" - keySequence="Esc Shift+<" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.goto.textStart" - contextId="org.eclipse.ui.textEditorScope" - keySequence="Ctrl+X [" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.goto.textEnd" - contextId="org.eclipse.ui.textEditorScope" - keySequence="Alt+>" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.goto.textEnd" - contextId="org.eclipse.ui.textEditorScope" - keySequence="Alt+Shift+>" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.goto.textEnd" - contextId="org.eclipse.ui.textEditorScope" - keySequence="Esc >" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.goto.textEnd" - contextId="org.eclipse.ui.textEditorScope" - keySequence="Esc Shift+>" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.goto.textEnd" - contextId="org.eclipse.ui.textEditorScope" - keySequence="Ctrl+X ]" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.scroll.lineUp" - contextId="org.eclipse.ui.textEditorScope" - keySequence="Alt+Z" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.scroll.lineUp" - contextId="org.eclipse.ui.textEditorScope" - keySequence="Esc Z" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.scroll.lineDown" - contextId="org.eclipse.ui.textEditorScope" - keySequence="Ctrl+Z" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.deleteNext" - contextId="org.eclipse.ui.textEditorScope" - keySequence="Ctrl+D" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.deletePreviousWord" - contextId="org.eclipse.ui.textEditorScope" - keySequence="Alt+Bs" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.deletePreviousWord" - contextId="org.eclipse.ui.textEditorScope" - keySequence="Esc Bs" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.deleteNextWord" - contextId="org.eclipse.ui.textEditorScope" - keySequence="Alt+D" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.deleteNextWord" - contextId="org.eclipse.ui.textEditorScope" - keySequence="Esc D" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.contentAssist.proposals" - contextId="org.eclipse.ui.contexts.dialogAndWindow" - keySequence="Alt+/" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.contentAssist.contextInformation" - keySequence="Alt+?" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - <keyBinding - commandId="org.eclipse.ui.edit.text.contentAssist.contextInformation" - keySequence="Alt+Shift+?" - keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - </keyBinding> - </extension> - - <extension - point="org.eclipse.ui.actionSets"> - <actionSet - label="%textEditorPresentationActionSet.label" - visible="false" - id="org.eclipse.ui.edit.text.actionSet.presentation"> - <action - allowLabelUpdate="true" - style="toggle" - toolbarPath="Normal/Presentation" - id="org.eclipse.ui.edit.text.toggleShowSelectedElementOnly" - hoverIcon="icons/full/ctool16/segment_edit.gif" - definitionId="org.eclipse.ui.edit.text.toggleShowSelectedElementOnly" - disabledIcon="icons/full/dtool16/segment_edit.gif" - icon="icons/full/etool16/segment_edit.gif" - helpContextId="only_show_selected_element_action_context" - label="%onlyShowSelectedElement.label" - retarget="true" - tooltip="%onlyShowSelectedElement.tooltip"> - </action> - </actionSet> - </extension> -</plugin> diff --git a/org.eclipse.ui.workbench.texteditor/schema/quickDiffReferenceProvider.exsd b/org.eclipse.ui.workbench.texteditor/schema/quickDiffReferenceProvider.exsd deleted file mode 100644 index 7e26c6d9231..00000000000 --- a/org.eclipse.ui.workbench.texteditor/schema/quickDiffReferenceProvider.exsd +++ /dev/null @@ -1,149 +0,0 @@ -<?xml version='1.0' encoding='UTF-8'?> -<!-- Schema file written by PDE --> -<schema targetNamespace="org.eclipse.ui.workbench.texteditor"> -<annotation> - <appInfo> - <meta.schema plugin="org.eclipse.ui.workbench.texteditor" id="quickdiffReferenceProvider" name="Reference Provider"/> - </appInfo> - <documentation> - Allows contributors to add reference providers for the quick diff display. - </documentation> - </annotation> - - <element name="extension"> - <complexType> - <sequence> - <element ref="referenceprovider" minOccurs="1" maxOccurs="unbounded"/> - </sequence> - <attribute name="point" type="string" use="required"> - <annotation> - <documentation> - The fully qualified name of the extension point. - </documentation> - </annotation> - </attribute> - <attribute name="id" type="string"> - <annotation> - <documentation> - The optional id of this extension. - </documentation> - </annotation> - </attribute> - <attribute name="name" type="string"> - <annotation> - <documentation> - The optional name of this extension. - </documentation> - </annotation> - </attribute> - </complexType> - </element> - - <element name="referenceprovider"> - <annotation> - <appInfo> - <meta.element labelAttribute="name"/> - </appInfo> - <documentation> - The definition of a reference provider for the quick diff display. - </documentation> - </annotation> - <complexType> - <attribute name="class" type="string" use="required"> - <annotation> - <documentation> - The class of the reference provider, which must implement <code>org.eclipse.ui.editors.quickdiff.IQuickDiffReferenceProvider</code>. - </documentation> - <appInfo> - <meta.attribute kind="java"/> - </appInfo> - </annotation> - </attribute> - <attribute name="label" type="string"> - <annotation> - <documentation> - The display label for the provider, which will show up in the menu that allows the user to set the quick diff reference to this provider. - </documentation> - </annotation> - </attribute> - <attribute name="id" type="string" use="required"> - <annotation> - <documentation> - A string uniquely identifying this reference provider. - </documentation> - </annotation> - </attribute> - <attribute name="default" type="boolean"> - <annotation> - <documentation> - If this flag is set to <code>true</code>, this reference provider will be installed per default the first time quick diff is enabled for a document. If multiple providers are installed with the flag set are encountered, the first one is taken. - </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> - The following is an example of a reference provider definition. It contributes a provider that uses the version of a document saved on disk as a reference. - -<p> -<pre> - <extension point="quickdiff.referenceprovider"> - <referenceprovider - id="default" - name="%LastSavedProvider.name" - label="%quickdiff.referenceprovider.label" - class="org.eclipse.ui.internal.editors.quickdiff.providers.LastSaveReferenceProvider"> - </referenceprovider> - </extension> -</pre> -</p> - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="apiInfo"/> - </appInfo> - <documentation> - There is no additional API for managing reference providers. - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="implementation"/> - </appInfo> - <documentation> - The <code>org.eclipse.ui.editors</code> plugin contributes <code>LastSaveReferenceProvider</code>. See its implementation as an example. - </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.ui.workbench.texteditor/scripts/exportplugin.xml b/org.eclipse.ui.workbench.texteditor/scripts/exportplugin.xml deleted file mode 100644 index f6a1c5c7369..00000000000 --- a/org.eclipse.ui.workbench.texteditor/scripts/exportplugin.xml +++ /dev/null @@ -1,32 +0,0 @@ -<project name="Export Workbench Text Editor Fragment" default="export" basedir=".."> - <target name="init"> - <tstamp/> - <property name="destdir" value="../../plugin-export" /> - <property name="plugin" value="org.eclipse.ui.workbench.texteditor" /> - <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}/texteditor.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}/texteditorsrc.jar"> - <fileset dir="src" /> - </zip> - </target> - -</project>
\ No newline at end of file diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/contentassist/ContentAssistHandler.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/contentassist/ContentAssistHandler.java deleted file mode 100644 index 0689fe5a9de..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/contentassist/ContentAssistHandler.java +++ /dev/null @@ -1,238 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.contentassist; - -import java.util.List; -import java.util.Map; - -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.widgets.Combo; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Text; - -import org.eclipse.jface.contentassist.AbstractControlContentAssistSubjectAdapter; -import org.eclipse.jface.contentassist.ComboContentAssistSubjectAdapter; -import org.eclipse.jface.contentassist.SubjectControlContentAssistant; -import org.eclipse.jface.contentassist.TextContentAssistSubjectAdapter; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.LabelProvider; - -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.commands.AbstractHandler; -import org.eclipse.ui.commands.ExecutionException; -import org.eclipse.ui.commands.HandlerSubmission; -import org.eclipse.ui.commands.ICommand; -import org.eclipse.ui.commands.ICommandManager; -import org.eclipse.ui.commands.IHandler; -import org.eclipse.ui.commands.IKeySequenceBinding; -import org.eclipse.ui.commands.IWorkbenchCommandSupport; -import org.eclipse.ui.commands.Priority; -import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds; - -/** - * A content assistant handler which handles the key binding and - * the cue for a {@link org.eclipse.jface.text.contentassist.ContentAssistant} - * and its subject adapter. - * - * @since 3.0 - */ -public class ContentAssistHandler { - /** - * The target control. - */ - private Control fControl; - /** - * The content assist subject adapter. - */ - private AbstractControlContentAssistSubjectAdapter fContentAssistSubjectAdapter; - /** - * The content assistant. - */ - private SubjectControlContentAssistant fContentAssistant; - /** - * The currently installed HandlerSubmission, or <code>null</code> iff none installed. - * This is also used as flag to tell whether content assist is enabled - */ - private FocusListener fFocusListener; - /** - * The currently installed HandlerSubmission, or <code>null</code> iff none installed. - */ - private HandlerSubmission fHandlerSubmission; - - /** - * Creates a new {@link ContentAssistHandler} for the given {@link Combo}. - * Only a single {@link ContentAssistHandler} may be installed on a {@link Combo} instance. - * Content Assist is enabled by default. - * - * @param combo target combo - * @param contentAssistant a configured content assistant - * @return a new {@link ContentAssistHandler} - */ - public static ContentAssistHandler createHandlerForCombo(Combo combo, SubjectControlContentAssistant contentAssistant) { - return new ContentAssistHandler(combo, new ComboContentAssistSubjectAdapter(combo), contentAssistant); - } - - /** - * Creates a new {@link ContentAssistHandler} for the given {@link Text}. - * Only a single {@link ContentAssistHandler} may be installed on a {@link Text} instance. - * Content Assist is enabled by default. - * - * @param text target text - * @param contentAssistant a configured content assistant - * @return a new {@link ContentAssistHandler} - */ - public static ContentAssistHandler createHandlerForText(Text text, SubjectControlContentAssistant contentAssistant) { - return new ContentAssistHandler(text, new TextContentAssistSubjectAdapter(text), contentAssistant); - } - - /** - * Internal constructor. - * - * @param control target control - * @param subjectAdapter content assist subject adapter - * @param contentAssistant content assistant - */ - private ContentAssistHandler( - Control control, - AbstractControlContentAssistSubjectAdapter subjectAdapter, - SubjectControlContentAssistant contentAssistant) { - fControl= control; - fContentAssistant= contentAssistant; - fContentAssistSubjectAdapter= subjectAdapter; - setEnabled(true); - fControl.addDisposeListener(new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - setEnabled(false); - } - }); - } - - /** - * @return <code>true</code> iff content assist is enabled - */ - public boolean isEnabled() { - return fFocusListener != null; - } - - /** - * Controls enablement of content assist. - * When enabled, a cue is shown next to the focused field - * and the affordance hover shows the shortcut. - * - * @param enable enable content assist iff true - */ - public void setEnabled(boolean enable) { - if (enable == isEnabled()) - return; - - if (enable) - enable(); - else - disable(); - } - - /** - * Enable content assist. - */ - private void enable() { - if (! fControl.isDisposed()) { - fContentAssistant.install(fContentAssistSubjectAdapter); - installCueLabelProvider(); - installFocusListener(); - if (fControl.isFocusControl()) - activateHandler(); - } - } - - /** - * Disable content assist. - */ - private void disable() { - if (! fControl.isDisposed()) { - fContentAssistant.uninstall(); - fContentAssistSubjectAdapter.setContentAssistCueProvider(null); - fControl.removeFocusListener(fFocusListener); - fFocusListener= null; - if (fHandlerSubmission != null) - deactivateHandler(); - } - } - - /** - * Create and install the {@link LabelProvider} for fContentAssistSubjectAdapter. - */ - private void installCueLabelProvider() { - ILabelProvider labelProvider= new LabelProvider() { - /** - * @inheritDoc - */ - public String getText(Object element) { - ICommandManager commandManager= PlatformUI.getWorkbench().getCommandSupport().getCommandManager(); - ICommand command= commandManager.getCommand(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS); - List bindings= command.getKeySequenceBindings(); - if (bindings.size() == 0) { - return ContentAssistMessages.getString("ContentAssistHandler.contentAssistAvailable"); //$NON-NLS-1$ - } else { - IKeySequenceBinding ksb= (IKeySequenceBinding) bindings.get(0); - Object[] args= { ksb.getKeySequence().format() }; - return ContentAssistMessages.getFormattedString("ContentAssistHandler.contentAssistAvailableWithKeyBinding", args); //$NON-NLS-1$ - } - } - }; - fContentAssistSubjectAdapter.setContentAssistCueProvider(labelProvider); - } - - /** - * Create fFocusListener and install it on fControl. - */ - private void installFocusListener() { - fFocusListener= new FocusListener() { - public void focusGained(final FocusEvent e) { - activateHandler(); - } - public void focusLost(FocusEvent e) { - if (fHandlerSubmission != null) - deactivateHandler(); - } - }; - fControl.addFocusListener(fFocusListener); - } - - /** - * Create and register fHandlerSubmission. - */ - private void activateHandler() { - final IHandler handler= new AbstractHandler() { - public Object execute(Map parameterValuesByName) throws ExecutionException { - if (isEnabled()) - fContentAssistant.showPossibleCompletions(); - return null; - } - }; - fHandlerSubmission= new HandlerSubmission(null, fControl.getShell(), null, - ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS, handler, Priority.MEDIUM); - IWorkbenchCommandSupport commandSupport= PlatformUI.getWorkbench().getCommandSupport(); - commandSupport.addHandlerSubmission(fHandlerSubmission); - } - - /** - * Unregister the {@link HandlerSubmission} from the shell. - */ - private void deactivateHandler() { - IWorkbenchCommandSupport commandSupport= PlatformUI.getWorkbench().getCommandSupport(); - commandSupport.removeHandlerSubmission(fHandlerSubmission); - fHandlerSubmission= null; - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/contentassist/ContentAssistMessages.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/contentassist/ContentAssistMessages.java deleted file mode 100644 index b992262a284..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/contentassist/ContentAssistMessages.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.contentassist; - -import java.text.MessageFormat; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - - -/** - * Helper class to get NLSed messages. - * - * @since 3.0 - */ -class ContentAssistMessages { - - private static final String RESOURCE_BUNDLE= ContentAssistMessages.class.getName(); - - private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE); - - private ContentAssistMessages() { - } - - /** - * Gets a string from the resource bundle. - * - * @param key the string used to get the bundle value, must not be null - * @return the string from the resource bundle - */ - public static String getString(String key) { - try { - return fgResourceBundle.getString(key); - } catch (MissingResourceException e) { - return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$ - } - } - - /** - * Gets a string from the resource bundle and formats it with the given arguments. - * - * @param key the string used to get the bundle value, must not be null - * @param args the arguments used to format the string - * @return the formatted string - */ - public static String getFormattedString(String key, Object[] args) { - String format= null; - try { - format= fgResourceBundle.getString(key); - } catch (MissingResourceException e) { - return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$ - } - return MessageFormat.format(format, args); - } - - /** - * Gets a string from the resource bundle and formats it with the given argument. - * - * @param key the string used to get the bundle value, must not be null - * @param arg the argument used to format the string - * @return the formatted string - */ - public static String getFormattedString(String key, Object arg) { - String format= null; - try { - format= fgResourceBundle.getString(key); - } catch (MissingResourceException e) { - return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$ - } - if (arg == null) - arg= ""; //$NON-NLS-1$ - return MessageFormat.format(format, new Object[] { arg }); - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/contentassist/ContentAssistMessages.properties b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/contentassist/ContentAssistMessages.properties deleted file mode 100644 index 4e4f8b1f6c3..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/contentassist/ContentAssistMessages.properties +++ /dev/null @@ -1,14 +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 -############################################################################### - - -ContentAssistHandler.contentAssistAvailable= Content Assist Available -ContentAssistHandler.contentAssistAvailableWithKeyBinding= Content Assist Available ({0}) diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/AnnotationExpandHover.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/AnnotationExpandHover.java deleted file mode 100644 index 7c8094e7efc..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/AnnotationExpandHover.java +++ /dev/null @@ -1,305 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.internal.texteditor; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -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.custom.StyledText; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.swt.widgets.Shell; - -import org.eclipse.jface.viewers.IDoubleClickListener; - -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.IInformationControlCreatorExtension; -import org.eclipse.jface.text.ITextViewerExtension5; -import org.eclipse.jface.text.Position; -import org.eclipse.jface.text.TextViewer; -import org.eclipse.jface.text.source.Annotation; -import org.eclipse.jface.text.source.CompositeRuler; -import org.eclipse.jface.text.source.IAnnotationAccess; -import org.eclipse.jface.text.source.IAnnotationAccessExtension; -import org.eclipse.jface.text.source.IAnnotationHover; -import org.eclipse.jface.text.source.IAnnotationHoverExtension; -import org.eclipse.jface.text.source.IAnnotationModel; -import org.eclipse.jface.text.source.ILineRange; -import org.eclipse.jface.text.source.ISourceViewer; -import org.eclipse.jface.text.source.IVerticalRulerListener; -import org.eclipse.jface.text.source.LineRange; -import org.eclipse.jface.text.source.VerticalRulerEvent; - -import org.eclipse.ui.internal.texteditor.AnnotationExpansionControl.AnnotationHoverInput; - -/** - * @since 3.0 - */ -public class AnnotationExpandHover implements IAnnotationHover, IAnnotationHoverExtension { - - private class InformationControlCreator implements IInformationControlCreator, IInformationControlCreatorExtension { - - /* - * @see org.eclipse.jface.text.IInformationControlCreator#createInformationControl(org.eclipse.swt.widgets.Shell) - */ - public IInformationControl createInformationControl(Shell parent) { - return new AnnotationExpansionControl(parent, SWT.NONE, fAnnotationAccess); - } - - /* - * @see org.eclipse.jface.text.IInformationControlCreatorExtension#canReuse(org.eclipse.jface.text.IInformationControl) - */ - public boolean canReuse(IInformationControl control) { - return control instanceof AnnotationExpansionControl; - } - - /* - * @see org.eclipse.jface.text.IInformationControlCreatorExtension#canReplace(org.eclipse.jface.text.IInformationControlCreator) - */ - public boolean canReplace(IInformationControlCreator creator) { - return creator == this; - } - } - - private class VerticalRulerListener implements IVerticalRulerListener { - - /* - * @see org.eclipse.jface.text.source.IVerticalRulerListener#annotationSelected(org.eclipse.jface.text.source.VerticalRulerEvent) - */ - public void annotationSelected(VerticalRulerEvent event) { - fCompositeRuler.fireAnnotationSelected(event); - } - - /* - * @see org.eclipse.jface.text.source.IVerticalRulerListener#annotationDefaultSelected(org.eclipse.jface.text.source.VerticalRulerEvent) - */ - public void annotationDefaultSelected(VerticalRulerEvent event) { - fCompositeRuler.fireAnnotationDefaultSelected(event); - } - - /* - * @see org.eclipse.jface.text.source.IVerticalRulerListener#annotationContextMenuAboutToShow(org.eclipse.jface.text.source.VerticalRulerEvent, org.eclipse.swt.widgets.Menu) - */ - public void annotationContextMenuAboutToShow(VerticalRulerEvent event, Menu menu) { - fCompositeRuler.fireAnnotationContextMenuAboutToShow(event, menu); - } - } - - - private final IInformationControlCreator fgCreator= new InformationControlCreator(); - protected final IVerticalRulerListener fgListener= new VerticalRulerListener(); - protected CompositeRuler fCompositeRuler; - protected IDoubleClickListener fDblClickListener; - protected IAnnotationAccess fAnnotationAccess; - - /** - * Creates a new hover instance. - * - * @param ruler - * @param access - * @param doubleClickListener - */ - public AnnotationExpandHover(CompositeRuler ruler, IAnnotationAccess access, IDoubleClickListener doubleClickListener) { - fCompositeRuler= ruler; - fAnnotationAccess= access; - fDblClickListener= doubleClickListener; - } - - /* - * @see org.eclipse.jface.text.source.IAnnotationHover#getHoverInfo(org.eclipse.jface.text.source.ISourceViewer, int) - */ - public String getHoverInfo(ISourceViewer sourceViewer, int line) { - // we don't have any sensible return value as text - return null; - } - - protected Object getHoverInfoForLine(ISourceViewer viewer, int line) { - IAnnotationModel model= viewer.getAnnotationModel(); - IDocument document= viewer.getDocument(); - - if (model == null) - return null; - - List exact= new ArrayList(); - HashMap messagesAtPosition= new HashMap(); - - Iterator e= model.getAnnotationIterator(); - while (e.hasNext()) { - Annotation annotation= (Annotation) e.next(); - Position position= model.getPosition(annotation); - if (position == null) - continue; - - if (compareRulerLine(position, document, line) == 1) { - if (isDuplicateMessage(messagesAtPosition, position, annotation.getText())) - continue; - - exact.add(annotation); - } - } - - if (exact.size() < 1) - return null; - - sort(exact, model); - - if (exact.size() > 0) - setLastRulerMouseLocation(viewer, line); - - AnnotationHoverInput input= new AnnotationHoverInput(); - input.fAnnotations= (Annotation[]) exact.toArray(new Annotation[0]); - input.fViewer= viewer; - input.fRulerInfo= fCompositeRuler; - input.fAnnotationListener= fgListener; - input.fDoubleClickListener= fDblClickListener; - input.model= model; - - return input; - } - - protected void sort(List exact, final IAnnotationModel model) { - class AnnotationComparator implements Comparator { - - /* - * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) - */ - public int compare(Object o1, Object o2) { - Annotation a1= (Annotation) o1; - Annotation a2= (Annotation) o2; - - Position p1= model.getPosition(a1); - Position p2= model.getPosition(a2); - - // annotation order: - // primary order: by position in line - // secondary: annotation importance - if (p1.offset == p2.offset) - return getOrder(a2) - getOrder(a1); - else - return p1.offset - p2.offset; - } - } - - Collections.sort(exact, new AnnotationComparator()); - - } - - protected int getOrder(Annotation annotation) { - if (fAnnotationAccess instanceof IAnnotationAccessExtension) { - IAnnotationAccessExtension extension= (IAnnotationAccessExtension) fAnnotationAccess; - return extension.getLayer(annotation); - } - return IAnnotationAccessExtension.DEFAULT_LAYER; - } - - protected boolean isDuplicateMessage(Map messagesAtPosition, Position position, String message) { - if (messagesAtPosition.containsKey(position)) { - Object value= messagesAtPosition.get(position); - if (message == null || message.equals(value)) - return true; - - if (value instanceof List) { - List messages= (List)value; - if (messages.contains(message)) - return true; - else - messages.add(message); - } else { - ArrayList messages= new ArrayList(); - messages.add(value); - messages.add(message); - messagesAtPosition.put(position, messages); - } - } else - messagesAtPosition.put(position, message); - return false; - } - - protected void setLastRulerMouseLocation(ISourceViewer viewer, int line) { - // set last mouse activity in order to get the correct context menu - if (fCompositeRuler != null) { - StyledText st= viewer.getTextWidget(); - if (st != null && !st.isDisposed()) { - if (viewer instanceof ITextViewerExtension5) { - int widgetLine= ((ITextViewerExtension5)viewer).modelLine2WidgetLine(line); - Point loc= st.getLocationAtOffset(st.getOffsetAtLine(widgetLine)); - fCompositeRuler.setLocationOfLastMouseButtonActivity(0, loc.y); - } else if (viewer instanceof TextViewer) { - // TODO remove once TextViewer implements the extension - int widgetLine= ((TextViewer)viewer).modelLine2WidgetLine(line); - Point loc= st.getLocationAtOffset(st.getOffsetAtLine(widgetLine)); - fCompositeRuler.setLocationOfLastMouseButtonActivity(0, loc.y); - } - } - } - } - - /** - * Returns the distance to the ruler line. - * - * @param position the position - * @param document the document - * @param line the line number - * @return the distance to the ruler line - */ - protected int compareRulerLine(Position position, IDocument document, int line) { - - if (position.getOffset() > -1 && position.getLength() > -1) { - try { - int firstLine= document.getLineOfOffset(position.getOffset()); - if (line == firstLine) - return 1; - if (firstLine <= line && line <= document.getLineOfOffset(position.getOffset() + position.getLength())) - return 2; - } catch (BadLocationException x) { - } - } - - return 0; - } - - /* - * @see org.eclipse.jface.text.source.IAnnotationHoverExtension#getHoverControlCreator() - */ - public IInformationControlCreator getHoverControlCreator() { - return fgCreator; - } - - /* - * @see org.eclipse.jface.text.source.IAnnotationHoverExtension#getHoverInfo(org.eclipse.jface.text.source.ISourceViewer, org.eclipse.jface.text.source.ILineRange, int) - */ - public Object getHoverInfo(ISourceViewer sourceViewer, ILineRange lineRange, int visibleLines) { - return getHoverInfoForLine(sourceViewer, lineRange.getStartLine()); - } - - /* - * @see org.eclipse.jface.text.source.IAnnotationHoverExtension#getHoverLineRange(org.eclipse.jface.text.source.ISourceViewer, int) - */ - public ILineRange getHoverLineRange(ISourceViewer viewer, int lineNumber) { - return new LineRange(lineNumber, 1); - } - - /* - * @see org.eclipse.jface.text.source.IAnnotationHoverExtension#canHandleMouseCursor() - */ - public boolean canHandleMouseCursor() { - return true; - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/AnnotationExpansionControl.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/AnnotationExpansionControl.java deleted file mode 100644 index 043e5f58ac3..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/AnnotationExpansionControl.java +++ /dev/null @@ -1,795 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.internal.texteditor; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.StyleRange; -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.MenuEvent; -import org.eclipse.swt.events.MenuListener; -import org.eclipse.swt.events.MouseAdapter; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.events.MouseTrackAdapter; -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.Cursor; -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.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.swt.widgets.Shell; -import org.eclipse.swt.widgets.Widget; - -import org.eclipse.jface.viewers.IDoubleClickListener; - -import org.eclipse.jface.text.AbstractInformationControlManager; -import org.eclipse.jface.text.DefaultInformationControl; -import org.eclipse.jface.text.IInformationControl; -import org.eclipse.jface.text.IInformationControlCreator; -import org.eclipse.jface.text.IInformationControlExtension; -import org.eclipse.jface.text.IInformationControlExtension2; -import org.eclipse.jface.text.IRegion; -import org.eclipse.jface.text.IViewportListener; -import org.eclipse.jface.text.Position; -import org.eclipse.jface.text.Region; -import org.eclipse.jface.text.TextViewer; -import org.eclipse.jface.text.source.Annotation; -import org.eclipse.jface.text.source.IAnnotationAccess; -import org.eclipse.jface.text.source.IAnnotationAccessExtension; -import org.eclipse.jface.text.source.IVerticalRulerListener; -import org.eclipse.jface.text.source.IAnnotationModel; -import org.eclipse.jface.text.source.ISourceViewer; -import org.eclipse.jface.text.source.IVerticalRulerInfo; -import org.eclipse.jface.text.source.VerticalRulerEvent; - - -/** - * A control that can display a number of annotations. The control can decide how it layouts the - * annotations to present them to the user. - * - * <p>Each annotation can have its custom context menu and hover.</p> - * - * @since 3.0 - */ -public class AnnotationExpansionControl implements IInformationControl, IInformationControlExtension, IInformationControlExtension2 { - - - public interface ICallback { - void run(IInformationControlExtension2 control); - } - - /** - * Input used by the control to display the annotations. - * TODO move to top-level class - * TODO encapsulate fields - * - * @since 3.0 - */ - public static class AnnotationHoverInput { - public Annotation[] fAnnotations; - public ISourceViewer fViewer; - public IVerticalRulerInfo fRulerInfo; - public IVerticalRulerListener fAnnotationListener; - public IDoubleClickListener fDoubleClickListener; - public ICallback redoAction; - public IAnnotationModel model; - } - - private final class Item { - Annotation fAnnotation; - Canvas canvas; - StyleRange[] oldStyles; - - public void selected() { - Display disp= fShell.getDisplay(); - canvas.setCursor(fHandCursor); - // TODO: shade - for now: set grey background - canvas.setBackground(getSelectionColor(disp)); - - // highlight the viewer background at its position - oldStyles= setViewerBackground(fAnnotation); - - // set the selection - fSelection= this; - - if (fHoverManager != null) - fHoverManager.showInformation(); - - if (fInput.fAnnotationListener != null) { - VerticalRulerEvent event= new VerticalRulerEvent(fAnnotation); - fInput.fAnnotationListener.annotationSelected(event); - } - - } - - public void defaultSelected() { - if (fInput.fAnnotationListener != null) { - VerticalRulerEvent event= new VerticalRulerEvent(fAnnotation); - fInput.fAnnotationListener.annotationDefaultSelected(event); - } - - dispose(); - } - - public void showContextMenu(Menu menu) { - if (fInput.fAnnotationListener != null) { - VerticalRulerEvent event= new VerticalRulerEvent(fAnnotation); - fInput.fAnnotationListener.annotationContextMenuAboutToShow(event, menu); - } - } - - public void deselect() { - // hide the popup -// fHoverManager.disposeInformationControl(); - - // deselect - fSelection= null; - - resetViewerBackground(oldStyles); - oldStyles= null; - - Display disp= fShell.getDisplay(); - canvas.setCursor(null); - // TODO: remove shading - for now: set standard background - canvas.setBackground(disp.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); - - } - - } - - /** - * Disposes of an item - */ - private final class MyDisposeListener implements DisposeListener { - /* - * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent) - */ - public void widgetDisposed(DisposeEvent e) { - Item item= (Item) ((Widget) e.getSource()).getData(); - item.deselect(); - item.canvas= null; - item.fAnnotation= null; - item.oldStyles= null; - - ((Widget) e.getSource()).setData(null); - } - } - - /** - * Listener on context menu invocation on the items - */ - private final class MyMenuDetectListener implements Listener { - /* - * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event) - */ - public void handleEvent(Event event) { - if (event.type == SWT.MenuDetect) { - // TODO: show per-item menu - // for now: show ruler context menu - if (fInput != null) { - Control ruler= fInput.fRulerInfo.getControl(); - if (ruler != null && !ruler.isDisposed()) { - Menu menu= ruler.getMenu(); - if (menu != null && !menu.isDisposed()) { - menu.setLocation(event.x, event.y); - menu.addMenuListener(new MenuListener() { - - public void menuHidden(MenuEvent e) { - dispose(); - } - - public void menuShown(MenuEvent e) { - } - - }); - menu.setVisible(true); - } - } - } - } - } - } - - /** - * Listener on mouse events on the items. - */ - private final class MyMouseListener extends MouseAdapter { - /* - * @see org.eclipse.swt.events.MouseListener#mouseDoubleClick(org.eclipse.swt.events.MouseEvent) - */ - public void mouseDoubleClick(MouseEvent e) { - Item item= (Item) ((Widget) e.getSource()).getData(); - if (e.button == 1 && item.fAnnotation == fInput.fAnnotations[0] && fInput.fDoubleClickListener != null) { - fInput.fDoubleClickListener.doubleClick(null); - // special code for JDT to renew the annotation set. - if (fInput.redoAction != null) - fInput.redoAction.run(AnnotationExpansionControl.this); - } -// dispose(); - // TODO special action to invoke double-click action on the vertical ruler - // how about -// Canvas can= (Canvas) e.getSource(); -// Annotation a= (Annotation) can.getData(); -// if (a != null) { -// a.getDoubleClickAction().run(); -// } - } - - /* - * @see org.eclipse.swt.events.MouseListener#mouseUp(org.eclipse.swt.events.MouseEvent) - */ - public void mouseUp(MouseEvent e) { - Item item= (Item) ((Widget) e.getSource()).getData(); - // TODO for now, to make double click work: disable single click on the first item - // disable later when the annotationlistener selectively handles input - if (item != null && e.button == 1) // && item.fAnnotation != fInput.fAnnotations[0]) - item.defaultSelected(); - } - - /* - * @see org.eclipse.swt.events.MouseAdapter#mouseDown(org.eclipse.swt.events.MouseEvent) - */ - public void mouseDown(MouseEvent e) { - // TODO Auto-generated method stub - super.mouseDown(e); - } - } - - /** - * Listener on mouse track events on the items. - */ - private final class MyMouseTrackListener implements MouseTrackListener { - /* - * @see org.eclipse.swt.events.MouseTrackListener#mouseEnter(org.eclipse.swt.events.MouseEvent) - */ - public void mouseEnter(MouseEvent e) { - Item item= (Item) ((Widget) e.getSource()).getData(); - if (item != null) - item.selected(); - } - - /* - * @see org.eclipse.swt.events.MouseTrackListener#mouseExit(org.eclipse.swt.events.MouseEvent) - */ - public void mouseExit(MouseEvent e) { - - Item item= (Item) ((Widget) e.getSource()).getData(); - if (item != null) - item.deselect(); - - // if the event lies outside the entire popup, dispose - org.eclipse.swt.graphics.Region region= fShell.getRegion(); - Canvas can= (Canvas) e.getSource(); - Point p= can.toDisplay(e.x, e.y); - if (region == null) { - Rectangle bounds= fShell.getBounds(); -// p= fShell.toControl(p); - if (!bounds.contains(p)) - dispose(); - } else { - p= fShell.toControl(p); - if (!region.contains(p)) - dispose(); - } - - - } - - /* - * @see org.eclipse.swt.events.MouseTrackListener#mouseHover(org.eclipse.swt.events.MouseEvent) - */ - public void mouseHover(MouseEvent e) { - if (fHoverManager == null) { - fHoverManager= new HoverManager(); - fHoverManager.takesFocusWhenVisible(false); - fHoverManager.install(fComposite); - fHoverManager.showInformation(); - } - } - } - - /** - * Listener on paint events on the items. Paints the annotation image on the given <code>GC</code>. - */ - private final class MyPaintListener implements PaintListener { - /* - * @see org.eclipse.swt.events.PaintListener#paintControl(org.eclipse.swt.events.PaintEvent) - */ - public void paintControl(PaintEvent e) { - Canvas can= (Canvas) e.getSource(); - Annotation a= ((Item) can.getData()).fAnnotation; - if (a != null) { - Rectangle rect= new Rectangle(fLayouter.getBorderWidth(), fLayouter.getBorderWidth(), fLayouter.getAnnotationSize(), fLayouter.getAnnotationSize()); - if (fAnnotationAccessExtension != null) - fAnnotationAccessExtension.paint(a, e.gc, can, rect); - } - } - } - - /** - * Our own private hover manager used to shop per-item pop-ups. - */ - private final class HoverManager extends AbstractInformationControlManager { - - /** - * - */ - public HoverManager() { - super(new IInformationControlCreator() { - public IInformationControl createInformationControl(Shell parent) { - return new DefaultInformationControl(parent); - } - }); - - setMargins(5, 10); - setAnchor(ANCHOR_BOTTOM); - setFallbackAnchors(new Anchor[] { ANCHOR_LEFT, ANCHOR_RIGHT} ); - } - - /* - * @see org.eclipse.jface.text.AbstractInformationControlManager#computeInformation() - */ - protected void computeInformation() { - if (fSelection != null) { - Rectangle subjectArea= fSelection.canvas.getBounds(); - Annotation annotation= fSelection.fAnnotation; - String msg; - if (annotation != null) - msg= annotation.getText(); - else - msg= null; - - setInformation(msg, subjectArea); - } - } - - - } - - /** Model data. */ - protected AnnotationHoverInput fInput; - /** The control's shell */ - private Shell fShell; - /** The composite combining all the items. */ - protected Composite fComposite; - /** The hand cursor. */ - private Cursor fHandCursor; - /** The currently selected item, or <code>null</code> if none is selected. */ - private Item fSelection; - /** The hover manager for the per-item hovers. */ - private HoverManager fHoverManager; - /** The annotation access extension. */ - private IAnnotationAccessExtension fAnnotationAccessExtension; - - - /* listener legion */ - private final MyPaintListener fPaintListener; - private final MyMouseTrackListener fMouseTrackListener; - private final MyMouseListener fMouseListener; - private final MyMenuDetectListener fMenuDetectListener; - private final DisposeListener fDisposeListener; - private final IViewportListener fViewportListener; - - private LinearLayouter fLayouter; - - /** - * Creates a new control. - * - * @param parent - * @param shellStyle - * @param access - */ - public AnnotationExpansionControl(Shell parent, int shellStyle, IAnnotationAccess access) { - fPaintListener= new MyPaintListener(); - fMouseTrackListener= new MyMouseTrackListener(); - fMouseListener= new MyMouseListener(); - fMenuDetectListener= new MyMenuDetectListener(); - fDisposeListener= new MyDisposeListener(); - fViewportListener= new IViewportListener() { - - public void viewportChanged(int verticalOffset) { - dispose(); - } - - }; - fLayouter= new LinearLayouter(); - - if (access instanceof IAnnotationAccessExtension) - fAnnotationAccessExtension= (IAnnotationAccessExtension) access; - - fShell= new Shell(parent, shellStyle | SWT.NO_FOCUS | SWT.ON_TOP); - Display display= fShell.getDisplay(); - fShell.setBackground(display.getSystemColor(SWT.COLOR_BLACK)); - fComposite= new Composite(fShell, SWT.NO_FOCUS | SWT.NO_REDRAW_RESIZE | SWT.NO_TRIM); -// fComposite= new Composite(fShell, SWT.NO_FOCUS | SWT.NO_REDRAW_RESIZE | SWT.NO_TRIM | SWT.V_SCROLL); - - GridLayout layout= new GridLayout(1, true); - layout.marginHeight= 0; - layout.marginWidth= 0; - fShell.setLayout(layout); - - GridData data= new GridData(GridData.FILL_BOTH); - data.heightHint= fLayouter.getAnnotationSize() + 2 * fLayouter.getBorderWidth() + 4; - fComposite.setLayoutData(data); - fComposite.addMouseTrackListener(new MouseTrackAdapter() { - - public void mouseExit(MouseEvent e) { - if (fComposite == null) - return; - Control[] children= fComposite.getChildren(); - for (int i= 0; i < children.length; i++) { - if (children[i].getBounds().contains(e.x, e.y)) - return; - } - - // if none of the children contains the event, we left the popup - dispose(); - } - - }); - -// fComposite.getVerticalBar().addListener(SWT.Selection, new Listener() { -// -// public void handleEvent(Event event) { -// Rectangle bounds= fShell.getBounds(); -// int x= bounds.x - fLayouter.getAnnotationSize() - fLayouter.getBorderWidth(); -// int y= bounds.y; -// fShell.setBounds(x, y, bounds.width, bounds.height); -// } -// -// }); - - fHandCursor= new Cursor(display, SWT.CURSOR_HAND); - fShell.setCursor(fHandCursor); - fComposite.setCursor(fHandCursor); - - setInfoSystemColor(); - } - - private void setInfoSystemColor() { - Display display= fShell.getDisplay(); - setForegroundColor(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND)); - setBackgroundColor(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); - } - - /* - * @see org.eclipse.jface.text.IInformationControl#setInformation(java.lang.String) - */ - public void setInformation(String information) { - setInput(null); - } - - - /* - * @see org.eclipse.jface.text.IInformationControlExtension2#setInput(java.lang.Object) - */ - public void setInput(Object input) { - if (fInput != null && fInput.fViewer != null) - fInput.fViewer.removeViewportListener(fViewportListener); - - if (input instanceof AnnotationHoverInput) - fInput= (AnnotationHoverInput) input; - else - fInput= null; - - inputChanged(fInput, null); - } - - protected void inputChanged(Object newInput, Object newSelection) { - refresh(); - } - - protected void refresh() { - adjustItemNumber(); - - if (fInput == null) - return; - - if (fInput.fAnnotations == null) - return; - - if (fInput.fViewer != null) - fInput.fViewer.addViewportListener(fViewportListener); - - fShell.setRegion(fLayouter.getShellRegion(fInput.fAnnotations.length)); - - Layout layout= fLayouter.getLayout(fInput.fAnnotations.length); - fComposite.setLayout(layout); - - Control[] children= fComposite.getChildren(); - for (int i= 0; i < fInput.fAnnotations.length; i++) { - Canvas canvas= (Canvas) children[i]; - Item item= new Item(); - item.canvas= canvas; - item.fAnnotation= fInput.fAnnotations[i]; - canvas.setData(item); - canvas.redraw(); - } - - } - - protected void adjustItemNumber() { - if (fComposite == null) - return; - - Control[] children= fComposite.getChildren(); - int oldSize= children.length; - int newSize= fInput == null ? 0 : fInput.fAnnotations.length; - - Display display= fShell.getDisplay(); - - // add missing items - for (int i= oldSize; i < newSize; i++) { - Canvas canvas= new Canvas(fComposite, SWT.NONE); - Object gridData= fLayouter.getLayoutData(); - canvas.setLayoutData(gridData); - canvas.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); - - canvas.addPaintListener(fPaintListener); - - canvas.addMouseTrackListener(fMouseTrackListener); - - canvas.addMouseListener(fMouseListener); - - canvas.addListener(SWT.MenuDetect, fMenuDetectListener); - - canvas.addDisposeListener(fDisposeListener); - } - - // dispose of exceeding resources - for (int i= oldSize; i > newSize; i--) { - Item item= (Item) children[i - 1].getData(); - item.deselect(); - children[i - 1].dispose(); - } - - } - - /* - * @see IInformationControl#setVisible(boolean) - */ - public void setVisible(boolean visible) { - fShell.setVisible(visible); - } - - /* - * @see IInformationControl#dispose() - */ - public void dispose() { - if (fShell != null) { - if (!fShell.isDisposed()) - fShell.dispose(); - fShell= null; - fComposite= null; - if (fHandCursor != null) - fHandCursor.dispose(); - fHandCursor= null; - if (fHoverManager != null) - fHoverManager.dispose(); - fHoverManager= null; - fSelection= null; - } - } - - /* - * @see org.eclipse.jface.text.IInformationControlExtension#hasContents() - */ - public boolean hasContents() { - return fInput.fAnnotations != null && fInput.fAnnotations.length > 0; - } - - /* - * @see org.eclipse.jface.text.IInformationControl#setSizeConstraints(int, int) - */ - public void setSizeConstraints(int maxWidth, int maxHeight) { - //fMaxWidth= maxWidth; - //fMaxHeight= maxHeight; - } - - /* - * @see org.eclipse.jface.text.IInformationControl#computeSizeHint() - */ - public Point computeSizeHint() { - return fShell.computeSize(SWT.DEFAULT, SWT.DEFAULT); - } - - /* - * @see IInformationControl#setLocation(Point) - */ - public void setLocation(Point location) { - fShell.setLocation(location); - } - - /* - * @see IInformationControl#setSize(int, int) - */ - public void setSize(int width, int height) { - fShell.setSize(width, height); - } - - /* - * @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) { - fComposite.setForeground(foreground); - } - - /* - * @see IInformationControl#setBackgroundColor(Color) - */ - public void setBackgroundColor(Color background) { - fComposite.setBackground(background); - } - - /* - * @see IInformationControl#isFocusControl() - */ - public boolean isFocusControl() { - if (fComposite.isFocusControl()) - return true; - else { - Control[] children= fComposite.getChildren(); - for (int i= 0; i < children.length; i++) { - if (children[i].isFocusControl()) - return true; - } - } - return false; - } - - /* - * @see IInformationControl#setFocus() - */ - public void setFocus() { - fShell.forceFocus(); - } - - /* - * @see IInformationControl#addFocusListener(FocusListener) - */ - public void addFocusListener(FocusListener listener) { - fShell.addFocusListener(listener); - } - - /* - * @see IInformationControl#removeFocusListener(FocusListener) - */ - public void removeFocusListener(FocusListener listener) { - fShell.removeFocusListener(listener); - } - - private StyleRange[] setViewerBackground(Annotation annotation) { - StyledText text= fInput.fViewer.getTextWidget(); - if (text == null || text.isDisposed()) - return null; - - Display disp= text.getDisplay(); - - Position pos= fInput.model.getPosition(annotation); - if (pos == null) - return null; - - IRegion region= ((TextViewer)fInput.fViewer).modelRange2WidgetRange(new Region(pos.offset, pos.length)); - - StyleRange[] ranges= text.getStyleRanges(region.getOffset(), region.getLength()); - - List undoRanges= new ArrayList(ranges.length); - for (int i= 0; i < ranges.length; i++) { - undoRanges.add(ranges[i].clone()); - } - - int offset= region.getOffset(); - StyleRange current= undoRanges.size() > 0 ? (StyleRange) undoRanges.get(0) : null; - int curStart= current != null ? current.start : region.getOffset() + region.getLength(); - int curEnd= current != null ? current.start + current.length : -1; - int index= 0; - - // fill no-style regions - while (curEnd < region.getOffset() + region.getLength()) { - // add empty range - if (curStart > offset) { - StyleRange undoRange= new StyleRange(offset, curStart - offset, null, null); - undoRanges.add(index, undoRange); - index++; - } - - // step - index++; - if (index < undoRanges.size()) { - offset= curEnd; - current= (StyleRange) undoRanges.get(index); - curStart= current.start; - curEnd= current.start + current.length; - } else if (index == undoRanges.size()) { - // last one - offset= curEnd; - current= null; - curStart= region.getOffset() + region.getLength(); - curEnd= -1; - } else - curEnd= region.getOffset() + region.getLength(); - } - - // create modified styles (with background) - List shadedRanges= new ArrayList(undoRanges.size()); - for (Iterator it= undoRanges.iterator(); it.hasNext(); ) { - StyleRange range= (StyleRange) ((StyleRange) it.next()).clone(); - shadedRanges.add(range); - range.background= getHighlightColor(disp); - } - - // set the ranges one by one - for (Iterator iter= shadedRanges.iterator(); iter.hasNext(); ) { - text.setStyleRange((StyleRange) iter.next()); - - } - - return (StyleRange[]) undoRanges.toArray(undoRanges.toArray(new StyleRange[0])); - } - - private void resetViewerBackground(StyleRange[] oldRanges) { - - if (oldRanges == null) - return; - - if (fInput == null) - return; - - StyledText text= fInput.fViewer.getTextWidget(); - if (text == null || text.isDisposed()) - return; - - // set the ranges one by one - for (int i= 0; i < oldRanges.length; i++) { - text.setStyleRange(oldRanges[i]); - } - } - - private Color getHighlightColor(Display disp) { - return disp.getSystemColor(SWT.COLOR_GRAY); - } - - private Color getSelectionColor(Display disp) { - return disp.getSystemColor(SWT.COLOR_GRAY); - } - -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/EditPosition.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/EditPosition.java deleted file mode 100644 index f6ad5d1b686..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/EditPosition.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.internal.texteditor; - -import org.eclipse.jface.text.Assert; -import org.eclipse.jface.text.Position; -import org.eclipse.jface.viewers.ISelection; - -import org.eclipse.ui.IEditorInput; - -/** - * Data structure representing an edit position. - * - * @since 2.1 - */ -public final class EditPosition { - - /** The editor input */ - private final IEditorInput fEditorInput; - /** The editor ID */ - private final String fEditorId; - /** The selection */ - private final ISelection fSelection; - /** The position */ - private final Position fPosition; - - /** - * Creates a new edit position. - * - * @param editorInput the editor input - * @param editorId the editor ID - * @param selection the selection - * @param pos the position - */ - public EditPosition(IEditorInput editorInput, String editorId, ISelection selection, Position pos) { - Assert.isNotNull(editorInput); - Assert.isNotNull(editorId); - fEditorId= editorId; - fEditorInput= editorInput; - fSelection= selection; - fPosition= pos; - } - - /** - * Returns the editor input for this edit position. - * - * @return the editor input of this edit position - */ - IEditorInput getEditorInput() { - return fEditorInput; - } - - /** - * Returns the editor id for this edit position. - * - * @return the editor input of this edit position - */ - String getEditorId() { - return fEditorId; - } - - /** - * Returns the selection of this edit position. - * - * @return the selection of this edit position - */ - ISelection getSelection() { - return fSelection; - } - - /** - * Returns the the position. - * - * @return the position - */ - Position getPosition() { - return fPosition; - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/EditorMessages.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/EditorMessages.java deleted file mode 100644 index 9f3739260a6..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/EditorMessages.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.internal.texteditor; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -class EditorMessages { - - private static final String RESOURCE_BUNDLE= EditorMessages.class.getName(); - private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE); - - private EditorMessages() { - } - - 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.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/EditorMessages.properties b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/EditorMessages.properties deleted file mode 100644 index c14d15ebe07..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/EditorMessages.properties +++ /dev/null @@ -1,16 +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 -############################################################################### - - -## Errors ## - -Editor.error.gotoLastEditPosition.title= Problems going to last edit position -Editor.error.gotoLastEditPosition.message= Unable to go to the last edit position. diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/GotoLastEditPositionAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/GotoLastEditPositionAction.java deleted file mode 100644 index 3368f18aefb..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/GotoLastEditPositionAction.java +++ /dev/null @@ -1,176 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.internal.texteditor; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; - -import org.eclipse.jface.text.Position; - -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.IWorkbenchWindowActionDelegate; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.help.WorkbenchHelp; -import org.eclipse.ui.texteditor.IAbstractTextEditorHelpContextIds; -import org.eclipse.ui.texteditor.ITextEditor; -import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds; - -/** - * Goes to last edit position. - * - * @see org.eclipse.ui.internal.texteditor.EditPosition - * @since 2.1 - */ -public class GotoLastEditPositionAction extends Action implements IWorkbenchWindowActionDelegate { - - /** The worbench window */ - private IWorkbenchWindow fWindow; - /** The action */ - private IAction fAction; - - /** - * Creates a goto last edit action. - */ - public GotoLastEditPositionAction() { - WorkbenchHelp.setHelp(this, IAbstractTextEditorHelpContextIds.GOTO_LAST_EDIT_POSITION_ACTION); - setId(ITextEditorActionDefinitionIds.GOTO_LAST_EDIT_POSITION); - setActionDefinitionId(ITextEditorActionDefinitionIds.GOTO_LAST_EDIT_POSITION); - setEnabled(false); - } - - /* - * @see IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow) - */ - public void init(IWorkbenchWindow window) { - fWindow= window; - } - - /* - * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) - */ - public void run(IAction action) { - run(); - } - - /* - * @see IAction#run() - */ - public void run() { - EditPosition editPosition= TextEditorPlugin.getDefault().getLastEditPosition(); - if (editPosition == null) - return; - - final Position pos= editPosition.getPosition(); - if (pos == null || pos.isDeleted) - return; - - IWorkbenchWindow window= getWindow(); - if (window == null) - return; - - IWorkbenchPage page= window.getActivePage(); - - IEditorPart editor; - try { - editor= page.openEditor(editPosition.getEditorInput(), editPosition.getEditorId()); - } catch (PartInitException ex) { - editor= null; - } - - // Optimization - could also use else branch - if (editor instanceof ITextEditor) { - ITextEditor textEditor= (ITextEditor)editor; - textEditor.selectAndReveal(pos.offset, pos.length); - } -// } else -// if (editor != null) { -// final IEditorInput input= editor.getEditorInput(); -// final IEditorPart finalEditor= editor; -// if (input instanceof IFileEditorInput) { -// -// WorkspaceModifyOperation op = new WorkspaceModifyOperation() { -// protected void execute(IProgressMonitor monitor) throws CoreException { -// IMarker marker= null; -// try { -// marker= ((IFileEditorInput)input).getFile().createMarker(IMarker.TEXT); -// marker.setAttribute(IMarker.CHAR_START, pos.offset); -// marker.setAttribute(IMarker.CHAR_END, pos.offset + pos.length); -// -// finalEditor.gotoMarker(marker); -// -// } finally { -// if (marker != null) -// marker.delete(); -// } -// } -// }; -// -// try { -// op.run(null); -// } catch (InvocationTargetException ex) { -// String message= EditorMessages.getString("Editor.error.gotoLastEditPosition.message"); //$NON-NLS-1$ -// if (fWindow != null) { -// Shell shell= fWindow.getShell(); -// String title= EditorMessages.getString("Editor.error.gotoLastEditPosition.title"); //$NON-NLS-1$ -// MessageDialog.openError(shell, title, message); -// } else { -// Throwable t= ex.getTargetException(); -// IStatus status= new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, 0, message, t); -// TextEditorPlugin.getDefault().getLog().log(status); -// } -// } catch (InterruptedException e) { -// Assert.isTrue(false, "this operation can not be cancelled"); //$NON-NLS-1$ -// } -// } -// editor.setFocus(); -// } - } - - /* - * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) - */ - public void selectionChanged(IAction action, ISelection selection) { - boolean enabled= TextEditorPlugin.getDefault().getLastEditPosition() != null; - setEnabled(enabled); - action.setEnabled(enabled); - - // This is no longer needed once the action is enabled. - if (!enabled) { - // adding the same action twice has no effect. - TextEditorPlugin.getDefault().addLastEditPositionDependentAction(action); - // this is always the same action for this instance - fAction= action; - } - } - - /** - * Returns the workbench window. - * - * @return the workbench window - */ - private IWorkbenchWindow getWindow() { - if (fWindow == null) - fWindow= PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - return fWindow; - } - - /* - * @see IWorkbenchWindowActionDelegate#dispose() - */ - public void dispose() { - fWindow= null; - TextEditorPlugin.getDefault().removeLastEditPositionDependentAction(fAction); - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/LinearLayouter.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/LinearLayouter.java deleted file mode 100644 index c85569d3819..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/LinearLayouter.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.internal.texteditor; - -import org.eclipse.swt.graphics.Region; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Layout; - -/** - * - * - * @since 3.0 - */ -public class LinearLayouter { - - private static final int ANNOTATION_SIZE= 14; - private static final int BORDER_WIDTH= 2; - - public Layout getLayout(int itemCount) { - // simple layout: a row of items - GridLayout layout= new GridLayout(itemCount, true); - layout.horizontalSpacing= 1; - layout.verticalSpacing= 0; - layout.marginHeight= 1; - layout.marginWidth= 1; - return layout; - } - - public Object getLayoutData() { - GridData gridData= new GridData(ANNOTATION_SIZE + 2 * BORDER_WIDTH, ANNOTATION_SIZE + 2 * BORDER_WIDTH); - gridData.horizontalAlignment= GridData.CENTER; - gridData.verticalAlignment= GridData.CENTER; - return gridData; - } - - public int getAnnotationSize() { - return ANNOTATION_SIZE; - } - - public int getBorderWidth() { - return BORDER_WIDTH; - } - - public Region getShellRegion(int itemCount) { - // no special region - set to null for default shell size - return null; - } - -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/TextEditorPlugin.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/TextEditorPlugin.java deleted file mode 100644 index c21aaf24b54..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/TextEditorPlugin.java +++ /dev/null @@ -1,180 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.internal.texteditor; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - -import org.osgi.framework.BundleContext; - -import org.eclipse.core.runtime.IRegistryChangeEvent; -import org.eclipse.core.runtime.IRegistryChangeListener; -import org.eclipse.core.runtime.Platform; - -import org.eclipse.jface.action.IAction; - -import org.eclipse.jface.text.Assert; - -import org.eclipse.ui.internal.texteditor.quickdiff.QuickDiffExtensionsRegistry; -import org.eclipse.ui.plugin.AbstractUIPlugin; - -/** - * The plug-in runtime class for the text editor UI plug-in (id <code>"org.eclipse.ui.workbench.texteditor"</code>). - * This class provides static methods for: - * <ul> - * <li> getting the last editor position.</li> - * </ul> - * <p> - * This class provides static methods and fields only; it is not intended to be - * instantiated or subclassed by clients. - * </p> - * - * @since 2.1 - */ -public final class TextEditorPlugin extends AbstractUIPlugin implements IRegistryChangeListener { - - /** The plug-in instance */ - private static TextEditorPlugin fgPlugin; - - /** The last edit position */ - private EditPosition fLastEditPosition; - /** The action which goes to the last edit position */ - private Set fLastEditPositionDependentActions; - - /** - * The the quick diff extension registry. - * @since 3.0 - */ - private QuickDiffExtensionsRegistry fQuickDiffExtensionRegistry; - - /** - * Creates a plug-in instance. - */ - public TextEditorPlugin() { - super(); - Assert.isTrue(fgPlugin == null); - fgPlugin= this; - } - - /** - * Returns the plug-in instance. - * - * @return the text editor plug-in instance - * @since 3.0 - */ - public static TextEditorPlugin getDefault() { - return fgPlugin; - } - - /** - * Text editor UI plug-in Id (value <code>"org.eclipse.ui.workbench.texteditor"</code>). - */ - public static final String PLUGIN_ID= "org.eclipse.ui.workbench.texteditor"; //$NON-NLS-1$ - - /** - * Extension Id of quick diff reference provider extension point. - * (value <code>"quickDiffReferenceProvider"</code>). - * @since 3.0 - */ - public static final String REFERENCE_PROVIDER_EXTENSION_POINT= "quickDiffReferenceProvider"; //$NON-NLS-1$ - - /** - * Returns the last edit position. - * - * @return the last edit position or <code>null</code> if there is no last edit position - * @see EditPosition - */ - EditPosition getLastEditPosition() { - return fLastEditPosition; - } - - /** - * Sets the last edit position. - * - * @param lastEditPosition the last edit position - * @see EditPosition - */ - public void setLastEditPosition(EditPosition lastEditPosition) { - fLastEditPosition= lastEditPosition; - if (fLastEditPosition != null && fLastEditPositionDependentActions != null) { - Iterator iter= fLastEditPositionDependentActions.iterator(); - while (iter.hasNext()) - ((IAction)iter.next()).setEnabled(true); - fLastEditPositionDependentActions= null; - } - } - - /** - * Adds the given action to the last edit position dependent actions. - * - * @param action the goto last edit position action - */ - void addLastEditPositionDependentAction(IAction action) { - if (fLastEditPosition != null) - return; - if (fLastEditPositionDependentActions == null) - fLastEditPositionDependentActions= new HashSet(); - fLastEditPositionDependentActions.add(action); - } - - /** - * Removes the given action from the last edit position dependent actions. - * - * @param action the action that depends on the last edit position - */ - void removeLastEditPositionDependentAction(IAction action) { - if (fLastEditPosition != null) - return; - if (fLastEditPositionDependentActions != null) - fLastEditPositionDependentActions.remove(action); - } - - - /* - * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) - * @since 3.0 - */ - public void start(BundleContext context) throws Exception { - super.start(context); - fQuickDiffExtensionRegistry= new QuickDiffExtensionsRegistry(); - Platform.getExtensionRegistry().addRegistryChangeListener(this, PLUGIN_ID); - } - - /* - * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) - * @since 3.0 - */ - public void stop(BundleContext context) throws Exception { - Platform.getExtensionRegistry().removeRegistryChangeListener(this); - fQuickDiffExtensionRegistry= null; - super.stop(context); - } - - /* - * @see org.eclipse.core.runtime.IRegistryChangeListener#registryChanged(org.eclipse.core.runtime.IRegistryChangeEvent) - * @since 3.0 - */ - public void registryChanged(IRegistryChangeEvent event) { - if (fQuickDiffExtensionRegistry != null && event.getExtensionDeltas(PLUGIN_ID, REFERENCE_PROVIDER_EXTENSION_POINT).length > 0) - fQuickDiffExtensionRegistry.reloadExtensions(); - } - - /** - * Returns this plug-ins quick diff extension registry. - * - * @return the quick diff extension registry or <code>null</code> if this plug-in has been shutdown - * @since 3.0 - */ - public QuickDiffExtensionsRegistry getQuickDiffExtensionRegistry() { - return fQuickDiffExtensionRegistry; - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DiffRegion.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DiffRegion.java deleted file mode 100644 index 989a67eefc7..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DiffRegion.java +++ /dev/null @@ -1,205 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.internal.texteditor.quickdiff; - -import java.util.List; -import java.util.ListIterator; - -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.source.Annotation; -import org.eclipse.jface.text.source.ILineDiffInfo; - -import org.eclipse.ui.internal.texteditor.quickdiff.compare.rangedifferencer.RangeDifference; - - -/** - * The local implementation of <code>ILineDiffInfo</code>. As instances are - * also <code>Annotation</code>s, they can be used in - * <code>DocumentLineDiffer</code>s <code>IAnnotationModel</code> protocol. - * - * @since 3.0 - */ -public final class DiffRegion extends Annotation implements ILineDiffInfo { - private final RangeDifference fDifference; - - private final int fOffset; - - private final List fList; - - private final IDocument fDocument; - - /** - * Creates a new diff region. - * - * @param difference - * @param offset - * @param differences - * @param source - */ - public DiffRegion(RangeDifference difference, int offset, List differences, IDocument source) { - super("org.eclipse.ui.workbench.texteditor.quickdiffChange", false, null); //$NON-NLS-1$ - fOffset= offset; - fDifference= difference; - fList= differences; - fDocument= source; - } - - /* - * @see org.eclipse.jface.text.source.Annotation#getType() - */ - public String getType() { - // we return unknown for unchanged regions to avoid - // them getting displayed. - switch (getChangeType()) { - case CHANGED: - return "org.eclipse.ui.workbench.texteditor.quickdiffChange"; //$NON-NLS-1$ - case ADDED: - return "org.eclipse.ui.workbench.texteditor.quickdiffAddition"; //$NON-NLS-1$ - case UNCHANGED: - return "org.eclipse.ui.workbench.texteditor.quickdiffUnchanged"; //$NON-NLS-1$ - default: - return TYPE_UNKNOWN; - } - } - - /* - * @see org.eclipse.jface.text.source.ILineDiffInfo#getRemovedLinesBelow() - */ - public int getRemovedLinesBelow() { - if (fOffset == fDifference.rightLength() - 1) { - if (getChangeType() != UNCHANGED) { - return Math.max(fDifference.leftLength() - fDifference.rightLength(), 0); - } else { - for (ListIterator it= fList.listIterator(); it.hasNext();) { - if (fDifference.equals(it.next())) { - if (it.hasNext()) { - RangeDifference next= (RangeDifference) it.next(); - if (next.rightLength() == 0) - return Math.max(next.leftLength() - next.rightLength(), 0); - } - return 0; - } - } - return 0; - } - } else - return 0; - } - - /* - * @see org.eclipse.jface.text.source.ILineDiffInfo#getChangeType() - */ - public int getChangeType() { - if (fDifference.kind() == RangeDifference.NOCHANGE) - return UNCHANGED; - else { - if (fOffset >= fDifference.leftLength()) - return ADDED; - else - return CHANGED; - } - } - - /* - * @see org.eclipse.jface.text.source.ILineDiffInfo#getRemovedLinesAbove() - */ - public int getRemovedLinesAbove() { - if (getChangeType() != UNCHANGED || fOffset != 0) - return 0; - else { - for (ListIterator it= fList.listIterator(fList.size()); it.hasPrevious();) { - if (fDifference.equals(it.previous())) { - if (it.hasPrevious()) { - RangeDifference previous= (RangeDifference) it.previous(); - return Math.max(previous.leftLength() - previous.rightLength(), 0); - } else - return 0; - } - } - return 0; - } - } - - /* - * @see org.eclipse.jface.text.source.ILineDiffInfo#hasChanges() - */ - public boolean hasChanges() { - return getChangeType() != UNCHANGED || getRemovedLinesAbove() > 0 || getRemovedLinesBelow() > 0; - } - - /* - * @see org.eclipse.jface.text.source.ILineDiffInfo#getOriginalText() - */ - public String[] getOriginalText() { - IDocument doc= fDocument; - if (doc != null) { - int startLine= fDifference.leftStart() + fOffset; - if (startLine >= fDifference.leftEnd()) - return new String[0]; // original text of an added line is - // empty - - int endLine= startLine + getRemovedLinesBelow(); - if (getChangeType() == UNCHANGED) - startLine++; - String[] ret= new String[endLine - startLine + 1]; - for (int i= 0; i < ret.length; i++) { - try { - ret[i]= doc.get(doc.getLineOffset(startLine + i), doc.getLineLength(startLine + i)); - } catch (BadLocationException e) { - ret[i]= new String(); - } - } - return ret; - } - - // in initialization phase? - return new String[0]; - } - - /* - * @see org.eclipse.jface.text.source.Annotation#getText() - */ - public String getText() { - int r= fDifference.rightLength(); - int l= fDifference.leftLength(); - int c= Math.min(r, l); - int a= r - l; - String changed= c > 0 ? QuickDiffMessages.getFormattedString("quickdiff.annotation.changed", new Integer(c)) : null; //$NON-NLS-1$ - String added; - if (a > 0) - added= QuickDiffMessages.getFormattedString("quickdiff.annotation.added", new Integer(a)); //$NON-NLS-1$ - else if (a < 0) - added= QuickDiffMessages.getFormattedString("quickdiff.annotation.deleted", new Integer(-a)); //$NON-NLS-1$ - else - added= null; - String line= c > 1 || c == 0 && Math.abs(a) > 1 ? QuickDiffMessages.getString("quickdiff.annotation.line_plural") : QuickDiffMessages.getString("quickdiff.annotation.line_singular"); //$NON-NLS-1$//$NON-NLS-2$ - - String ret= (changed != null ? changed : "") + (changed != null ? " " + line : "") //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ - + (changed != null && added != null ? ", " : " ") + (added != null ? added : "") //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ - + (added != null && changed == null ? " " + line : ""); //$NON-NLS-1$//$NON-NLS-2$ - return ret; - } - - /** - * @return Returns the difference. - */ - public RangeDifference getDifference() { - return fDifference; - } - - /** - * @return Returns the offset. - */ - public int getOffset() { - return fOffset; - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DocumentLineDiffer.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DocumentLineDiffer.java deleted file mode 100644 index ded5172317d..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DocumentLineDiffer.java +++ /dev/null @@ -1,1405 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.internal.texteditor.quickdiff; - -import java.util.ArrayList; -import java.util.ConcurrentModificationException; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.ListIterator; - -import org.eclipse.core.runtime.CoreException; -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.runtime.jobs.Job; - -import org.eclipse.jface.util.Assert; - -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.Document; -import org.eclipse.jface.text.DocumentEvent; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.IDocumentListener; -import org.eclipse.jface.text.IRegion; -import org.eclipse.jface.text.Position; -import org.eclipse.jface.text.Region; -import org.eclipse.jface.text.source.Annotation; -import org.eclipse.jface.text.source.AnnotationModelEvent; -import org.eclipse.jface.text.source.IAnnotationModel; -import org.eclipse.jface.text.source.IAnnotationModelListener; -import org.eclipse.jface.text.source.IAnnotationModelListenerExtension; -import org.eclipse.jface.text.source.ILineDiffInfo; -import org.eclipse.jface.text.source.ILineDiffer; - -import org.eclipse.ui.texteditor.quickdiff.IQuickDiffReferenceProvider; - -import org.eclipse.ui.internal.texteditor.TextEditorPlugin; -import org.eclipse.ui.internal.texteditor.quickdiff.compare.rangedifferencer.DocLineComparator; -import org.eclipse.ui.internal.texteditor.quickdiff.compare.rangedifferencer.RangeDifference; -import org.eclipse.ui.internal.texteditor.quickdiff.compare.rangedifferencer.RangeDifferencer; -import org.eclipse.ui.internal.texteditor.quickdiff.compare.rangedifferencer.LinkedRangeFactory.LowMemoryException; - -/** - * Standard implementation of <code>ILineDiffer</code> as an incremental diff engine. A - * <code>DocumentLineDiffer</code> can be initialized to some start state. Once connected to a - * <code>IDocument</code> and a reference document has been set, changes reported via the - * <code>IDocumentListener</code> interface will be tracked and the incremental diff updated. - * - * <p>The diff state can be queried using the <code>ILineDiffer</code> interface.</p> - * - * <p>Since diff information is model information attached to a document, this class implements - * <code>IAnnotationModel</code> and can be attached to <code>IAnnotationModelExtension</code>s.</p> - * - * <p>This class is not supposed to be subclassed.</p> - * - * @since 3.0 - */ -public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnnotationModel { - - /** - * Artificial line difference information indicating a change with an empty line as original text. - */ - private static class LineChangeInfo implements ILineDiffInfo { - - private static final String[] ORIGINAL_TEXT= new String[] { "\n" }; //$NON-NLS-1$ - - /* - * @see org.eclipse.jface.text.source.ILineDiffInfo#getRemovedLinesBelow() - */ - public int getRemovedLinesBelow() { - return 0; - } - - /* - * @see org.eclipse.jface.text.source.ILineDiffInfo#getRemovedLinesAbove() - */ - public int getRemovedLinesAbove() { - return 0; - } - - /* - * @see org.eclipse.jface.text.source.ILineDiffInfo#getChangeType() - */ - public int getChangeType() { - return CHANGED; - } - - /* - * @see org.eclipse.jface.text.source.ILineDiffInfo#hasChanges() - */ - public boolean hasChanges() { - return true; - } - - /* - * @see org.eclipse.jface.text.source.ILineDiffInfo#getOriginalText() - */ - public String[] getOriginalText() { - return ORIGINAL_TEXT; - } - } - - /** Tells whether this class is in debug mode. */ - private static boolean DEBUG= "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.ui.workbench.texteditor/debug/DocumentLineDiffer")); //$NON-NLS-1$//$NON-NLS-2$ - - /** Suspended state */ - private static final int SUSPENDED= 0; - /** Initializing state */ - private static final int INITIALIZING= 1; - /** Synchronized state */ - private static final int SYNCHRONIZED= 2; - - /** This differ's state */ - private int fState= SUSPENDED; - /** Artificial line difference information indicating a change with an empty line as original text. */ - private final ILineDiffInfo fLineChangeInfo= new LineChangeInfo(); - - /** The provider for the reference document. */ - IQuickDiffReferenceProvider fReferenceProvider; - /** The number of clients connected to this model. */ - private int fOpenConnections; - /** The current document being tracked. */ - private IDocument fLeftDocument; - /** The reference document. */ - private IDocument fRightDocument; - /** - * Flag to indicate whether a change has been made to the line table and any clients should - * update their presentation. - */ - private boolean fUpdateNeeded; - /** The listeners on this annotation model. */ - private List fAnnotationModelListeners= new ArrayList(); - /** The job currently initializing the differ, or <code>null</code> if there is none. */ - private Job fInitializationJob; - /** Stores <code>DocumentEvents</code> while an initialization is going on. */ - private List fStoredEvents= new ArrayList(); - /** - * The differences between <code>fLeftDocument</code> and <code>fRightDocument</code>. - * This is the model we work on. - */ - private List fDifferences= new ArrayList(); - /** - * The differences removed in one iteration. Stored to be able to send out differentiated - * annotation events. - */ - private List fRemoved= new ArrayList(); - /** - * The differences added in one iteration. Stored to be able to send out differentiated - * annotation events. - */ - private List fAdded= new ArrayList(); - /** - * The differences changed in one iteration. Stored to be able to send out differentiated - * annotation events. - */ - private List fChanged= new ArrayList(); - /** The first line affected by a document event. */ - private int fFirstLine; - /** The number of lines affected by a document event. */ - private int fNLines; - /** The most recent range difference returned in a getLineInfo call, so it can be recyled. */ - private RangeDifference fLastDifference; - /** - * <code>true</code> if incoming document events should be ignored, - * <code>false</code> if not. - */ - private boolean fIgnoreDocumentEvents= true; - - /** - * Creates a new differ. - */ - public DocumentLineDiffer() { - } - - /* ILineDiffer implementation */ - - /* - * @see org.eclipse.jface.text.source.ILineDiffer#getLineInfo(int) - */ - public ILineDiffInfo getLineInfo(int line) { - - if (isSuspended()) - return fLineChangeInfo; - - // try cache first / speeds up linear search - RangeDifference last= fLastDifference; - if (last != null && last.rightStart() <= line && last.rightEnd() > line) - return new DiffRegion(last, line - last.rightStart(), fDifferences, fLeftDocument); - - fLastDifference= getRangeDifferenceForRightLine(line); - last= fLastDifference; - if (last != null) - return new DiffRegion(last, line - last.rightStart(), fDifferences, fLeftDocument); - else - return null; - } - - /* - * @see org.eclipse.jface.text.source.ILineDiffer#revertLine(int) - */ - public synchronized void revertLine(int line) throws BadLocationException { - if (!isInitialized()) - throw new BadLocationException(QuickDiffMessages.getString("quickdiff.nonsynchronized")); //$NON-NLS-1$ - - DiffRegion region= (DiffRegion) getLineInfo(line); - if (region == null || fRightDocument == null || fLeftDocument == null) - return; - - RangeDifference diff= region.getDifference(); - int rOffset= fRightDocument.getLineOffset(line); - int rLength= fRightDocument.getLineLength(line); - int leftLine= diff.leftStart() + region.getOffset(); - String replacement; - if (leftLine >= diff.leftEnd()) // restoring a deleted line? - replacement= new String(); - else { - int lOffset= fLeftDocument.getLineOffset(leftLine); - int lLength= fLeftDocument.getLineLength(leftLine); - replacement= fLeftDocument.get(lOffset, lLength); - } - fRightDocument.replace(rOffset, rLength, replacement); - } - - /* - * @see org.eclipse.jface.text.source.ILineDiffer#revertBlock(int) - */ - public synchronized void revertBlock(int line) throws BadLocationException { - if (!isInitialized()) - throw new BadLocationException(QuickDiffMessages.getString("quickdiff.nonsynchronized")); //$NON-NLS-1$ - - DiffRegion region= (DiffRegion) getLineInfo(line); - if (region == null || fRightDocument == null || fLeftDocument == null) - return; - - RangeDifference diff= region.getDifference(); - int rOffset= fRightDocument.getLineOffset(diff.rightStart()); - int rLength= fRightDocument.getLineOffset(diff.rightEnd() - 1) + fRightDocument.getLineLength(diff.rightEnd() - 1) - rOffset; - int lOffset= fLeftDocument.getLineOffset(diff.leftStart()); - int lLength= fLeftDocument.getLineOffset(diff.leftEnd() - 1) + fLeftDocument.getLineLength(diff.leftEnd() - 1) - lOffset; - fRightDocument.replace(rOffset, rLength, fLeftDocument.get(lOffset, lLength)); - } - - /* - * @see org.eclipse.jface.text.source.ILineDiffer#revertSelection(int, int) - */ - public synchronized void revertSelection(int line, int nLines) throws BadLocationException { - if (!isInitialized()) - throw new BadLocationException(QuickDiffMessages.getString("quickdiff.nonsynchronized")); //$NON-NLS-1$ - - int rOffset= -1, rLength= -1, lOffset= -1, lLength= -1; - RangeDifference diff= null; - Iterator it= fDifferences.iterator(); - - // get start - while (it.hasNext()) { - diff= (RangeDifference) it.next(); - if (line < diff.rightEnd()) { - rOffset= fRightDocument.getLineOffset(line); - int leftLine= Math.min(diff.leftStart() + line - diff.rightStart(), diff.leftEnd() - 1); - lOffset= fLeftDocument.getLineOffset(leftLine); - break; - } - } - - if (rOffset == -1 || lOffset == -1) - return; - - // get end / length - int to= line + nLines - 1; - while (it.hasNext()) { - diff= (RangeDifference) it.next(); - if (to < diff.rightEnd()) { - int rEndOffset= fRightDocument.getLineOffset(to) + fRightDocument.getLineLength(to); - rLength= rEndOffset - rOffset; - int leftLine= Math.min(diff.leftStart() + to - diff.rightStart(), diff.leftEnd() - 1); - int lEndOffset= fLeftDocument.getLineOffset(leftLine) + fLeftDocument.getLineLength(leftLine); - lLength= lEndOffset - lOffset; - break; - } - } - - if (rLength == -1 || lLength == -1) - return; - - fRightDocument.replace(rOffset, rLength, fLeftDocument.get(lOffset, lLength)); - } - - /* - * @see org.eclipse.jface.text.source.ILineDiffer#restoreAfterLine(int) - */ - public synchronized int restoreAfterLine(int line) throws BadLocationException { - if (!isInitialized()) - throw new BadLocationException(QuickDiffMessages.getString("quickdiff.nonsynchronized")); //$NON-NLS-1$ - - DiffRegion region= (DiffRegion) getLineInfo(line); - if (region == null || fRightDocument == null || fLeftDocument == null) - return 0; - - if (region.getRemovedLinesBelow() < 1) - return 0; - - RangeDifference diff= null; - for (Iterator it= fDifferences.iterator(); it.hasNext();) { - diff= (RangeDifference) it.next(); - if (line >= diff.rightStart() && line < diff.rightEnd()) { - if (diff.kind() == RangeDifference.NOCHANGE && it.hasNext()) - diff= (RangeDifference) it.next(); - break; - } - } - - if (diff == null) - return 0; - - int rOffset= fRightDocument.getLineOffset(diff.rightEnd()); - int rLength= 0; - int leftLine= diff.leftStart() + diff.rightLength(); - int lOffset= fLeftDocument.getLineOffset(leftLine); - int lLength= fLeftDocument.getLineOffset(diff.leftEnd() - 1) + fLeftDocument.getLineLength(diff.leftEnd() - 1) - lOffset; - fRightDocument.replace(rOffset, rLength, fLeftDocument.get(lOffset, lLength)); - - return diff.leftLength() - diff.rightLength(); - } - - /** - * Returns the receivers initialization state. - * - * @return <code>true</code> if we are initialized and in sync with the document. - */ - private boolean isInitialized() { - return fState == SYNCHRONIZED; - } - - /** - * Returns the receivers synchronization state. - * - * @return <code>true</code> if we are initialized and in sync with the document. - */ - public synchronized boolean isSynchronized() { - return fState == SYNCHRONIZED; - } - - /** - * Returns <code>true</code> if the differ is suspended. - * - * @return <code>true</code> if the differ is suspended - */ - private synchronized boolean isSuspended() { - return fState == SUSPENDED; - } - - /** - * Sets the reference provider for this instance. If one has been installed before, it is - * disposed. - * - * @param provider the new provider - */ - public void setReferenceProvider(IQuickDiffReferenceProvider provider) { - Assert.isNotNull(provider); - if (provider != fReferenceProvider) { - if (fReferenceProvider != null) - fReferenceProvider.dispose(); - fReferenceProvider= provider; - initialize(); - } - } - - /** - * Returns the reference provider currently installed, or <code>null</code> if none is installed. - * - * @return the current reference provider. - */ - public IQuickDiffReferenceProvider getReferenceProvider() { - return fReferenceProvider; - } - - /** - * (Re-)initializes the differ using the current reference and <code>DiffInitializer</code> - */ - synchronized void initialize() { - // make new incoming changes go into the queue of stored events, plus signal we can't restore. - fState= INITIALIZING; - - if (fRightDocument == null) - return; - - // there is no point in receiving updates before the job we get a new copy of the document for diffing - fIgnoreDocumentEvents= true; - - if (fLeftDocument != null) { - fLeftDocument.removeDocumentListener(this); - fLeftDocument= null; - } - - // if there already is a job: - // return if it has not started yet, cancel it if already running - final Job oldJob= fInitializationJob; - if (oldJob != null) { - // don't chain up jobs if there is one waiting already. - if (oldJob.getState() == Job.WAITING) - return; - else - oldJob.cancel(); - } - - fInitializationJob= new Job(QuickDiffMessages.getString("quickdiff.initialize")) { //$NON-NLS-1$ - - /* - * This is run in a different thread. As the documents might be synchronized, never ever - * access the documents in a synchronized section or expect deadlocks. See - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44692 - */ - public IStatus run(IProgressMonitor monitor) { - - // 1: wait for any previous job that was canceled to avoid job flooding - // It will return relatively quickly as RangeDifferencer supports canceling - if (oldJob != null) - try { - oldJob.join(); - } catch (InterruptedException e) { - // will not happen as noone interrupts our thread - Assert.isTrue(false); - } - - - // 2: get the reference document - IQuickDiffReferenceProvider provider= fReferenceProvider; - final IDocument left; - try { - left= provider == null ? null : provider.getReference(monitor); - } catch (CoreException e) { - synchronized (DocumentLineDiffer.this) { - if (isCanceled(monitor)) - return Status.CANCEL_STATUS; - else { - clearModel(); - fireModelChanged(); - DocumentLineDiffer.this.notifyAll(); - return e.getStatus(); - } - } - } catch (OperationCanceledException e) { - return Status.CANCEL_STATUS; - } - - // Getting our own copies of the documents for offline diffing. - // - // We need to make sure that we do get all document modifications after - // copying the documents as we want to reinject them later on to become consistent. - // - // Now this is fun. The reference documents may be PartiallySynchronizedDocuments - // which will result in a deadlock if they get changed externally before we get - // our exclusive copies. - // Here's what we do: we try over and over (without synchronization) to get copies - // without interleaving modification. If there is a document change, we just repeat. - - IDocument right= fRightDocument; // fRightDocument, but not subject to change - IDocument actual= null; // the copy of the actual (right) document - IDocument reference= null; // the copy of the reference (left) document - - synchronized (DocumentLineDiffer.this) { - // 4: take an early exit if the documents are not valid - if (left == null || right == null) { - if (isCanceled(monitor)) - return Status.CANCEL_STATUS; - else { - clearModel(); - fireModelChanged(); - DocumentLineDiffer.this.notifyAll(); - return Status.OK_STATUS; - } - } - - // set the reference document - fLeftDocument= left; - // start listening to document events. - fIgnoreDocumentEvents= false; - } - - // accessing the reference docuent offline - reference provider need - // to be able to deal with this. - left.addDocumentListener(DocumentLineDiffer.this); - - int i= 0; - do { - if (i++ == 100) // XXX this is an arbitrary emergency exit in case a referenced document goes nuts - return new Status(IStatus.ERROR, TextEditorPlugin.PLUGIN_ID, IStatus.OK, QuickDiffMessages.getFormattedString("quickdiff.error.getting_document_content", new Object[] {left.getClass(), right.getClass()}), null); //$NON-NLS-1$ - - // clear events - synchronized (DocumentLineDiffer.this) { - if (isCanceled(monitor)) - return Status.CANCEL_STATUS; - - fStoredEvents.clear(); - } - - // access documents unsynched: - // get an exclusive copy of the actual document - reference= createCopy(left); - actual= createCopy(right); - - synchronized (DocumentLineDiffer.this) { - if (fStoredEvents.size() == 0 && reference != null && actual != null) - break; - } - - } while (true); - - // 6: Do Da Diffing - DocLineComparator ref= new DocLineComparator(reference, null, false); - DocLineComparator act= new DocLineComparator(actual, null, false); - List diffs; - try { - diffs= RangeDifferencer.findRanges(monitor, ref, act); - } catch (LowMemoryException e) { - handleLowMemory(e); - return Status.CANCEL_STATUS; - } - - // 7: Reset the model to the just gotten differences - // re-inject stored events to get up to date. - synchronized (DocumentLineDiffer.this) { - if (isCanceled(monitor)) - return Status.CANCEL_STATUS; - - // set the new differences so we can operate on them - fDifferences= diffs; - } - - // reinject events accumulated in the meantime. - try { - do { - DocumentEvent event; - synchronized (DocumentLineDiffer.this) { - if (isCanceled(monitor)) - return Status.CANCEL_STATUS; - - if (fStoredEvents.isEmpty()) { - // we are done - fInitializationJob= null; - fState= SYNCHRONIZED; - fLastDifference= null; - - // inform blocking calls. - DocumentLineDiffer.this.notifyAll(); - - break; - } else { - event= (DocumentEvent) fStoredEvents.remove(0); - } - } - - // access documents unsynched: - handleAboutToBeChanged(event); - handleChanged(event); - - } while (true); - - } catch (BadLocationException e) { - left.removeDocumentListener(DocumentLineDiffer.this); - clearModel(); - initialize(); - return Status.CANCEL_STATUS; - } catch (LowMemoryException e) { - handleLowMemory(e); - return Status.CANCEL_STATUS; - } - - fireModelChanged(); - return Status.OK_STATUS; - } - - private boolean isCanceled(IProgressMonitor monitor) { - return fInitializationJob != this || monitor != null && monitor.isCanceled(); - } - - private void clearModel() { - fLeftDocument= null; - fInitializationJob= null; - fStoredEvents.clear(); - fLastDifference= null; - fDifferences.clear(); - } - - /** - * Creates a copy of <code>document</code> and catches any - * exceptions that may occur if the document is not modified concurrently. - * Do not call this method in a synchronized block as document.get() is called - * and may result in a deadlock otherwise. - * - * @param document the document to create a copy of - * @return a copy of the document, or <code>null</code> if an exception was thrown - */ - private IDocument createCopy(IDocument document) { - Assert.isNotNull(document); - // TODO needs for sure a safer synchronization method - // this is a temporary workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=56091 - try { - return new Document(document.get()); - } catch (NullPointerException e) { - } catch (ArrayStoreException e) { - } catch (IndexOutOfBoundsException e) { - } catch (ConcurrentModificationException e) { - } - return null; - } - }; - - fInitializationJob.setSystem(true); - fInitializationJob.setPriority(Job.DECORATE); - fInitializationJob.schedule(); - } - - /* IDocumentListener implementation */ - - /* - * @see org.eclipse.jface.text.IDocumentListener#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent) - */ - public synchronized void documentAboutToBeChanged(DocumentEvent event) { - if (fIgnoreDocumentEvents) - return; - - // if a initialization is going on, we just store the events in the meantime - if (!isInitialized() && fInitializationJob != null) { - fStoredEvents.add(event); - return; - } - - try { - handleAboutToBeChanged(event); - } catch (BadLocationException e) { - reinitOnError(e); - return; - } catch (NullPointerException e) { - reinitOnError(e); - return; - } catch (ArrayStoreException e) { - reinitOnError(e); - return; - } catch (IndexOutOfBoundsException e) { - reinitOnError(e); - return; - } catch (ConcurrentModificationException e) { - reinitOnError(e); - return; - } - } - - - /** - * Unsynchronized version of <code>documentAboutToBeChanged</code>, called by <code>documentAboutToBeChanged</code> - * and {@link #initialize()}. - * - * @param event the document event to be handled - */ - void handleAboutToBeChanged(DocumentEvent event) throws BadLocationException { - IDocument doc= event.getDocument(); - if (doc == null) - return; - - // store size of replaced region (never synchronized -> not a problem) - fFirstLine= doc.getLineOfOffset(event.getOffset()); // store change bounding lines - fNLines= doc.getLineOfOffset(event.getOffset() + event.getLength()) - fFirstLine + 1; - } - - /* - * @see org.eclipse.jface.text.IDocumentListener#documentChanged(org.eclipse.jface.text.DocumentEvent) - */ - public synchronized void documentChanged(DocumentEvent event) { - if (fIgnoreDocumentEvents) - return; - - if (!isInitialized()) - return; - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=44692 - // don't allow incremental update for changes from the reference document - // as this could deadlock - if (event.getDocument() == fLeftDocument) { - initialize(); - return; - } - - try { - handleChanged(event); - } catch (BadLocationException e) { - reinitOnError(e); - return; - } catch (NullPointerException e) { - reinitOnError(e); - return; - } catch (ArrayStoreException e) { - reinitOnError(e); - return; - } catch (IndexOutOfBoundsException e) { - reinitOnError(e); - return; - } catch (ConcurrentModificationException e) { - reinitOnError(e); - return; - } catch (LowMemoryException e) { - handleLowMemory(e); - return; - } - - // inform listeners about change - if (fUpdateNeeded) { - AnnotationModelEvent ame= new AnnotationModelEvent(this, false); - for (Iterator it= fAdded.iterator(); it.hasNext(); ) { - RangeDifference rd= (RangeDifference) it.next(); - ame.annotationAdded(rd.getDiffRegion(fDifferences, fLeftDocument)); - } - for (Iterator it= fRemoved.iterator(); it.hasNext(); ) { - RangeDifference rd= (RangeDifference) it.next(); - ame.annotationRemoved(rd.getDiffRegion(fDifferences, fLeftDocument)); - } - for (Iterator it= fChanged.iterator(); it.hasNext(); ) { - RangeDifference rd= (RangeDifference) it.next(); - ame.annotationChanged(rd.getDiffRegion(fDifferences, fLeftDocument)); - } - fireModelChanged(ame); - fUpdateNeeded= false; - } - } - - /** - * Re-initializes the differ if an exception is thrown upon accessing the documents. This can - * happen if the documents get concurrently modified from a background thread. - * - * @param e the exception thrown, which is logged in debug mode - */ - private void reinitOnError(Exception e) { - if (DEBUG) - System.err.println("reinitializing quickdiff:\n" + e.getLocalizedMessage() + "\n" + e.getStackTrace()); //$NON-NLS-1$//$NON-NLS-2$ - initialize(); - } - - /** - * Implementation of documentChanged, non synchronized. - * - * @param event the document event - * @throws LowMemoryException if the differ runs out of memory - */ - void handleChanged(DocumentEvent event) throws BadLocationException, LowMemoryException { - /* - * Now, here we have a great example of object oriented programming. - */ - - // documents: left, right; modified and unchanged are either of both - IDocument left= fLeftDocument; - IDocument right= fRightDocument; - IDocument modified= event.getDocument(); - if (modified != left && modified != right) - Assert.isTrue(false); - - String insertion= event.getText(); - int added= insertion == null ? 1 : modified.computeNumberOfLines(insertion) + 1; - // size: the size of the document change in lines - - // put an upper bound to the delay we can afford - if (added > 50 || fNLines > 50) { - initialize(); - return; - } - - int size= Math.max(fNLines, added) + 1; - int lineDelta= added - fNLines; - int lastLine= fFirstLine + fNLines - 1; - - int repetitionField; - if (modified == left) { - int originalLine= getRightLine(lastLine + 1); - repetitionField= searchForRepetitionField(size - 1, right, originalLine); - } else { - int originalLine= getLeftLine(lastLine + 1); - repetitionField= searchForRepetitionField(size - 1, left, originalLine); - } - lastLine += repetitionField; - - - // get enclosing range: search for a consistent block of at least the size of our - // change before and after the change. - RangeDifference consistentBefore, consistentAfter; - if (modified == left) { - consistentBefore= findConsistentRangeBeforeLeft(fFirstLine, size); - consistentAfter= findConsistentRangeAfterLeft(lastLine, size); - } else { - consistentBefore= findConsistentRangeBeforeRight(fFirstLine, size); - consistentAfter= findConsistentRangeAfterRight(lastLine, size); - } - - // optimize unchanged blocks: if the consistent blocks around the change are larger than - // size, we redimension them (especially important when there are only very little changes. - int shiftBefore= 0; - if (consistentBefore.kind() == RangeDifference.NOCHANGE) { - int unchanged; - if (modified == left) - unchanged= Math.min(fFirstLine, consistentBefore.leftEnd()) - consistentBefore.leftStart(); - else - unchanged= Math.min(fFirstLine, consistentBefore.rightEnd()) - consistentBefore.rightStart(); - - shiftBefore= Math.max(0, unchanged - size); - } - - int shiftAfter= 0; - if (consistentAfter.kind() == RangeDifference.NOCHANGE) { - int unchanged; - if (modified == left) - unchanged= consistentAfter.leftEnd() - Math.max(lastLine + 1, consistentAfter.leftStart()); - else - unchanged= consistentAfter.rightEnd() - Math.max(lastLine + 1, consistentAfter.rightStart()); - - shiftAfter= Math.max(0, unchanged - size); - } - - // get the document regions that will be rediffed, take into account that on the - // document, the change has already happened. - // left (reference) document - int leftOffset= left.getLineOffset(consistentBefore.leftStart() + shiftBefore); - int leftLine= Math.max(consistentAfter.leftEnd() - 1, 0); - if (modified == left) - leftLine += lineDelta; - IRegion leftLastLine= left.getLineInformation(leftLine - shiftAfter); - int leftEndOffset= leftLastLine.getOffset() + leftLastLine.getLength(); - IRegion leftRegion= new Region(leftOffset, leftEndOffset - leftOffset); - DocLineComparator reference= new DocLineComparator(left, leftRegion, false); - - // right (actual) document - int rightOffset= right.getLineOffset(consistentBefore.rightStart() + shiftBefore); - int rightLine= Math.max(consistentAfter.rightEnd() - 1, 0); - if (modified == right) - rightLine += lineDelta; - IRegion rightLastLine= right.getLineInformation(rightLine - shiftAfter); - int rightEndOffset= rightLastLine.getOffset() + rightLastLine.getLength(); - IRegion rightRegion= new Region(rightOffset, rightEndOffset - rightOffset); - DocLineComparator change= new DocLineComparator(right, rightRegion, false); - - // put an upper bound to the delay we can afford - if (leftLine - shiftAfter - (consistentBefore.leftStart() + shiftBefore) > 50 || rightLine - shiftAfter - (consistentBefore.rightStart() + shiftBefore) > 50) { - initialize(); - return; - } - - // debug -// System.out.println("compare window: "+size+"\n\n<" + left.get(leftRegion.getOffset(), leftRegion.getLength()) + //$NON-NLS-1$//$NON-NLS-2$ -// ">\n\n<" + right.get(rightRegion.getOffset(), rightRegion.getLength()) + ">\n"); //$NON-NLS-1$ //$NON-NLS-2$ - - // compare - List diffs= RangeDifferencer.findRanges(reference, change); - if (diffs.size() == 0) { - diffs.add(new RangeDifference(RangeDifference.CHANGE, 0, 0, 0, 0)); - } - - - // shift the partial diffs to the absolute document positions - int leftShift= consistentBefore.leftStart() + shiftBefore; - int rightShift= consistentBefore.rightStart() + shiftBefore; - for (Iterator it= diffs.iterator(); it.hasNext();) { - RangeDifference d= (RangeDifference) it.next(); - d.shiftLeft(leftShift); - d.shiftRight(rightShift); - } - - // undo optimization shifting - if (shiftBefore > 0) { - RangeDifference first= (RangeDifference) diffs.get(0); - if (first.kind() == RangeDifference.NOCHANGE) - first.extendStart(-shiftBefore); - else - diffs.add(0, new RangeDifference(RangeDifference.NOCHANGE, first.rightStart() - shiftBefore, shiftBefore, first.leftStart() - shiftBefore, shiftBefore)); - } - - RangeDifference last= (RangeDifference) diffs.get(diffs.size() - 1); - if (shiftAfter > 0) { - if (last.kind() == RangeDifference.NOCHANGE) - last.extendEnd(shiftAfter); - else - diffs.add(new RangeDifference(RangeDifference.NOCHANGE, last.rightEnd(), shiftAfter , last.leftEnd(), shiftAfter)); - } - - // replace changed diff range - ListIterator it= fDifferences.listIterator(); - Iterator newIt= diffs.iterator(); - RangeDifference current; - boolean changed= false; - - // replace regions from consistentBefore to consistentAfter with new diffs - - // search for consistentBefore - do { - Assert.isTrue(it.hasNext()); - current= (RangeDifference) it.next(); - } while (current != consistentBefore); - Assert.isTrue(current == consistentBefore); - - fChanged.clear(); - fRemoved.clear(); - fAdded.clear(); - - // replace until consistentAfter - while (current != consistentAfter) { - if (newIt.hasNext()) { - Object o= newIt.next(); - if (!current.equals(o)) { - fRemoved.add(current); - fAdded.add(o); - changed= true; - it.set(o); - } - } else { - fRemoved.add(current); - it.remove(); - fUpdateNeeded= true; - } - Assert.isTrue(it.hasNext()); - current= (RangeDifference) it.next(); - } - - // replace consistentAfter - Assert.isTrue(current == consistentAfter); - if (newIt.hasNext()) { - Object o= newIt.next(); - if (!current.equals(o)) { - fRemoved.add(current); - fAdded.add(o); - changed= true; - it.set(o); - } - } else { - fRemoved.add(current); - it.remove(); - fUpdateNeeded= true; - } - - // add remaining new diffs - while (newIt.hasNext()) { - Object next= newIt.next(); - fAdded.add(next); - it.add(next); - changed= true; - } - - // shift the old remaining diffs - boolean init= true; - while (it.hasNext()) { - current= (RangeDifference) it.next(); - if (init) { - init= false; - leftShift= last.leftEnd() - current.leftStart(); - rightShift= last.rightEnd() - current.rightStart(); - if (leftShift != 0 || rightShift != 0) - changed= true; - else - break; - } -// fChanged.add(current); // not needed since positional shifting is not handled by an annotation model - current.shiftLeft(leftShift); - current.shiftRight(rightShift); - } - - fUpdateNeeded= changed; - fLastDifference= null; - - } - - /** - * Finds a consistent range of at least size before <code>line</code> in the left document. - * - * @param line the line before which the range has to occur - * @param size the minimal size of the range - * @return the first range found, or the first range in the differ if none can be found - */ - private RangeDifference findConsistentRangeBeforeLeft(int line, int size) { - RangeDifference found= null; - - for (ListIterator it= fDifferences.listIterator(); it.hasNext();) { - RangeDifference difference= (RangeDifference) it.next(); - if (found == null || difference.kind() == RangeDifference.NOCHANGE - && (difference.leftEnd() < line && difference.leftLength() >= size - || difference.leftEnd() >= line && line - difference.leftStart() >= size)) - found= difference; - - if (difference.leftEnd() >= line) - break; - } - - return found; - } - - /** - * Finds a consistent range of at least size after <code>line</code> in the left document. - * - * @param line the line after which the range has to occur - * @param size the minimal size of the range - * @return the first range found, or the last range in the differ if none can be found - */ - private RangeDifference findConsistentRangeAfterLeft(int line, int size) { - RangeDifference found= null; - - for (ListIterator it= fDifferences.listIterator(fDifferences.size()); it.hasPrevious();) { - RangeDifference difference= (RangeDifference) it.previous(); - if (found == null || difference.kind() == RangeDifference.NOCHANGE - && (difference.leftStart() > line && difference.leftLength() >= size - || difference.leftStart() <= line && difference.leftEnd() - line >= size)) - found= difference; - - if (difference.leftStart() <= line) - break; - - } - - return found; - } - - /** - * Finds a consistent range of at least size before <code>line</code> in the right document. - * - * @param line the line before which the range has to occur - * @param size the minimal size of the range - * @return the first range found, or the first range in the differ if none can be found - */ - private RangeDifference findConsistentRangeBeforeRight(int line, int size) { - RangeDifference found= null; - - int unchanged= -1; // the number of unchanged lines before line - for (ListIterator it= fDifferences.listIterator(); it.hasNext();) { - RangeDifference difference= (RangeDifference) it.next(); - if (found == null) - found= difference; - else if (difference.kind() == RangeDifference.NOCHANGE) { - unchanged= Math.min(line, difference.rightEnd()) - difference.rightStart(); - if (unchanged >= size) - found= difference; - } - - if (difference.rightEnd() >= line) - break; - } - - return found; - } - - /** - * Finds a consistent range of at least size after <code>line</code> in the right document. - * - * @param line the line after which the range has to occur - * @param size the minimal size of the range - * @return the first range found, or the last range in the differ if none can be found - */ - private RangeDifference findConsistentRangeAfterRight(int line, int size) { - RangeDifference found= null; - - int unchanged= -1; // the number of unchanged lines after line - for (ListIterator it= fDifferences.listIterator(fDifferences.size()); it.hasPrevious();) { - RangeDifference difference= (RangeDifference) it.previous(); - if (found == null) - found= difference; - else if (difference.kind() == RangeDifference.NOCHANGE) { - unchanged= difference.rightEnd() - Math.max(line + 1, difference.rightStart()); // + 1 to step over the changed line - if (unchanged >= size) - found= difference; - } - - if (difference.rightStart() <= line) - break; - } - - return found; - } - - /** - * Returns the size of a repetition field starting a <code>line</code>. - * - * @param size the maximal length of the repeat window - * @param doc the document to search - * @param line the line to start searching - * @return the size of a found repetition field, or zero - * @throws BadLocationException if <code>doc</code> is modified concurrently - */ - private int searchForRepetitionField(int size, IDocument doc, int line) throws BadLocationException { - /* - Repetition fields: a line wise repetition of maximal size <code>size</code> - can urge a change to come at its end, as diffing greedily takes the longest - unchanged range possible: - <pre> - before - repeat - repeat - repeat - repeat - repeat - repeat - repeat - repeat - after - </pre> - - Inserting another repeat element anywhere in the repetition field will create - an addition at its end. - - Size is one less than our window size (as this is already one more than the actual number - of affected lines. - */ - - /* - * Implementation: - * Window of maximum repetition size. Whenever the current matches the first in the window, - * we advance it by one. If there are more free slots in the window, the current line is - * appended. - * We terminate if the current line does not match and there are no more free slots. - * - * TODO what if we have a prefix to a repetition field? Probably does not matter. - */ - LinkedList window= new LinkedList(); - int nLines= doc.getNumberOfLines(); - int repetition= line - 1; - int l= line; - - while (l >= 0 && l < nLines) { - IRegion r= doc.getLineInformation(l); - String current= doc.get(r.getOffset(), r.getLength()); - - if (!window.isEmpty() && window.get(0).equals(current)) { - // repetition found, shift - window.removeFirst(); - window.addLast(current); - repetition= l; - } else { - // no repetition, add if there is room - // otherwise return - if (window.size() < size) - window.addLast(current); - else - break; - } - - l++; - } - - int fieldLength= repetition - line + 1; - Assert.isTrue(fieldLength >= 0); - return fieldLength; - } - - /** - * Gets the corresponding line on the left side for a line on the right. - * - * @param rightLine the line on the right side - * @return the corresponding left hand line, or <code>-1</code> - */ - private int getLeftLine(int rightLine) { - RangeDifference d= getRangeDifferenceForRightLine(rightLine); - if (d == null) - return -1; - return Math.min(d.leftEnd() - 1, d.leftStart() + rightLine - d.rightStart()); - } - - /** - * Gets the corresponding line on the right side for a line on the left. - * - * @param leftLine the line on the left side - * @return the corresponding right hand line, or <code>-1</code> - */ - private int getRightLine(int leftLine) { - RangeDifference d= getRangeDifferenceForLeftLine(leftLine); - if (d == null) - return -1; - return Math.min(d.rightEnd() - 1, d.rightStart() + leftLine - d.leftStart()); - } - - /** - * Gets the RangeDifference for a line on the left hand side. - * - * @param leftLine the line on the left side - * @return the corresponding RangeDifference, or <code>null</code> - */ - private RangeDifference getRangeDifferenceForLeftLine(int leftLine) { - for (Iterator it= fDifferences.iterator(); it.hasNext();) { - RangeDifference d= (RangeDifference) it.next(); - if (leftLine >= d.leftStart() && leftLine < d.leftEnd()) { - return d; - } - } - return null; - } - - /** - * Gets the RangeDifference for a line on the right hand side. - * - * @param rightLine the line on the right side - * @return the corresponding RangeDifference, or <code>null</code> - */ - private RangeDifference getRangeDifferenceForRightLine(int rightLine) { - for (Iterator it= fDifferences.iterator(); it.hasNext();) { - RangeDifference d= (RangeDifference) it.next(); - if (rightLine >= d.rightStart() && rightLine < d.rightEnd()) { - return d; - } - } - return null; - } - - /* - * @see org.eclipse.jface.text.source.IAnnotationModel#addAnnotationModelListener(org.eclipse.jface.text.source.IAnnotationModelListener) - */ - public void addAnnotationModelListener(IAnnotationModelListener listener) { - fAnnotationModelListeners.add(listener); - } - - /* - * @see org.eclipse.jface.text.source.IAnnotationModel#removeAnnotationModelListener(org.eclipse.jface.text.source.IAnnotationModelListener) - */ - public void removeAnnotationModelListener(IAnnotationModelListener listener) { - fAnnotationModelListeners.remove(listener); - } - - /* - * @see org.eclipse.jface.text.source.IAnnotationModel#connect(org.eclipse.jface.text.IDocument) - */ - public void connect(IDocument document) { - Assert.isTrue(fRightDocument == null || fRightDocument == document); - - ++fOpenConnections; - if (fOpenConnections == 1) { - fRightDocument= document; - fRightDocument.addDocumentListener(this); - initialize(); - } - } - - /* - * @see org.eclipse.jface.text.source.IAnnotationModel#disconnect(org.eclipse.jface.text.IDocument) - */ - public void disconnect(IDocument document) { - Assert.isTrue(fRightDocument == document); - - --fOpenConnections; - - if (fOpenConnections == 0) - uninstall(); - } - - /** - * Uninstalls all components and dereferences any objects. - */ - private void uninstall() { - synchronized (this) { - fState= SUSPENDED; - fIgnoreDocumentEvents= true; - if (fInitializationJob != null) - fInitializationJob.cancel(); - fInitializationJob= null; - - if (fLeftDocument != null) - fLeftDocument.removeDocumentListener(this); - fLeftDocument= null; - - if (fRightDocument != null) - fRightDocument.removeDocumentListener(this); - fRightDocument= null; - } - - if (fReferenceProvider != null) { - fReferenceProvider.dispose(); - fReferenceProvider= null; - } - - fDifferences.clear(); - } - - /* - * @see org.eclipse.jface.text.source.IAnnotationModel#addAnnotation(org.eclipse.jface.text.source.Annotation, org.eclipse.jface.text.Position) - */ - public void addAnnotation(Annotation annotation, Position position) { - throw new UnsupportedOperationException(); - } - - /* - * @see org.eclipse.jface.text.source.IAnnotationModel#removeAnnotation(org.eclipse.jface.text.source.Annotation) - */ - public void removeAnnotation(Annotation annotation) { - throw new UnsupportedOperationException(); - } - - /* - * @see org.eclipse.jface.text.source.IAnnotationModel#getAnnotationIterator() - */ - public Iterator getAnnotationIterator() { - final List copy= new ArrayList(fDifferences); - final Iterator iter= copy.iterator(); - return new Iterator() { - - public void remove() { - throw new UnsupportedOperationException(); - } - - public boolean hasNext() { - return iter.hasNext(); - } - - public Object next() { - RangeDifference diff= (RangeDifference) iter.next(); - return diff.getDiffRegion(copy, fLeftDocument); - } - - }; - } - - /* - * @see org.eclipse.jface.text.source.IAnnotationModel#getPosition(org.eclipse.jface.text.source.Annotation) - */ - public Position getPosition(Annotation annotation) { - if (fRightDocument != null && annotation instanceof DiffRegion) { - RangeDifference difference= ((DiffRegion)annotation).getDifference(); - try { - int offset= fRightDocument.getLineOffset(difference.rightStart()); - return new Position(offset, fRightDocument.getLineOffset(difference.rightEnd() - 1) + fRightDocument.getLineLength(difference.rightEnd() - 1) - offset); - } catch (BadLocationException e) { - // ignore and return null; - } - } - return null; - } - - /** - * Informs all annotation model listeners that this model has been changed. - */ - protected void fireModelChanged() { - fireModelChanged(new AnnotationModelEvent(this)); - } - - /** - * Informs all annotation model listeners that this model has been changed - * as described in the annotation model event. The event is sent out - * to all listeners implementing <code>IAnnotationModelListenerExtension</code>. - * All other listeners are notified by just calling <code>modelChanged(IAnnotationModel)</code>. - * - * @param event the event to be sent out to the listeners - */ - protected void fireModelChanged(AnnotationModelEvent event) { - ArrayList v= new ArrayList(fAnnotationModelListeners); - Iterator e= v.iterator(); - while (e.hasNext()) { - IAnnotationModelListener l= (IAnnotationModelListener)e.next(); - if (l instanceof IAnnotationModelListenerExtension) - ((IAnnotationModelListenerExtension)l).modelChanged(event); - else - l.modelChanged(this); - } - } - - /** - * Stops diffing of this differ. All differences are cleared. - */ - public synchronized void suspend() { - if (fInitializationJob != null) { - fInitializationJob.cancel(); - fInitializationJob= null; - } - if (fRightDocument != null) - fRightDocument.removeDocumentListener(this); - if (fLeftDocument != null) - fLeftDocument.removeDocumentListener(this); - fLeftDocument= null; - - fLastDifference= null; - fStoredEvents.clear(); - fDifferences.clear(); - - fState= SUSPENDED; - - fireModelChanged(); - } - - /** - * Resumes diffing of this differ. Must only be called after suspend. - */ - public synchronized void resume() { - if (fRightDocument != null) - fRightDocument.addDocumentListener(this); - initialize(); - } - - /** - * Handle low memory situation during diffing. Called from UI and jobs. - * - * @param e the low memory exception - */ - private void handleLowMemory(LowMemoryException e) { - if (DEBUG) - System.err.println("Disabling QuickDiff:\n" + e); //$NON-NLS-1$ - suspend(); - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffExtensionsRegistry.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffExtensionsRegistry.java deleted file mode 100644 index 8cd692eace7..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffExtensionsRegistry.java +++ /dev/null @@ -1,93 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.internal.texteditor.quickdiff; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtensionRegistry; -import org.eclipse.core.runtime.Platform; - -import org.eclipse.ui.internal.texteditor.TextEditorPlugin; -import org.eclipse.ui.texteditor.quickdiff.ReferenceProviderDescriptor; - -/** - * Access class for the quick diff reference provider extension point. - * - * @since 3.0 - */ -public class QuickDiffExtensionsRegistry { - - /** The default reference provider's descriptor. */ - private ReferenceProviderDescriptor fDefaultDescriptor; - /** The list returned to callers of <code>getExtensions</code>. */ - private List fDescriptors; - - /** - * Creates a new instance. - */ - public QuickDiffExtensionsRegistry() { - } - - /** - * Returns the first descriptor with the <code>default</code> attribute set to <code>true</code>. - * - * @return the descriptor of the default reference provider. - */ - public synchronized ReferenceProviderDescriptor getDefaultProvider() { - ensureRegistered(); - return fDefaultDescriptor; - } - - /** - * Returns a non-modifiable list of <code>ReferenceProviderDescriptor</code> describing all extension - * to the <code>quickDiffReferenceProvider</code> extension point. - * - * @return the list of extensions to the <code>quickDiffReferenceProvider</code> extension point. - */ - public synchronized List getReferenceProviderDescriptors() { - ensureRegistered(); - return fDescriptors; - } - - /** - * Ensures that the extensions are read and stored in <code>fDescriptors</code>. - */ - private void ensureRegistered() { - if (fDescriptors == null) - reloadExtensions(); - } - - /** - * Reads all extensions. - * <p> - * This method can be called more than once in - * order to reload from a changed extension registry. - * </p> - */ - public synchronized void reloadExtensions() { - fDefaultDescriptor= null; - IExtensionRegistry registry= Platform.getExtensionRegistry(); - List list= new ArrayList(); - - IConfigurationElement[] elements= registry.getConfigurationElementsFor(TextEditorPlugin.PLUGIN_ID, TextEditorPlugin.REFERENCE_PROVIDER_EXTENSION_POINT); - for (int i= 0; i < elements.length; i++) { - ReferenceProviderDescriptor desc= new ReferenceProviderDescriptor(elements[i]); - if (fDefaultDescriptor == null && desc.getDefault()) - fDefaultDescriptor= desc; - list.add(desc); - } - - fDescriptors= Collections.unmodifiableList(list); - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffMessages.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffMessages.java deleted file mode 100644 index f0ca8e8ad9c..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffMessages.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.ui.internal.texteditor.quickdiff; - -import java.text.MessageFormat; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -/** - * Helper class which wraps the specified resource bundle - * and offers methods to access the bundle. - * - * @since 3.0 - */ -public class QuickDiffMessages { - - private static final String RESOURCE_BUNDLE= "org.eclipse.ui.internal.texteditor.quickdiff.QuickDiffMessages";//$NON-NLS-1$ - - private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE); - - private QuickDiffMessages() { - } - - 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; - } - - 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.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffMessages.properties b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffMessages.properties deleted file mode 100644 index 36e3dad34db..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffMessages.properties +++ /dev/null @@ -1,35 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2004 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Common Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/cpl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### -quickdiff.toggle.enable= Enable Q&uickDiff -quickdiff.toggle.disable= Disable Q&uickDiff - -quickdiff.initialize= Initializing Quick Diff -quickdiff.nonsynchronized= Quick Diff Is Not in Sync - Cannot Restore -quickdiff.annotation.changed={0} changed -quickdiff.annotation.added={0} added -quickdiff.annotation.deleted={0} deleted -quickdiff.annotation.line_singular=line -quickdiff.annotation.line_plural=lines - -quickdiff.menu.label= Set QuickDiff Re&ference - -RevertLineAction.description= Reverts the current line to its original state -RevertLineAction.label= Revert &Line -RevertLineAction.delete.label= Delete Added &Line -RevertBlockAction.description= Reverts a contiguous block of modified lines -RevertBlockAction.label= R&evert Block -RevertSelectionAction.description= Reverts any modified lines in the selection -RevertSelectionAction.label= Revert S&election -RestoreAction.description= Restores deleted lines into the current document -RestoreAction.label= Restore &Deleted Line -RestoreAction.multiple.label= Restore {0} &Deleted Lines - -quickdiff.error.getting_document_content= Unable to get document content. Left document type: {0}; right document type: {1}. diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffRestoreAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffRestoreAction.java deleted file mode 100644 index 890d9533c4c..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffRestoreAction.java +++ /dev/null @@ -1,161 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.internal.texteditor.quickdiff; - -import java.util.ResourceBundle; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionProvider; - -import org.eclipse.jface.text.IRewriteTarget; -import org.eclipse.jface.text.ITextSelection; -import org.eclipse.jface.text.source.IAnnotationModel; -import org.eclipse.jface.text.source.IAnnotationModelExtension; -import org.eclipse.jface.text.source.IChangeRulerColumn; -import org.eclipse.jface.text.source.ILineDiffer; -import org.eclipse.jface.text.source.IVerticalRulerInfo; - -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.texteditor.IDocumentProvider; -import org.eclipse.ui.texteditor.IEditorStatusLine; -import org.eclipse.ui.texteditor.ITextEditor; -import org.eclipse.ui.texteditor.TextEditorAction; - -/** - * Abstract superclass of actions that restore / revert parts of a document displayed in the action's - * editor to the state described by the {@link ILineDiffer ILineDiffer} associated with the document's - * {@link IAnnotationModel IAnnotationModel}. - * - * @since 3.0 - */ -public abstract class QuickDiffRestoreAction extends TextEditorAction { - - /** - * Creates a new instance. - * - * @param bundle the resource bundle - * @param prefix a prefix to be prepended to the various resource keys - * @param editor the editor this action belongs to - */ - QuickDiffRestoreAction(ResourceBundle bundle, String prefix, ITextEditor editor) { - super(bundle, prefix, editor); - } - - /** - * Called by this action's run method inside a pair of calls to <code>IRewriteTarget.beginCompoundChange</code> - * and <code>IRewriteTarget.endCompoundChange</code>(). - * - * @see IRewriteTarget - */ - protected abstract void runCompoundChange(); - - /* - * @see org.eclipse.jface.action.IAction#run() - */ - public void run() { - ITextEditor editor= getTextEditor(); - if (editor == null || !validateEditorInputState()) - return; - IRewriteTarget target= (IRewriteTarget)editor.getAdapter(IRewriteTarget.class); - if (target != null) - target.beginCompoundChange(); - runCompoundChange(); - if (target != null) - target.endCompoundChange(); - - } - - /* - * @see org.eclipse.ui.texteditor.TextEditorAction#update() - */ - public void update() { - super.update(); - if (isEnabled()) - setEnabled(canModifyEditor()); - } - - /** - * Returns the selection of the editor this action belongs to. - * - * @return the editor's selection, or <code>null</code> - */ - protected ITextSelection getSelection() { - if (getTextEditor() == null) - return null; - ISelectionProvider sp= getTextEditor().getSelectionProvider(); - if (sp == null) - return null; - ISelection s= sp.getSelection(); - if (s instanceof ITextSelection) - return (ITextSelection)s; - else - return null; - } - - /** - * Returns the annotation model of the document displayed in this action's editor, if it - * implements the {@link IAnnotationModelExtension IAnnotationModelExtension} interface. - * - * @return the displayed document's annotation model if it is an <code>IAnnotationModelExtension</code>, or <code>null</code> - */ - private IAnnotationModelExtension getModel() { - if (getTextEditor() == null) - return null; - IDocumentProvider provider= getTextEditor().getDocumentProvider(); - IEditorInput editorInput= getTextEditor().getEditorInput(); - IAnnotationModel m= provider.getAnnotationModel(editorInput); - if (m instanceof IAnnotationModelExtension) { - return (IAnnotationModelExtension)m; - } else { - return null; - } - } - - /** - * Returns the diff model associated with the annotation model of the document currently displayed - * in this action's editor, if any. - * - * @return the diff model associated with the displayed document, or <code>null</code> - */ - protected ILineDiffer getDiffer() { - IAnnotationModelExtension extension= getModel(); - if (extension != null) - return (ILineDiffer)extension.getAnnotationModel(IChangeRulerColumn.QUICK_DIFF_MODEL_ID); - else - return null; - } - - /** - * Returns a <code>IVerticalRulerInfo</code> if this action's editor adapts to one. - * - * @return the <code>IVerticalRulerInfo</code> for the editor's vertical ruler, or <code>null</code> - */ - protected IVerticalRulerInfo getRuler() { - if (getTextEditor() != null) - return (IVerticalRulerInfo)getTextEditor().getAdapter(IVerticalRulerInfo.class); - else - return null; - } - - /** - * Sets the status line error message to <code>string</code>. - * - * @param string the message to be displayed as error. - */ - protected void setStatus(String string) { - if (getTextEditor() != null) { - IEditorStatusLine statusLine= (IEditorStatusLine) getTextEditor().getAdapter(IEditorStatusLine.class); - if (statusLine != null) { - statusLine.setMessage(true, string, null); - } - } - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/ReferenceSelectionAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/ReferenceSelectionAction.java deleted file mode 100644 index 5fab0c97f63..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/ReferenceSelectionAction.java +++ /dev/null @@ -1,170 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.internal.texteditor.quickdiff; - -import org.eclipse.jface.action.Action; - -import org.eclipse.jface.text.Assert; -import org.eclipse.jface.text.source.IAnnotationModel; -import org.eclipse.jface.text.source.IAnnotationModelExtension; -import org.eclipse.jface.text.source.IChangeRulerColumn; - -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.texteditor.quickdiff.IQuickDiffReferenceProvider; -import org.eclipse.ui.texteditor.quickdiff.ReferenceProviderDescriptor; -import org.eclipse.ui.texteditor.IDocumentProvider; -import org.eclipse.ui.texteditor.ITextEditor; -import org.eclipse.ui.texteditor.ITextEditorExtension3; -import org.eclipse.ui.texteditor.IUpdate; - - -/** - * Action to set the quick diff reference for the document displayed in the editor. An instance of - * this class is created for every extension to the extension point <code>quickdiff.referenceprovider</code>, and for - * every editor. It acts as a proxy; its <code>run</code> method installs the reference provider - * specified by the extension with the quick diff differ on the current document. - * - * @since 3.0 - */ -public class ReferenceSelectionAction extends Action implements IUpdate { - - /** The editor we get the document from. */ - private ITextEditor fEditor= null; - /** The descriptor of the managed extension. */ - private final ReferenceProviderDescriptor fDescriptor; - /** The implementation of the extension, after it has been loaded. */ - private IQuickDiffReferenceProvider fProvider; - - /** - * Creates a new instance that will lazily create the implementation provided by the extension. - * - * @param descriptor describes the extension. - * @param editor the editor for which this action is created. - */ - public ReferenceSelectionAction(ReferenceProviderDescriptor descriptor, ITextEditor editor) { - super("", AS_RADIO_BUTTON); //$NON-NLS-1$ - setChecked(false); - setEnabled(true); - Assert.isLegal(descriptor != null); - fDescriptor= descriptor; - fEditor= editor; - update(); - } - - /** - * Creates an instance of the implementation provided by the extension, if none has been created - * before. Otherwise, the cached implementation is returned. - * @return The <code>IQuickDiffProviderImplementation</code> instance provided by the extension. - */ - private IQuickDiffReferenceProvider getProvider() { - if (fProvider == null) { - fProvider= fDescriptor.createProvider(); - } - return fProvider; - } - - /* - * @see org.eclipse.jface.action.IAction#run() - */ - public void run() { - - DocumentLineDiffer differ= getDiffer(true); // create if needed, so the user does not have to toggle display when he selects a reference - if (differ == null) - return; - - if (fEditor instanceof ITextEditorExtension3) { - ITextEditorExtension3 extension= (ITextEditorExtension3) fEditor; - IQuickDiffReferenceProvider provider= getProvider(); - if (provider != null) { - provider.setActiveEditor(fEditor); - if (provider.isEnabled()) { - differ.setReferenceProvider(provider); - extension.showChangeInformation(true); - setEnabled(true); - } else - setEnabled(false); - } - } - } - - /* - * @see org.eclipse.ui.texteditor.IUpdate#update() - */ - public void update() { - /* two things happen here: - * 1: checked state setting - if a provider is already installed, and its id matches - * our id, we are in checked state. - * 2: enablement - if the extending plugin has been loaded, we check the provider for - * enablement and take it as our own. - */ - setText(fDescriptor.getLabel()); - DocumentLineDiffer differ= getDiffer(false); // don't create it if we're not showing - setChecked(false); - if (differ != null) { - IQuickDiffReferenceProvider provider= differ.getReferenceProvider(); - if (provider != null && provider.getId().equals(fDescriptor.getId())) { - setChecked(true); - } - } - - if (fDescriptor.isPluginLoaded()) { - getProvider(); - if (fProvider == null) { - setEnabled(false); - } else { - fProvider.setActiveEditor(fEditor); - setEnabled(fProvider.isEnabled()); - } - } else { - // optimistically enable it - setEnabled(true); - } - } - - /** - * Fetches the differ installed with the current editor's document's annotation model. If none - * is installed yet, and <code>createIfNeeded</code> is true, one is created and attached to the - * model. - * - * @param createIfNeeded when set to <code>true</code>, a new differ will be created if needed. - * @return the differ installed with the annotation model, or <code>null</code>. - */ - private DocumentLineDiffer getDiffer(boolean createIfNeeded) { - // get annotation model - if (fEditor == null) - return null; - - IDocumentProvider provider= fEditor.getDocumentProvider(); - IEditorInput editorInput= fEditor.getEditorInput(); - if (provider == null || editorInput == null) - return null; - - IAnnotationModel m= provider.getAnnotationModel(editorInput); - IAnnotationModelExtension model= null; - if (m instanceof IAnnotationModelExtension) { - model= (IAnnotationModelExtension)m; - } else { - return null; - } - - // get differ - DocumentLineDiffer differ= (DocumentLineDiffer)model.getAnnotationModel(IChangeRulerColumn.QUICK_DIFF_MODEL_ID); - - // create if needed - if (differ == null && createIfNeeded) { - differ= new DocumentLineDiffer(); - model.addAnnotationModel(IChangeRulerColumn.QUICK_DIFF_MODEL_ID, differ); - } - - return differ; - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/RestoreAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/RestoreAction.java deleted file mode 100644 index 908e1a46c34..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/RestoreAction.java +++ /dev/null @@ -1,100 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.internal.texteditor.quickdiff; - - -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.source.ILineDiffInfo; -import org.eclipse.jface.text.source.ILineDiffer; -import org.eclipse.jface.text.source.IVerticalRulerInfo; - -import org.eclipse.ui.texteditor.ITextEditor; - -/** - * Action that will restore a block of deleted lines at the current caret position in an editor. - * - * @since 3.0 - */ -public class RestoreAction extends QuickDiffRestoreAction { - /** Resource key prefix. */ - private static final String PREFIX= "RestoreAction."; //$NON-NLS-1$ - /** Resource key for a single deleted line. */ - private static final String SINGLE_KEY= PREFIX + "label"; //$NON-NLS-1$ - /** Resource key for multiple deleted lines. */ - private static final String MULTIPLE_KEY= PREFIX + "multiple.label"; //$NON-NLS-1$ - - /** The line to be restored. Set in <code>update()</code>. */ - private int fLine; - - /** - * Creates a new instance. - * - * @param editor the editor this action belongs to - */ - public RestoreAction(ITextEditor editor) { - super(QuickDiffMessages.getResourceBundle(), PREFIX, editor); - } - - /* - * @see org.eclipse.ui.texteditor.IUpdate#update() - */ - public void update() { - super.update(); - - if (!isEnabled()) - return; - - setEnabled(false); - IVerticalRulerInfo ruler= getRuler(); - if (ruler == null) - return; - fLine= ruler.getLineOfLastMouseButtonActivity(); - ILineDiffer differ= getDiffer(); - if (differ == null) - return; - ILineDiffInfo info= differ.getLineInfo(fLine); - if (info != null && (info.getRemovedLinesAbove() > 0 || info.getRemovedLinesBelow() > 0)) { - if (info.getRemovedLinesBelow() == 0) { - fLine--; - } else if (info.getRemovedLinesAbove() != 0) { -// // if there are deleted lines above and below the line, take the closer one; -// int lineHeight= fCachedTextWidget.getLineHeight(); -// if (fMousePosition != null -// && fMousePosition.y % lineHeight <= lineHeight / 2) { -// fLine--; -// } - // take the one below for now TODO adjust to old viewer-dependent behaviour - } - info= differ.getLineInfo(fLine); - if (info.getRemovedLinesBelow() == 1) - setText(QuickDiffMessages.getString(SINGLE_KEY)); - else - setText(QuickDiffMessages.getFormattedString(MULTIPLE_KEY, String.valueOf(info.getRemovedLinesBelow()))); //$NON-NLS-1$ - setEnabled(true); - } - } - - /* - * @see org.eclipse.ui.internal.editors.quickdiff.QuickDiffRestoreAction#runCompoundChange() - */ - public void runCompoundChange() { - if (!isEnabled()) - return; - ILineDiffer differ= getDiffer(); - if (differ != null) { - try { - differ.restoreAfterLine(fLine); - } catch (BadLocationException e) { - setStatus(e.getMessage()); - } - } - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/RevertBlockAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/RevertBlockAction.java deleted file mode 100644 index b8e027d0404..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/RevertBlockAction.java +++ /dev/null @@ -1,91 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.internal.texteditor.quickdiff; - - -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.source.ILineDiffInfo; -import org.eclipse.jface.text.source.ILineDiffer; -import org.eclipse.jface.text.source.IVerticalRulerInfo; - -import org.eclipse.ui.texteditor.ITextEditor; - -/** - * Action that will revert a contiguous block of added, deleted and changes lines in the currently - * displayed document to the state in the reference document. - * - * @since 3.0 - */ -public class RevertBlockAction extends QuickDiffRestoreAction { - /** Resource key prefix. */ - private static final String PREFIX= "RevertBlockAction."; //$NON-NLS-1$ - - /** The line to be restored. Set in <code>update()</code>. */ - private int fLine; - - /** - * Creates a new instance. - * - * @param editor the editor this action belongs to - */ - public RevertBlockAction(ITextEditor editor) { - super(QuickDiffMessages.getResourceBundle(), PREFIX, editor); - } - - /* - * @see org.eclipse.ui.texteditor.IUpdate#update() - */ - public void update() { - super.update(); - - if (!isEnabled()) - return; - - setEnabled(false); - IVerticalRulerInfo ruler= getRuler(); - if (ruler == null) - return; - fLine= ruler.getLineOfLastMouseButtonActivity(); - ILineDiffer differ= getDiffer(); - if (differ == null) - return; - ILineDiffInfo info= differ.getLineInfo(fLine); - if (info != null && info.getChangeType() != ILineDiffInfo.UNCHANGED) { - boolean hasBlock= false; - if (fLine > 0) { - info= differ.getLineInfo(fLine - 1); - hasBlock= info != null && info.hasChanges(); - } - if (!hasBlock) { - info= differ.getLineInfo(fLine + 1); - hasBlock= info != null && info.hasChanges(); - } - if (hasBlock) - setEnabled(true); - } - } - - /* - * @see org.eclipse.ui.internal.editors.quickdiff.QuickDiffRestoreAction#runCompoundChange() - */ - public void runCompoundChange() { - if (!isEnabled()) - return; - ILineDiffer differ= getDiffer(); - if (differ != null) { - try { - differ.revertBlock(fLine); - } catch (BadLocationException e) { - setStatus(e.getMessage()); - } - } - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/RevertLineAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/RevertLineAction.java deleted file mode 100644 index 99498afae87..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/RevertLineAction.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.internal.texteditor.quickdiff; - - -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.source.ILineDiffInfo; -import org.eclipse.jface.text.source.ILineDiffer; -import org.eclipse.jface.text.source.IVerticalRulerInfo; - -import org.eclipse.ui.texteditor.ITextEditor; - -/** - * Action that will revert a line in the currently displayed document to the state in the - * reference document. - * - * @since 3.0 - */ -public class RevertLineAction extends QuickDiffRestoreAction { - /** Resource key prefix. */ - private static final String PREFIX= "RevertLineAction."; //$NON-NLS-1$ - /** Resource key for added lines - they will be deleted. */ - private static final String DELETE_KEY= PREFIX + "delete.label"; //$NON-NLS-1$ - /** Resource key for changed lines - they will be reverted. */ - private static final String REVERT_KEY= PREFIX + "label"; //$NON-NLS-1$ - - /** The line to be restored. Set in <code>update()</code>. */ - private int fLine; - - /** - * Creates a new instance. - * - * @param editor the editor this action belongs to - */ - public RevertLineAction(ITextEditor editor) { - super(QuickDiffMessages.getResourceBundle(), PREFIX, editor); - } - - /* - * @see org.eclipse.ui.texteditor.IUpdate#update() - */ - public void update() { - super.update(); - - if (!isEnabled()) - return; - - setEnabled(false); - IVerticalRulerInfo ruler= getRuler(); - if (ruler == null) - return; - fLine= ruler.getLineOfLastMouseButtonActivity(); - ILineDiffer differ= getDiffer(); - if (differ == null) - return; - ILineDiffInfo info= differ.getLineInfo(fLine); - if (info != null && info.getChangeType() != ILineDiffInfo.UNCHANGED) { - if (info.getChangeType() == ILineDiffInfo.ADDED) - setText(QuickDiffMessages.getString(DELETE_KEY)); - else - setText(QuickDiffMessages.getString(REVERT_KEY)); - setEnabled(true); - } - } - - /* - * @see org.eclipse.ui.internal.editors.quickdiff.QuickDiffRestoreAction#runCompoundChange() - */ - public void runCompoundChange() { - if (!isEnabled()) - return; - ILineDiffer differ= getDiffer(); - if (differ != null) { - try { - differ.revertLine(fLine); - } catch (BadLocationException e) { - setStatus(e.getMessage()); - } - } - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/RevertSelectionAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/RevertSelectionAction.java deleted file mode 100644 index 0f04bfc545e..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/RevertSelectionAction.java +++ /dev/null @@ -1,102 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.internal.texteditor.quickdiff; - - -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.ITextSelection; -import org.eclipse.jface.text.source.ILineDiffInfo; -import org.eclipse.jface.text.source.ILineDiffer; -import org.eclipse.jface.text.source.IVerticalRulerInfo; - -import org.eclipse.ui.texteditor.ITextEditor; - -/** - * Action that will revert the added, deleted and changes lines in the selection on the currently - * displayed document to the state in the reference document. - * - * @since 3.0 - */ -public class RevertSelectionAction extends QuickDiffRestoreAction { - /** The first line to be restored. Set in <code>update()</code>. */ - private int fStartLine; - /** The last line to be restored. Set in <code>update()</code>. */ - private int fEndLine; - - /** - * Creates a new instance. - * - * @param editor the editor this action belongs to - */ - public RevertSelectionAction(ITextEditor editor) { - super(QuickDiffMessages.getResourceBundle(), "RevertSelectionAction.", editor); //$NON-NLS-1$ - } - - /* - * @see org.eclipse.ui.texteditor.IUpdate#update() - */ - public void update() { - super.update(); - - if (!isEnabled()) - return; - - setEnabled(false); - - ITextSelection selection= getSelection(); - if (selection == null) - return; - fStartLine= selection.getStartLine(); - fEndLine= selection.getEndLine(); - - // only enable if mouse activity is inside line range - IVerticalRulerInfo ruler= getRuler(); - if (ruler == null) - return; - int activityLine= ruler.getLineOfLastMouseButtonActivity(); - if (activityLine < fStartLine || activityLine > fEndLine + 1) - // + 1 to cover the case where the selection goes to the offset of the next line - return; - - ILineDiffer differ= getDiffer(); - if (differ == null) - return; - - // only enable if selection covers at least two lines - if (fEndLine > fStartLine) { - for (int i= fStartLine; i <= fEndLine; i++) { - ILineDiffInfo info= differ.getLineInfo(i); - if (info != null && info.hasChanges()) { - setEnabled(true); - } - } - } - } - - /* - * @see org.eclipse.ui.internal.editors.quickdiff.QuickDiffRestoreAction#runCompoundChange() - */ - public void runCompoundChange() { - // recheck if run without being enabled - if (!isEnabled()) - return; - - ILineDiffer differ= getDiffer(); - if (differ != null) { - try { - differ.revertSelection(fStartLine, fEndLine - fStartLine + 1); - } catch (BadLocationException e) { - setStatus(e.getMessage()); - } - } - } - -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/DifferencesIterator.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/DifferencesIterator.java deleted file mode 100644 index cdcf9907b51..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/DifferencesIterator.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.internal.texteditor.quickdiff.compare.rangedifferencer; - -import java.util.ArrayList; -import java.util.List; - -/** - * A custom iterator to iterate over a List of <code>RangeDifferences</code>. - * It is used internally by the <code>RangeDifferencer</code>. - * - * @since 3.0 - */ -/* package */ class DifferencesIterator { - - List fRange; - int fIndex; - RangeDifference[] fArray; - RangeDifference fDifference; - - /** - * Creates a differences iterator on an array of <code>RangeDifference</code>s. - */ - DifferencesIterator(RangeDifference[] differenceRanges) { - - fArray= differenceRanges; - fIndex= 0; - fRange= new ArrayList(); - if (fIndex < fArray.length) - fDifference= fArray[fIndex++]; - else - fDifference= null; - } - - /** - * Returns the number of RangeDifferences - */ - int getCount() { - return fRange.size(); - } - - /** - * Appends the edit to its list and moves to the next <code>RangeDifference</code>. - */ - void next() { - fRange.add(fDifference); - if (fDifference != null) { - if (fIndex < fArray.length) - fDifference= fArray[fIndex++]; - else - fDifference= null; - } - } - - /** - * Difference iterators are used in pairs. - * This method returns the other iterator. - */ - DifferencesIterator other(DifferencesIterator right, DifferencesIterator left) { - if (this == right) - return left; - return right; - } - - /** - * Removes all <code>RangeDifference</code>s - */ - void removeAll() { - fRange.clear(); - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/DocLineComparator.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/DocLineComparator.java deleted file mode 100644 index 873409fc04a..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/DocLineComparator.java +++ /dev/null @@ -1,349 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.internal.texteditor.quickdiff.compare.rangedifferencer; - -import org.eclipse.jface.text.*; - -/** - * Implements the <code>IRangeComparator</code> interface for lines in a document. - * A <code>DocLineComparator</code> is used as the input for the <code>RangeDifferencer</code> - * engine to perform a line oriented compare on documents. - * <p> - * A <code>DocLineComparator</code> doesn't know anything about line separators because - * its notion of lines is solely defined in the underlying <code>IDocument</code>. - */ -public final class DocLineComparator implements IRangeComparator { - - /** - * Document based character sequence. - */ - public static class DocumentCharSequence implements CharSequence { - - /** Document */ - private IDocument fDocument; - - /** Offset */ - private int fOffset; - - /** Length */ - private int fLength; - - /** - * Leave uninitialized. The document, offset and length have to be set - * before use. - */ - public DocumentCharSequence() { - // do nothing - } - - /** - * Initialize with the sequence of characters in the given document - * starting at the given offset with the given length. - * - * @param document The document - * @param offset The offset - * @param length The length - */ - public DocumentCharSequence(IDocument document, int offset, int length) { - fDocument= document; - fOffset= offset; - fLength= length; - } - - /* - * @see java.lang.CharSequence#length() - */ - public int length() { - return fLength; - } - - /* - * @see java.lang.CharSequence#charAt(int) - */ - public char charAt(int index) { - try { - return fDocument.getChar(fOffset + index); - } catch (BadLocationException e) { - throw new IndexOutOfBoundsException(); - } - } - - /* - * @see java.lang.CharSequence#subSequence(int, int) - */ - public CharSequence subSequence(int start, int end) { - return new DocumentCharSequence(fDocument, start, end - start); - } - - - /* - * @see java.lang.Object#hashCode() - */ - public int hashCode() { - int hash= 0; - for (int i= 0, n= fLength; i < n; i++) - hash= 29*hash + charAt(i); - return hash; - } - - - /* - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equals(Object obj) { - if (obj == this) - return true; - if (!(obj instanceof DocumentCharSequence)) - return false; - DocumentCharSequence buffer= (DocumentCharSequence) obj; - int length= buffer.length(); - if (length != fLength) - return false; - for (int i= 0; i < length; i++) - if (buffer.charAt(i) != charAt(i)) - return false; - return true; - } - - /** - * Sets the document to the given. - * - * @param document the document to be set - */ - public void setDocument(IDocument document) { - fDocument= document; - } - - /** - * Sets the offset to the given value. - * - * @param offset the offset to be set - */ - public void setOffset(int offset) { - fOffset= offset; - } - - /** - * Sets the length to the given value. - * - * @param length the length to be set - */ - public void setLength(int length) { - fLength= length; - } - } - - private final IDocument fDocument; - private final int fLineOffset; - private final int fLineCount; - private final int fLength; - private final boolean fIgnoreWhiteSpace; - private final int fMaxOffset; - - - private boolean fSkip= false; - private int fLastOffset; - private int fLastLength; - - /** Cached document character sequence */ - private DocumentCharSequence fThisBuffer= new DocumentCharSequence(); - /** Cached document character sequence */ - private DocumentCharSequence fOtherBuffer= new DocumentCharSequence(); - - /** - * Creates a <code>DocLineComparator</code> for the given document range. - * ignoreWhiteSpace controls whether comparing lines (in method - * <code>rangesEqual<code>) should ignore whitespace. - * - * @param document the document from which the lines are taken - * @param region if non-<code>null</code> only lines within this range are taken - * @param ignoreWhiteSpace if <code>true</code> white space is ignored when comparing lines - */ - public DocLineComparator(IDocument document, IRegion region, boolean ignoreWhiteSpace) { - - fDocument= document; - fIgnoreWhiteSpace= ignoreWhiteSpace; - - if (region != null) { - fLength= region.getLength(); - int start= region.getOffset(); - int lineOffset= 0; - try { - lineOffset= fDocument.getLineOfOffset(start); - } catch (BadLocationException ex) { - } - fLineOffset= lineOffset; - - fMaxOffset= start + fLength; - - if (fLength == 0) - fLineCount= 0; - else { - int endLine= fDocument.getNumberOfLines(); - try { - endLine= fDocument.getLineOfOffset(start + fLength); - } catch (BadLocationException ex) { - } - fLineCount= endLine - fLineOffset + 1; - } - - } else { - fLineOffset= 0; - fLength= document.getLength(); - fLineCount= fDocument.getNumberOfLines(); - fMaxOffset= fDocument.getLength(); - } - } - - /** - * Returns the number of lines in the document. - * - * @return number of lines - */ - public int getRangeCount() { - return fLineCount; - } - - /** - * Computes the length of line <code>line</code>. - * - * @param line the line requested - * @return the line length or <code>0</code> if <code>line</code> is not a valid line in the document - */ - private int getLineLength(int line) { - if (line >= fLineCount) - return 0; - try { - int docLine= fLineOffset + line; - String delim= fDocument.getLineDelimiter(docLine); - int length= fDocument.getLineLength(docLine) - (delim == null ? 0 : delim.length()); - if (line == fLineCount - 1) { - fLastOffset= fDocument.getLineOffset(docLine); - fLastLength= Math.min(length, fMaxOffset - fLastOffset); - } else { - fLastOffset= -1; - fLastLength= length; - } - return fLastLength; - } catch (BadLocationException e) { - fLastOffset= 0; - fLastLength= 0; - fSkip= true; - return 0; - } - } - - /** - * Returns <code>true</code> if a line given by the first index - * matches a line specified by the other <code>IRangeComparator</code> and index. - * - * @param thisIndex the number of the line within this range comparator - * @param other the range comparator to compare this with - * @param otherIndex the number of the line within the other comparator - * @return <code>true</code> if the lines are equal - */ - public boolean rangesEqual(int thisIndex, IRangeComparator other, int otherIndex) { - - if (other != null && other.getClass() == getClass()) { - DocLineComparator dlc= (DocLineComparator) other; - - if (fIgnoreWhiteSpace) { - - extract(thisIndex, fThisBuffer); - dlc.extract(otherIndex, fOtherBuffer); - return compare(fThisBuffer, fOtherBuffer); - - } else { - - int tlen= getLineLength(thisIndex); - int olen= dlc.getLineLength(otherIndex); - if (tlen == olen) { - extract(thisIndex, fThisBuffer); - dlc.extract(otherIndex, fOtherBuffer); - return fThisBuffer.equals(fOtherBuffer); - } - } - } - return false; - } - - /** - * Aborts the comparison if the number of tokens is too large. - * - * @return <code>true</code> to abort a token comparison - */ - public boolean skipRangeComparison(int length, int max, IRangeComparator other) { - return fSkip; - } - - //---- private methods - - /** - * Extract a single line from the underlying document without the line separator - * into the given document based character sequence. - * - * @param line the number of the line to extract - * @param buffer the document based character sequence - */ - private void extract(int line, DocumentCharSequence buffer) { - if (line < fLineCount) { - try { - int docLine= fLineOffset + line; - if (fLastOffset == -1) - fLastOffset= fDocument.getLineOffset(docLine); - - buffer.setDocument(fDocument); - buffer.setOffset(fLastOffset); - buffer.setLength(fLastLength); - return; - } catch(BadLocationException e) { - fSkip= true; - } - } - buffer.setDocument(fDocument); - buffer.setOffset(0); - buffer.setLength(0); - } - - private boolean compare(CharSequence s1, CharSequence s2) { - int l1= s1.length(); - int l2= s2.length(); - int c1= 0, c2= 0; - int i1= 0, i2= 0; - - while (c1 != -1) { - - c1= -1; - while (i1 < l1) { - char c= s1.charAt(i1++); - if (! Character.isWhitespace(c)) { - c1= c; - break; - } - } - - c2= -1; - while (i2 < l2) { - char c= s2.charAt(i2++); - if (! Character.isWhitespace(c)) { - c2= c; - break; - } - } - - if (c1 != c2) - return false; - } - return true; - } - -} - diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/IRangeComparator.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/IRangeComparator.java deleted file mode 100644 index 49e2dbb9cdd..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/IRangeComparator.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.internal.texteditor.quickdiff.compare.rangedifferencer; - -/** - * For breaking an object to compare into a sequence of comparable entities. - * <p> - * It is used by <code>RangeDifferencer</code> to find longest sequences of - * matching and non-matching ranges. - * <p> - * For example, to compare two text documents and find longest common sequences - * of matching and non-matching lines, the implementation must break the document - * into lines. <code>getRangeCount</code> would return the number of lines in the - * document, and <code>rangesEqual</code> would compare a specified line given - * with one in another <code>IRangeComparator</code>. - * </p> - * <p> - * Clients should implement this interface; there is no standard implementation. - * </p> - * - * @since 3.0 - */ -public interface IRangeComparator { - - /** - * Returns the number of comparable entities. - * - * @return the number of comparable entities - */ - int getRangeCount(); - - /** - * Returns whether the comparable entity given by the first index - * matches an entity specified by the other <code>IRangeComparator</code> and index. - * - * @param thisIndex the index of the comparable entity within this <code>IRangeComparator</code> - * @param other the IRangeComparator to compare this with - * @param otherIndex the index of the comparable entity within the other <code>IRangeComparator</code> - * @return <code>true</code> if the comparable entities are equal - */ - boolean rangesEqual(int thisIndex, IRangeComparator other, int otherIndex); - - /** - * Returns whether a comparison should be skipped because it would be too costly (or lengthy). - * - * @param length a number on which to base the decision whether to return - * <code>true</code> or <code>false</code> - * @param maxLength another number on which to base the decision whether to return - * <code>true</code> or <code>false</code> - * @param other the other <code>IRangeComparator</code> to compare with - * @return <code>true</code> to avoid a too lengthy range comparison - */ - boolean skipRangeComparison(int length, int maxLength, IRangeComparator other); -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/ITokenComparator.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/ITokenComparator.java deleted file mode 100644 index cca23859c7e..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/ITokenComparator.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.ui.internal.texteditor.quickdiff.compare.rangedifferencer; - - - -/** - * For performing a so-called "token compare" on a line of text. - * This interface extends the <code>IRangeComparator</code> interface - * so that it can be used by the <code>TextMergeViewer</code>. - * <p> - * <code>TextMergeViewer</code> activates the token compare when navigating into - * a range of differing lines. At first the lines are selected as a block. - * When navigating into this block the token compare shows for every line - * the differing token by selecting them. - * <p> - * <code>TextMergeViewer</code>'s default token comparator works on characters separated - * by whitespace. If a different strategy is needed (for example, to use Java tokens in - * a Java-aware merge viewer), clients may create their own token - * comparators by implementing this interface (and overriding the - * <code>TextMergeViewer.createTokenComparator</code> factory method). - * </p> - * - * @see TextMergeViewer - * @since 3.0 - */ -public interface ITokenComparator extends IRangeComparator { - - /** - * Returns the start character position of the token with the given index. - * If the index is out of range (but not negative) the character position - * behind the last character (the length of the input string) is returned. - * - * @param index index of the token for which to return the start position - * @return the start position of the token with the given index - * @throws java.lang.IndexOutOfBoundsException if index is negative - */ - int getTokenStart(int index); - - /** - * Returns the character length of the token with the given index. - * If the index is out of range (but not negative) the value 0 is returned. - * - * @param index index of the token for which to return the start position - * @return the character length of the token with the given index - * @throws java.lang.IndexOutOfBoundsException if index is negative - */ - int getTokenLength(int index); -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/LinkedRangeDifference.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/LinkedRangeDifference.java deleted file mode 100644 index fba18456825..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/LinkedRangeDifference.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.ui.internal.texteditor.quickdiff.compare.rangedifferencer; - -/** - * @since 3.0 - */ -/* package */ class LinkedRangeDifference extends RangeDifference { - - static final int INSERT= 0; - static final int DELETE= 1; - - LinkedRangeDifference fNext; - - /** - * Creates a LinkedRangeDifference an initializes it to the error state - */ - LinkedRangeDifference() { - super(ERROR); - fNext= null; - } - - /** - * Constructs and links a LinkeRangeDifference to another LinkedRangeDifference - */ - LinkedRangeDifference(LinkedRangeDifference next, int operation) { - super(operation); - fNext= next; - } - - /** - * Follows the next link - */ - LinkedRangeDifference getNext() { - return fNext; - } - - boolean isDelete() { - return kind() == DELETE; - } - - boolean isInsert() { - return kind() == INSERT; - } - - /** - * Sets the next link of this LinkedRangeDifference - */ - void setNext(LinkedRangeDifference next) { - fNext= next; - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/LinkedRangeFactory.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/LinkedRangeFactory.java deleted file mode 100644 index 704d407ea4d..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/LinkedRangeFactory.java +++ /dev/null @@ -1,110 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.internal.texteditor.quickdiff.compare.rangedifferencer; - -/** - * Memory-monitoring factory for <code>LinkedRangeDifference</code>. - * - * @since 3.0 - */ -public class LinkedRangeFactory { - - /** - * Exception that is thrown after the minimal allowed free memory is reached. - */ - public static class LowMemoryException extends Exception { - - /** - * Initialize without detail message. - */ - public LowMemoryException() { - super(); - } - - /** - * Initialize with the given detail message. - * - * @param message the detail message - */ - public LowMemoryException(String message) { - super(message); - } - } - - /** - * Relative amount of memory that must be free in order to allow the creation of additional instances - */ - private static final double THRESHOLD= 0.1; - /** - * Number of instantiations after which the amount of free memory is checked - */ - private static final long CHECK_INTERVAL= 5000; - /** - * Considered maximal size of a difference object in bytes. - */ - private static final long OBJECT_SIZE= 100; - /** - * The maximal memory requirement for the next round in bytes. - */ - private static final long MAXIMAL_INTERVAL_REQUIREMENT= CHECK_INTERVAL * OBJECT_SIZE; - /** - * Allowed memory consumption in bytes. - */ - private static final long MAX_MEMORY_CONSUMPTION= 10 * 1024 * 1024; - /** - * The maximal number of instances. - */ - private static final long MAX_INSTANCES= MAX_MEMORY_CONSUMPTION / OBJECT_SIZE; - - - /** - * Preallocated low memory exception - */ - private LowMemoryException fLowMemoryException= new LowMemoryException(); - - /** - * Number of instantiations - */ - private long fCount= 0; - - /** - * Create a new linked range difference with the given next range and operation. - * - * @param next the next linked range difference - * @param operation the operation - * @return the new linked range difference - * @throws LowMemoryException - */ - public LinkedRangeDifference newRange(LinkedRangeDifference next, int operation) throws LowMemoryException { - check(); - return new LinkedRangeDifference(next, operation); - } - - /** - * After <code>CHECK_INTERVAL</code> calls check whether at least a fraction of <code>THRESHOLD</code> - * of the maximal available memory is free, otherwise throw an {@link LowMemoryException}. - * - * @throws LowMemoryException - */ - private void check() throws LowMemoryException { - if (fCount % CHECK_INTERVAL == 0) { - - Runtime runtime= Runtime.getRuntime(); - long maxMemory= runtime.maxMemory(); - long maxFreeMemory= maxMemory - (runtime.totalMemory() - runtime.freeMemory()); - - if (((float) (maxFreeMemory - MAXIMAL_INTERVAL_REQUIREMENT)) / maxMemory < THRESHOLD) - throw fLowMemoryException; - } - if (++fCount >= MAX_INSTANCES) - throw fLowMemoryException; - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/RangeDifference.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/RangeDifference.java deleted file mode 100644 index 6e84b0c8715..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/RangeDifference.java +++ /dev/null @@ -1,289 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.internal.texteditor.quickdiff.compare.rangedifferencer; - -import java.util.List; - -import org.eclipse.jface.text.Assert; -import org.eclipse.jface.text.IDocument; - -import org.eclipse.ui.internal.texteditor.quickdiff.DiffRegion; - -/** - * Description of a change between two or three ranges of comparable entities. - * <p> - * <code>RangeDifference</code> objects are the elements of a compare result returned from - * the <code>RangeDifferencer</code> <code>find* </code> methods. - * Clients use these objects as they are returned from the differencer. - * This class is not intended to be instantiated or subclassed. - * <p> - * Note: A range in the <code>RangeDifference</code> object is given as a start index - * and length in terms of comparable entities. However, these entity indices and counts - * are not necessarily character positions. For example, if an entity represents a line - * in a document, the start index would be a line number and the count would be in lines. - * </p> - * - * @see RangeDifferencer - * @since 3.0 - */ -public class RangeDifference { - - /** Two-way change constant indicating no change. */ - public final static int NOCHANGE= 0; - /** Two-way change constant indicating two-way change (same as <code>RIGHT</code>) */ - public final static int CHANGE= 2; - - /** Three-way change constant indicating a change in both right and left. */ - public final static int CONFLICT= 1; - /** Three-way change constant indicating a change in right. */ - public final static int RIGHT= 2; - /** Three-way change constant indicating a change in left. */ - public final static int LEFT= 3; - /** - * Three-way change constant indicating the same change in both right and left, - * that is only the ancestor is different. - */ - public final static int ANCESTOR= 4; - - /** Constant indicating an unknown change kind. */ - public final static int ERROR= 5; - - /** the kind of change: NOCHANGE, CHANGE, LEFT, RIGHT, ANCESTOR, CONFLICT, ERROR */ - int fKind; - - int fLeftStart; - int fLeftLength; - int fRightStart; - int fRightLength; - int lAncestorStart; - int lAncestorLength; - private DiffRegion fRegion; - - /** - * Creates a new range difference with the given change kind. - * - * @param changeKind the kind of change - */ - public RangeDifference(int changeKind) { - fKind= changeKind; - } - - /** - * Creates a new <code>RangeDifference</code> with the given change kind - * and left and right ranges. - * - * @param kind the kind of change - * @param rightStart start index of entity on right side - * @param rightLength number of entities on right side - * @param leftStart start index of entity on left side - * @param leftLength number of entities on left side - */ - public RangeDifference(int kind, int rightStart, int rightLength, int leftStart, int leftLength) { - fKind= kind; - fRightStart= rightStart; - fRightLength= rightLength; - fLeftStart= leftStart; - fLeftLength= leftLength; - } - - /** - * Creates a new <code>RangeDifference</code> with the given change kind - * and left, right, and ancestor ranges. - * - * @param kind the kind of change - * @param rightStart start index of entity on right side - * @param rightLength number of entities on right side - * @param leftStart start index of entity on left side - * @param leftLength number of entities on left side - * @param ancestorStart start index of entity on ancestor side - * @param ancestorLength number of entities on ancestor side - */ - public RangeDifference(int kind, int rightStart, int rightLength, int leftStart, int leftLength, - int ancestorStart, int ancestorLength) { - this(kind, rightStart, rightLength, leftStart, leftLength); - lAncestorStart= ancestorStart; - lAncestorLength= ancestorLength; - } - - /** - * Returns the kind of difference. - * - * @return the kind of difference, one of - * <code>NOCHANGE</code>, <code>CHANGE</code>, <code>LEFT</code>, <code>RIGHT</code>, - * <code>ANCESTOR</code>, <code>CONFLICT</code>, <code>ERROR</code> - */ - public int kind() { - return fKind; - } - - /** - * Returns the start index of the entity range on the ancestor side. - * - * @return the start index of the entity range on the ancestor side - */ - public int ancestorStart() { - return lAncestorStart; - } - - /** - * Returns the number of entities on the ancestor side. - * - * @return the number of entities on the ancestor side - */ - public int ancestorLength() { - return lAncestorLength; - } - - /** - * Returns the end index of the entity range on the ancestor side. - * - * @return the end index of the entity range on the ancestor side - */ - public int ancestorEnd() { - return lAncestorStart + lAncestorLength; - } - - /** - * Returns the start index of the entity range on the right side. - * - * @return the start index of the entity range on the right side - */ - public int rightStart() { - return fRightStart; - } - - /** - * Returns the number of entities on the right side. - * - * @return the number of entities on the right side - */ - public int rightLength() { - return fRightLength; - } - - /** - * Returns the end index of the entity range on the right side. - * - * @return the end index of the entity range on the right side - */ - public int rightEnd() { - return fRightStart + fRightLength; - } - - /** - * Returns the start index of the entity range on the left side. - * - * @return the start index of the entity range on the left side - */ - public int leftStart() { - return fLeftStart; - } - - /** - * Returns the number of entities on the left side. - * - * @return the number of entities on the left side - */ - public int leftLength() { - return fLeftLength; - } - - /** - * Returns the end index of the entity range on the left side. - * - * @return the end index of the entity range on the left side - */ - public int leftEnd() { - return fLeftStart + fLeftLength; - } - - /** - * Returns the maximum number of entities in the left, right, and ancestor sides of this range. - * - * @return the maximum number of entities in the left, right, and ancestor sides of this range - */ - public int maxLength() { - return Math.max(fRightLength, Math.max(fLeftLength, lAncestorLength)); - } - - /** - * Shifts the offset into the left document of the receiver. - * - * @param shift the number of elements to shift - */ - public void shiftLeft(int shift) { - Assert.isTrue(shift + fLeftStart >= 0); - fLeftStart += shift; - } - - /** - * Shifts the offset into the right document of the receiver. - * - * @param shift the number of elements to shift - */ - public void shiftRight(int shift) { - Assert.isTrue(shift + fRightStart >= 0); - fRightStart += shift; - } - - /** - * Resizes the receiver <code>shift</code> units, on both sides, by - * moving the start of the difference. - * - * @param shift the number of elements to shift - */ - public void extendStart(int shift) { - Assert.isTrue(shift + fRightStart >= 0); - Assert.isTrue(shift + fLeftStart >= 0); - fRightStart += shift; - fRightLength -= shift; - fLeftStart += shift; - fLeftLength -= shift; - } - - /** - * Resizes the receiver <code>shift</code> units, on both sides, by - * moving the end of the difference. - * - * @param shift the number of elements to shift - */ - public void extendEnd(int shift) { - Assert.isTrue(shift + fRightLength >= 0); - Assert.isTrue(shift + fLeftLength >= 0); - fRightLength += shift; - fLeftLength += shift; - } - - /* - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equals(Object obj) { - if (obj instanceof RangeDifference) { - RangeDifference d= (RangeDifference) obj; - return fKind == d.fKind && fRightStart == d.fRightStart && fRightLength == d.fRightLength && fLeftStart == d.fLeftStart && fLeftLength == d.fLeftLength; - } - return false; - } - - /** - * Returns the diff region corresponding to this range difference. - * - * @param differences the list of differences around this one difference - * @param source the original document (left document) that this difference refers to - * @return a <code>DiffRegion</code> corresponding to this difference - */ - public DiffRegion getDiffRegion(List differences, IDocument source) { - if (fRegion == null) - fRegion= new DiffRegion(this, 0, differences, source); - return fRegion; - } -} - diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/RangeDifferencer.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/RangeDifferencer.java deleted file mode 100644 index 6ca079c6e51..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/RangeDifferencer.java +++ /dev/null @@ -1,555 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.internal.texteditor.quickdiff.compare.rangedifferencer; - -import java.util.*; - -import org.eclipse.jface.util.Assert; - -import org.eclipse.ui.internal.texteditor.quickdiff.compare.rangedifferencer.LinkedRangeFactory.LowMemoryException; - -import org.eclipse.core.runtime.IProgressMonitor; - -/** - * A <code>RangeDifferencer</code> finds the differences between two or three <code>IRangeComparator</code>s. - * <p> - * To use the differencer, clients provide an <code>IRangeComparator</code> - * that breaks their input data into a sequence of comparable entities. The differencer - * returns the differences among these sequences as an array of <code>RangeDifference</code> objects - * (<code>findDifferences</code> methods). - * Every <code>RangeDifference</code> represents a single kind of difference - * and the corresponding ranges of the underlying comparable entities in the - * left, right, and optionally ancestor sides. - * <p> - * Alternatively, the <code>findRanges</code> methods not only return objects for - * the differing ranges but for non-differing ranges too. - * <p> - * The algorithm used is an objectified version of one described in: - * <it>A File Comparison Program,</it> by Webb Miller and Eugene W. Myers, - * Software Practice and Experience, Vol. 15, Nov. 1985. - * - * @see IRangeComparator - * @see RangeDifference - * @since 3.0 - */ -public final class RangeDifferencer { - - private static final RangeDifference[] EMPTY_RESULT= new RangeDifference[0]; - - /* (non Javadoc) - * Non instantiatiable! - */ - private RangeDifferencer() { - } - - /** - * Finds the differences between two <code>IRangeComparator</code>s. - * The differences are returned as an array of <code>RangeDifference</code>s. - * If no differences are detected an empty array is returned. - * - * @param left the left range comparator - * @param right the right range comparator - * @return an array of range differences, or an empty array if no differences were found - * @throws LowMemoryException if the differencer runs out of memory - */ - public static RangeDifference[] findDifferences(IRangeComparator left, IRangeComparator right) throws LowMemoryException { - return findDifferences((IProgressMonitor)null, left, right); - } - - /** - * Finds the differences between two <code>IRangeComparator</code>s. - * The differences are returned as an array of <code>RangeDifference</code>s. - * If no differences are detected an empty array is returned. - * - * @param pm if not <code>null</code> used to report progress - * @param left the left range comparator - * @param right the right range comparator - * @return an array of range differences, or an empty array if no differences were found - * @throws LowMemoryException if the differencer runs out of memory - * @since 2.0 - */ - public static RangeDifference[] findDifferences(IProgressMonitor pm, IRangeComparator left, IRangeComparator right) throws LowMemoryException { - - // assert that both IRangeComparators are of the same class - Assert.isTrue(right.getClass().equals(left.getClass())); - - int rightSize= right.getRangeCount(); - int leftSize= left.getRangeCount(); - // - // Differences matrix: - // only the last d of each diagonal is stored, i.e., lastDiagonal[k] = row of d - // - int diagLen= 2 * Math.max(rightSize, leftSize); // bound on the size of edit script - int maxDiagonal= diagLen; - int lastDiagonal[]= new int[diagLen + 1]; // the row containing the last d - // on diagonal k (lastDiagonal[k] = row) - int origin= diagLen / 2; // origin of diagonal 0 - - // script corresponding to d[k] - LinkedRangeDifference script[]= new LinkedRangeDifference[diagLen + 1]; - int row, col; - - // find common prefix - for (row= 0; row < rightSize && row < leftSize && rangesEqual(right, row, left, row) == true; ++row) { - // do nothing - } - - lastDiagonal[origin]= row; - script[origin]= null; - int lower= (row == rightSize) ? origin + 1 : origin - 1; - int upper= (row == leftSize) ? origin - 1 : origin + 1; - - if (lower > upper) - return EMPTY_RESULT; - - //System.out.println("findDifferences: " + maxDiagonal + " " + lower + " " + upper); - LinkedRangeFactory factory= new LinkedRangeFactory(); - - // for each value of the edit distance - for (int d= 1; d <= maxDiagonal; ++d) { // d is the current edit distance - - if (pm != null) - pm.worked(1); - - if (right.skipRangeComparison(d, maxDiagonal, left)) - return EMPTY_RESULT; // should be something we already found - - // for each relevant diagonal (-d, -d+2 ..., d-2, d) - for (int k= lower; k <= upper; k += 2) { // k is the current diagonal - LinkedRangeDifference edit; - - if (pm != null && pm.isCanceled()) - return EMPTY_RESULT; - - if (k == origin - d || k != origin + d && lastDiagonal[k + 1] >= lastDiagonal[k - 1]) { - // - // move down - // - row= lastDiagonal[k + 1] + 1; - edit= factory.newRange(script[k + 1], LinkedRangeDifference.DELETE); - } else { - // - // move right - // - row= lastDiagonal[k - 1]; - edit= factory.newRange(script[k - 1], LinkedRangeDifference.INSERT); - } - col= row + k - origin; - edit.fRightStart= row; - edit.fLeftStart= col; - Assert.isTrue(k >= 0 && k <= maxDiagonal); - script[k]= edit; - - // slide down the diagonal as far as possible - while (row < rightSize && col < leftSize && rangesEqual(right, row, left, col) == true) { - ++row; - ++col; - } - - Assert.isTrue(k >= 0 && k <= maxDiagonal); // Unreasonable value for diagonal index - lastDiagonal[k]= row; - - if (row == rightSize && col == leftSize) { - //showScript(script[k], right, left); - return createDifferencesRanges(script[k]); - } - if (row == rightSize) - lower= k + 2; - if (col == leftSize) - upper= k - 2; - } - --lower; - ++upper; - } - // too many differences - Assert.isTrue(false); - return null; - } - - /** - * Finds the differences among three <code>IRangeComparator</code>s. - * The differences are returned as a list of <code>RangeDifference</code>s. - * If no differences are detected an empty list is returned. - * If the ancestor range comparator is <code>null</code>, a two-way - * comparison is performed. - * - * @param ancestor the ancestor range comparator or <code>null</code> - * @param left the left range comparator - * @param right the right range comparator - * @return an array of range differences, or an empty array if no differences were found - * @throws LowMemoryException if the differencer runs out of memory - */ - public static RangeDifference[] findDifferences(IRangeComparator ancestor, IRangeComparator left, IRangeComparator right) throws LowMemoryException { - return findDifferences(null, ancestor, left, right); - } - - /** - * Finds the differences among three <code>IRangeComparator</code>s. - * The differences are returned as a list of <code>RangeDifference</code>s. - * If no differences are detected an empty list is returned. - * If the ancestor range comparator is <code>null</code>, a two-way - * comparison is performed. - * - * @param pm if not <code>null</code> used to report progress - * @param ancestor the ancestor range comparator or <code>null</code> - * @param left the left range comparator - * @param right the right range comparator - * @return an array of range differences, or an empty array if no differences were found - * @throws LowMemoryException if the differencer runs out of memory - * @since 2.0 - */ - public static RangeDifference[] findDifferences(IProgressMonitor pm, IRangeComparator ancestor, IRangeComparator left, IRangeComparator right) throws LowMemoryException { - - if (ancestor == null) - return findDifferences(pm, left, right); - - RangeDifference[] leftAncestorScript= null; - RangeDifference[] rightAncestorScript= findDifferences(pm, ancestor, right); - if (rightAncestorScript != null) - leftAncestorScript= findDifferences(pm, ancestor, left); - if (rightAncestorScript == null || leftAncestorScript == null) - return null; - - DifferencesIterator myIter= new DifferencesIterator(rightAncestorScript); - DifferencesIterator yourIter= new DifferencesIterator(leftAncestorScript); - - List diff3= new ArrayList(); - diff3.add(new RangeDifference(RangeDifference.ERROR)); // add a sentinel - - int changeRangeStart= 0; - int changeRangeEnd= 0; - // - // Combine the two two-way edit scripts into one - // - while (myIter.fDifference != null || yourIter.fDifference != null) { - - DifferencesIterator startThread; - myIter.removeAll(); - yourIter.removeAll(); - // - // take the next diff that is closer to the start - // - if (myIter.fDifference == null) - startThread= yourIter; - else if (yourIter.fDifference == null) - startThread= myIter; - else { // not at end of both scripts take the lowest range - if (myIter.fDifference.fLeftStart <= yourIter.fDifference.fLeftStart) // 2 -> common (Ancestor) change range - startThread= myIter; - else - startThread= yourIter; - } - changeRangeStart= startThread.fDifference.fLeftStart; - changeRangeEnd= startThread.fDifference.leftEnd(); - - startThread.next(); - // - // check for overlapping changes with other thread - // merge overlapping changes with this range - // - DifferencesIterator other= startThread.other(myIter, yourIter); - while (other.fDifference != null && other.fDifference.fLeftStart <= changeRangeEnd) { - int newMax= other.fDifference.leftEnd(); - other.next(); - if (newMax >= changeRangeEnd) { - changeRangeEnd= newMax; - other= other.other(myIter, yourIter); - } - } - diff3.add(createRangeDifference3(myIter, yourIter, diff3, right, left, changeRangeStart, changeRangeEnd)); - } - - // remove sentinel - diff3.remove(0); - return (RangeDifference[]) diff3.toArray(EMPTY_RESULT); - } - - /** - * Finds the differences among two <code>IRangeComparator</code>s. - * In contrast to <code>findDifferences</code>, the result - * contains <code>RangeDifference</code> elements for non-differing ranges too. - * - * @param left the left range comparator - * @param right the right range comparator - * @return an array of range differences - * @throws LowMemoryException if the differencer runs out of memory - */ - public static List findRanges(IRangeComparator left, IRangeComparator right) throws LowMemoryException { - return findRanges((IProgressMonitor)null, left, right); - } - - /** - * Finds the differences among two <code>IRangeComparator</code>s. - * In contrast to <code>findDifferences</code>, the result - * contains <code>RangeDifference</code> elements for non-differing ranges too. - * - * @param pm if not <code>null</code> used to report progress - * @param left the left range comparator - * @param right the right range comparator - * @return an array of range differences - * @throws LowMemoryException if the differencer runs out of memory - * @since 2.0 - */ - public static List findRanges(IProgressMonitor pm, IRangeComparator left, IRangeComparator right) throws LowMemoryException { - RangeDifference[] in= findDifferences(pm, left, right); - List out= new ArrayList(); - - RangeDifference rd; - - int mstart= 0; - int ystart= 0; - - for (int i= 0; i < in.length; i++) { - RangeDifference es= in[i]; - - rd= new RangeDifference(RangeDifference.NOCHANGE, mstart, es.rightStart() - mstart, ystart, es.leftStart() - ystart); - if (rd.maxLength() != 0) - out.add(rd); - - out.add(es); - - mstart= es.rightEnd(); - ystart= es.leftEnd(); - } - rd= new RangeDifference(RangeDifference.NOCHANGE, mstart, right.getRangeCount() - mstart, ystart, left.getRangeCount() - ystart); - if (rd.maxLength() > 0) - out.add(rd); - - return out; - } - - /** - * Finds the differences among three <code>IRangeComparator</code>s. - * In contrast to <code>findDifferences</code>, the result - * contains <code>RangeDifference</code> elements for non-differing ranges too. - * If the ancestor range comparator is <code>null</code>, a two-way - * comparison is performed. - * - * @param pm if not <code>null</code> used to report progress - * @param ancestor the ancestor range comparator or <code>null</code> - * @param left the left range comparator - * @param right the right range comparator - * @return an array of range differences - * @throws LowMemoryException if the differencer runs out of memory - */ - public static List findRanges(IRangeComparator ancestor, IRangeComparator left, IRangeComparator right) throws LowMemoryException { - return findRanges(null, ancestor, left, right); - } - - /** - * Finds the differences among three <code>IRangeComparator</code>s. - * In contrast to <code>findDifferences</code>, the result - * contains <code>RangeDifference</code> elements for non-differing ranges too. - * If the ancestor range comparator is <code>null</code>, a two-way - * comparison is performed. - * - * @param pm if not <code>null</code> used to report progress - * @param ancestor the ancestor range comparator or <code>null</code> - * @param left the left range comparator - * @param right the right range comparator - * @return an array of range differences - * @throws LowMemoryException if the differencer runs out of memory - * @since 2.0 - */ - public static List findRanges(IProgressMonitor pm, IRangeComparator ancestor, IRangeComparator left, IRangeComparator right) throws LowMemoryException { - - if (ancestor == null) - return findRanges(pm, left, right); - - RangeDifference[] in= findDifferences(pm, ancestor, left, right); - List out= new ArrayList(); - - RangeDifference rd; - - int mstart= 0; - int ystart= 0; - int astart= 0; - - for (int i= 0; i < in.length; i++) { - RangeDifference es= in[i]; - - rd= new RangeDifference(RangeDifference.NOCHANGE, mstart, es.rightStart() - mstart, ystart, es.leftStart() - ystart, astart, es.ancestorStart() - astart); - if (rd.maxLength() > 0) - out.add(rd); - - out.add(es); - - mstart= es.rightEnd(); - ystart= es.leftEnd(); - astart= es.ancestorEnd(); - } - rd= new RangeDifference(RangeDifference.NOCHANGE, mstart, right.getRangeCount() - mstart, ystart, left.getRangeCount() - ystart, astart, ancestor.getRangeCount() - astart); - if (rd.maxLength() > 0) - out.add(rd); - - return out; - } - - //---- private methods - - /** - * Creates a Vector of DifferencesRanges out of the LinkedRangeDifference. - * It coalesces adjacent changes. - * In addition, indices are changed such that the ranges are 1) open, i.e, - * the end of the range is not included, and 2) are zero based. - */ - private static RangeDifference[] createDifferencesRanges(LinkedRangeDifference start) { - - LinkedRangeDifference ep= reverseDifferences(start); - ArrayList result= new ArrayList(); - RangeDifference es= null; - - while (ep != null) { - es= new RangeDifference(RangeDifference.CHANGE); - - if (ep.isInsert()) { - es.fRightStart= ep.fRightStart + 1; - es.fLeftStart= ep.fLeftStart; - RangeDifference b= ep; - do { - ep= ep.getNext(); - es.fLeftLength++; - } while (ep != null && ep.isInsert() && ep.fRightStart == b.fRightStart); - } else { - es.fRightStart= ep.fRightStart; - es.fLeftStart= ep.fLeftStart; - - RangeDifference a= ep; - // - // deleted lines - // - do { - a= ep; - ep= ep.getNext(); - es.fRightLength++; - } while (ep != null && ep.isDelete() && ep.fRightStart == a.fRightStart + 1); - - boolean change= (ep != null && ep.isInsert() && ep.fRightStart == a.fRightStart); - - if (change) { - RangeDifference b= ep; - // - // replacement lines - // - do { - ep= ep.getNext(); - es.fLeftLength++; - } while (ep != null && ep.isInsert() && ep.fRightStart == b.fRightStart); - } else { - es.fLeftLength= 0; - } - es.fLeftStart++; // meaning of range changes from "insert after", to "replace with" - - } - // - // the script commands are 1 based, subtract one to make them zero based - // - es.fRightStart--; - es.fLeftStart--; - result.add(es); - } - return (RangeDifference[]) result.toArray(EMPTY_RESULT); - } - - /** - * Creates a <code>RangeDifference3</code> given the - * state of two DifferenceIterators. - */ - private static RangeDifference createRangeDifference3( - DifferencesIterator myIter, - DifferencesIterator yourIter, - List diff3, - IRangeComparator right, - IRangeComparator left, - int changeRangeStart, - int changeRangeEnd) { - - int rightStart, rightEnd; - int leftStart, leftEnd; - int kind= RangeDifference.ERROR; - RangeDifference last= (RangeDifference) diff3.get(diff3.size() - 1); - - Assert.isTrue((myIter.getCount() != 0 || yourIter.getCount() != 0)); // At least one range array must be non-empty - // - // find corresponding lines to fChangeRangeStart/End in right and left - // - if (myIter.getCount() == 0) { // only left changed - rightStart= changeRangeStart - last.ancestorEnd() + last.rightEnd(); - rightEnd= changeRangeEnd - last.ancestorEnd() + last.rightEnd(); - kind= RangeDifference.LEFT; - } else { - RangeDifference f= (RangeDifference) myIter.fRange.get(0); - RangeDifference l= (RangeDifference) myIter.fRange.get(myIter.fRange.size() - 1); - rightStart= changeRangeStart - f.fLeftStart + f.fRightStart; - rightEnd= changeRangeEnd - l.leftEnd() + l.rightEnd(); - } - - if (yourIter.getCount() == 0) { // only right changed - leftStart= changeRangeStart - last.ancestorEnd() + last.leftEnd(); - leftEnd= changeRangeEnd - last.ancestorEnd() + last.leftEnd(); - kind= RangeDifference.RIGHT; - } else { - RangeDifference f= (RangeDifference) yourIter.fRange.get(0); - RangeDifference l= (RangeDifference) yourIter.fRange.get(yourIter.fRange.size() - 1); - leftStart= changeRangeStart - f.fLeftStart + f.fRightStart; - leftEnd= changeRangeEnd - l.leftEnd() + l.rightEnd(); - } - - if (kind == RangeDifference.ERROR) { // overlapping change (conflict) -> compare the changed ranges - if (rangeSpansEqual(right, rightStart, rightEnd - rightStart, left, leftStart, leftEnd - leftStart)) - kind= RangeDifference.ANCESTOR; - else - kind= RangeDifference.CONFLICT; - } - return new RangeDifference(kind, rightStart, rightEnd - rightStart, leftStart, leftEnd - leftStart, changeRangeStart, changeRangeEnd - changeRangeStart); - } - - /** - * Tests if two ranges are equal - */ - private static boolean rangesEqual(IRangeComparator a, int ai, IRangeComparator b, int bi) { - return a.rangesEqual(ai, b, bi); - } - - /** - * Tests whether <code>right</code> and <code>left</left> changed in the same way - */ - private static boolean rangeSpansEqual(IRangeComparator right, int rightStart, int rightLen, IRangeComparator left, int leftStart, int leftLen) { - if (rightLen == leftLen) { - int i= 0; - for (i= 0; i < rightLen; i++) { - if (!rangesEqual(right, rightStart + i, left, leftStart + i)) - break; - } - if (i == rightLen) - return true; - } - return false; - } - - /** - * Reverses the range differences - */ - private static LinkedRangeDifference reverseDifferences(LinkedRangeDifference start) { - LinkedRangeDifference ep, behind, ahead; - - ahead= start; - ep= null; - while (ahead != null) { - behind= ep; - ep= ahead; - ahead= ahead.getNext(); - ep.setNext(behind); - } - return ep; - } -} - diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/package.html b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/package.html deleted file mode 100644 index 270a74d7b8d..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/package.html +++ /dev/null @@ -1,12 +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>QuickDiff Internal</title> -</head> -<body> -Copy of the respective classes in org.eclipse.compare.rangedifferencer in order to avoid circular dependencies. -</body> -</html> diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/package.html b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/package.html deleted file mode 100644 index 610f4b03deb..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/package.html +++ /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"> - <meta name="Author" content="IBM"> - <meta name="GENERATOR" content="Mozilla/4.51 [en] (WinNT; I) [Netscape]"> - <title>QuickDiff Internal</title> -</head> -<body> -Implementation for quick diff display, restore actions and the <code>org.eclipse.ui.editors.quickDiffReferenceProvider</code> -extension point. -</body> -</html> diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractDocumentProvider.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractDocumentProvider.java deleted file mode 100644 index d445026fd17..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractDocumentProvider.java +++ /dev/null @@ -1,1028 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.texteditor; - - -import java.lang.reflect.InvocationTargetException; -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.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.ISchedulingRule; - -import org.eclipse.jface.operation.IRunnableContext; -import org.eclipse.jface.operation.IRunnableWithProgress; - -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.source.IAnnotationModel; - -import org.eclipse.ui.internal.texteditor.TextEditorPlugin; - - - -/** - * An abstract implementation of a sharable document provider. - * <p> - * Subclasses must implement <code>createDocument</code>, - * <code>createAnnotationModel</code>, and <code>doSaveDocument</code>. - * </p> - */ -public abstract class AbstractDocumentProvider implements IDocumentProvider, IDocumentProviderExtension, IDocumentProviderExtension2, IDocumentProviderExtension3 { - - /** - * Operation created by the document provider and to be executed by the providers runnable context. - * - * @since 3.0 - */ - protected static abstract class DocumentProviderOperation implements IRunnableWithProgress { - - /** - * The actual functionality of this operation. - * - * @param monitor a progress monitor to track execution - * @throws CoreException - */ - protected abstract void execute(IProgressMonitor monitor) throws CoreException; - - /* - * @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor) - */ - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - execute(monitor); - } catch (CoreException x) { - throw new InvocationTargetException(x); - } - } - } - - /** - * Collection of all information managed for a connected element. - */ - protected class ElementInfo implements IDocumentListener { - - /** The element for which the info is stored */ - public Object fElement; - /** How often the element has been connected */ - public int fCount; - /** Can the element be saved */ - public boolean fCanBeSaved; - /** The element's document */ - public IDocument fDocument; - /** The element's annotation model */ - public IAnnotationModel fModel; - /** - * Has element state been validated - * @since 2.0 - */ - public boolean fIsStateValidated; - /** - * The status of this element - * @since 2.0 - */ - public IStatus fStatus; - - - /** - * Creates a new element info, initialized with the given - * document and annotation model. - * - * @param document the document - * @param model the annotation model - */ - public ElementInfo(IDocument document, IAnnotationModel model) { - fDocument= document; - fModel= model; - fCount= 0; - fCanBeSaved= false; - fIsStateValidated= false; - } - - /** - * An element info equals another object if this object is an element info - * and if the documents of the two element infos are equal. - * @see Object#equals(java.lang.Object) - */ - public boolean equals(Object o) { - if (o instanceof ElementInfo) { - ElementInfo e= (ElementInfo) o; - return fDocument.equals(e.fDocument); - } - return false; - } - - /* - * @see Object#hashCode() - */ - public int hashCode() { - return fDocument.hashCode(); - } - - /* - * @see IDocumentListener#documentChanged(DocumentEvent) - */ - public void documentChanged(DocumentEvent event) { - fCanBeSaved= true; - removeUnchangedElementListeners(fElement, this); - fireElementDirtyStateChanged(fElement, fCanBeSaved); - } - - /* - * @see IDocumentListener#documentAboutToBeChanged(DocumentEvent) - */ - public void documentAboutToBeChanged(DocumentEvent event) { - } - } - - - /** - * Enables a certain behavior. - * Indicates whether this provider should behave as described in - * use case 5 of http://bugs.eclipse.org/bugs/show_bug.cgi?id=10806. - * Current value: <code>true</code> since 3.0 - * @since 2.0 - */ - static final protected boolean PR10806_UC5_ENABLED= true; - - /** - * Enables a certain behavior. - * Indicates whether this provider should behave as described in - * http://bugs.eclipse.org/bugs/show_bug.cgi?id=14469 - * Notes: This contradicts <code>PR10806_UC5_ENABLED</code>. - * Current value: <code>false</code> since 3.0 - * @since 2.0 - */ - static final protected boolean PR14469_ENABLED= false; - - /** - * Constant for representing the OK status. This is considered a value object. - * @since 2.0 - */ - static final protected IStatus STATUS_OK= new Status(IStatus.OK, TextEditorPlugin.PLUGIN_ID, IStatus.OK, EditorMessages.getString("AbstractDocumentProvider.ok"), null); //$NON-NLS-1$ - - /** - * Constant for representing the error status. This is considered a value object. - * @since 2.0 - */ - static final protected IStatus STATUS_ERROR= new Status(IStatus.ERROR, TextEditorPlugin.PLUGIN_ID, IStatus.INFO, EditorMessages.getString("AbstractDocumentProvider.error"), null); //$NON-NLS-1$ - - - /** Element information of all connected elements */ - private Map fElementInfoMap= new HashMap(); - /** The element state listeners */ - private List fElementStateListeners= new ArrayList(); - /** - * The current progress monitor - * @since 2.1 - */ - private IProgressMonitor fProgressMonitor; - - - /** - * Creates a new document provider. - */ - protected AbstractDocumentProvider() { - } - - /** - * Creates the document for the given element. - * <p> - * Subclasses must implement this method.</p> - * - * @param element the element - * @return the document - * @exception CoreException if the document could not be created - */ - protected abstract IDocument createDocument(Object element) throws CoreException; - - /** - * Creates an annotation model for the given element. - * <p> - * Subclasses must implement this method.</p> - * - * @param element the element - * @return the annotation model - * @exception CoreException if the annotation model could not be created - */ - protected abstract IAnnotationModel createAnnotationModel(Object element) throws CoreException; - - /** - * Performs the actual work of saving the given document provided for the - * given element. - * <p> - * Subclasses must implement this method.</p> - * - * @param monitor a progress monitor to report progress and request cancellation - * @param element the element - * @param document the document - * @param overwrite indicates whether an overwrite should happen if necessary - * @exception CoreException if document could not be stored to the given element - */ - protected abstract void doSaveDocument(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite) throws CoreException; - - /** - * Returns the runnable context for this document provider. - * - * @param monitor a progress monitor to track the operation - * @return the runnable context for this document provider - * @since 3.0 - */ - protected abstract IRunnableContext getOperationRunner(IProgressMonitor monitor); - - /** - * Returns the scheduling rule required for executing - * <code>synchronize</code> on the given element. This default - * implementation returns <code>null</code>. - * - * @param element the element - * @return the scheduling rule for <code>synchronize</code> - * @since 3.0 - */ - protected ISchedulingRule getSynchronizeRule(Object element) { - return null; - } - - /** - * Returns the scheduling rule required for executing - * <code>validateState</code> on the given element. This default - * implementation returns <code>null</code>. - * - * @param element the element - * @return the scheduling rule for <code>validateState</code> - * @since 3.0 - */ - protected ISchedulingRule getValidateStateRule(Object element) { - return null; - } - - /** - * Returns the scheduling rule required for executing - * <code>save</code> on the given element. This default - * implementation returns <code>null</code>. - * - * @param element the element - * @return the scheduling rule for <code>save</code> - * @since 3.0 - */ - protected ISchedulingRule getSaveRule(Object element) { - return null; - } - - /** - * Returns the scheduling rule required for executing - * <code>reset</code> on the given element. This default - * implementation returns <code>null</code>. - * - * @param element the element - * @return the scheduling rule for <code>reset</code> - * @since 3.0 - */ - protected ISchedulingRule getResetRule(Object element) { - return null; - } - - /** - * Returns the element info object for the given element. - * - * @param element the element - * @return the element info object, or <code>null</code> if none - */ - protected ElementInfo getElementInfo(Object element) { - return (ElementInfo) fElementInfoMap.get(element); - } - - /** - * Creates a new element info object for the given element. - * <p> - * This method is called from <code>connect</code> when an element info needs - * to be created. The <code>AbstractDocumentProvider</code> implementation - * of this method returns a new element info object whose document and - * annotation model are the values of <code>createDocument(element)</code> - * and <code>createAnnotationModel(element)</code>, respectively. Subclasses - * may override.</p> - * - * @param element the element - * @return a new element info object - * @exception CoreException if the document or annotation model could not be created - */ - protected ElementInfo createElementInfo(Object element) throws CoreException { - return new ElementInfo(createDocument(element), createAnnotationModel(element)); - } - - /** - * Disposes of the given element info object. - * <p> - * This method is called when an element info is disposed. The - * <code>AbstractDocumentProvider</code> implementation of this - * method does nothing. Subclasses may reimplement.</p> - * - * @param element the element - * @param info the element info object - */ - protected void disposeElementInfo(Object element, ElementInfo info) { - } - - /** - * Called on initial creation and when the dirty state of the element - * changes to <code>false</code>. Adds all listeners which must be - * active as long as the element is not dirty. This method is called - * before <code>fireElementDirtyStateChanged</code> or <code> - * fireElementContentReplaced</code> is called. - * Subclasses may extend. - * - * @param element the element - * @param info the element info object - */ - protected void addUnchangedElementListeners(Object element, ElementInfo info) { - if (info.fDocument != null) - info.fDocument.addDocumentListener(info); - } - - /** - * Called when the given element gets dirty. Removes all listeners - * which must be active only when the element is not dirty. This - * method is called before <code>fireElementDirtyStateChanged</code> - * or <code>fireElementContentReplaced</code> is called. - * Subclasses may extend. - * - * @param element the element - * @param info the element info object - */ - protected void removeUnchangedElementListeners(Object element, ElementInfo info) { - if (info.fDocument != null) - info.fDocument.removeDocumentListener(info); - } - - /** - * Enumerates the elements connected via this document provider. - * - * @return the list of elements (element type: <code>Object</code>) - */ - protected Iterator getConnectedElements() { - Set s= new HashSet(); - Set keys= fElementInfoMap.keySet(); - if (keys != null) - s.addAll(keys); - return s.iterator(); - } - - /* - * @see IDocumentProvider#connect(Object) - */ - public final void connect(Object element) throws CoreException { - ElementInfo info= (ElementInfo) fElementInfoMap.get(element); - if (info == null) { - - info= createElementInfo(element); - if (info == null) - info= new ElementInfo(null, null); - - info.fElement= element; - - addUnchangedElementListeners(element, info); - - fElementInfoMap.put(element, info); - if (fElementInfoMap.size() == 1) - connected(); - } - ++ info.fCount; - } - - /** - * This hook method is called when this provider starts managing documents for - * elements. I.e. it is called when the first element gets connected to this provider. - * Subclasses may extend. - * @since 2.0 - */ - protected void connected() { - } - - /* - * @see IDocumentProvider#disconnect - */ - public final void disconnect(Object element) { - ElementInfo info= (ElementInfo) fElementInfoMap.get(element); - - if (info == null) - return; - - if (info.fCount == 1) { - - fElementInfoMap.remove(element); - removeUnchangedElementListeners(element, info); - disposeElementInfo(element, info); - - if (fElementInfoMap.size() == 0) - disconnected(); - - } else - -- info.fCount; - } - - /** - * This hook method is called when this provider stops managing documents for - * element. I.e. it is called when the last element gets disconnected from this provider. - * Subclasses may extend. - * @since 2.0 - */ - protected void disconnected() { - } - - /* - * @see IDocumentProvider#getDocument(Object) - */ - public IDocument getDocument(Object element) { - - if (element == null) - return null; - - ElementInfo info= (ElementInfo) fElementInfoMap.get(element); - return (info != null ? info.fDocument : null); - } - - /* - * @see IDocumentProvider#mustSaveDocument(Object) - */ - public boolean mustSaveDocument(Object element) { - - if (element == null) - return false; - - ElementInfo info= (ElementInfo) fElementInfoMap.get(element); - return (info != null ? info.fCount == 1 && info.fCanBeSaved : false); - } - - /* - * @see IDocumentProvider#getAnnotationModel(Object) - */ - public IAnnotationModel getAnnotationModel(Object element) { - - if (element == null) - return null; - - ElementInfo info= (ElementInfo) fElementInfoMap.get(element); - return (info != null ? info.fModel : null); - } - - /* - * @see IDocumentProvider#canSaveDocument(Object) - */ - public boolean canSaveDocument(Object element) { - - if (element == null) - return false; - - ElementInfo info= (ElementInfo) fElementInfoMap.get(element); - return (info != null ? info.fCanBeSaved : false); - } - - /** - * Executes the actual work of reseting the given elements document. - * - * @param element the element - * @param monitor the progress monitor - * @throws CoreException - * @since 3.0 - */ - protected void doResetDocument(Object element, IProgressMonitor monitor) throws CoreException { - ElementInfo info= (ElementInfo) fElementInfoMap.get(element); - if (info != null) { - - IDocument original= null; - IStatus status= null; - - try { - original= createDocument(element); - } catch (CoreException x) { - status= x.getStatus(); - } - - info.fStatus= status; - - if (original != null) { - fireElementContentAboutToBeReplaced(element); - info.fDocument.set(original.get()); - if (info.fCanBeSaved) { - info.fCanBeSaved= false; - addUnchangedElementListeners(element, info); - } - fireElementContentReplaced(element); - fireElementDirtyStateChanged(element, false); - } - } - } - - /** - * Executes the given operation in the providers runnable context. - * - * @param operation the operation to be executes - * @param monitor the progress monitor - * @exception CoreException the operation's core exception - * @since 3.0 - */ - protected void executeOperation(DocumentProviderOperation operation, IProgressMonitor monitor) throws CoreException { - try { - IRunnableContext runner= getOperationRunner(monitor); - if (runner != null) - runner.run(false, false, operation); - else - operation.run(monitor); - } catch (InvocationTargetException x) { - Throwable e= x.getTargetException(); - if (e instanceof CoreException) - throw (CoreException) e; - String message= (e.getMessage() != null ? e.getMessage() : ""); //$NON-NLS-1$ - throw new CoreException(new Status(IStatus.ERROR, TextEditorPlugin.PLUGIN_ID, IStatus.ERROR, message, e)); - } catch (InterruptedException x) { - String message= (x.getMessage() != null ? x.getMessage() : ""); //$NON-NLS-1$ - throw new CoreException(new Status(IStatus.CANCEL, TextEditorPlugin.PLUGIN_ID, IStatus.OK, message, x)); - } - } - - /* - * @see IDocumentProvider#resetDocument(Object) - */ - public final void resetDocument(final Object element) throws CoreException { - - if (element == null) - return; - - class ResetOperation extends DocumentProviderOperation implements ISchedulingRuleProvider { - - protected void execute(IProgressMonitor monitor) throws CoreException { - doResetDocument(element, monitor); - } - - public ISchedulingRule getSchedulingRule() { - return getResetRule(element); - } - } - - executeOperation(new ResetOperation(), getProgressMonitor()); - } - - - /* - * @see IDocumentProvider#saveDocument(IProgressMonitor, Object, IDocument, boolean) - */ - public final void saveDocument(IProgressMonitor monitor, final Object element, final IDocument document, final boolean overwrite) throws CoreException { - - if (element == null) - return; - - class SaveOperation extends DocumentProviderOperation implements ISchedulingRuleProvider { - - /* - * @see org.eclipse.ui.texteditor.AbstractDocumentProvider.DocumentProviderOperation#execute(org.eclipse.core.runtime.IProgressMonitor) - */ - protected void execute(IProgressMonitor pm) throws CoreException { - ElementInfo info= (ElementInfo) fElementInfoMap.get(element); - if (info != null) { - if (info.fDocument != document) { - Status status= new Status(IStatus.WARNING, TextEditorPlugin.PLUGIN_ID, IStatus.ERROR, EditorMessages.getString("AbstractDocumentProvider.error.save.inuse"), null); //$NON-NLS-1$ - throw new CoreException(status); - } - - doSaveDocument(pm, element, document, overwrite); - - if (pm != null && pm.isCanceled()) - return; - - info.fCanBeSaved= false; - addUnchangedElementListeners(element, info); - fireElementDirtyStateChanged(element, false); - - } else { - doSaveDocument(pm, element, document, overwrite); - } - } - - public ISchedulingRule getSchedulingRule() { - return getSaveRule(element); - } - } - - executeOperation(new SaveOperation(), monitor); - } - - /** - * The <code>AbstractDocumentProvider</code> implementation of this - * <code>IDocumentProvider</code> method does nothing. Subclasses may - * reimplement. - * - * @param element the element - */ - public void aboutToChange(Object element) { - } - - /** - * The <code>AbstractDocumentProvider</code> implementation of this - * <code>IDocumentProvider</code> method does nothing. Subclasses may - * reimplement. - * - * @param element the element - */ - public void changed(Object element) { - } - - /* - * @see IDocumentProvider#addElementStateListener(IElementStateListener) - */ - public void addElementStateListener(IElementStateListener listener) { - Assert.isNotNull(listener); - if (!fElementStateListeners.contains(listener)) - fElementStateListeners.add(listener); - } - - /* - * @see IDocumentProvider#removeElementStateListener(IElementStateListener) - */ - public void removeElementStateListener(IElementStateListener listener) { - Assert.isNotNull(listener); - fElementStateListeners.remove(listener); - } - - /** - * Informs all registered element state listeners about a change in the - * dirty state of the given element. - * - * @param element the element - * @param isDirty the new dirty state - * @see IElementStateListener#elementDirtyStateChanged(Object, boolean) - */ - protected void fireElementDirtyStateChanged(Object element, boolean isDirty) { - Iterator e= new ArrayList(fElementStateListeners).iterator(); - while (e.hasNext()) { - IElementStateListener l= (IElementStateListener) e.next(); - l.elementDirtyStateChanged(element, isDirty); - } - } - - /** - * Informs all registered element state listeners about an impending - * replace of the given element's content. - * - * @param element the element - * @see IElementStateListener#elementContentAboutToBeReplaced(Object) - */ - protected void fireElementContentAboutToBeReplaced(Object element) { - Iterator e= new ArrayList(fElementStateListeners).iterator(); - while (e.hasNext()) { - IElementStateListener l= (IElementStateListener) e.next(); - l.elementContentAboutToBeReplaced(element); - } - } - - /** - * Informs all registered element state listeners about the just-completed - * replace of the given element's content. - * - * @param element the element - * @see IElementStateListener#elementContentReplaced(Object) - */ - protected void fireElementContentReplaced(Object element) { - Iterator e= new ArrayList(fElementStateListeners).iterator(); - while (e.hasNext()) { - IElementStateListener l= (IElementStateListener) e.next(); - l.elementContentReplaced(element); - } - } - - /** - * Informs all registered element state listeners about the deletion - * of the given element. - * - * @param element the element - * @see IElementStateListener#elementDeleted(Object) - */ - protected void fireElementDeleted(Object element) { - Iterator e= new ArrayList(fElementStateListeners).iterator(); - while (e.hasNext()) { - IElementStateListener l= (IElementStateListener) e.next(); - l.elementDeleted(element); - } - } - - /** - * Informs all registered element state listeners about a move. - * - * @param originalElement the element before the move - * @param movedElement the element after the move - * @see IElementStateListener#elementMoved(Object, Object) - */ - protected void fireElementMoved(Object originalElement, Object movedElement) { - Iterator e= new ArrayList(fElementStateListeners).iterator(); - while (e.hasNext()) { - IElementStateListener l= (IElementStateListener) e.next(); - l.elementMoved(originalElement, movedElement); - } - } - - /* - * @see IDocumentProvider#getModificationStamp(Object) - * @since 2.0 - */ - public long getModificationStamp(Object element) { - return 0; - } - - /* - * @see IDocumentProvider#getSynchronizationStamp(Object) - * @since 2.0 - */ - public long getSynchronizationStamp(Object element) { - return 0; - } - - /* - * @see IDocumentProvider#isDeleted(Object) - * @since 2.0 - */ - public boolean isDeleted(Object element) { - return false; - } - - /* - * @see IDocumentProviderExtension#isReadOnly(Object) - * @since 2.0 - */ - public boolean isReadOnly(Object element) { - return true; - } - - /* - * @see IDocumentProviderExtension#isModifiable(Object) - * @since 2.0 - */ - public boolean isModifiable(Object element) { - return false; - } - - /** - * Returns whether <code>validateState</code> has been called for the given element - * since the element's state has potentially been invalidated. - * - * @param element the element - * @return whether <code>validateState</code> has been called for the given element - * @since 2.0 - */ - public boolean isStateValidated(Object element) { - ElementInfo info= (ElementInfo) fElementInfoMap.get(element); - if (info != null) - return info.fIsStateValidated; - return false; - } - - /** - * Hook method for validating the state of the given element. Must not take care of cache updating etc. - * Default implementation is empty. - * - * @param element the element - * @param computationContext the context in which validation happens - * @exception CoreException in case validation fails - * @since 2.0 - */ - protected void doValidateState(Object element, Object computationContext) throws CoreException { - } - - /* - * @see IDocumentProviderExtension#validateState(Object, Object) - * @since 2.0 - */ - public void validateState(final Object element, final Object computationContext) throws CoreException { - if (element == null) - return; - - class ValidateStateOperation extends DocumentProviderOperation implements ISchedulingRuleProvider { - - protected void execute(IProgressMonitor monitor) throws CoreException { - ElementInfo info= (ElementInfo) fElementInfoMap.get(element); - if (info == null) - return; - - doValidateState(element, computationContext); - - doUpdateStateCache(element); - info.fIsStateValidated= true; - fireElementStateValidationChanged(element, true); - } - - public ISchedulingRule getSchedulingRule() { - return getValidateStateRule(element); - } - } - - executeOperation(new ValidateStateOperation(), getProgressMonitor()); - } - - /** - * Hook method for updating the state of the given element. - * Default implementation is empty. - * - * @param element the element - * @exception CoreException in case state cache updating fails - * @since 2.0 - */ - protected void doUpdateStateCache(Object element) throws CoreException { - } - - /** - * Returns whether the state of the element must be invalidated given its - * previous read-only state. - * - * @param element the element - * @param wasReadOnly the previous read-only state - * @return <code>true</code> if the state of the given element must be invalidated - * @since 2.0 - */ - protected boolean invalidatesState(Object element, boolean wasReadOnly) { - Assert.isTrue(PR10806_UC5_ENABLED != PR14469_ENABLED); - boolean readOnlyChanged= (isReadOnly(element) != wasReadOnly && !wasReadOnly); - if (PR14469_ENABLED) - return readOnlyChanged && !canSaveDocument(element); - return readOnlyChanged; - } - - /* - * @see IDocumentProviderExtension#updateStateCache(Object) - * @since 2.0 - */ - final public void updateStateCache(Object element) throws CoreException { - ElementInfo info= (ElementInfo) fElementInfoMap.get(element); - if (info != null) { - boolean wasReadOnly= isReadOnly(element); - doUpdateStateCache(element); - if (invalidatesState(element, wasReadOnly)) { - info.fIsStateValidated= false; - fireElementStateValidationChanged(element, false); - } - } - } - - /* - * @see IDocumentProviderExtension#setCanSaveDocument(Object) - * @since 2.0 - */ - public void setCanSaveDocument(Object element) { - if (element != null) { - ElementInfo info= (ElementInfo) fElementInfoMap.get(element); - if (info != null) { - info.fCanBeSaved= true; - removeUnchangedElementListeners(element, info); - fireElementDirtyStateChanged(element, info.fCanBeSaved); - } - } - } - - /** - * Informs all registered element state listeners about a change in the - * state validation of the given element. - * - * @param element the element - * @param isStateValidated - * @see IElementStateListenerExtension#elementStateValidationChanged(Object, boolean) - * @since 2.0 - */ - protected void fireElementStateValidationChanged(Object element, boolean isStateValidated) { - Iterator e= new ArrayList(fElementStateListeners).iterator(); - while (e.hasNext()) { - Object o= e.next(); - if (o instanceof IElementStateListenerExtension) { - IElementStateListenerExtension l= (IElementStateListenerExtension) o; - l.elementStateValidationChanged(element, isStateValidated); - } - } - } - - /** - * Informs all registered element state listeners about the current state - * change of the element - * - * @param element the element - * @see IElementStateListenerExtension#elementStateChanging(Object) - * @since 2.0 - */ - protected void fireElementStateChanging(Object element) { - Iterator e= new ArrayList(fElementStateListeners).iterator(); - while (e.hasNext()) { - Object o= e.next(); - if (o instanceof IElementStateListenerExtension) { - IElementStateListenerExtension l= (IElementStateListenerExtension) o; - l.elementStateChanging(element); - } - } - } - - /** - * Informs all registered element state listeners about the failed - * state change of the element - * - * @param element the element - * @see IElementStateListenerExtension#elementStateChangeFailed(Object) - * @since 2.0 - */ - protected void fireElementStateChangeFailed(Object element) { - Iterator e= new ArrayList(fElementStateListeners).iterator(); - while (e.hasNext()) { - Object o= e.next(); - if (o instanceof IElementStateListenerExtension) { - IElementStateListenerExtension l= (IElementStateListenerExtension) o; - l.elementStateChangeFailed(element); - } - } - } - - /* - * @see IDocumentProviderExtension#getStatus(Object) - * @since 2.0 - */ - public IStatus getStatus(Object element) { - ElementInfo info= (ElementInfo) fElementInfoMap.get(element); - if (info != null) { - if (info.fStatus != null) - return info.fStatus; - return (info.fDocument == null ? STATUS_ERROR : STATUS_OK); - } - - return STATUS_ERROR; - } - - /** - * Performs the actual work of synchronizing the given element. - * - * @param element the element - * @param monitor the progress monitor - * @exception CoreException in the case that synchronization fails - * @since 3.0 - */ - protected void doSynchronize(Object element, IProgressMonitor monitor) throws CoreException { - } - - /* - * @see org.eclipse.ui.texteditor.IDocumentProviderExtension#synchronize(Object) - * @since 2.0 - */ - public final void synchronize(final Object element) throws CoreException { - - if (element == null) - return; - - class SynchronizeOperation extends DocumentProviderOperation implements ISchedulingRuleProvider { - - protected void execute(IProgressMonitor monitor) throws CoreException { - doSynchronize(element, monitor); - } - - public ISchedulingRule getSchedulingRule() { - return getSynchronizeRule(element); - } - } - - executeOperation(new SynchronizeOperation(), getProgressMonitor()); - } - - /* - * @see org.eclipse.ui.texteditor.IDocumentProviderExtension2#getProgressMonitor() - * @since 2.1 - */ - public IProgressMonitor getProgressMonitor() { - return fProgressMonitor == null ? new NullProgressMonitor() : fProgressMonitor; - } - - /* - * @see org.eclipse.ui.texteditor.IDocumentProviderExtension2#setProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) - * @since 2.1 - */ - public void setProgressMonitor(IProgressMonitor progressMonitor) { - fProgressMonitor= progressMonitor; - } - - /* - * @see org.eclipse.ui.texteditor.IDocumentProviderExtension3#isSynchronized(java.lang.Object) - * @since 3.0 - */ - public boolean isSynchronized(Object element) { - return true; - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractRulerActionDelegate.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractRulerActionDelegate.java deleted file mode 100644 index f720363ed2d..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractRulerActionDelegate.java +++ /dev/null @@ -1,147 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.ui.texteditor; - - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.action.IMenuListener; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.text.source.IVerticalRulerInfo; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.events.MouseListener; -import org.eclipse.swt.widgets.Control; - -import org.eclipse.ui.IEditorActionDelegate; -import org.eclipse.ui.IEditorPart; - -/** - * This class serves as an adapter for actions contributed to the vertical ruler's - * context menu. This adapter provides the contributed actions access to their editor - * and the editor's vertical ruler. These actions gain only limited access to the vertical - * ruler as defined by <code>IVerticalRulerInfo</code>. The adapter updates the - * adapter (inner) action on menu and mouse action on the vertical ruler.<p> - * Extending classes must implement the factory method - * <code>createAction(ITextEditor editor, IVerticalRulerInfo)</code>. - * - * @since 2.0 - */ -public abstract class AbstractRulerActionDelegate implements IEditorActionDelegate, MouseListener, IMenuListener { - - /** The editor. */ - private IEditorPart fEditor; - /** The action calling the action delegate. */ - private IAction fCallerAction; - /** The underlying action. */ - private IAction fAction; - - /** - * The factory method creating the underlying action. - * - * @param editor the editor the action to be created will work on - * @param rulerInfo the vertical ruler the action to be created will work on - * @return the created action - */ - protected abstract IAction createAction(ITextEditor editor, IVerticalRulerInfo rulerInfo); - - - /* - * @see IEditorActionDelegate#setActiveEditor(org.eclipse.jface.action.IAction, org.eclipse.ui.IEditorPart) - */ - public void setActiveEditor(IAction callerAction, IEditorPart targetEditor) { - if (fEditor != null) { - IVerticalRulerInfo rulerInfo= (IVerticalRulerInfo) fEditor.getAdapter(IVerticalRulerInfo.class); - if (rulerInfo != null) { - Control control= rulerInfo.getControl(); - if (control != null && !control.isDisposed()) - control.removeMouseListener(this); - } - - if (fEditor instanceof ITextEditorExtension) - ((ITextEditorExtension) fEditor).removeRulerContextMenuListener(this); - } - - fEditor= targetEditor; - fCallerAction= callerAction; - fAction= null; - - if (fEditor != null && fEditor instanceof ITextEditor) { - if (fEditor instanceof ITextEditorExtension) - ((ITextEditorExtension) fEditor).addRulerContextMenuListener(this); - - IVerticalRulerInfo rulerInfo= (IVerticalRulerInfo) fEditor.getAdapter(IVerticalRulerInfo.class); - if (rulerInfo != null) { - fAction= createAction((ITextEditor) fEditor, rulerInfo); - update(); - - Control control= rulerInfo.getControl(); - if (control != null && !control.isDisposed()) - control.addMouseListener(this); - } - } - } - - /* - * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) - */ - public void run(IAction callerAction) { - if (fAction != null) - fAction.run(); - } - - /* - * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) - */ - public void selectionChanged(IAction action, ISelection selection) { - update(); - } - - /** - * Requests the adaptee to update itself to the current state. - */ - private void update() { - if (fAction instanceof IUpdate) { - ((IUpdate) fAction).update(); - if (fCallerAction != null) { - fCallerAction.setText(fAction.getText()); - fCallerAction.setEnabled(fAction.isEnabled()); - } - } - } - - /* - * @see IMenuListener#menuAboutToShow(org.eclipse.jface.action.IMenuManager) - */ - public void menuAboutToShow(IMenuManager manager) { - update(); - } - - /* - * @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) { - update(); - } - - /* - * @see MouseListener#mouseUp(org.eclipse.swt.events.MouseEvent) - */ - public void mouseUp(MouseEvent e) { - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java deleted file mode 100644 index 456d28807bd..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java +++ /dev/null @@ -1,5129 +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 - * Chris.Dennis@invidi.com - http://bugs.eclipse.org/bugs/show_bug.cgi?id=29027 - *******************************************************************************/ -package org.eclipse.ui.texteditor; - - -import java.lang.reflect.InvocationTargetException; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.ResourceBundle; - -import org.osgi.framework.Bundle; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.ILog; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.BusyIndicator; -import org.eclipse.swt.custom.ST; -import org.eclipse.swt.custom.StyledText; -import org.eclipse.swt.custom.VerifyKeyListener; -import org.eclipse.swt.dnd.DND; -import org.eclipse.swt.dnd.DropTarget; -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.ShellAdapter; -import org.eclipse.swt.events.ShellEvent; -import org.eclipse.swt.events.VerifyEvent; -import org.eclipse.swt.events.VerifyListener; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.FontData; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.ImageData; -import org.eclipse.swt.graphics.PaletteData; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.widgets.Caret; -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.Shell; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.action.IMenuListener; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.IStatusLineManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.preference.PreferenceConverter; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -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.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.IFindReplaceTarget; -import org.eclipse.jface.text.IFindReplaceTargetExtension; -import org.eclipse.jface.text.IMarkRegionTarget; -import org.eclipse.jface.text.IRegion; -import org.eclipse.jface.text.IRewriteTarget; -import org.eclipse.jface.text.ISelectionValidator; -import org.eclipse.jface.text.ITextInputListener; -import org.eclipse.jface.text.ITextListener; -import org.eclipse.jface.text.ITextOperationTarget; -import org.eclipse.jface.text.ITextSelection; -import org.eclipse.jface.text.ITextViewerExtension; -import org.eclipse.jface.text.ITextViewerExtension5; -import org.eclipse.jface.text.Position; -import org.eclipse.jface.text.Region; -import org.eclipse.jface.text.TextEvent; -import org.eclipse.jface.text.TextSelection; -import org.eclipse.jface.text.source.Annotation; -import org.eclipse.jface.text.source.IAnnotationModel; -import org.eclipse.jface.text.source.ISourceViewer; -import org.eclipse.jface.text.source.IVerticalRuler; -import org.eclipse.jface.text.source.IVerticalRulerExtension; -import org.eclipse.jface.text.source.IVerticalRulerInfo; -import org.eclipse.jface.text.source.SourceViewer; -import org.eclipse.jface.text.source.SourceViewerConfiguration; -import org.eclipse.jface.text.source.VerticalRuler; - -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.IEditorActionBarContributor; -import org.eclipse.ui.IEditorDescriptor; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorRegistry; -import org.eclipse.ui.IEditorSite; -import org.eclipse.ui.IKeyBindingService; -import org.eclipse.ui.INavigationLocation; -import org.eclipse.ui.INavigationLocationProvider; -import org.eclipse.ui.IPartListener; -import org.eclipse.ui.IReusableEditor; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.help.WorkbenchHelp; -import org.eclipse.ui.internal.ActionDescriptor; -import org.eclipse.ui.internal.EditorPluginAction; -import org.eclipse.ui.internal.texteditor.EditPosition; -import org.eclipse.ui.internal.texteditor.TextEditorPlugin; -import org.eclipse.ui.part.EditorActionBarContributor; -import org.eclipse.ui.part.EditorPart; - - -/** - * Abstract base implementation of a text editor. - * <p> - * Subclasses are responsible for configuring the editor appropriately. - * The standard text editor, <code>TextEditor</code>, is one such example.</p> - * <p> - * If a subclass calls <code>setEditorContextMenuId</code> the arguments is - * used as the id under which the editor's context menu is registered for extensions. - * If no id is set, the context menu is registered under <b>[editor_id].EditorContext</b> - * whereby [editor_id] is replaced with the editor's part id. If the editor is instructed to - * run in version 1.0 context menu registration compatibility mode, the latter form of the - * registration even happens if a context menu id has been set via <code>setEditorContextMenuId</code>. - * If no id is set while in compatibility mode, the menu is registered under - * <code>DEFAULT_EDITOR_CONTEXT_MENU_ID</code>.</p> - * <p> - * If a subclass calls <code>setRulerContextMenuId</code> the argument is - * used as the id under which the ruler's context menu is registered for extensions. - * If no id is set, the context menu is registered under <b>[editor_id].RulerContext</b> - * whereby [editor_id] is replaced with the editor's part id. If the editor is instructed to - * run in version 1.0 context menu registration compatibility mode, the latter form of the - * registration even happens if a context menu id has been set via <code>setRulerContextMenuId</code>. - * If no id is set while in compatibility mode, the menu is registered under - * <code>DEFAULT_RULER_CONTEXT_MENU_ID</code>.</p> - * - * @see org.eclipse.ui.editors.text.TextEditor - */ -public abstract class AbstractTextEditor extends EditorPart implements ITextEditor, IReusableEditor, ITextEditorExtension, ITextEditorExtension2, ITextEditorExtension3, INavigationLocationProvider { - - /** - * Tag used in xml configuration files to specify editor action contributions. - * Current value: <code>editorContribution</code> - * @since 2.0 - */ - private static final String TAG_CONTRIBUTION_TYPE= "editorContribution"; //$NON-NLS-1$ - - /** - * The caret width for the wide (double) caret. - * Value: {@value} - * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=21715 - * @since 3.0 - */ - private static final int WIDE_CARET_WIDTH= 2; - - /** - * The caret width for the narrow (single) caret. - * Value: {@value} - * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=21715 - * @since 3.0 - */ - private static final int SINGLE_CARET_WIDTH= 1; - - /** - * The text input listener. - * - * @see ITextInputListener - * @since 2.1 - */ - private static class TextInputListener implements ITextInputListener { - /** Indicates whether the editor input changed during the process of state validation. */ - public boolean inputChanged; - - /* Detectors for editor input changes during the process of state validation. */ - public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {} - public void inputDocumentChanged(IDocument oldInput, IDocument newInput) { inputChanged= true; } - } - - /** - * Internal element state listener. - */ - class ElementStateListener implements IElementStateListener, IElementStateListenerExtension { - - /** - * Internal <code>VerifyListener</code> for performing the state validation of the - * editor input in case of the first attempted manipulation via typing on the keyboard. - * @since 2.0 - */ - class Validator implements VerifyListener { - /* - * @see VerifyListener#verifyText(org.eclipse.swt.events.VerifyEvent) - */ - public void verifyText(VerifyEvent e) { - IDocument document= getDocumentProvider().getDocument(getEditorInput()); - final boolean[] documentChanged= new boolean[1]; - IDocumentListener listener= new IDocumentListener() { - public void documentAboutToBeChanged(DocumentEvent event) { - } - public void documentChanged(DocumentEvent event) { - documentChanged[0]= true; - } - }; - try { - if (document != null) - document.addDocumentListener(listener); - if (! validateEditorInputState() || documentChanged[0]) - e.doit= false; - } finally { - if (document != null) - document.removeDocumentListener(listener); - } - } - } - - /** - * The listener's validator. - * @since 2.0 - */ - private Validator fValidator; - /** - * The display used for posting runnable into the UI thread. - * @since 3.0 - */ - private Display fDisplay; - - /* - * @see IElementStateListenerExtension#elementStateValidationChanged(Object, boolean) - * @since 2.0 - */ - public void elementStateValidationChanged(final Object element, final boolean isStateValidated) { - if (element != null && element.equals(getEditorInput())) { - Runnable r= new Runnable() { - public void run() { - enableSanityChecking(true); - if (isStateValidated && fValidator != null) { - ISourceViewer viewer= getSourceViewer(); - if (viewer != null) { - StyledText textWidget= viewer.getTextWidget(); - if (textWidget != null && !textWidget.isDisposed()) - textWidget.removeVerifyListener(fValidator); - fValidator= null; - enableStateValidation(false); - } - } else if (!isStateValidated && fValidator == null) { - ISourceViewer viewer= getSourceViewer(); - if (viewer != null) { - StyledText textWidget= viewer.getTextWidget(); - if (textWidget != null && !textWidget.isDisposed()) { - fValidator= new Validator(); - enableStateValidation(true); - textWidget.addVerifyListener(fValidator); - } - } - } - } - }; - execute(r); - } - } - - - /* - * @see IElementStateListener#elementDirtyStateChanged(Object, boolean) - */ - public void elementDirtyStateChanged(Object element, boolean isDirty) { - if (element != null && element.equals(getEditorInput())) { - Runnable r= new Runnable() { - public void run() { - enableSanityChecking(true); - firePropertyChange(PROP_DIRTY); - } - }; - execute(r); - } - } - - /* - * @see IElementStateListener#elementContentAboutToBeReplaced(Object) - */ - public void elementContentAboutToBeReplaced(Object element) { - if (element != null && element.equals(getEditorInput())) { - Runnable r= new Runnable() { - public void run() { - enableSanityChecking(true); - rememberSelection(); - resetHighlightRange(); - } - }; - execute(r); - } - } - - /* - * @see IElementStateListener#elementContentReplaced(Object) - */ - public void elementContentReplaced(Object element) { - if (element != null && element.equals(getEditorInput())) { - Runnable r= new Runnable() { - public void run() { - enableSanityChecking(true); - firePropertyChange(PROP_DIRTY); - restoreSelection(); - handleElementContentReplaced(); - } - }; - execute(r); - } - } - - /* - * @see IElementStateListener#elementDeleted(Object) - */ - public void elementDeleted(Object deletedElement) { - if (deletedElement != null && deletedElement.equals(getEditorInput())) { - Runnable r= new Runnable() { - public void run() { - enableSanityChecking(true); - close(false); - } - }; - execute(r); - } - } - - /* - * @see IElementStateListener#elementMoved(Object, Object) - */ - public void elementMoved(final Object originalElement, final Object movedElement) { - if (originalElement != null && originalElement.equals(getEditorInput())) { - Runnable r= new Runnable() { - public void run() { - enableSanityChecking(true); - - if (!canHandleMove((IEditorInput) originalElement, (IEditorInput) movedElement)) { - close(true); - return; - } - - if (movedElement == null || movedElement instanceof IEditorInput) { - rememberSelection(); - - IDocumentProvider d= getDocumentProvider(); - IDocument changed= null; - String previousContent= null; - if (isDirty()) { - changed= d.getDocument(getEditorInput()); - if (changed != null) - previousContent= changed.get(); - } - - setInput((IEditorInput) movedElement); - - if (changed != null) { - d.getDocument(getEditorInput()).set(previousContent); - validateState(getEditorInput()); - updateStatusField(ITextEditorActionConstants.STATUS_CATEGORY_ELEMENT_STATE); - } - - restoreSelection(); - } - } - }; - execute(r); - } - } - - /* - * @see IElementStateListenerExtension#elementStateChanging(Object) - * @since 2.0 - */ - public void elementStateChanging(Object element) { - if (element != null && element.equals(getEditorInput())) - enableSanityChecking(false); - } - - /* - * @see IElementStateListenerExtension#elementStateChangeFailed(Object) - * @since 2.0 - */ - public void elementStateChangeFailed(Object element) { - if (element != null && element.equals(getEditorInput())) - enableSanityChecking(true); - } - - /** - * Executes the given runnable in the UI thread. - * - * @param runnable runnable to be executed - * @since 3.0 - */ - private void execute(Runnable runnable) { - if (Display.getCurrent() != null) - runnable.run(); - else { - if (fDisplay == null) - fDisplay= getSite().getShell().getDisplay(); - fDisplay.asyncExec(runnable); - } - } - } - - /** - * Internal text listener for updating all content dependent - * actions. The updating is done asynchronously. - */ - class TextListener implements ITextListener, ITextInputListener { - - /** The posted updater code. */ - private Runnable fRunnable= new Runnable() { - public void run() { - fIsRunnablePosted= false; - - if (fSourceViewer != null) { - updateContentDependentActions(); - - // remember the last edit position - if (isDirty() && fUpdateLastEditPosition) { - fUpdateLastEditPosition= false; - ISelection sel= getSelectionProvider().getSelection(); - IEditorInput input= getEditorInput(); - IDocument document= getDocumentProvider().getDocument(input); - - if (fLocalLastEditPosition != null) { - document.removePosition(fLocalLastEditPosition); - fLocalLastEditPosition= null; - } - - if (sel instanceof ITextSelection && !sel.isEmpty()) { - ITextSelection s= (ITextSelection) sel; - fLocalLastEditPosition= new Position(s.getOffset(), s.getLength()); - try { - document.addPosition(fLocalLastEditPosition); - } catch (BadLocationException ex) { - fLocalLastEditPosition= null; - } - } - TextEditorPlugin.getDefault().setLastEditPosition(new EditPosition(input, getEditorSite().getId(), getSelectionProvider().getSelection(), fLocalLastEditPosition)); - } - } - } - }; - - /** Display used for posting the updater code. */ - private Display fDisplay; - /** - * The editor's last edit position - * @since 3.0 - */ - private Position fLocalLastEditPosition; - /** - * Has the runnable been posted? - * @since 3.0 - */ - private boolean fIsRunnablePosted= false; - /** - * Should the last edit position be updated? - * @since 3.0 - */ - private boolean fUpdateLastEditPosition= false; - - /* - * @see ITextListener#textChanged(TextEvent) - */ - public void textChanged(TextEvent event) { - - /* - * Also works for text events which do not base on a DocumentEvent. - * This way, if the visible document of the viewer changes, all content - * dependent actions are updated as well. - */ - - if (fDisplay == null) - fDisplay= getSite().getShell().getDisplay(); - - if (event.getDocumentEvent() != null) - fUpdateLastEditPosition= true; - - if (!fIsRunnablePosted) { - fIsRunnablePosted= true; - fDisplay.asyncExec(fRunnable); - } - } - - /* - * @see org.eclipse.jface.text.ITextInputListener#inputDocumentAboutToBeChanged(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IDocument) - */ - public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) { - if (oldInput != null && fLocalLastEditPosition != null) { - oldInput.removePosition(fLocalLastEditPosition); - fLocalLastEditPosition= null; - } - } - - /* - * @see org.eclipse.jface.text.ITextInputListener#inputDocumentChanged(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IDocument) - */ - public void inputDocumentChanged(IDocument oldInput, IDocument newInput) { - } - } - - /** - * Internal property change listener for handling changes in the editor's preferences. - */ - class PropertyChangeListener implements IPropertyChangeListener { - /* - * @see IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) - */ - public void propertyChange(PropertyChangeEvent event) { - handlePreferenceStoreChanged(event); - } - } - - /** - * Internal property change listener for handling workbench font changes. - * @since 2.1 - */ - class FontPropertyChangeListener implements IPropertyChangeListener { - /* - * @see IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) - */ - public void propertyChange(PropertyChangeEvent event) { - if (fSourceViewer == null) - return; - - String property= event.getProperty(); - - if (getFontPropertyPreferenceKey().equals(property)) { - initializeViewerFont(fSourceViewer); - updateCaret(); - } - } - } - - /** - * Internal key verify listener for triggering action activation codes. - */ - class ActivationCodeTrigger implements VerifyKeyListener { - - /** Indicates whether this trigger has been installed. */ - private boolean fIsInstalled= false; - /** - * The key binding service to use. - * @since 2.0 - */ - private IKeyBindingService fKeyBindingService; - - /* - * @see VerifyKeyListener#verifyKey(org.eclipse.swt.events.VerifyEvent) - */ - public void verifyKey(VerifyEvent event) { - - ActionActivationCode code= null; - int size= fActivationCodes.size(); - for (int i= 0; i < size; i++) { - code= (ActionActivationCode) fActivationCodes.get(i); - if (code.matches(event)) { - IAction action= getAction(code.fActionId); - if (action != null) { - - if (action instanceof IUpdate) - ((IUpdate) action).update(); - - if (!action.isEnabled() && action instanceof IReadOnlyDependent) { - IReadOnlyDependent dependent= (IReadOnlyDependent) action; - boolean writable= dependent.isEnabled(true); - if (writable) { - event.doit= false; - return; - } - } else if (action.isEnabled()) { - event.doit= false; - action.run(); - return; - } - } - } - } - } - - /** - * Installs this trigger on the editor's text widget. - * @since 2.0 - */ - public void install() { - if (!fIsInstalled) { - - if (fSourceViewer instanceof ITextViewerExtension) { - ITextViewerExtension e= (ITextViewerExtension) fSourceViewer; - e.prependVerifyKeyListener(this); - } else { - StyledText text= fSourceViewer.getTextWidget(); - text.addVerifyKeyListener(this); - } - - fKeyBindingService= getEditorSite().getKeyBindingService(); - fIsInstalled= true; - } - } - - /** - * Uninstalls this trigger from the editor's text widget. - * @since 2.0 - */ - public void uninstall() { - if (fIsInstalled) { - - if (fSourceViewer instanceof ITextViewerExtension) { - ITextViewerExtension e= (ITextViewerExtension) fSourceViewer; - e.removeVerifyKeyListener(this); - } else if (fSourceViewer != null) { - StyledText text= fSourceViewer.getTextWidget(); - if (text != null && !text.isDisposed()) - text.removeVerifyKeyListener(fActivationCodeTrigger); - } - - fIsInstalled= false; - fKeyBindingService= null; - } - } - - /** - * Registers the given action for key activation. - * @param action the action to be registered - * @since 2.0 - */ - public void registerActionForKeyActivation(IAction action) { - if (action.getActionDefinitionId() != null) - fKeyBindingService.registerAction(action); - } - - /** - * The given action is no longer available for key activation - * @param action the action to be unregistered - * @since 2.0 - */ - public void unregisterActionFromKeyActivation(IAction action) { - if (action.getActionDefinitionId() != null) - fKeyBindingService.unregisterAction(action); - } - - /** - * Sets the keybindings scopes for this editor. - * @param keyBindingScopes the keybinding scopes - * @since 2.1 - */ - public void setScopes(String[] keyBindingScopes) { - if (keyBindingScopes != null && keyBindingScopes.length > 0) - fKeyBindingService.setScopes(keyBindingScopes); - } - } - - /** - * Representation of action activation codes. - */ - static class ActionActivationCode { - - /** The action id. */ - public String fActionId; - /** The character. */ - public char fCharacter; - /** The key code. */ - public int fKeyCode= -1; - /** The state mask. */ - public int fStateMask= SWT.DEFAULT; - - /** - * Creates a new action activation code for the given action id. - * @param actionId the action id - */ - public ActionActivationCode(String actionId) { - fActionId= actionId; - } - - /** - * Returns <code>true</code> if this activation code matches the given verify event. - * @param event the event to test for matching - * @return whether this activation code matches <code>event</code> - */ - public boolean matches(VerifyEvent event) { - return (event.character == fCharacter && - (fKeyCode == -1 || event.keyCode == fKeyCode) && - (fStateMask == SWT.DEFAULT || event.stateMask == fStateMask)); - } - } - - /** - * Internal part and shell activation listener for triggering state validation. - * @since 2.0 - */ - class ActivationListener extends ShellAdapter implements IPartListener { - - /** Cache of the active workbench part. */ - private IWorkbenchPart fActivePart; - /** Indicates whether activation handling is currently be done. */ - private boolean fIsHandlingActivation= false; - - /* - * @see IPartListener#partActivated(org.eclipse.ui.IWorkbenchPart) - */ - public void partActivated(IWorkbenchPart part) { - fActivePart= part; - handleActivation(); - } - - /* - * @see IPartListener#partBroughtToTop(org.eclipse.ui.IWorkbenchPart) - */ - public void partBroughtToTop(IWorkbenchPart part) { - } - - /* - * @see IPartListener#partClosed(org.eclipse.ui.IWorkbenchPart) - */ - public void partClosed(IWorkbenchPart part) { - } - - /* - * @see IPartListener#partDeactivated(org.eclipse.ui.IWorkbenchPart) - */ - public void partDeactivated(IWorkbenchPart part) { - fActivePart= null; - } - - /* - * @see IPartListener#partOpened(org.eclipse.ui.IWorkbenchPart) - */ - public void partOpened(IWorkbenchPart part) { - } - - /* - * @see ShellListener#shellActivated(org.eclipse.swt.events.ShellEvent) - */ - public void shellActivated(ShellEvent e) { - /* - * Workaround for problem described in - * http://dev.eclipse.org/bugs/show_bug.cgi?id=11731 - * Will be removed when SWT has solved the problem. - */ - e.widget.getDisplay().asyncExec(new Runnable() { - public void run() { - handleActivation(); - } - }); - } - - /** - * Handles the activation triggering a element state check in the editor. - */ - private void handleActivation() { - if (fIsHandlingActivation) - return; - - if (fActivePart == AbstractTextEditor.this) { - fIsHandlingActivation= true; - try { - safelySanityCheckState(getEditorInput()); - } finally { - fIsHandlingActivation= false; - } - } - } - } - - /** - * Internal interface for a cursor listener. I.e. aggregation - * of mouse and key listener. - * @since 2.0 - */ - interface ICursorListener extends MouseListener, KeyListener { - } - - /** - * Maps an action definition id to an StyledText action. - * @since 2.0 - */ - static class IdMapEntry { - - /** The action id. */ - private String fActionId; - /** The StyledText action. */ - private int fAction; - - /** - * Creates a new mapping. - * @param actionId the action id - * @param action the StyledText action - */ - public IdMapEntry(String actionId, int action) { - fActionId= actionId; - fAction= action; - } - - /** - * Returns the action id. - * @return the action id - */ - public String getActionId() { - return fActionId; - } - - /** - * Returns the action. - * @return the action - */ - public int getAction() { - return fAction; - } - } - - /** - * Internal action to scroll the editor's viewer by a specified number of lines. - * @since 2.0 - */ - class ScrollLinesAction extends Action { - - /** Number of lines to scroll. */ - private int fScrollIncrement; - - /** - * Creates a new scroll action that scroll the given number of lines. If the - * increment is < 0, it's scrolling up, if > 0 it's scrolling down. - * @param scrollIncrement the number of lines to scroll - */ - public ScrollLinesAction(int scrollIncrement) { - fScrollIncrement= scrollIncrement; - } - - /* - * @see IAction#run() - */ - public void run() { - ISourceViewer viewer= getSourceViewer(); - if (viewer instanceof ITextViewerExtension5) { - ITextViewerExtension5 extension= (ITextViewerExtension5) viewer; - StyledText textWidget= viewer.getTextWidget(); - int topIndex= textWidget.getTopIndex(); - int newTopIndex= Math.max(0, topIndex + fScrollIncrement); - viewer.setTopIndex(extension.widgetLine2ModelLine(newTopIndex)); - } else { - int topIndex= viewer.getTopIndex(); - int newTopIndex= Math.max(0, topIndex + fScrollIncrement); - viewer.setTopIndex(newTopIndex); - } - } - } - - /** - * Action to toggle the insert mode. The action is checked if smart mode is - * turned on. - * - * @since 2.1 - */ - class ToggleInsertModeAction extends ResourceAction { - - public ToggleInsertModeAction(ResourceBundle bundle, String prefix) { - super(bundle, prefix, IAction.AS_CHECK_BOX); - } - - /* - * @see org.eclipse.jface.action.IAction#run() - */ - public void run() { - switchToNextInsertMode(); - } - - /* - * @see org.eclipse.jface.action.IAction#isChecked() - * @since 3.0 - */ - public boolean isChecked() { - return fInsertMode == SMART_INSERT; - } - } - - /** - * Action to toggle the overwrite mode. - * - * @since 3.0 - */ - class ToggleOverwriteModeAction extends ResourceAction { - - public ToggleOverwriteModeAction(ResourceBundle bundle, String prefix) { - super(bundle, prefix); - } - - /* - * @see org.eclipse.jface.action.IAction#run() - */ - public void run() { - toggleOverwriteMode(); - } - } - - /** - * This action implements smart end. - * Instead of going to the end of a line it does the following: - * - if smart home/end is enabled and the caret is before the line's last non-whitespace and then the caret is moved directly after it - * - if the caret is after last non-whitespace the caret is moved at the end of the line - * - if the caret is at the end of the line the caret is moved directly after the line's last non-whitespace character - * @since 2.1 - */ - class LineEndAction extends TextNavigationAction { - - /** boolean flag which tells if the text up to the line end should be selected. */ - private boolean fDoSelect; - - /** - * Create a new line end action. - * - * @param textWidget the styled text widget - * @param doSelect a boolean flag which tells if the text up to the line end should be selected - */ - public LineEndAction(StyledText textWidget, boolean doSelect) { - super(textWidget, ST.LINE_END); - fDoSelect= doSelect; - } - - /* - * @see org.eclipse.jface.action.IAction#run() - */ - public void run() { - boolean isSmartHomeEndEnabled= false; - IPreferenceStore store= getPreferenceStore(); - if (store != null) - isSmartHomeEndEnabled= store.getBoolean(AbstractTextEditor.PREFERENCE_NAVIGATION_SMART_HOME_END); - - StyledText st= getSourceViewer().getTextWidget(); - if (st == null || st.isDisposed()) - return; - int caretOffset= st.getCaretOffset(); - int lineNumber= st.getLineAtOffset(caretOffset); - int lineOffset= st.getOffsetAtLine(lineNumber); - - int lineLength; - try { - int caretOffsetInDocument= widgetOffset2ModelOffset(getSourceViewer(), caretOffset); - lineLength= getSourceViewer().getDocument().getLineInformationOfOffset(caretOffsetInDocument).getLength(); - } catch (BadLocationException ex) { - return; - } - int lineEndOffset= lineOffset + lineLength; - - int delta= lineEndOffset - st.getCharCount(); - if (delta > 0) { - lineEndOffset -= delta; - lineLength -= delta; - } - - String line= ""; //$NON-NLS-1$ - if (lineLength > 0) - line= st.getText(lineOffset, lineEndOffset - 1); - int i= lineLength - 1; - while (i > -1 && Character.isWhitespace(line.charAt(i))) { - i--; - } - i++; - - // Remember current selection - Point oldSelection= st.getSelection(); - - // Compute new caret position - int newCaretOffset= -1; - - if (isSmartHomeEndEnabled) { - - if (caretOffset - lineOffset == i) - // to end of line - newCaretOffset= lineEndOffset; - else - // to end of text - newCaretOffset= lineOffset + i; - - } else { - - if (caretOffset < lineEndOffset) - // to end of line - newCaretOffset= lineEndOffset; - - } - - if (newCaretOffset == -1) - newCaretOffset= caretOffset; - else - st.setCaretOffset(newCaretOffset); - - st.setCaretOffset(newCaretOffset); - if (fDoSelect) { - if (caretOffset < oldSelection.y) - st.setSelection(oldSelection.y, newCaretOffset); - else - st.setSelection(oldSelection.x, newCaretOffset); - } else - st.setSelection(newCaretOffset); - - fireSelectionChanged(oldSelection); - } - } - - /** - * This action implements smart home. - * Instead of going to the start of a line it does the following: - * - if smart home/end is enabled and the caret is after the line's first non-whitespace then the caret is moved directly before it - * - if the caret is before the line's first non-whitespace the caret is moved to the beginning of the line - * - if the caret is at the beginning of the line the caret is moved directly before the line's first non-whitespace character - * @since 2.1 - */ - protected class LineStartAction extends TextNavigationAction { - - /** boolean flag which tells if the text up to the beginning of the line should be selected. */ - private final boolean fDoSelect; - - /** - * Creates a new line start action. - * - * @param textWidget the styled text widget - * @param doSelect a boolean flag which tells if the text up to the beginning of the line should be selected - */ - public LineStartAction(final StyledText textWidget, final boolean doSelect) { - super(textWidget, ST.LINE_START); - fDoSelect= doSelect; - } - - /** - * Computes the offset of the line start position. - * - * @param document The document where to compute the line start position - * @param line The line to determine the start position of - * @param length The length of the line - * @param offset The caret position in the document - * @return The offset of the line start - * @since 3.0 - */ - protected int getLineStartPosition(final IDocument document, final String line, final int length, final int offset) { - int index= 0; - while (index < length && Character.isWhitespace(line.charAt(index))) - index++; - return index; - } - - /* - * @see org.eclipse.jface.action.IAction#run() - */ - public void run() { - boolean isSmartHomeEndEnabled= false; - IPreferenceStore store= getPreferenceStore(); - if (store != null) - isSmartHomeEndEnabled= store.getBoolean(AbstractTextEditor.PREFERENCE_NAVIGATION_SMART_HOME_END); - - StyledText st= getSourceViewer().getTextWidget(); - if (st == null || st.isDisposed()) - return; - - int caretOffset= st.getCaretOffset(); - int lineNumber= st.getLineAtOffset(caretOffset); - int lineOffset= st.getOffsetAtLine(lineNumber); - - int lineLength; - int caretOffsetInDocument; - final IDocument document= getSourceViewer().getDocument(); - - try { - caretOffsetInDocument= widgetOffset2ModelOffset(getSourceViewer(), caretOffset); - lineLength= document.getLineInformationOfOffset(caretOffsetInDocument).getLength(); - } catch (BadLocationException ex) { - return; - } - - String line= ""; //$NON-NLS-1$ - if (lineLength > 0) { - int end= lineOffset + lineLength - 1; - end= Math.min(end, st.getCharCount() -1); - line= st.getText(lineOffset, end); - } - - // Compute the line start offset - int index= getLineStartPosition(document, line, lineLength, caretOffsetInDocument); - - // Remember current selection - Point oldSelection= st.getSelection(); - - // Compute new caret position - int newCaretOffset= -1; - if (isSmartHomeEndEnabled) { - - if (caretOffset - lineOffset == index) - // to beginning of line - newCaretOffset= lineOffset; - else - // to beginning of text - newCaretOffset= lineOffset + index; - - } else { - - if (caretOffset > lineOffset) - // to beginning of line - newCaretOffset= lineOffset; - } - - if (newCaretOffset == -1) - newCaretOffset= caretOffset; - else - st.setCaretOffset(newCaretOffset); - - if (fDoSelect) { - if (caretOffset < oldSelection.y) - st.setSelection(oldSelection.y, newCaretOffset); - else - st.setSelection(oldSelection.x, newCaretOffset); - } else - st.setSelection(newCaretOffset); - - fireSelectionChanged(oldSelection); - } - - } - - /** - * Internal action to show the editor's ruler context menu (accessibility). - * @since 2.0 - */ - class ShowRulerContextMenuAction extends Action { - /* - * @see IAction#run() - */ - public void run() { - if (fSourceViewer == null) - return; - - StyledText text= fSourceViewer.getTextWidget(); - if (text == null || text.isDisposed()) - return; - - Point location= text.getLocationAtOffset(text.getCaretOffset()); - location.x= 0; - - if (fVerticalRuler instanceof IVerticalRulerExtension) - ((IVerticalRulerExtension) fVerticalRuler).setLocationOfLastMouseButtonActivity(location.x, location.y); - - location= text.toDisplay(location); - fRulerContextMenu.setLocation(location.x, location.y); - fRulerContextMenu.setVisible(true); - } - } - - - /** - * Editor specific selection provider which wraps the source viewer's selection provider. - * @since 2.1 - */ - class SelectionProvider implements IPostSelectionProvider, ISelectionValidator { - - /* - * @see org.eclipse.jface.viewers.ISelectionProvider#addSelectionChangedListener(ISelectionChangedListener) - */ - public void addSelectionChangedListener(ISelectionChangedListener listener) { - if (fSourceViewer != null) - fSourceViewer.getSelectionProvider().addSelectionChangedListener(listener); - } - - /* - * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection() - */ - public ISelection getSelection() { - return doGetSelection(); - } - - /* - * @see org.eclipse.jface.viewers.ISelectionProvider#removeSelectionChangedListener(ISelectionChangedListener) - */ - public void removeSelectionChangedListener(ISelectionChangedListener listener) { - if (fSourceViewer != null) - fSourceViewer.getSelectionProvider().removeSelectionChangedListener(listener); - } - - /* - * @see org.eclipse.jface.viewers.ISelectionProvider#setSelection(ISelection) - */ - public void setSelection(ISelection selection) { - doSetSelection(selection); - } - - /* - * @see org.eclipse.jface.text.IPostSelectionProvider#addPostSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) - * @since 3.0 - */ - public void addPostSelectionChangedListener(ISelectionChangedListener listener) { - if (fSourceViewer != null) { - if (fSourceViewer.getSelectionProvider() instanceof IPostSelectionProvider) { - IPostSelectionProvider provider= (IPostSelectionProvider) fSourceViewer.getSelectionProvider(); - provider.addPostSelectionChangedListener(listener); - } - } - } - - /* - * @see org.eclipse.jface.text.IPostSelectionProvider#removePostSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) - * @since 3.0 - */ - public void removePostSelectionChangedListener(ISelectionChangedListener listener) { - if (fSourceViewer != null) { - if (fSourceViewer.getSelectionProvider() instanceof IPostSelectionProvider) { - IPostSelectionProvider provider= (IPostSelectionProvider) fSourceViewer.getSelectionProvider(); - provider.removePostSelectionChangedListener(listener); - } - } - } - - /* - * @see org.eclipse.jface.text.IPostSelectionValidator#isValid() - * @since 3.0 - */ - public boolean isValid(ISelection postSelection) { - return fSelectionListener != null && fSelectionListener.isValid(postSelection); - } - } - - /** - * Internal implementation class for a change listener. - * @since 3.0 - */ - protected abstract class AbstractSelectionChangedListener implements ISelectionChangedListener { - - /** - * Installs this selection changed listener with the given selection provider. If - * the selection provider is a post selection provider, post selection changed - * events are the preferred choice, otherwise normal selection changed events - * are requested. - * - * @param selectionProvider - */ - public void install(ISelectionProvider selectionProvider) { - if (selectionProvider == null) - return; - - if (selectionProvider instanceof IPostSelectionProvider) { - IPostSelectionProvider provider= (IPostSelectionProvider) selectionProvider; - provider.addPostSelectionChangedListener(this); - } else { - selectionProvider.addSelectionChangedListener(this); - } - } - - /** - * Removes this selection changed listener from the given selection provider. - * - * @param selectionProvider the selection provider - */ - public void uninstall(ISelectionProvider selectionProvider) { - if (selectionProvider == null) - return; - - if (selectionProvider instanceof IPostSelectionProvider) { - IPostSelectionProvider provider= (IPostSelectionProvider) selectionProvider; - provider.removePostSelectionChangedListener(this); - } else { - selectionProvider.removeSelectionChangedListener(this); - } - } - } - - /** - * This selection listener allows the SelectionProvider to implement {@link ISelectionValidator}. - * - * @since 3.0 - */ - private class SelectionListener extends AbstractSelectionChangedListener implements IDocumentListener { - - private IDocument fDocument; - private final Object INVALID_SELECTION= new Object(); - private Object fPostSelection= INVALID_SELECTION; - - /* - * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) - */ - public synchronized void selectionChanged(SelectionChangedEvent event) { - fPostSelection= event.getSelection(); - } - - /* - * @see org.eclipse.jface.text.IDocumentListener#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent) - * @since 3.0 - */ - public synchronized void documentAboutToBeChanged(DocumentEvent event) { - fPostSelection= INVALID_SELECTION; - } - - /* - * @see org.eclipse.jface.text.IDocumentListener#documentChanged(org.eclipse.jface.text.DocumentEvent) - * @since 3.0 - */ - public void documentChanged(DocumentEvent event) { - } - - public synchronized boolean isValid(ISelection selection) { - return fPostSelection != INVALID_SELECTION && fPostSelection == selection; - } - - public void setDocument(IDocument document) { - if (fDocument != null) - fDocument.removeDocumentListener(this); - - fDocument= document; - if (fDocument != null) - fDocument.addDocumentListener(this); - } - - /* - * @see org.eclipse.ui.texteditor.AbstractTextEditor.AbstractSelectionChangedListener#install(org.eclipse.jface.viewers.ISelectionProvider) - * @since 3.0 - */ - public void install(ISelectionProvider selectionProvider) { - super.install(selectionProvider); - - if (selectionProvider != null) - selectionProvider.addSelectionChangedListener(this); - } - - /* - * @see org.eclipse.ui.texteditor.AbstractTextEditor.AbstractSelectionChangedListener#uninstall(org.eclipse.jface.viewers.ISelectionProvider) - * @since 3.0 - */ - public void uninstall(ISelectionProvider selectionProvider) { - if (selectionProvider != null) - selectionProvider.removeSelectionChangedListener(this); - - if (fDocument != null) { - fDocument.removeDocumentListener(this); - fDocument= null; - } - super.uninstall(selectionProvider); - } - } - - - /** - * Key used to look up font preference. - * Value: <code>"org.eclipse.jface.textfont"</code> - * - * @deprecated As of 2.1, replaced by {@link JFaceResources#TEXT_FONT} - */ - public final static String PREFERENCE_FONT= JFaceResources.TEXT_FONT; - /** - * Key used to look up foreground color preference. - * Value: <code>AbstractTextEditor.Color.Foreground</code> - * @since 2.0 - */ - public final static String PREFERENCE_COLOR_FOREGROUND= "AbstractTextEditor.Color.Foreground"; //$NON-NLS-1$ - /** - * Key used to look up background color preference. - * Value: <code>AbstractTextEditor.Color.Background</code> - * @since 2.0 - */ - public final static String PREFERENCE_COLOR_BACKGROUND= "AbstractTextEditor.Color.Background"; //$NON-NLS-1$ - /** - * Key used to look up foreground color system default preference. - * Value: <code>AbstractTextEditor.Color.Foreground.SystemDefault</code> - * @since 2.0 - */ - public final static String PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT= "AbstractTextEditor.Color.Foreground.SystemDefault"; //$NON-NLS-1$ - /** - * Key used to look up background color system default preference. - * Value: <code>AbstractTextEditor.Color.Background.SystemDefault</code> - * @since 2.0 - */ - public final static String PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT= "AbstractTextEditor.Color.Background.SystemDefault"; //$NON-NLS-1$ - /** - * Key used to look up selection foreground color preference. - * Value: <code>AbstractTextEditor.Color.SelectionForeground</code> - * @since 3.0 - */ - public final static String PREFERENCE_COLOR_SELECTION_FOREGROUND= "AbstractTextEditor.Color.SelectionForeground"; //$NON-NLS-1$ - /** - * Key used to look up selection background color preference. - * Value: <code>AbstractTextEditor.Color.SelectionBackground</code> - * @since 3.0 - */ - public final static String PREFERENCE_COLOR_SELECTION_BACKGROUND= "AbstractTextEditor.Color.SelectionBackground"; //$NON-NLS-1$ - /** - * Key used to look up selection foreground color system default preference. - * Value: <code>AbstractTextEditor.Color.SelectionForeground.SystemDefault</code> - * @since 3.0 - */ - public final static String PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT= "AbstractTextEditor.Color.SelectionForeground.SystemDefault"; //$NON-NLS-1$ - /** - * Key used to look up selection background color system default preference. - * Value: <code>AbstractTextEditor.Color.SelectionBackground.SystemDefault</code> - * @since 3.0 - */ - public final static String PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT= "AbstractTextEditor.Color.SelectionBackground.SystemDefault"; //$NON-NLS-1$ - /** - * Key used to look up find scope background color preference. - * Value: <code>AbstractTextEditor.Color.FindScope</code> - * @since 2.0 - */ - public final static String PREFERENCE_COLOR_FIND_SCOPE= "AbstractTextEditor.Color.FindScope"; //$NON-NLS-1$ - /** - * Key used to look up smart home/end preference. - * Value: <code>AbstractTextEditor.Navigation.SmartHomeEnd</code> - * @since 2.1 - */ - public final static String PREFERENCE_NAVIGATION_SMART_HOME_END= "AbstractTextEditor.Navigation.SmartHomeEnd"; //$NON-NLS-1$ - /** - * Key used to look up the custom caret preference. - * Value: {@value} - * @since 3.0 - */ - public final static String PREFERENCE_USE_CUSTOM_CARETS= "AbstractTextEditor.Accessibility.UseCustomCarets"; //$NON-NLS-1$ - /** - * Key used to look up the caret width preference. - * Value: {@value} - * @since 3.0 - */ - public final static String PREFERENCE_WIDE_CARET= "AbstractTextEditor.Accessibility.WideCaret"; //$NON-NLS-1$ - - - /** Menu id for the editor context menu. */ - public final static String DEFAULT_EDITOR_CONTEXT_MENU_ID= "#EditorContext"; //$NON-NLS-1$ - /** Menu id for the ruler context menu. */ - public final static String DEFAULT_RULER_CONTEXT_MENU_ID= "#RulerContext"; //$NON-NLS-1$ - - /** The width of the vertical ruler. */ - protected final static int VERTICAL_RULER_WIDTH= 12; - - /** - * The complete mapping between action definition IDs used by eclipse and StyledText actions. - * - * @since 2.0 - */ - protected final static IdMapEntry[] ACTION_MAP= new IdMapEntry[] { - // navigation - new IdMapEntry(ITextEditorActionDefinitionIds.LINE_UP, ST.LINE_UP), - new IdMapEntry(ITextEditorActionDefinitionIds.LINE_DOWN, ST.LINE_DOWN), - new IdMapEntry(ITextEditorActionDefinitionIds.LINE_START, ST.LINE_START), - new IdMapEntry(ITextEditorActionDefinitionIds.LINE_END, ST.LINE_END), - new IdMapEntry(ITextEditorActionDefinitionIds.COLUMN_PREVIOUS, ST.COLUMN_PREVIOUS), - new IdMapEntry(ITextEditorActionDefinitionIds.COLUMN_NEXT, ST.COLUMN_NEXT), - new IdMapEntry(ITextEditorActionDefinitionIds.PAGE_UP, ST.PAGE_UP), - new IdMapEntry(ITextEditorActionDefinitionIds.PAGE_DOWN, ST.PAGE_DOWN), - new IdMapEntry(ITextEditorActionDefinitionIds.WORD_PREVIOUS, ST.WORD_PREVIOUS), - new IdMapEntry(ITextEditorActionDefinitionIds.WORD_NEXT, ST.WORD_NEXT), - new IdMapEntry(ITextEditorActionDefinitionIds.TEXT_START, ST.TEXT_START), - new IdMapEntry(ITextEditorActionDefinitionIds.TEXT_END, ST.TEXT_END), - new IdMapEntry(ITextEditorActionDefinitionIds.WINDOW_START, ST.WINDOW_START), - new IdMapEntry(ITextEditorActionDefinitionIds.WINDOW_END, ST.WINDOW_END), - // selection - new IdMapEntry(ITextEditorActionDefinitionIds.SELECT_LINE_UP, ST.SELECT_LINE_UP), - new IdMapEntry(ITextEditorActionDefinitionIds.SELECT_LINE_DOWN, ST.SELECT_LINE_DOWN), - new IdMapEntry(ITextEditorActionDefinitionIds.SELECT_LINE_START, ST.SELECT_LINE_START), - new IdMapEntry(ITextEditorActionDefinitionIds.SELECT_LINE_END, ST.SELECT_LINE_END), - new IdMapEntry(ITextEditorActionDefinitionIds.SELECT_COLUMN_PREVIOUS, ST.SELECT_COLUMN_PREVIOUS), - new IdMapEntry(ITextEditorActionDefinitionIds.SELECT_COLUMN_NEXT, ST.SELECT_COLUMN_NEXT), - new IdMapEntry(ITextEditorActionDefinitionIds.SELECT_PAGE_UP, ST.SELECT_PAGE_UP), - new IdMapEntry(ITextEditorActionDefinitionIds.SELECT_PAGE_DOWN, ST.SELECT_PAGE_DOWN), - new IdMapEntry(ITextEditorActionDefinitionIds.SELECT_WORD_PREVIOUS, ST.SELECT_WORD_PREVIOUS), - new IdMapEntry(ITextEditorActionDefinitionIds.SELECT_WORD_NEXT, ST.SELECT_WORD_NEXT), - new IdMapEntry(ITextEditorActionDefinitionIds.SELECT_TEXT_START, ST.SELECT_TEXT_START), - new IdMapEntry(ITextEditorActionDefinitionIds.SELECT_TEXT_END, ST.SELECT_TEXT_END), - new IdMapEntry(ITextEditorActionDefinitionIds.SELECT_WINDOW_START, ST.SELECT_WINDOW_START), - new IdMapEntry(ITextEditorActionDefinitionIds.SELECT_WINDOW_END, ST.SELECT_WINDOW_END), - // modification - new IdMapEntry(ITextEditorActionDefinitionIds.CUT, ST.CUT), - new IdMapEntry(ITextEditorActionDefinitionIds.COPY, ST.COPY), - new IdMapEntry(ITextEditorActionDefinitionIds.PASTE, ST.PASTE), - new IdMapEntry(ITextEditorActionDefinitionIds.DELETE_PREVIOUS, ST.DELETE_PREVIOUS), - new IdMapEntry(ITextEditorActionDefinitionIds.DELETE_NEXT, ST.DELETE_NEXT), - new IdMapEntry(ITextEditorActionDefinitionIds.DELETE_PREVIOUS_WORD, ST.DELETE_WORD_PREVIOUS), - new IdMapEntry(ITextEditorActionDefinitionIds.DELETE_NEXT_WORD, ST.DELETE_WORD_NEXT), - // miscellaneous - new IdMapEntry(ITextEditorActionDefinitionIds.TOGGLE_OVERWRITE, ST.TOGGLE_OVERWRITE) - }; - - private final String fReadOnlyLabel = EditorMessages.getString("Editor.statusline.state.readonly.label"); //$NON-NLS-1$ - private final String fWritableLabel = EditorMessages.getString("Editor.statusline.state.writable.label"); //$NON-NLS-1$ - private final String fInsertModeLabel = EditorMessages.getString("Editor.statusline.mode.insert.label"); //$NON-NLS-1$ - private final String fOverwriteModeLabel = EditorMessages.getString("Editor.statusline.mode.overwrite.label"); //$NON-NLS-1$ - private final String fSmartInsertModeLabel= EditorMessages.getString("Editor.statusline.mode.smartinsert.label"); //$NON-NLS-1$ - - /** The error message shown in the status line in case of failed information look up. */ - protected final String fErrorLabel= EditorMessages.getString("Editor.statusline.error.label"); //$NON-NLS-1$ - - /** - * Data structure for the position label value. - */ - private static class PositionLabelValue { - - public int fValue; - - public String toString() { - return String.valueOf(fValue); - } - } - /** The pattern used to show the position label in the status line. */ - private final String fPositionLabelPattern= EditorMessages.getString("Editor.statusline.position.pattern"); //$NON-NLS-1$ - /** The position label value of the current line. */ - private final PositionLabelValue fLineLabel= new PositionLabelValue(); - /** The position label value of the current column. */ - private final PositionLabelValue fColumnLabel= new PositionLabelValue(); - /** The arguments for the position label pattern. */ - private final Object[] fPositionLabelPatternArguments= new Object[] { fLineLabel, fColumnLabel }; - - - - - - /** The editor's explicit document provider. */ - private IDocumentProvider fExplicitDocumentProvider; - /** The editor's preference store. */ - private IPreferenceStore fPreferenceStore; - /** The editor's range indicator. */ - private Annotation fRangeIndicator; - /** The editor's source viewer configuration. */ - private SourceViewerConfiguration fConfiguration; - /** The editor's source viewer. */ - private ISourceViewer fSourceViewer; - /** - * The editor's selection provider. - * @since 2.1 - */ - private SelectionProvider fSelectionProvider= new SelectionProvider(); - /** - * The editor's selection listener. - * @since 3.0 - */ - private SelectionListener fSelectionListener; - /** The editor's font. */ - private Font fFont; /** - * The editor's foreground color. - * @since 2.0 - */ - private Color fForegroundColor; - /** - * The editor's background color. - * @since 2.0 - */ - private Color fBackgroundColor; - /** - * The editor's selection foreground color. - * @since 3.0 - */ - private Color fSelectionForegroundColor; - /** - * The editor's selection background color. - * @since 3.0 - */ - private Color fSelectionBackgroundColor; - /** - * The find scope's highlight color. - * @since 2.0 - */ - private Color fFindScopeHighlightColor; - - /** - * The editor's status line. - * @since 2.1 - */ - private IEditorStatusLine fEditorStatusLine; - /** The editor's vertical ruler. */ - private IVerticalRuler fVerticalRuler; - /** The editor's context menu id. */ - private String fEditorContextMenuId; - /** The ruler's context menu id. */ - private String fRulerContextMenuId; - /** The editor's help context id. */ - private String fHelpContextId; - /** The editor's presentation mode. */ - private boolean fShowHighlightRangeOnly; - /** The actions registered with the editor. */ - private Map fActions= new HashMap(10); - /** The actions marked as selection dependent. */ - private List fSelectionActions= new ArrayList(5); - /** The actions marked as content dependent. */ - private List fContentActions= new ArrayList(5); - /** - * The actions marked as property dependent. - * @since 2.0 - */ - private List fPropertyActions= new ArrayList(5); - /** - * The actions marked as state dependent. - * @since 2.0 - */ - private List fStateActions= new ArrayList(5); - /** The editor's action activation codes. */ - private List fActivationCodes= new ArrayList(2); - /** The verify key listener for activation code triggering. */ - private ActivationCodeTrigger fActivationCodeTrigger= new ActivationCodeTrigger(); - /** Context menu listener. */ - private IMenuListener fMenuListener; - /** Vertical ruler mouse listener. */ - private MouseListener fMouseListener; - /** Selection changed listener. */ - private ISelectionChangedListener fSelectionChangedListener; - /** Title image to be disposed. */ - private Image fTitleImage; - /** The text context menu to be disposed. */ - private Menu fTextContextMenu; - /** The ruler context menu to be disposed. */ - private Menu fRulerContextMenu; - /** The editor's element state listener. */ - private IElementStateListener fElementStateListener= new ElementStateListener(); - /** - * The editor's text input listener. - * @since 2.1 - */ - private TextInputListener fTextInputListener= new TextInputListener(); - /** The editor's text listener. */ - private TextListener fTextListener= new TextListener(); - /** The editor's property change listener. */ - private IPropertyChangeListener fPropertyChangeListener= new PropertyChangeListener(); - /** - * The editor's font properties change listener. - * @since 2.1 - */ - private IPropertyChangeListener fFontPropertyChangeListener= new FontPropertyChangeListener(); - - /** - * The editor's activation listener. - * @since 2.0 - */ - private ActivationListener fActivationListener= new ActivationListener(); - /** - * The map of the editor's status fields. - * @since 2.0 - */ - private Map fStatusFields; - /** - * The editor's cursor listener. - * @since 2.0 - */ - private ICursorListener fCursorListener; - /** - * The editor's remembered text selection. - * @since 2.0 - */ - private ISelection fRememberedSelection; - /** - * Indicates whether the editor runs in 1.0 context menu registration compatibility mode. - * @since 2.0 - */ - private boolean fCompatibilityMode= true; - /** - * The number of reentrances into error correction code while saving. - * @since 2.0 - */ - private int fErrorCorrectionOnSave; - /** - * The delete line target. - * @since 2.1 - */ - private DeleteLineTarget fDeleteLineTarget; - /** - * The incremental find target. - * @since 2.0 - */ - private IncrementalFindTarget fIncrementalFindTarget; - /** - * The mark region target. - * @since 2.0 - */ - private IMarkRegionTarget fMarkRegionTarget; - /** - * Cached modification stamp of the editor's input. - * @since 2.0 - */ - private long fModificationStamp= -1; - /** - * Ruler context menu listeners. - * @since 2.0 - */ - private List fRulerContextMenuListeners= new ArrayList(); - /** - * Indicates whether sanity checking in enabled. - * @since 2.0 - */ - private boolean fIsSanityCheckEnabled= true; - /** - * The find replace target. - * @since 2.1 - */ - private FindReplaceTarget fFindReplaceTarget; - /** - * Indicates whether state validation is enabled. - * @since 2.1 - */ - private boolean fIsStateValidationEnabled= true; - /** - * The key binding scopes of this editor. - * @since 2.1 - */ - private String[] fKeyBindingScopes; - /** - * Whether the overwrite mode can be turned on. - * @since 3.0 - */ - private boolean fIsOverwriteModeEnabled= true; - /** - * Whether the overwrite mode is currently on. - * @since 3.0 - */ - private boolean fIsOverwriting= false; - /** - * The editor's insert mode. - * @since 3.0 - */ - private InsertMode fInsertMode= SMART_INSERT; - /** - * The sequence of legal editor insert modes. - * @since 3.0 - */ - private List fLegalInsertModes= null; - /** - * The non-default caret. - * @since 3.0 - */ - private Caret fNonDefaultCaret; - /** - * The image used in non-default caret. - * @since 3.0 - */ - private Image fNonDefaultCaretImage; - /** - * The styled text's initial caret. - * @since 3.0 - */ - private Caret fInitialCaret; - - /** - * Creates a new text editor. If not explicitly set, this editor uses - * a <code>SourceViewerConfiguration</code> to configure its - * source viewer. This viewer does not have a range indicator installed, - * nor any menu id set. By default, the created editor runs in 1.0 context - * menu registration compatibility mode. - */ - protected AbstractTextEditor() { - super(); - fEditorContextMenuId= null; - fRulerContextMenuId= null; - fHelpContextId= null; - } - - /* - * @see ITextEditor#getDocumentProvider() - */ - public IDocumentProvider getDocumentProvider() { - return fExplicitDocumentProvider; - } - - /** - * Returns the editor's range indicator. May return <code>null</code> if no - * range indicator is installed. - * - * @return the editor's range indicator which may be <code>null</code> - */ - protected final Annotation getRangeIndicator() { - return fRangeIndicator; - } - - /** - * Returns the editor's source viewer configuration. May return <code>null</code> - * before the editor's part has been created and after disposal. - * - * @return the editor's source viewer configuration which may be <code>null</code> - */ - protected final SourceViewerConfiguration getSourceViewerConfiguration() { - return fConfiguration; - } - - /** - * Returns the editor's source viewer. May return <code>null</code> before - * the editor's part has been created and after disposal. - * - * @return the editor's source viewer which may be <code>null</code> - */ - protected final ISourceViewer getSourceViewer() { - return fSourceViewer; - } - - /** - * Returns the editor's vertical ruler. May return <code>null</code> before - * the editor's part has been created and after disposal. - * - * @return the editor's vertical ruler which may be <code>null</code> - */ - protected final IVerticalRuler getVerticalRuler() { - return fVerticalRuler; - } - - /** - * Returns the editor's context menu id. May return <code>null</code> before - * the editor's part has been created. - * - * @return the editor's context menu id which may be <code>null</code> - */ - protected final String getEditorContextMenuId() { - return fEditorContextMenuId; - } - - /** - * Returns the ruler's context menu id. May return <code>null</code> before - * the editor's part has been created. - * - * @return the ruler's context menu id which may be <code>null</code> - */ - protected final String getRulerContextMenuId() { - return fRulerContextMenuId; - } - - /** - * Returns the editor's help context id or <code>null</code> if none has - * been set. - * - * @return the editor's help context id which may be <code>null</code> - */ - protected final String getHelpContextId() { - return fHelpContextId; - } - - /** - * Returns this editor's preference store or <code>null</code> if none has - * been set. - * - * @return this editor's preference store which may be <code>null</code> - */ - protected final IPreferenceStore getPreferenceStore() { - return fPreferenceStore; - } - - /** - * Sets this editor's document provider. This method must be - * called before the editor's control is created. - * - * @param provider the document provider - */ - protected void setDocumentProvider(IDocumentProvider provider) { - Assert.isNotNull(provider); - fExplicitDocumentProvider= provider; - } - - /** - * Sets this editor's source viewer configuration used to configure its - * internal source viewer. This method must be called before the editor's - * control is created. If not, this editor uses a <code>SourceViewerConfiguration</code>. - * - * @param configuration the source viewer configuration object - */ - protected void setSourceViewerConfiguration(SourceViewerConfiguration configuration) { - Assert.isNotNull(configuration); - fConfiguration= configuration; - } - - /** - * Sets the annotation which this editor uses to represent the highlight - * range if the editor is configured to show the entire document. If the - * range indicator is not set, this editor will not show a range indication. - * - * @param rangeIndicator the annotation - */ - protected void setRangeIndicator(Annotation rangeIndicator) { - Assert.isNotNull(rangeIndicator); - fRangeIndicator= rangeIndicator; - } - - /** - * Sets this editor's context menu id. - * - * @param contextMenuId the context menu id - */ - protected void setEditorContextMenuId(String contextMenuId) { - Assert.isNotNull(contextMenuId); - fEditorContextMenuId= contextMenuId; - } - - /** - * Sets the ruler's context menu id. - * - * @param contextMenuId the context menu id - */ - protected void setRulerContextMenuId(String contextMenuId) { - Assert.isNotNull(contextMenuId); - fRulerContextMenuId= contextMenuId; - } - - /** - * Sets the context menu registration 1.0 compatibility mode. (See class - * description for more details.) - * - * @param compatible <code>true</code> if compatibility mode is enabled - * @since 2.0 - */ - protected final void setCompatibilityMode(boolean compatible) { - fCompatibilityMode= compatible; - } - - /** - * Sets the editor's help context id. - * - * @param helpContextId the help context id - */ - protected void setHelpContextId(String helpContextId) { - Assert.isNotNull(helpContextId); - fHelpContextId= helpContextId; - } - - /** - * Sets the keybinding scopes for this editor. - * - * @param scopes a non-empty array of keybinding scope identifiers - * @since 2.1 - */ - protected void setKeyBindingScopes(String[] scopes) { - Assert.isTrue(scopes != null && scopes.length > 0); - fKeyBindingScopes= scopes; - } - - /** - * Sets this editor's preference store. This method must be - * called before the editor's control is created. - * - * @param store the preference store or <code>null</code> to unset the - * preference store - */ - protected void setPreferenceStore(IPreferenceStore store) { - if (fPreferenceStore != null) - fPreferenceStore.removePropertyChangeListener(fPropertyChangeListener); - - fPreferenceStore= store; - - if (fPreferenceStore != null) - fPreferenceStore.addPropertyChangeListener(fPropertyChangeListener); - } - - /* - * @see ITextEditor#isEditable() - */ - public boolean isEditable() { - IDocumentProvider provider= getDocumentProvider(); - if (provider instanceof IDocumentProviderExtension) { - IDocumentProviderExtension extension= (IDocumentProviderExtension) provider; - return extension.isModifiable(getEditorInput()); - } - return false; - } - - /** - * {@inheritDoc} - * <p> - * Returns <code>null</code> after disposal. - * </p> - * - * @return the selection provider or <code>null</code> if the editor has - * been disposed - */ - public ISelectionProvider getSelectionProvider() { - return fSelectionProvider; - } - - /** - * Remembers the current selection of this editor. This method is called when, e.g., - * the content of the editor is about to be reverted to the saved state. This method - * remembers the selection in a semantic format, i.e., in a format which allows to - * restore the selection even if the originally selected text is no longer part of the - * editor's content. - * <p> - * Subclasses should implement this method including all necessary state. This - * default implementation remembers the textual range only and is thus purely - * syntactic.</p> - * - * @see #restoreSelection() - * @since 2.0 - */ - protected void rememberSelection() { - fRememberedSelection= doGetSelection(); - } - - /** - * Returns the current selection. - * @return ISelection - * @since 2.1 - */ - protected ISelection doGetSelection() { - ISelectionProvider sp= null; - if (fSourceViewer != null) - sp= fSourceViewer.getSelectionProvider(); - return (sp == null ? null : sp.getSelection()); - } - - /** - * Restores a selection previously remembered by <code>rememberSelection</code>. - * Subclasses may reimplement this method and thereby semantically adapt the - * remembered selection. This default implementation just selects the - * remembered textual range. - * - * @see #rememberSelection() - * @since 2.0 - */ - protected void restoreSelection() { - if (fRememberedSelection instanceof ITextSelection) { - ITextSelection textSelection= (ITextSelection)fRememberedSelection; - if (isValidSelection(textSelection.getOffset(), textSelection.getLength())) - doSetSelection(fRememberedSelection); - } - fRememberedSelection= null; - } - - /** - * Tells whether the given selection is valid. - * - * @param offset the offset of the selection - * @param length the length of the selection - * @return <code>true</code> if the selection is valid - * @since 2.1 - */ - private boolean isValidSelection(int offset, int length) { - IDocumentProvider provider= getDocumentProvider(); - if (provider != null) { - IDocument document= provider.getDocument(getEditorInput()); - if (document != null) { - int end= offset + length; - int documentLength= document.getLength(); - return 0 <= offset && offset <= documentLength && 0 <= end && end <= documentLength; - } - } - return false; - } - - /** - * Sets the given selection. - * @param selection - * @since 2.1 - */ - protected void doSetSelection(ISelection selection) { - if (selection instanceof ITextSelection) { - ITextSelection textSelection= (ITextSelection) selection; - selectAndReveal(textSelection.getOffset(), textSelection.getLength()); - } - } - - /** - * Creates and returns the listener on this editor's context menus. - * - * @return the menu listener - */ - protected final IMenuListener getContextMenuListener() { - if (fMenuListener == null) { - fMenuListener= new IMenuListener() { - - public void menuAboutToShow(IMenuManager menu) { - String id= menu.getId(); - if (getRulerContextMenuId().equals(id)) { - setFocus(); - rulerContextMenuAboutToShow(menu); - } else if (getEditorContextMenuId().equals(id)) { - setFocus(); - editorContextMenuAboutToShow(menu); - } - } - }; - } - return fMenuListener; - } - - /** - * Creates and returns the listener on this editor's vertical ruler. - * - * @return the mouse listener - */ - protected final MouseListener getRulerMouseListener() { - if (fMouseListener == null) { - fMouseListener= new MouseListener() { - - private boolean fDoubleClicked= false; - - private void triggerAction(String actionID) { - IAction action= getAction(actionID); - if (action != null) { - if (action instanceof IUpdate) - ((IUpdate) action).update(); - if (action.isEnabled()) - action.run(); - } - } - - public void mouseUp(MouseEvent e) { - setFocus(); - if (1 == e.button && !fDoubleClicked) - triggerAction(ITextEditorActionConstants.RULER_CLICK); - fDoubleClicked= false; - } - - public void mouseDoubleClick(MouseEvent e) { - if (1 == e.button) { - fDoubleClicked= true; - triggerAction(ITextEditorActionConstants.RULER_DOUBLE_CLICK); - } - } - - public void mouseDown(MouseEvent e) { - StyledText text= fSourceViewer.getTextWidget(); - if (text != null && !text.isDisposed()) { - Display display= text.getDisplay(); - Point location= display.getCursorLocation(); - fRulerContextMenu.setLocation(location.x, location.y); - } - } - }; - } - return fMouseListener; - } - - /** - * Returns this editor's selection changed listener to be installed - * on the editor's source viewer. - * - * @return the listener - */ - protected final ISelectionChangedListener getSelectionChangedListener() { - if (fSelectionChangedListener == null) { - fSelectionChangedListener= new ISelectionChangedListener() { - - private Runnable fRunnable= new Runnable() { - public void run() { - // check whether editor has not been disposed yet - if (fSourceViewer != null && fSourceViewer.getDocument() != null) { - updateSelectionDependentActions(); - } - } - }; - - private Display fDisplay; - - public void selectionChanged(SelectionChangedEvent event) { - if (fDisplay == null) - fDisplay= getSite().getShell().getDisplay(); - fDisplay.asyncExec(fRunnable); - handleCursorPositionChanged(); - } - }; - } - - return fSelectionChangedListener; - } - - /** - * Returns this editor's "cursor" listener to be installed on the editor's - * source viewer. This listener is listening to key and mouse button events. - * It triggers the updating of the status line by calling - * <code>handleCursorPositionChanged()</code>. - * - * @return the listener - * @since 2.0 - */ - protected final ICursorListener getCursorListener() { - if (fCursorListener == null) { - fCursorListener= new ICursorListener() { - - public void keyPressed(KeyEvent e) { - handleCursorPositionChanged(); - } - - public void keyReleased(KeyEvent e) { - } - - public void mouseDoubleClick(MouseEvent e) { - } - - public void mouseDown(MouseEvent e) { - } - - public void mouseUp(MouseEvent e) { - handleCursorPositionChanged(); - } - }; - } - return fCursorListener; - } - - /** - * Implements the <code>init</code> method of <code>IEditorPart</code>. - * Subclasses replacing <code>init</code> may choose to call this method in - * their implementation. - * - * @param window the site's workbench window - * @param site the editor's site - * @param input the editor input for the editor being created - * @throws PartInitException if {@link #doSetInput(IEditorInput)} fails or gets canceled - * - * @see org.eclipse.ui.IEditorPart#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput) - * @since 2.1 - */ - protected final void internalInit(IWorkbenchWindow window, final IEditorSite site, final IEditorInput input) throws PartInitException { - - IRunnableWithProgress runnable= new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - - if (getDocumentProvider() instanceof IDocumentProviderExtension2) { - IDocumentProviderExtension2 extension= (IDocumentProviderExtension2) getDocumentProvider(); - extension.setProgressMonitor(monitor); - } - - doSetInput(input); - - } catch (CoreException x) { - throw new InvocationTargetException(x); - } finally { - if (getDocumentProvider() instanceof IDocumentProviderExtension2) { - IDocumentProviderExtension2 extension= (IDocumentProviderExtension2) getDocumentProvider(); - extension.setProgressMonitor(null); - } - } - } - }; - - try { - window.run(false, true, runnable); - } catch (InterruptedException x) { - } catch (InvocationTargetException x) { - Throwable t= x.getTargetException(); - if (t instanceof CoreException) - throw new PartInitException(((CoreException) t).getStatus()); - throw new PartInitException(new Status(IStatus.ERROR, TextEditorPlugin.PLUGIN_ID, IStatus.OK, EditorMessages.getString("Editor.error.init"), t)); //$NON-NLS-1$ - } - } - - /* - * @see IEditorPart#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput) - */ - public void init(final IEditorSite site, final IEditorInput input) throws PartInitException { - - setSite(site); - - IWorkbenchWindow window= getSite().getWorkbenchWindow(); - internalInit(window, site, input); - - window.getPartService().addPartListener(fActivationListener); - window.getShell().addShellListener(fActivationListener); - } - - /** - * Creates the vertical ruler to be used by this editor. - * Subclasses may re-implement this method. - * - * @return the vertical ruler - */ - protected IVerticalRuler createVerticalRuler() { - return new VerticalRuler(VERTICAL_RULER_WIDTH); - } - - /** - * Creates the source viewer to be used by this editor. - * Subclasses may re-implement this method. - * - * @param parent the parent control - * @param ruler the vertical ruler - * @param styles style bits, <code>SWT.WRAP</code> is currently not supported - * @return the source viewer - */ - protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) { - return new SourceViewer(parent, ruler, styles); - } - - /** - * Initializes the drag and drop support for the given viewer based on - * provided editor adapter for drop target listeners. - * - * @param viewer the viewer - * @since 3.0 - */ - protected void initializeDragAndDrop(ISourceViewer viewer) { - ITextEditorDropTargetListener listener= (ITextEditorDropTargetListener) getAdapter(ITextEditorDropTargetListener.class); - - if (listener == null) { - Object object= Platform.getAdapterManager().loadAdapter(this, "org.eclipse.ui.texteditor.ITextEditorDropTargetListener"); //$NON-NLS-1$ - if (object instanceof ITextEditorDropTargetListener) - listener= (ITextEditorDropTargetListener)object; - } - - if (listener != null) { - DropTarget dropTarget = new DropTarget(viewer.getTextWidget(), DND.DROP_COPY | DND.DROP_MOVE); - dropTarget.setTransfer(listener.getTransfers()); - dropTarget.addDropListener(listener); - } - } - - /** - * The <code>AbstractTextEditor</code> implementation of this - * <code>IWorkbenchPart</code> method creates the vertical ruler and - * source viewer. - * <p> - * Subclasses may extend this method. Besides extending this method, the - * behavior of <code>createPartControl</code> may be customized by - * calling, extending or replacing the following methods: <br> - * Subclasses may supply customized implementations for some members using - * the following methods before <code>createPartControl</code> is invoked: - * <ul> - * <li> - * {@linkplain #setSourceViewerConfiguration(SourceViewerConfiguration) setSourceViewerConfiguration} - * to supply a custom source viewer configuration,</li> - * <li>{@linkplain #setRangeIndicator(Annotation) setRangeIndicator} to - * provide a range indicator,</li> - * <li>{@linkplain #setHelpContextId(String) setHelpContextId} to provide a - * help context id,</li> - * <li>{@linkplain #setEditorContextMenuId(String) setEditorContextMenuId} - * to set a custom context menu id,</li> - * <li>{@linkplain #setRulerContextMenuId(String) setRulerContextMenuId} to - * set a custom ruler context menu id.</li> - * </ul> - * <br> - * Subclasses may replace the following methods called from within - * <code>createPartControl</code>: - * <ul> - * <li>{@linkplain #createVerticalRuler() createVerticalRuler} to supply a - * custom vertical ruler,</li> - * <li>{@linkplain #createSourceViewer(Composite, IVerticalRuler, int) createSourceViewer} - * to supply a custom source viewer,</li> - * <li>{@linkplain #getSelectionProvider() getSelectionProvider} to supply - * a custom selection provider.</li> - * </ul> - * <br> - * Subclasses may extend the following methods called from within - * <code>createPartControl</code>: - * <ul> - * <li> - * {@linkplain #initializeViewerColors(ISourceViewer) initializeViewerColors} - * to customize the viewer color scheme (may also be replaced),</li> - * <li> - * {@linkplain #initializeDragAndDrop(ISourceViewer) initializeDragAndDrop} - * to customize drag and drop (may also be replaced),</li> - * <li>{@linkplain #createNavigationActions() createNavigationActions} to - * add navigation actions,</li> - * <li>{@linkplain #createActions() createActions} to add text editor - * actions.</li> - * </ul> - * </p> - * - * @param parent the parent composite - */ - public void createPartControl(Composite parent) { - - fVerticalRuler= createVerticalRuler(); - - int styles= SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION; - fSourceViewer= createSourceViewer(parent, fVerticalRuler, styles); - - if (fConfiguration == null) - fConfiguration= new SourceViewerConfiguration(); - fSourceViewer.configure(fConfiguration); - - if (fRangeIndicator != null) - fSourceViewer.setRangeIndicator(fRangeIndicator); - - fSourceViewer.addTextListener(fTextListener); - fSourceViewer.addTextInputListener(fTextListener); - getSelectionProvider().addSelectionChangedListener(getSelectionChangedListener()); - - initializeViewerFont(fSourceViewer); - initializeViewerColors(fSourceViewer); - initializeFindScopeColor(fSourceViewer); - initializeDragAndDrop(fSourceViewer); - - StyledText styledText= fSourceViewer.getTextWidget(); - - /* gestures commented out until proper solution (i.e. preference page) can be found - * for bug # 28417: - * - final Map gestureMap = new HashMap(); - - gestureMap.put("E", "org.eclipse.ui.navigate.forwardHistory"); - gestureMap.put("N", "org.eclipse.ui.file.save"); - gestureMap.put("NW", "org.eclipse.ui.file.saveAll"); - gestureMap.put("S", "org.eclipse.ui.file.close"); - gestureMap.put("SW", "org.eclipse.ui.file.closeAll"); - gestureMap.put("W", "org.eclipse.ui.navigate.backwardHistory"); - gestureMap.put("EN", "org.eclipse.ui.edit.copy"); - gestureMap.put("ES", "org.eclipse.ui.edit.paste"); - gestureMap.put("EW", "org.eclipse.ui.edit.cut"); - - Capture capture = Capture.create(); - capture.setControl(styledText); - - capture.addCaptureListener(new CaptureListener() { - public void gesture(Gesture gesture) { - if (gesture.getPen() == 3) { - String actionId = (String) gestureMap.get(Util.recognize(gesture.getPoints(), 20)); - - if (actionId != null) { - IKeyBindingService keyBindingService = getEditorSite().getKeyBindingService(); - - if (keyBindingService instanceof KeyBindingService) { - IAction action = ((KeyBindingService) keyBindingService).getAction(actionId); - - if (action != null) { - if (action instanceof IUpdate) - ((IUpdate) action).update(); - - if (action.isEnabled()) - action.run(); - } - } - - return; - } - - fTextContextMenu.setVisible(true); - } - }; - }); - */ - - styledText.addMouseListener(getCursorListener()); - styledText.addKeyListener(getCursorListener()); - - if (getHelpContextId() != null) - WorkbenchHelp.setHelp(styledText, getHelpContextId()); - - - String id= fEditorContextMenuId != null ? fEditorContextMenuId : DEFAULT_EDITOR_CONTEXT_MENU_ID; - - MenuManager manager= new MenuManager(id, id); - manager.setRemoveAllWhenShown(true); - manager.addMenuListener(getContextMenuListener()); - fTextContextMenu= manager.createContextMenu(styledText); - - // comment this line if using gestures, above. - styledText.setMenu(fTextContextMenu); - - if (fEditorContextMenuId != null) - getSite().registerContextMenu(fEditorContextMenuId, manager, getSelectionProvider()); - else if (fCompatibilityMode) - getSite().registerContextMenu(DEFAULT_EDITOR_CONTEXT_MENU_ID, manager, getSelectionProvider()); - - if ((fEditorContextMenuId != null && fCompatibilityMode) || fEditorContextMenuId == null) { - String partId= getSite().getId(); - if (partId != null) - getSite().registerContextMenu(partId + ".EditorContext", manager, getSelectionProvider()); //$NON-NLS-1$ - } - - if (fEditorContextMenuId == null) - fEditorContextMenuId= DEFAULT_EDITOR_CONTEXT_MENU_ID; - - - id= fRulerContextMenuId != null ? fRulerContextMenuId : DEFAULT_RULER_CONTEXT_MENU_ID; - manager= new MenuManager(id, id); - manager.setRemoveAllWhenShown(true); - manager.addMenuListener(getContextMenuListener()); - - Control rulerControl= fVerticalRuler.getControl(); - fRulerContextMenu= manager.createContextMenu(rulerControl); - rulerControl.setMenu(fRulerContextMenu); - rulerControl.addMouseListener(getRulerMouseListener()); - - if (fRulerContextMenuId != null) - getSite().registerContextMenu(fRulerContextMenuId, manager, getSelectionProvider()); - else if (fCompatibilityMode) - getSite().registerContextMenu(DEFAULT_RULER_CONTEXT_MENU_ID, manager, getSelectionProvider()); - - if ((fRulerContextMenuId != null && fCompatibilityMode) || fRulerContextMenuId == null) { - String partId= getSite().getId(); - if (partId != null) - getSite().registerContextMenu(partId + ".RulerContext", manager, getSelectionProvider()); //$NON-NLS-1$ - } - - if (fRulerContextMenuId == null) - fRulerContextMenuId= DEFAULT_RULER_CONTEXT_MENU_ID; - - getSite().setSelectionProvider(getSelectionProvider()); - - fSelectionListener= new SelectionListener(); - fSelectionListener.install(getSelectionProvider()); - fSelectionListener.setDocument(getDocumentProvider().getDocument(getEditorInput())); - - initializeActivationCodeTrigger(); - - createNavigationActions(); - createAccessibilityActions(); - createActions(); - - initializeSourceViewer(getEditorInput()); - - JFaceResources.getFontRegistry().addListener(fFontPropertyChangeListener); - } - - /** - * Initializes the activation code trigger. - * - * @since 2.1 - */ - private void initializeActivationCodeTrigger() { - fActivationCodeTrigger.install(); - fActivationCodeTrigger.setScopes(fKeyBindingScopes); - } - - /** - * Initializes the given viewer's font. - * - * @param viewer the viewer - * @since 2.0 - */ - private void initializeViewerFont(ISourceViewer viewer) { - - boolean isSharedFont= true; - Font font= null; - String symbolicFontName= getSymbolicFontName(); - - if (symbolicFontName != null) - font= JFaceResources.getFont(symbolicFontName); - else if (fPreferenceStore != null) { - // Backward compatibility - if (fPreferenceStore.contains(JFaceResources.TEXT_FONT) && !fPreferenceStore.isDefault(JFaceResources.TEXT_FONT)) { - FontData data= PreferenceConverter.getFontData(fPreferenceStore, JFaceResources.TEXT_FONT); - - if (data != null) { - isSharedFont= false; - font= new Font(viewer.getTextWidget().getDisplay(), data); - } - } - } - if (font == null) - font= JFaceResources.getTextFont(); - - setFont(viewer, font); - - if (fFont != null) { - fFont.dispose(); - fFont= null; - } - - if (!isSharedFont) - fFont= font; - } - - /** - * Sets the font for the given viewer sustaining selection and scroll position. - * - * @param sourceViewer the source viewer - * @param font the font - * @since 2.0 - */ - private void setFont(ISourceViewer sourceViewer, Font font) { - if (sourceViewer.getDocument() != null) { - - Point selection= sourceViewer.getSelectedRange(); - int topIndex= sourceViewer.getTopIndex(); - - StyledText styledText= sourceViewer.getTextWidget(); - Control parent= styledText; - if (sourceViewer instanceof ITextViewerExtension) { - ITextViewerExtension extension= (ITextViewerExtension) sourceViewer; - parent= extension.getControl(); - } - - parent.setRedraw(false); - - styledText.setFont(font); - - if (fVerticalRuler instanceof IVerticalRulerExtension) { - IVerticalRulerExtension e= (IVerticalRulerExtension) fVerticalRuler; - e.setFont(font); - } - - sourceViewer.setSelectedRange(selection.x , selection.y); - sourceViewer.setTopIndex(topIndex); - - if (parent instanceof Composite) { - Composite composite= (Composite) parent; - composite.layout(true); - } - - parent.setRedraw(true); - - - } else { - - StyledText styledText= sourceViewer.getTextWidget(); - styledText.setFont(font); - - if (fVerticalRuler instanceof IVerticalRulerExtension) { - IVerticalRulerExtension e= (IVerticalRulerExtension) fVerticalRuler; - e.setFont(font); - } - } - } - - /** - * Creates a color from the information stored in the given preference store. - * Returns <code>null</code> if there is no such information available. - * - * @param store the store to read from - * @param key the key used for the lookup in the preference store - * @param display the display used create the color - * @return the created color according to the specification in the preference store - * @since 2.0 - */ - private Color createColor(IPreferenceStore store, String key, Display display) { - - RGB rgb= null; - - if (store.contains(key)) { - - if (store.isDefault(key)) - rgb= PreferenceConverter.getDefaultColor(store, key); - else - rgb= PreferenceConverter.getColor(store, key); - - if (rgb != null) - return new Color(display, rgb); - } - - return null; - } - - /** - * Initializes the fore- and background colors of the given viewer for both - * normal and selected text. - * - * @param viewer the viewer to be initialized - * @since 2.0 - */ - protected void initializeViewerColors(ISourceViewer viewer) { - - IPreferenceStore store= getPreferenceStore(); - if (store != null) { - - StyledText styledText= viewer.getTextWidget(); - - // ----------- foreground color -------------------- - Color color= store.getBoolean(PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT) - ? null - : createColor(store, PREFERENCE_COLOR_FOREGROUND, styledText.getDisplay()); - styledText.setForeground(color); - - if (fForegroundColor != null) - fForegroundColor.dispose(); - - fForegroundColor= color; - - // ---------- background color ---------------------- - color= store.getBoolean(PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT) - ? null - : createColor(store, PREFERENCE_COLOR_BACKGROUND, styledText.getDisplay()); - styledText.setBackground(color); - - if (fBackgroundColor != null) - fBackgroundColor.dispose(); - - fBackgroundColor= color; - - // ----------- selection foreground color -------------------- - color= store.getBoolean(PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT) - ? null - : createColor(store, PREFERENCE_COLOR_SELECTION_FOREGROUND, styledText.getDisplay()); - styledText.setSelectionForeground(color); - - if (fSelectionForegroundColor != null) - fSelectionForegroundColor.dispose(); - - fSelectionForegroundColor= color; - - // ---------- selection background color ---------------------- - color= store.getBoolean(PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT) - ? null - : createColor(store, PREFERENCE_COLOR_SELECTION_BACKGROUND, styledText.getDisplay()); - styledText.setSelectionBackground(color); - - if (fSelectionBackgroundColor != null) - fSelectionBackgroundColor.dispose(); - - fSelectionBackgroundColor= color; - } - } - - /** - * Initializes the background color used for highlighting the document ranges - * defining search scopes. - * - * @param viewer the viewer to initialize - * @since 2.0 - */ - private void initializeFindScopeColor(ISourceViewer viewer) { - - IPreferenceStore store= getPreferenceStore(); - if (store != null) { - - StyledText styledText= viewer.getTextWidget(); - - Color color= createColor(store, PREFERENCE_COLOR_FIND_SCOPE, styledText.getDisplay()); - - IFindReplaceTarget target= viewer.getFindReplaceTarget(); - if (target != null && target instanceof IFindReplaceTargetExtension) - ((IFindReplaceTargetExtension) target).setScopeHighlightColor(color); - - if (fFindScopeHighlightColor != null) - fFindScopeHighlightColor.dispose(); - - fFindScopeHighlightColor= color; - } - } - - - /** - * Initializes the editor's source viewer based on the given editor input. - * - * @param input the editor input to be used to initialize the source viewer - */ - private void initializeSourceViewer(IEditorInput input) { - - IAnnotationModel model= getDocumentProvider().getAnnotationModel(input); - IDocument document= getDocumentProvider().getDocument(input); - - if (document != null) { - fSourceViewer.setDocument(document, model); - fSourceViewer.setEditable(isEditable()); - fSourceViewer.showAnnotations(model != null); - } - - if (fElementStateListener instanceof IElementStateListenerExtension) { - IElementStateListenerExtension extension= (IElementStateListenerExtension) fElementStateListener; - extension.elementStateValidationChanged(input, false); - } - - if (fInitialCaret == null) - fInitialCaret= getSourceViewer().getTextWidget().getCaret(); - - if (fIsOverwriting) - fSourceViewer.getTextWidget().invokeAction(ST.TOGGLE_OVERWRITE); - handleInsertModeChanged(); - } - - /** - * Initializes the editor's title based on the given editor input. - * - * @param input the editor input to be used - */ - private void initializeTitle(IEditorInput input) { - - Image oldImage= fTitleImage; - fTitleImage= null; - String title= ""; //$NON-NLS-1$ - - if (input != null) { - IEditorRegistry editorRegistry = getEditorSite().getPage().getWorkbenchWindow().getWorkbench().getEditorRegistry(); - IEditorDescriptor editorDesc= editorRegistry.findEditor(getSite().getId()); - ImageDescriptor imageDesc= editorDesc != null ? editorDesc.getImageDescriptor() : null; - - fTitleImage= imageDesc != null ? imageDesc.createImage() : null; - title= input.getName(); - } - - setTitleImage(fTitleImage); - setTitle(title); - - firePropertyChange(PROP_DIRTY); - - if (oldImage != null && !oldImage.isDisposed()) - oldImage.dispose(); - } - - /** - * Hook method for setting the document provider for the given input. - * This default implementation does nothing. Clients may - * reimplement. - * - * @param input the input of this editor. - * @since 3.0 - */ - protected void setDocumentProvider(IEditorInput input) { - } - - /** - * If there is no explicit document provider set, the implicit one is - * re-initialized based on the given editor input. - * - * @param input the editor input. - */ - private void updateDocumentProvider(IEditorInput input) { - - IProgressMonitor rememberedProgressMonitor= null; - - IDocumentProvider provider= getDocumentProvider(); - if (provider != null) { - provider.removeElementStateListener(fElementStateListener); - if (provider instanceof IDocumentProviderExtension2) { - IDocumentProviderExtension2 extension= (IDocumentProviderExtension2) provider; - rememberedProgressMonitor= extension.getProgressMonitor(); - extension.setProgressMonitor(null); - } - } - - setDocumentProvider(input); - - provider= getDocumentProvider(); - if (provider != null) { - provider.addElementStateListener(fElementStateListener); - if (provider instanceof IDocumentProviderExtension2) { - IDocumentProviderExtension2 extension= (IDocumentProviderExtension2) provider; - extension.setProgressMonitor(rememberedProgressMonitor); - } - } - } - - /** - * Called directly from <code>setInput</code> and from within a workspace - * runnable from <code>init</code>, this method does the actual setting - * of the editor input. Closes the editor if <code>input</code> is - * <code>null</code>. Disconnects from any previous editor input and its - * document provider and connects to the new one. - * <p> - * Subclasses may extend. - * </p> - * - * @param input the input to be set - * @exception CoreException if input cannot be connected to the document - * provider - */ - protected void doSetInput(IEditorInput input) throws CoreException { - - if (input == null) - - close(isSaveOnCloseNeeded()); - - else { - - IEditorInput oldInput= getEditorInput(); - if (oldInput != null) - getDocumentProvider().disconnect(oldInput); - - super.setInput(input); - - updateDocumentProvider(input); - - IDocumentProvider provider= getDocumentProvider(); - if (provider == null) { - IStatus s= new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.OK, EditorMessages.getString("Editor.error.no_provider"), null); //$NON-NLS-1$ - throw new CoreException(s); - } - - provider.connect(input); - - initializeTitle(input); - - if (fSourceViewer != null) - initializeSourceViewer(input); - - if (fIsOverwriting) - toggleOverwriteMode(); - setInsertMode((InsertMode) getLegalInsertModes().get(0)); - updateCaret(); - - updateStatusField(ITextEditorActionConstants.STATUS_CATEGORY_ELEMENT_STATE); - - if (fSelectionListener != null) - fSelectionListener.setDocument(getDocumentProvider().getDocument(input)); - } - } - - /* - * @see EditorPart#setInput(org.eclipse.ui.IEditorInput) - */ - public final void setInput(IEditorInput input) { - - try { - - doSetInput(input); - - } catch (CoreException x) { - String title= EditorMessages.getString("Editor.error.setinput.title"); //$NON-NLS-1$ - String msg= EditorMessages.getString("Editor.error.setinput.message"); //$NON-NLS-1$ - Shell shell= getSite().getShell(); - ErrorDialog.openError(shell, title, msg, x.getStatus()); - } - } - - /* - * @see ITextEditor#close - */ - public void close(final boolean save) { - - enableSanityChecking(false); - - Display display= getSite().getShell().getDisplay(); - display.asyncExec(new Runnable() { - public void run() { - if (fSourceViewer != null) { - // check whether editor has not been disposed yet - getSite().getPage().closeEditor(AbstractTextEditor.this, save); - } - } - }); - } - - /** - * The <code>AbstractTextEditor</code> implementation of this - * <code>IWorkbenchPart</code> method may be extended by subclasses. - * Subclasses must call <code>super.dispose()</code>. - * <p> - * Note that many methods may return <code>null</code> after the editor is - * disposed. - * </p> - */ - public void dispose() { - - if (fActivationListener != null) { - IWorkbenchWindow window= getSite().getWorkbenchWindow(); - window.getPartService().removePartListener(fActivationListener); - Shell shell= window.getShell(); - if (shell != null && !shell.isDisposed()) - shell.removeShellListener(fActivationListener); - fActivationListener= null; - } - - if (fTitleImage != null) { - fTitleImage.dispose(); - fTitleImage= null; - } - - if (fFont != null) { - fFont.dispose(); - fFont= null; - } - - disposeNonDefaultCaret(); - fInitialCaret= null; - - if (fForegroundColor != null) { - fForegroundColor.dispose(); - fForegroundColor= null; - } - - if (fBackgroundColor != null) { - fBackgroundColor.dispose(); - fBackgroundColor= null; - } - - if (fSelectionForegroundColor != null) { - fSelectionForegroundColor.dispose(); - fSelectionForegroundColor= null; - } - - if (fSelectionBackgroundColor != null) { - fSelectionBackgroundColor.dispose(); - fSelectionBackgroundColor= null; - } - - if (fFindScopeHighlightColor != null) { - fFindScopeHighlightColor.dispose(); - fFindScopeHighlightColor= null; - } - - if (fFontPropertyChangeListener != null) { - JFaceResources.getFontRegistry().removeListener(fFontPropertyChangeListener); - fFontPropertyChangeListener= null; - } - - if (fPropertyChangeListener != null) { - if (fPreferenceStore != null) { - fPreferenceStore.removePropertyChangeListener(fPropertyChangeListener); - fPreferenceStore= null; - } - fPropertyChangeListener= null; - } - - if (fActivationCodeTrigger != null) { - fActivationCodeTrigger.uninstall(); - fActivationCodeTrigger= null; - } - - if (fSelectionListener != null) { - fSelectionListener.uninstall(getSelectionProvider()); - fSelectionListener= null; - } - - disposeDocumentProvider(); - - if (fSourceViewer != null) { - - if (fTextListener != null) { - fSourceViewer.removeTextListener(fTextListener); - fSourceViewer.removeTextInputListener(fTextListener); - fTextListener= null; - } - - fTextInputListener= null; - fSelectionProvider= null; - fSourceViewer= null; - } - - if (fTextContextMenu != null) { - fTextContextMenu.dispose(); - fTextContextMenu= null; - } - - if (fRulerContextMenu != null) { - fRulerContextMenu.dispose(); - fRulerContextMenu= null; - } - - if (fActions != null) { - fActions.clear(); - fActions= null; - } - - if (fSelectionActions != null) { - fSelectionActions.clear(); - fSelectionActions= null; - } - - if (fContentActions != null) { - fContentActions.clear(); - fContentActions= null; - } - - if (fPropertyActions != null) { - fPropertyActions.clear(); - fPropertyActions= null; - } - - if (fStateActions != null) { - fStateActions.clear(); - fStateActions= null; - } - - if (fActivationCodes != null) { - fActivationCodes.clear(); - fActivationCodes= null; - } - - if (fEditorStatusLine != null) - fEditorStatusLine= null; - - if (fConfiguration != null) - fConfiguration= null; - - super.setInput(null); - - super.dispose(); - } - - /** - * Disposes of the connection with the document provider. Subclasses - * may extend. - * - * @since 3.0 - */ - protected void disposeDocumentProvider() { - IDocumentProvider provider= getDocumentProvider(); - if (provider != null) { - - IEditorInput input= getEditorInput(); - if (input != null) - provider.disconnect(input); - - if (fElementStateListener != null) { - provider.removeElementStateListener(fElementStateListener); - fElementStateListener= null; - } - - fExplicitDocumentProvider= null; - } - } - - /** - * Determines whether the given preference change affects the editor's - * presentation. This implementation always returns <code>false</code>. - * May be reimplemented by subclasses. - * - * @param event the event which should be investigated - * @return <code>true</code> if the event describes a preference change affecting the editor's presentation - * @since 2.0 - */ - protected boolean affectsTextPresentation(PropertyChangeEvent event) { - return false; - } - - /** - * Returns the symbolic font name for this editor as defined in XML. - * - * @return a String with the symbolic font name or <code>null</code> if - * none is defined - * @since 2.1 - */ - private String getSymbolicFontName() { - if (getConfigurationElement() != null) - return getConfigurationElement().getAttribute("symbolicFontName"); //$NON-NLS-1$ - else - return null; - } - - /** - * Returns the property preference key for the editor font. Subclasses may - * replace this method. - * - * @return a String with the key - * @since 2.1 - */ - protected final String getFontPropertyPreferenceKey() { - String symbolicFontName= getSymbolicFontName(); - - if (symbolicFontName != null) - return symbolicFontName; - else - return JFaceResources.TEXT_FONT; - } - - /** - * Handles a property change event describing a change of the editor's - * preference store and updates the preference related editor properties. - * <p> - * Subclasses may extend. - * </p> - * - * @param event the property change event - */ - protected void handlePreferenceStoreChanged(PropertyChangeEvent event) { - - if (fSourceViewer == null) - return; - - String property= event.getProperty(); - - if (getFontPropertyPreferenceKey().equals(property)) { - // There is a separate handler for font preference changes - return; - } else if (PREFERENCE_COLOR_FOREGROUND.equals(property) || PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT.equals(property) || - PREFERENCE_COLOR_BACKGROUND.equals(property) || PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT.equals(property) || - PREFERENCE_COLOR_SELECTION_FOREGROUND.equals(property) || PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT.equals(property) || - PREFERENCE_COLOR_SELECTION_BACKGROUND.equals(property) || PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT.equals(property)) - { - initializeViewerColors(fSourceViewer); - } else if (PREFERENCE_COLOR_FIND_SCOPE.equals(property)) { - initializeFindScopeColor(fSourceViewer); - } else if (PREFERENCE_USE_CUSTOM_CARETS.equals(property)) { - updateCaret(); - } else if (PREFERENCE_WIDE_CARET.equals(property)) { - updateCaret(); - } - - if (affectsTextPresentation(event)) - fSourceViewer.invalidateTextPresentation(); - } - - /** - * Returns the progress monitor related to this editor. It should not be - * necessary to extend this method. - * - * @return the progress monitor related to this editor - * @since 2.1 - */ - protected IProgressMonitor getProgressMonitor() { - - IProgressMonitor pm= null; - - IStatusLineManager manager= getStatusLineManager(); - if (manager != null) - pm= manager.getProgressMonitor(); - - return pm != null ? pm : new NullProgressMonitor(); - } - - /** - * Handles an external change of the editor's input element. Subclasses may - * extend. - */ - protected void handleEditorInputChanged() { - - String title; - String msg; - Shell shell= getSite().getShell(); - - final IDocumentProvider provider= getDocumentProvider(); - if (provider == null) { - // fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=15066 - close(false); - return; - } - - final IEditorInput input= getEditorInput(); - if (provider.isDeleted(input)) { - - if (isSaveAsAllowed()) { - - title= EditorMessages.getString("Editor.error.activated.deleted.save.title"); //$NON-NLS-1$ - msg= EditorMessages.getString("Editor.error.activated.deleted.save.message"); //$NON-NLS-1$ - - String[] buttons= { - EditorMessages.getString("Editor.error.activated.deleted.save.button.save"), //$NON-NLS-1$ - EditorMessages.getString("Editor.error.activated.deleted.save.button.close"), //$NON-NLS-1$ - }; - - MessageDialog dialog= new MessageDialog(shell, title, null, msg, MessageDialog.QUESTION, buttons, 0); - - if (dialog.open() == 0) { - IProgressMonitor pm= getProgressMonitor(); - performSaveAs(pm); - if (pm.isCanceled()) - handleEditorInputChanged(); - } else { - close(false); - } - - } else { - - title= EditorMessages.getString("Editor.error.activated.deleted.close.title"); //$NON-NLS-1$ - msg= EditorMessages.getString("Editor.error.activated.deleted.close.message"); //$NON-NLS-1$ - if (MessageDialog.openConfirm(shell, title, msg)) - close(false); - } - - } else { - - title= EditorMessages.getString("Editor.error.activated.outofsync.title"); //$NON-NLS-1$ - msg= EditorMessages.getString("Editor.error.activated.outofsync.message"); //$NON-NLS-1$ - - if (MessageDialog.openQuestion(shell, title, msg)) { - - - try { - if (provider instanceof IDocumentProviderExtension) { - IDocumentProviderExtension extension= (IDocumentProviderExtension) provider; - extension.synchronize(input); - } else { - doSetInput(input); - } - } catch (CoreException x) { - IStatus status= x.getStatus(); - if (status == null || status.getSeverity() != IStatus.CANCEL) { - title= EditorMessages.getString("Editor.error.refresh.outofsync.title"); //$NON-NLS-1$ - msg= EditorMessages.getString("Editor.error.refresh.outofsync.message"); //$NON-NLS-1$ - ErrorDialog.openError(shell, title, msg, x.getStatus()); - } - } - } - } - } - - /** - * The <code>AbstractTextEditor</code> implementation of this - * <code>IEditorPart</code> method calls <code>performSaveAs</code>. - * Subclasses may reimplement. - */ - public void doSaveAs() { - /* - * 1GEUSSR: ITPUI:ALL - User should never loose changes made in the editors. - * Changed Behavior to make sure that if called inside a regular save (because - * of deletion of input element) there is a way to report back to the caller. - */ - performSaveAs(getProgressMonitor()); - } - - /** - * Performs a save as and reports the result state back to the - * given progress monitor. This default implementation does nothing. - * Subclasses may reimplement. - * - * @param progressMonitor the progress monitor for communicating result state or <code>null</code> - */ - protected void performSaveAs(IProgressMonitor progressMonitor) { - } - - /** - * The <code>AbstractTextEditor</code> implementation of this - * <code>IEditorPart</code> method may be extended by subclasses. - * - * @param progressMonitor the progress monitor for communicating result state or <code>null</code> - */ - public void doSave(IProgressMonitor progressMonitor) { - - IDocumentProvider p= getDocumentProvider(); - if (p == null) - return; - - if (p.isDeleted(getEditorInput())) { - - if (isSaveAsAllowed()) { - - /* - * 1GEUSSR: ITPUI:ALL - User should never loose changes made in the editors. - * Changed Behavior to make sure that if called inside a regular save (because - * of deletion of input element) there is a way to report back to the caller. - */ - performSaveAs(progressMonitor); - - } else { - - Shell shell= getSite().getShell(); - String title= EditorMessages.getString("Editor.error.save.deleted.title"); //$NON-NLS-1$ - String msg= EditorMessages.getString("Editor.error.save.deleted.message"); //$NON-NLS-1$ - MessageDialog.openError(shell, title, msg); - } - - } else { - updateState(getEditorInput()); - validateState(getEditorInput()); - performSave(false, progressMonitor); - } - } - - /** - * Enables/disables sanity checking. - * @param enable <code>true</code> if sanity checking should be enabled, <code>false</code> otherwise - * @since 2.0 - */ - protected void enableSanityChecking(boolean enable) { - synchronized (this) { - fIsSanityCheckEnabled= enable; - } - } - - /** - * Checks the state of the given editor input if sanity checking is enabled. - * @param input the editor input whose state is to be checked - * @since 2.0 - */ - protected void safelySanityCheckState(IEditorInput input) { - boolean enabled= false; - - synchronized (this) { - enabled= fIsSanityCheckEnabled; - } - - if (enabled) - sanityCheckState(input); - } - - /** - * Checks the state of the given editor input. - * @param input the editor input whose state is to be checked - * @since 2.0 - */ - protected void sanityCheckState(IEditorInput input) { - - IDocumentProvider p= getDocumentProvider(); - if (p == null) - return; - - if (p instanceof IDocumentProviderExtension3) { - - IDocumentProviderExtension3 p3= (IDocumentProviderExtension3) p; - - long stamp= p.getModificationStamp(input); - if (stamp != fModificationStamp) { - fModificationStamp= stamp; - if (!p3.isSynchronized(input)) - handleEditorInputChanged(); - } - - } else { - - if (fModificationStamp == -1) - fModificationStamp= p.getSynchronizationStamp(input); - - long stamp= p.getModificationStamp(input); - if (stamp != fModificationStamp) { - fModificationStamp= stamp; - if (stamp != p.getSynchronizationStamp(input)) - handleEditorInputChanged(); - } - } - - updateState(getEditorInput()); - updateStatusField(ITextEditorActionConstants.STATUS_CATEGORY_ELEMENT_STATE); - } - - /** - * Enables/disables state validation. - * @param enable <code>true</code> if state validation should be enabled, <code>false</code> otherwise - * @since 2.1 - */ - protected void enableStateValidation(boolean enable) { - synchronized (this) { - fIsStateValidationEnabled= enable; - } - } - - /** - * Validates the state of the given editor input. The predominate intent - * of this method is to take any action probably necessary to ensure that - * the input can persistently be changed. - * - * @param input the input to be validated - * @since 2.0 - */ - protected void validateState(IEditorInput input) { - - IDocumentProvider provider= getDocumentProvider(); - if (! (provider instanceof IDocumentProviderExtension)) - return; - - IDocumentProviderExtension extension= (IDocumentProviderExtension) provider; - - try { - - extension.validateState(input, getSite().getShell()); - - } catch (CoreException x) { - IStatus status= x.getStatus(); - if (status == null || status.getSeverity() != IStatus.CANCEL) { - Bundle bundle = Platform.getBundle(PlatformUI.PLUGIN_ID); - ILog log= Platform.getLog(bundle); - log.log(x.getStatus()); - - Shell shell= getSite().getShell(); - String title= EditorMessages.getString("Editor.error.validateEdit.title"); //$NON-NLS-1$ - String msg= EditorMessages.getString("Editor.error.validateEdit.message"); //$NON-NLS-1$ - ErrorDialog.openError(shell, title, msg, x.getStatus()); - } - return; - } - - if (fSourceViewer != null) - fSourceViewer.setEditable(isEditable()); - - updateStateDependentActions(); - } - - /* - * @see org.eclipse.ui.texteditor.ITextEditorExtension2#validateEditorInputState() - * @since 2.1 - */ - public boolean validateEditorInputState() { - - boolean enabled= false; - - synchronized (this) { - enabled= fIsStateValidationEnabled; - } - - if (enabled) { - - ISourceViewer viewer= getSourceViewer(); - if (viewer == null) - return false; - - fTextInputListener.inputChanged= false; - viewer.addTextInputListener(fTextInputListener); - - try { - final IEditorInput input= getEditorInput(); - BusyIndicator.showWhile(getSite().getShell().getDisplay(), new Runnable() { - /* - * @see java.lang.Runnable#run() - */ - public void run() { - validateState(input); - } - }); - sanityCheckState(input); - return !isEditorInputReadOnly() && !fTextInputListener.inputChanged; - - } finally { - viewer.removeTextInputListener(fTextInputListener); - } - - } - - return !isEditorInputReadOnly(); - } - - /** - * Updates the state of the given editor input such as read-only flag. - * - * @param input the input to be validated - * @since 2.0 - */ - protected void updateState(IEditorInput input) { - IDocumentProvider provider= getDocumentProvider(); - if (provider instanceof IDocumentProviderExtension) { - IDocumentProviderExtension extension= (IDocumentProviderExtension) provider; - try { - - boolean wasReadOnly= isEditorInputReadOnly(); - extension.updateStateCache(input); - - if (fSourceViewer != null) - fSourceViewer.setEditable(isEditable()); - - if (wasReadOnly != isEditorInputReadOnly()) - updateStateDependentActions(); - - } catch (CoreException x) { - Bundle bundle = Platform.getBundle(PlatformUI.PLUGIN_ID); - ILog log= Platform.getLog(bundle); - log.log(x.getStatus()); - } - } - } - - /** - * Performs the save and handles errors appropriately. - * - * @param overwrite indicates whether or not overwriting is allowed - * @param progressMonitor the monitor in which to run the operation - * @since 3.0 - */ - protected void performSave(boolean overwrite, IProgressMonitor progressMonitor) { - - IDocumentProvider provider= getDocumentProvider(); - if (provider == null) - return; - - try { - - provider.aboutToChange(getEditorInput()); - IEditorInput input= getEditorInput(); - provider.saveDocument(progressMonitor, input, getDocumentProvider().getDocument(input), overwrite); - editorSaved(); - - } catch (CoreException x) { - IStatus status= x.getStatus(); - if (status == null || status.getSeverity() != IStatus.CANCEL) - handleExceptionOnSave(x, progressMonitor); - } finally { - provider.changed(getEditorInput()); - } - } - - /** - * Handles the given exception. If the exception reports an out-of-sync - * situation, this is reported to the user. Otherwise, the exception - * is generically reported. - * - * @param exception the exception to handle - * @param progressMonitor the progress monitor - */ - protected void handleExceptionOnSave(CoreException exception, IProgressMonitor progressMonitor) { - - try { - ++ fErrorCorrectionOnSave; - - Shell shell= getSite().getShell(); - - boolean isSynchronized= false; - IDocumentProvider p= getDocumentProvider(); - - if (p instanceof IDocumentProviderExtension3) { - IDocumentProviderExtension3 p3= (IDocumentProviderExtension3) p; - isSynchronized= p3.isSynchronized(getEditorInput()); - } else { - long modifiedStamp= p.getModificationStamp(getEditorInput()); - long synchStamp= p.getSynchronizationStamp(getEditorInput()); - isSynchronized= (modifiedStamp == synchStamp); - } - - if (fErrorCorrectionOnSave == 1 && !isSynchronized) { - - String title= EditorMessages.getString("Editor.error.save.outofsync.title"); //$NON-NLS-1$ - String msg= EditorMessages.getString("Editor.error.save.outofsync.message"); //$NON-NLS-1$ - - if (MessageDialog.openQuestion(shell, title, msg)) - performSave(true, progressMonitor); - else { - /* - * 1GEUPKR: ITPJUI:ALL - Loosing work with simultaneous edits - * Set progress monitor to canceled in order to report back - * to enclosing operations. - */ - if (progressMonitor != null) - progressMonitor.setCanceled(true); - } - } else { - - String title= EditorMessages.getString("Editor.error.save.title"); //$NON-NLS-1$ - String msg= EditorMessages.getString("Editor.error.save.message"); //$NON-NLS-1$ - ErrorDialog.openError(shell, title, msg, exception.getStatus()); - - /* - * 1GEUPKR: ITPJUI:ALL - Loosing work with simultaneous edits - * Set progress monitor to canceled in order to report back - * to enclosing operations. - */ - if (progressMonitor != null) - progressMonitor.setCanceled(true); - } - - } finally { - -- fErrorCorrectionOnSave; - } - } - - /** - * The <code>AbstractTextEditor</code> implementation of this - * <code>IEditorPart</code> method returns <code>false</code>. - * Subclasses may override. - * - * @return <code>false</code> - */ - public boolean isSaveAsAllowed() { - return false; - } - - /* - * @see EditorPart#isSaveOnCloseNeeded() - */ - public boolean isSaveOnCloseNeeded() { - IDocumentProvider p= getDocumentProvider(); - return p == null ? false : p.mustSaveDocument(getEditorInput()); - } - - /* - * @see EditorPart#isDirty() - */ - public boolean isDirty() { - IDocumentProvider p= getDocumentProvider(); - return p == null ? false : p.canSaveDocument(getEditorInput()); - } - - /** - * The <code>AbstractTextEditor</code> implementation of this - * <code>ITextEditor</code> method may be extended by subclasses. - */ - public void doRevertToSaved() { - IDocumentProvider p= getDocumentProvider(); - if (p == null) - return; - - performRevert(); - } - - /** - * Performs revert and handles errors appropriately. - * <p> - * Subclasses may extend. - * </p> - * - * @since 3.0 - */ - protected void performRevert() { - - IDocumentProvider provider= getDocumentProvider(); - if (provider == null) - return; - - try { - - provider.aboutToChange(getEditorInput()); - provider.resetDocument(getEditorInput()); - editorSaved(); - - } catch (CoreException x) { - IStatus status= x.getStatus(); - if (status == null || status.getSeverity() != IStatus.CANCEL ) { - Shell shell= getSite().getShell(); - String title= EditorMessages.getString("Editor.error.revert.title"); //$NON-NLS-1$ - String msg= EditorMessages.getString("Editor.error.revert.message"); //$NON-NLS-1$ - ErrorDialog.openError(shell, title, msg, x.getStatus()); - } - } finally { - provider.changed(getEditorInput()); - } - } - - /** - * Performs any additional action necessary to perform after the input - * document's content has been replaced. - * <p> - * Clients may extended this method. - * - * @since 3.0 - */ - protected void handleElementContentReplaced() { - } - - /* - * @see ITextEditor#setAction(String, IAction) - */ - public void setAction(String actionID, IAction action) { - Assert.isNotNull(actionID); - if (action == null) { - action= (IAction) fActions.remove(actionID); - if (action != null) - fActivationCodeTrigger.unregisterActionFromKeyActivation(action); - } else { - fActions.put(actionID, action); - fActivationCodeTrigger.registerActionForKeyActivation(action); - } - } - - /* - * @see ITextEditor#setActionActivationCode(String, char, int, int) - */ - public void setActionActivationCode(String actionID, char activationCharacter, int activationKeyCode, int activationStateMask) { - - Assert.isNotNull(actionID); - - ActionActivationCode found= findActionActivationCode(actionID); - if (found == null) { - found= new ActionActivationCode(actionID); - fActivationCodes.add(found); - } - - found.fCharacter= activationCharacter; - found.fKeyCode= activationKeyCode; - found.fStateMask= activationStateMask; - } - - /** - * Returns the activation code registered for the specified action. - * - * @param actionID the action id - * @return the registered activation code or <code>null</code> if no code has been installed - */ - private ActionActivationCode findActionActivationCode(String actionID) { - int size= fActivationCodes.size(); - for (int i= 0; i < size; i++) { - ActionActivationCode code= (ActionActivationCode) fActivationCodes.get(i); - if (actionID.equals(code.fActionId)) - return code; - } - return null; - } - - /* - * @see ITextEditor#removeActionActivationCode(String) - */ - public void removeActionActivationCode(String actionID) { - Assert.isNotNull(actionID); - ActionActivationCode code= findActionActivationCode(actionID); - if (code != null) - fActivationCodes.remove(code); - } - - /* - * @see ITextEditor#getAction(String) - */ - public IAction getAction(String actionID) { - Assert.isNotNull(actionID); - IAction action= (IAction) fActions.get(actionID); - - if (action == null) { - action= findContributedAction(actionID); - if (action != null) - setAction(actionID, action); - } - - return action; - } - - /** - * Returns the action with the given action id that has been contributed via XML to this editor. - * The lookup honors the dependencies of plug-ins. - * - * @param actionID the action id to look up - * @return the action that has been contributed - * @since 2.0 - */ - private IAction findContributedAction(String actionID) { - List actions= new ArrayList(); - IConfigurationElement[] elements= Platform.getExtensionRegistry().getConfigurationElementsFor(PlatformUI.PLUGIN_ID, "editorActions"); //$NON-NLS-1$ - for (int i= 0; i < elements.length; i++) { - IConfigurationElement element= elements[i]; - if (TAG_CONTRIBUTION_TYPE.equals(element.getName())) { - if (!getSite().getId().equals(element.getAttribute("targetID"))) //$NON-NLS-1$ - continue; - - IConfigurationElement[] children= element.getChildren("action"); //$NON-NLS-1$ - for (int j= 0; j < children.length; j++) { - IConfigurationElement child= children[j]; - if (actionID.equals(child.getAttribute("actionID"))) //$NON-NLS-1$ - actions.add(child); - } - } - } - int actionSize= actions.size(); - if (actionSize > 0) { - IConfigurationElement element; - if (actionSize > 1) { - IConfigurationElement[] actionArray= (IConfigurationElement[])actions.toArray(new IConfigurationElement[actionSize]); - ConfigurationElementSorter sorter= new ConfigurationElementSorter() { - /** - * {@inheritDoc} - */ - public IConfigurationElement getConfigurationElement(Object object) { - return (IConfigurationElement)object; - } - }; - sorter.sort(actionArray); - element= actionArray[0]; - } else - element= (IConfigurationElement)actions.get(0); - - String defId = element.getAttribute(ActionDescriptor.ATT_DEFINITION_ID); - return new EditorPluginAction(element, this, defId, IAction.AS_UNSPECIFIED); //$NON-NLS-1$ - } - - return null; - } - - /** - * Updates the specified action by calling <code>IUpdate.update</code> - * if applicable. - * - * @param actionId the action id - */ - private void updateAction(String actionId) { - Assert.isNotNull(actionId); - if (fActions != null) { - IAction action= (IAction) fActions.get(actionId); - if (action instanceof IUpdate) - ((IUpdate) action).update(); - } - } - - /** - * Marks or unmarks the given action to be updated on text selection changes. - * - * @param actionId the action id - * @param mark <code>true</code> if the action is selection dependent - */ - public void markAsSelectionDependentAction(String actionId, boolean mark) { - Assert.isNotNull(actionId); - if (mark) { - if (!fSelectionActions.contains(actionId)) - fSelectionActions.add(actionId); - } else - fSelectionActions.remove(actionId); - } - - /** - * Marks or unmarks the given action to be updated on content changes. - * - * @param actionId the action id - * @param mark <code>true</code> if the action is content dependent - */ - public void markAsContentDependentAction(String actionId, boolean mark) { - Assert.isNotNull(actionId); - if (mark) { - if (!fContentActions.contains(actionId)) - fContentActions.add(actionId); - } else - fContentActions.remove(actionId); - } - - /** - * Marks or unmarks the given action to be updated on property changes. - * - * @param actionId the action id - * @param mark <code>true</code> if the action is property dependent - * @since 2.0 - */ - public void markAsPropertyDependentAction(String actionId, boolean mark) { - Assert.isNotNull(actionId); - if (mark) { - if (!fPropertyActions.contains(actionId)) - fPropertyActions.add(actionId); - } else - fPropertyActions.remove(actionId); - } - - /** - * Marks or unmarks the given action to be updated on state changes. - * - * @param actionId the action id - * @param mark <code>true</code> if the action is state dependent - * @since 2.0 - */ - public void markAsStateDependentAction(String actionId, boolean mark) { - Assert.isNotNull(actionId); - if (mark) { - if (!fStateActions.contains(actionId)) - fStateActions.add(actionId); - } else - fStateActions.remove(actionId); - } - - /** - * Updates all selection dependent actions. - */ - protected void updateSelectionDependentActions() { - if (fSelectionActions != null) { - Iterator e= fSelectionActions.iterator(); - while (e.hasNext()) - updateAction((String) e.next()); - } - } - - /** - * Updates all content dependent actions. - */ - protected void updateContentDependentActions() { - if (fContentActions != null) { - Iterator e= fContentActions.iterator(); - while (e.hasNext()) - updateAction((String) e.next()); - } - } - - /** - * Updates all property dependent actions. - * @since 2.0 - */ - protected void updatePropertyDependentActions() { - if (fPropertyActions != null) { - Iterator e= fPropertyActions.iterator(); - while (e.hasNext()) - updateAction((String) e.next()); - } - } - - /** - * Updates all state dependent actions. - * @since 2.0 - */ - protected void updateStateDependentActions() { - if (fStateActions != null) { - Iterator e= fStateActions.iterator(); - while (e.hasNext()) - updateAction((String) e.next()); - } - } - - /** - * Creates action entries for all SWT StyledText actions as defined in - * <code>org.eclipse.swt.custom.ST</code>. Overwrites and - * extends the list of these actions afterwards. - * <p> - * Subclasses may extend. - * </p> - * @since 2.0 - */ - protected void createNavigationActions() { - - IAction action; - - StyledText textWidget= getSourceViewer().getTextWidget(); - for (int i= 0; i < ACTION_MAP.length; i++) { - IdMapEntry entry= ACTION_MAP[i]; - action= new TextNavigationAction(textWidget, entry.getAction()); - action.setActionDefinitionId(entry.getActionId()); - setAction(entry.getActionId(), action); - } - - action= new ToggleOverwriteModeAction(EditorMessages.getResourceBundle(), "Editor.ToggleOverwriteMode."); //$NON-NLS-1$ - action.setActionDefinitionId(ITextEditorActionDefinitionIds.TOGGLE_OVERWRITE); - setAction(ITextEditorActionDefinitionIds.TOGGLE_OVERWRITE, action); - textWidget.setKeyBinding(SWT.INSERT, SWT.NULL); - - action= new ScrollLinesAction(-1); - action.setActionDefinitionId(ITextEditorActionDefinitionIds.SCROLL_LINE_UP); - setAction(ITextEditorActionDefinitionIds.SCROLL_LINE_UP, action); - - action= new ScrollLinesAction(1); - action.setActionDefinitionId(ITextEditorActionDefinitionIds.SCROLL_LINE_DOWN); - setAction(ITextEditorActionDefinitionIds.SCROLL_LINE_DOWN, action); - - action= new LineEndAction(textWidget, false); - action.setActionDefinitionId(ITextEditorActionDefinitionIds.LINE_END); - setAction(ITextEditorActionDefinitionIds.LINE_END, action); - - action= new LineStartAction(textWidget, false); - action.setActionDefinitionId(ITextEditorActionDefinitionIds.LINE_START); - setAction(ITextEditorActionDefinitionIds.LINE_START, action); - - action= new LineEndAction(textWidget, true); - action.setActionDefinitionId(ITextEditorActionDefinitionIds.SELECT_LINE_END); - setAction(ITextEditorActionDefinitionIds.SELECT_LINE_END, action); - - action= new LineStartAction(textWidget, true); - action.setActionDefinitionId(ITextEditorActionDefinitionIds.SELECT_LINE_START); - setAction(ITextEditorActionDefinitionIds.SELECT_LINE_START, action); - - setActionActivationCode(ITextEditorActionDefinitionIds.LINE_END, (char) 0, SWT.END, SWT.NONE); - setActionActivationCode(ITextEditorActionDefinitionIds.LINE_START, (char) 0, SWT.HOME, SWT.NONE); - setActionActivationCode(ITextEditorActionDefinitionIds.SELECT_LINE_END, (char) 0, SWT.END, SWT.SHIFT); - setActionActivationCode(ITextEditorActionDefinitionIds.SELECT_LINE_START, (char) 0, SWT.HOME, SWT.SHIFT); - - // to accommodate https://bugs.eclipse.org/bugs/show_bug.cgi?id=51516 - // nullify handling of DELETE key by StyledText - textWidget.setKeyBinding(SWT.DEL, SWT.NULL); - } - - /** - * Creates this editor's accessibility actions. - * @since 2.0 - */ - private void createAccessibilityActions() { - IAction action= new ShowRulerContextMenuAction(); - action.setActionDefinitionId(ITextEditorActionDefinitionIds.SHOW_RULER_CONTEXT_MENU); - setAction(ITextEditorActionDefinitionIds.SHOW_RULER_CONTEXT_MENU, action); - } - - /** - * Creates this editor's standard actions and connects them with the global - * workbench actions. - * <p> - * Subclasses may extend.</p> - */ - protected void createActions() { - - ResourceAction action; - - action= new TextOperationAction(EditorMessages.getResourceBundle(), "Editor.Undo.", this, ITextOperationTarget.UNDO); //$NON-NLS-1$ - action.setHelpContextId(IAbstractTextEditorHelpContextIds.UNDO_ACTION); - action.setActionDefinitionId(ITextEditorActionDefinitionIds.UNDO); - setAction(ITextEditorActionConstants.UNDO, action); - - action= new TextOperationAction(EditorMessages.getResourceBundle(), "Editor.Redo.", this, ITextOperationTarget.REDO); //$NON-NLS-1$ - action.setHelpContextId(IAbstractTextEditorHelpContextIds.REDO_ACTION); - action.setActionDefinitionId(ITextEditorActionDefinitionIds.REDO); - setAction(ITextEditorActionConstants.REDO, action); - - action= new TextOperationAction(EditorMessages.getResourceBundle(), "Editor.Cut.", this, ITextOperationTarget.CUT); //$NON-NLS-1$ - action.setHelpContextId(IAbstractTextEditorHelpContextIds.CUT_ACTION); - action.setActionDefinitionId(ITextEditorActionDefinitionIds.CUT); - setAction(ITextEditorActionConstants.CUT, action); - - action= new TextOperationAction(EditorMessages.getResourceBundle(), "Editor.Copy.", this, ITextOperationTarget.COPY, true); //$NON-NLS-1$ - action.setHelpContextId(IAbstractTextEditorHelpContextIds.COPY_ACTION); - action.setActionDefinitionId(ITextEditorActionDefinitionIds.COPY); - setAction(ITextEditorActionConstants.COPY, action); - - action= new TextOperationAction(EditorMessages.getResourceBundle(), "Editor.Paste.", this, ITextOperationTarget.PASTE); //$NON-NLS-1$ - action.setHelpContextId(IAbstractTextEditorHelpContextIds.PASTE_ACTION); - action.setActionDefinitionId(ITextEditorActionDefinitionIds.PASTE); - setAction(ITextEditorActionConstants.PASTE, action); - - action= new TextOperationAction(EditorMessages.getResourceBundle(), "Editor.Delete.", this, ITextOperationTarget.DELETE); //$NON-NLS-1$ - action.setHelpContextId(IAbstractTextEditorHelpContextIds.DELETE_ACTION); - action.setActionDefinitionId(ITextEditorActionDefinitionIds.DELETE); - setAction(ITextEditorActionConstants.DELETE, action); - - action= new DeleteLineAction(EditorMessages.getResourceBundle(), "Editor.DeleteLine.", this, DeleteLineAction.WHOLE, false); //$NON-NLS-1$ - action.setHelpContextId(IAbstractTextEditorHelpContextIds.DELETE_LINE_ACTION); - action.setActionDefinitionId(ITextEditorActionDefinitionIds.DELETE_LINE); - setAction(ITextEditorActionConstants.DELETE_LINE, action); - - action= new DeleteLineAction(EditorMessages.getResourceBundle(), "Editor.CutLine.", this, DeleteLineAction.WHOLE, true); //$NON-NLS-1$ - action.setHelpContextId(IAbstractTextEditorHelpContextIds.CUT_LINE_ACTION); - action.setActionDefinitionId(ITextEditorActionDefinitionIds.CUT_LINE); - setAction(ITextEditorActionConstants.CUT_LINE, action); - - action= new DeleteLineAction(EditorMessages.getResourceBundle(), "Editor.DeleteLineToBeginning.", this, DeleteLineAction.TO_BEGINNING, false); //$NON-NLS-1$ - action.setHelpContextId(IAbstractTextEditorHelpContextIds.DELETE_LINE_TO_BEGINNING_ACTION); - action.setActionDefinitionId(ITextEditorActionDefinitionIds.DELETE_LINE_TO_BEGINNING); - setAction(ITextEditorActionConstants.DELETE_LINE_TO_BEGINNING, action); - - action= new DeleteLineAction(EditorMessages.getResourceBundle(), "Editor.CutLineToBeginning.", this, DeleteLineAction.TO_BEGINNING, true); //$NON-NLS-1$ - action.setHelpContextId(IAbstractTextEditorHelpContextIds.CUT_LINE_TO_BEGINNING_ACTION); - action.setActionDefinitionId(ITextEditorActionDefinitionIds.CUT_LINE_TO_BEGINNING); - setAction(ITextEditorActionConstants.CUT_LINE_TO_BEGINNING, action); - - action= new DeleteLineAction(EditorMessages.getResourceBundle(), "Editor.DeleteLineToEnd.", this, DeleteLineAction.TO_END, false); //$NON-NLS-1$ - action.setHelpContextId(IAbstractTextEditorHelpContextIds.DELETE_LINE_TO_END_ACTION); - action.setActionDefinitionId(ITextEditorActionDefinitionIds.DELETE_LINE_TO_END); - setAction(ITextEditorActionConstants.DELETE_LINE_TO_END, action); - - action= new DeleteLineAction(EditorMessages.getResourceBundle(), "Editor.CutLineToEnd.", this, DeleteLineAction.TO_END, true); //$NON-NLS-1$ - action.setHelpContextId(IAbstractTextEditorHelpContextIds.CUT_LINE_TO_END_ACTION); - action.setActionDefinitionId(ITextEditorActionDefinitionIds.CUT_LINE_TO_END); - setAction(ITextEditorActionConstants.CUT_LINE_TO_END, action); - - action= new MarkAction(EditorMessages.getResourceBundle(), "Editor.SetMark.", this, MarkAction.SET_MARK); //$NON-NLS-1$ - action.setHelpContextId(IAbstractTextEditorHelpContextIds.SET_MARK_ACTION); - action.setActionDefinitionId(ITextEditorActionDefinitionIds.SET_MARK); - setAction(ITextEditorActionConstants.SET_MARK, action); - - action= new MarkAction(EditorMessages.getResourceBundle(), "Editor.ClearMark.", this, MarkAction.CLEAR_MARK); //$NON-NLS-1$ - action.setHelpContextId(IAbstractTextEditorHelpContextIds.CLEAR_MARK_ACTION); - action.setActionDefinitionId(ITextEditorActionDefinitionIds.CLEAR_MARK); - setAction(ITextEditorActionConstants.CLEAR_MARK, action); - - action= new MarkAction(EditorMessages.getResourceBundle(), "Editor.SwapMark.", this, MarkAction.SWAP_MARK); //$NON-NLS-1$ - action.setHelpContextId(IAbstractTextEditorHelpContextIds.SWAP_MARK_ACTION); - action.setActionDefinitionId(ITextEditorActionDefinitionIds.SWAP_MARK); - setAction(ITextEditorActionConstants.SWAP_MARK, action); - - action= new TextOperationAction(EditorMessages.getResourceBundle(), "Editor.SelectAll.", this, ITextOperationTarget.SELECT_ALL, true); //$NON-NLS-1$ - action.setHelpContextId(IAbstractTextEditorHelpContextIds.SELECT_ALL_ACTION); - action.setActionDefinitionId(ITextEditorActionDefinitionIds.SELECT_ALL); - setAction(ITextEditorActionConstants.SELECT_ALL, action); - - action= new ShiftAction(EditorMessages.getResourceBundle(), "Editor.ShiftRight.", this, ITextOperationTarget.SHIFT_RIGHT); //$NON-NLS-1$ - action.setHelpContextId(IAbstractTextEditorHelpContextIds.SHIFT_RIGHT_ACTION); - action.setActionDefinitionId(ITextEditorActionDefinitionIds.SHIFT_RIGHT); - setAction(ITextEditorActionConstants.SHIFT_RIGHT, action); - - action= new ShiftAction(EditorMessages.getResourceBundle(), "Editor.ShiftRight.", this, ITextOperationTarget.SHIFT_RIGHT) { //$NON-NLS-1$ - public void update() { - updateForTab(); - } - }; - setAction(ITextEditorActionConstants.SHIFT_RIGHT_TAB, action); - - action= new ShiftAction(EditorMessages.getResourceBundle(), "Editor.ShiftLeft.", this, ITextOperationTarget.SHIFT_LEFT); //$NON-NLS-1$ - action.setHelpContextId(IAbstractTextEditorHelpContextIds.SHIFT_LEFT_ACTION); - action.setActionDefinitionId(ITextEditorActionDefinitionIds.SHIFT_LEFT); - setAction(ITextEditorActionConstants.SHIFT_LEFT, action); - - action= new TextOperationAction(EditorMessages.getResourceBundle(), "Editor.Print.", this, ITextOperationTarget.PRINT, true); //$NON-NLS-1$ - action.setHelpContextId(IAbstractTextEditorHelpContextIds.PRINT_ACTION); - action.setActionDefinitionId(ITextEditorActionDefinitionIds.PRINT); - setAction(ITextEditorActionConstants.PRINT, action); - - action= new FindReplaceAction(EditorMessages.getResourceBundle(), "Editor.FindReplace.", this); //$NON-NLS-1$ - action.setHelpContextId(IAbstractTextEditorHelpContextIds.FIND_ACTION); - action.setActionDefinitionId(ITextEditorActionDefinitionIds.FIND_REPLACE); - setAction(ITextEditorActionConstants.FIND, action); - - action= new FindNextAction(EditorMessages.getResourceBundle(), "Editor.FindNext.", this, true); //$NON-NLS-1$ - action.setHelpContextId(IAbstractTextEditorHelpContextIds.FIND_NEXT_ACTION); - action.setActionDefinitionId(ITextEditorActionDefinitionIds.FIND_NEXT); - setAction(ITextEditorActionConstants.FIND_NEXT, action); - - action= new FindNextAction(EditorMessages.getResourceBundle(), "Editor.FindPrevious.", this, false); //$NON-NLS-1$ - action.setHelpContextId(IAbstractTextEditorHelpContextIds.FIND_PREVIOUS_ACTION); - action.setActionDefinitionId(ITextEditorActionDefinitionIds.FIND_PREVIOUS); - setAction(ITextEditorActionConstants.FIND_PREVIOUS, action); - - action= new IncrementalFindAction(EditorMessages.getResourceBundle(), "Editor.FindIncremental.", this, true); //$NON-NLS-1$ - action.setHelpContextId(IAbstractTextEditorHelpContextIds.FIND_INCREMENTAL_ACTION); - action.setActionDefinitionId(ITextEditorActionDefinitionIds.FIND_INCREMENTAL); - setAction(ITextEditorActionConstants.FIND_INCREMENTAL, action); - - action= new IncrementalFindAction(EditorMessages.getResourceBundle(), "Editor.FindIncrementalReverse.", this, false); //$NON-NLS-1$ - action.setHelpContextId(IAbstractTextEditorHelpContextIds.FIND_INCREMENTAL_REVERSE_ACTION); - action.setActionDefinitionId(ITextEditorActionDefinitionIds.FIND_INCREMENTAL_REVERSE); - setAction(ITextEditorActionConstants.FIND_INCREMENTAL_REVERSE, action); - - action= new SaveAction(EditorMessages.getResourceBundle(), "Editor.Save.", this); //$NON-NLS-1$ - action.setHelpContextId(IAbstractTextEditorHelpContextIds.SAVE_ACTION); - /* - * if the line below is uncommented then the key binding does not work any more - * see https://bugs.eclipse.org/bugs/show_bug.cgi?id=53417 - */ -// action.setActionDefinitionId(ITextEditorActionDefinitionIds.SAVE); - setAction(ITextEditorActionConstants.SAVE, action); - - action= new RevertToSavedAction(EditorMessages.getResourceBundle(), "Editor.Revert.", this); //$NON-NLS-1$ - action.setHelpContextId(IAbstractTextEditorHelpContextIds.REVERT_TO_SAVED_ACTION); - action.setActionDefinitionId(ITextEditorActionDefinitionIds.REVERT_TO_SAVED); - setAction(ITextEditorActionConstants.REVERT_TO_SAVED, action); - - action= new GotoLineAction(EditorMessages.getResourceBundle(), "Editor.GotoLine.", this); //$NON-NLS-1$ - action.setHelpContextId(IAbstractTextEditorHelpContextIds.GOTO_LINE_ACTION); - action.setActionDefinitionId(ITextEditorActionDefinitionIds.LINE_GOTO); - setAction(ITextEditorActionConstants.GOTO_LINE, action); - - action = new MoveLinesAction(EditorMessages.getResourceBundle(), "Editor.MoveLinesUp.", this, true, false); //$NON-NLS-1$ - action.setHelpContextId(IAbstractTextEditorHelpContextIds.MOVE_LINES_ACTION); - action.setActionDefinitionId(ITextEditorActionDefinitionIds.MOVE_LINES_UP); - setAction(ITextEditorActionConstants.MOVE_LINE_UP, action); - - action = new MoveLinesAction(EditorMessages.getResourceBundle(), "Editor.MoveLinesDown.", this, false, false); //$NON-NLS-1$ - action.setHelpContextId(IAbstractTextEditorHelpContextIds.MOVE_LINES_ACTION); - action.setActionDefinitionId(ITextEditorActionDefinitionIds.MOVE_LINES_DOWN); - setAction(ITextEditorActionConstants.MOVE_LINE_DOWN, action); - - action = new MoveLinesAction(EditorMessages.getResourceBundle(), "Editor.CopyLineUp.", this, true, true); //$NON-NLS-1$ - action.setHelpContextId(IAbstractTextEditorHelpContextIds.COPY_LINES_ACTION); - action.setActionDefinitionId(ITextEditorActionDefinitionIds.COPY_LINES_UP); - setAction(ITextEditorActionConstants.COPY_LINE_UP, action); - - action = new MoveLinesAction(EditorMessages.getResourceBundle(), "Editor.CopyLineDown.", this, false, true); //$NON-NLS-1$ - action.setHelpContextId(IAbstractTextEditorHelpContextIds.COPY_LINES_ACTION); - action.setActionDefinitionId(ITextEditorActionDefinitionIds.COPY_LINES_DOWN); - setAction(ITextEditorActionConstants.COPY_LINE_DOWN, action); - - action = new CaseAction(EditorMessages.getResourceBundle(), "Editor.UpperCase.", this, true); //$NON-NLS-1$ - action.setHelpContextId(IAbstractTextEditorHelpContextIds.UPPER_CASE_ACTION); - action.setActionDefinitionId(ITextEditorActionDefinitionIds.UPPER_CASE); - setAction(ITextEditorActionConstants.UPPER_CASE, action); - - action = new CaseAction(EditorMessages.getResourceBundle(), "Editor.LowerCase.", this, false); //$NON-NLS-1$ - action.setHelpContextId(IAbstractTextEditorHelpContextIds.LOWER_CASE_ACTION); - action.setActionDefinitionId(ITextEditorActionDefinitionIds.LOWER_CASE); - setAction(ITextEditorActionConstants.LOWER_CASE, action); - - action = new InsertLineAction(EditorMessages.getResourceBundle(), "Editor.SmartEnter.", this, false); //$NON-NLS-1$ - action.setHelpContextId(IAbstractTextEditorHelpContextIds.SMART_ENTER_ACTION); - action.setActionDefinitionId(ITextEditorActionDefinitionIds.SMART_ENTER); - setAction(ITextEditorActionConstants.SMART_ENTER, action); - - action = new InsertLineAction(EditorMessages.getResourceBundle(), "Editor.SmartEnterInverse.", this, true); //$NON-NLS-1$ - action.setHelpContextId(IAbstractTextEditorHelpContextIds.SMART_ENTER_ACTION); - action.setActionDefinitionId(ITextEditorActionDefinitionIds.SMART_ENTER_INVERSE); - setAction(ITextEditorActionConstants.SMART_ENTER_INVERSE, action); - - action = new ToggleInsertModeAction(EditorMessages.getResourceBundle(), "Editor.ToggleInsertMode."); //$NON-NLS-1$ - action.setHelpContextId(IAbstractTextEditorHelpContextIds.TOGGLE_INSERT_MODE_ACTION); - action.setActionDefinitionId(ITextEditorActionDefinitionIds.TOGGLE_INSERT_MODE); - setAction(ITextEditorActionConstants.TOGGLE_INSERT_MODE, action); - - markAsContentDependentAction(ITextEditorActionConstants.UNDO, true); - markAsContentDependentAction(ITextEditorActionConstants.REDO, true); - markAsContentDependentAction(ITextEditorActionConstants.FIND, true); - markAsContentDependentAction(ITextEditorActionConstants.FIND_NEXT, true); - markAsContentDependentAction(ITextEditorActionConstants.FIND_PREVIOUS, true); - markAsContentDependentAction(ITextEditorActionConstants.FIND_INCREMENTAL, true); - markAsContentDependentAction(ITextEditorActionConstants.FIND_INCREMENTAL_REVERSE, true); - - markAsSelectionDependentAction(ITextEditorActionConstants.CUT, true); - markAsSelectionDependentAction(ITextEditorActionConstants.COPY, true); - markAsSelectionDependentAction(ITextEditorActionConstants.PASTE, true); - markAsSelectionDependentAction(ITextEditorActionConstants.DELETE, true); - markAsSelectionDependentAction(ITextEditorActionConstants.SHIFT_RIGHT, true); - markAsSelectionDependentAction(ITextEditorActionConstants.SHIFT_RIGHT_TAB, true); - markAsSelectionDependentAction(ITextEditorActionConstants.UPPER_CASE, true); - markAsSelectionDependentAction(ITextEditorActionConstants.LOWER_CASE, true); - - markAsPropertyDependentAction(ITextEditorActionConstants.UNDO, true); - markAsPropertyDependentAction(ITextEditorActionConstants.REDO, true); - markAsPropertyDependentAction(ITextEditorActionConstants.REVERT_TO_SAVED, true); - - markAsStateDependentAction(ITextEditorActionConstants.UNDO, true); - markAsStateDependentAction(ITextEditorActionConstants.REDO, true); - markAsStateDependentAction(ITextEditorActionConstants.CUT, true); - markAsStateDependentAction(ITextEditorActionConstants.PASTE, true); - markAsStateDependentAction(ITextEditorActionConstants.DELETE, true); - markAsStateDependentAction(ITextEditorActionConstants.SHIFT_RIGHT, true); - markAsStateDependentAction(ITextEditorActionConstants.SHIFT_RIGHT_TAB, true); - markAsStateDependentAction(ITextEditorActionConstants.SHIFT_LEFT, true); - markAsStateDependentAction(ITextEditorActionConstants.FIND, true); - markAsStateDependentAction(ITextEditorActionConstants.DELETE_LINE, true); - markAsStateDependentAction(ITextEditorActionConstants.DELETE_LINE_TO_BEGINNING, true); - markAsStateDependentAction(ITextEditorActionConstants.DELETE_LINE_TO_END, true); - markAsStateDependentAction(ITextEditorActionConstants.MOVE_LINE_UP, true); - markAsStateDependentAction(ITextEditorActionConstants.MOVE_LINE_DOWN, true); - markAsStateDependentAction(ITextEditorActionConstants.CUT_LINE, true); - markAsStateDependentAction(ITextEditorActionConstants.CUT_LINE_TO_BEGINNING, true); - markAsStateDependentAction(ITextEditorActionConstants.CUT_LINE_TO_END, true); - - setActionActivationCode(ITextEditorActionConstants.SHIFT_RIGHT_TAB,'\t', -1, SWT.NONE); - setActionActivationCode(ITextEditorActionConstants.SHIFT_LEFT, '\t', -1, SWT.SHIFT); - } - - /** - * Convenience method to add the action installed under the given action id to the given menu. - * @param menu the menu to add the action to - * @param actionId the id of the action to be added - */ - protected final void addAction(IMenuManager menu, String actionId) { - IAction action= getAction(actionId); - if (action != null) { - if (action instanceof IUpdate) - ((IUpdate) action).update(); - menu.add(action); - } - } - - /** - * Convenience method to add the action installed under the given action id to the specified group of the menu. - * @param menu the menu to add the action to - * @param group the group in the menu - * @param actionId the id of the action to add - */ - protected final void addAction(IMenuManager menu, String group, String actionId) { - IAction action= getAction(actionId); - if (action != null) { - if (action instanceof IUpdate) - ((IUpdate) action).update(); - - IMenuManager subMenu= menu.findMenuUsingPath(group); - if (subMenu != null) - subMenu.add(action); - else - menu.appendToGroup(group, action); - } - } - - /** - * Convenience method to add a new group after the specified group. - * @param menu the menu to add the new group to - * @param existingGroup the group after which to insert the new group - * @param newGroup the new group - */ - protected final void addGroup(IMenuManager menu, String existingGroup, String newGroup) { - IMenuManager subMenu= menu.findMenuUsingPath(existingGroup); - if (subMenu != null) - subMenu.add(new Separator(newGroup)); - else - menu.appendToGroup(existingGroup, new Separator(newGroup)); - } - - /** - * Sets up the ruler context menu before it is made visible. - * <p> - * Subclasses may extend to add other actions.</p> - * - * @param menu the menu - */ - protected void rulerContextMenuAboutToShow(IMenuManager menu) { - - menu.add(new Separator(ITextEditorActionConstants.GROUP_REST)); - menu.add(new Separator(ITextEditorActionConstants.MB_ADDITIONS)); - - for (Iterator i = fRulerContextMenuListeners.iterator(); i.hasNext();) - ((IMenuListener) i.next()).menuAboutToShow(menu); - - addAction(menu, ITextEditorActionConstants.RULER_MANAGE_BOOKMARKS); - addAction(menu, ITextEditorActionConstants.RULER_MANAGE_TASKS); - } - - /** - * Sets up this editor's context menu before it is made visible. - * <p> - * Subclasses may extend to add other actions.</p> - * - * @param menu the menu - */ - protected void editorContextMenuAboutToShow(IMenuManager menu) { - - menu.add(new Separator(ITextEditorActionConstants.GROUP_UNDO)); - menu.add(new Separator(ITextEditorActionConstants.GROUP_COPY)); - menu.add(new Separator(ITextEditorActionConstants.GROUP_PRINT)); - menu.add(new Separator(ITextEditorActionConstants.GROUP_EDIT)); - menu.add(new Separator(ITextEditorActionConstants.GROUP_FIND)); - menu.add(new Separator(ITextEditorActionConstants.GROUP_ADD)); - menu.add(new Separator(ITextEditorActionConstants.GROUP_REST)); - menu.add(new Separator(ITextEditorActionConstants.MB_ADDITIONS)); - menu.add(new Separator(ITextEditorActionConstants.GROUP_SAVE)); - - if (isEditable()) { - addAction(menu, ITextEditorActionConstants.GROUP_UNDO, ITextEditorActionConstants.UNDO); - addAction(menu, ITextEditorActionConstants.GROUP_UNDO, ITextEditorActionConstants.REVERT_TO_SAVED); - addAction(menu, ITextEditorActionConstants.GROUP_COPY, ITextEditorActionConstants.CUT); - addAction(menu, ITextEditorActionConstants.GROUP_COPY, ITextEditorActionConstants.COPY); - addAction(menu, ITextEditorActionConstants.GROUP_COPY, ITextEditorActionConstants.PASTE); - addAction(menu, ITextEditorActionConstants.GROUP_SAVE, ITextEditorActionConstants.SAVE); - } else { - addAction(menu, ITextEditorActionConstants.GROUP_COPY, ITextEditorActionConstants.COPY); - } - } - - /** - * Returns the status line manager of this editor. - * @return the status line manager of this editor - * @since 2.0 - */ - private IStatusLineManager getStatusLineManager() { - - IEditorActionBarContributor contributor= getEditorSite().getActionBarContributor(); - if (!(contributor instanceof EditorActionBarContributor)) - return null; - - IActionBars actionBars= ((EditorActionBarContributor) contributor).getActionBars(); - if (actionBars == null) - return null; - - return actionBars.getStatusLineManager(); - } - - /* - * @see IAdaptable#getAdapter(java.lang.Class) - */ - public Object getAdapter(Class required) { - - if (IEditorStatusLine.class.equals(required)) { - if (fEditorStatusLine == null) { - IStatusLineManager statusLineManager= getStatusLineManager(); - ISelectionProvider selectionProvider= getSelectionProvider(); - if (statusLineManager != null && selectionProvider != null) - fEditorStatusLine= new EditorStatusLine(statusLineManager, selectionProvider); - } - return fEditorStatusLine; - } - - if (IVerticalRulerInfo.class.equals(required)) { - if (fVerticalRuler != null) - return fVerticalRuler; - } - - if (IMarkRegionTarget.class.equals(required)) { - if (fMarkRegionTarget == null) { - IStatusLineManager manager= getStatusLineManager(); - if (manager != null) - fMarkRegionTarget= (fSourceViewer == null ? null : new MarkRegionTarget(fSourceViewer, manager)); - } - return fMarkRegionTarget; - } - - if (DeleteLineTarget.class.equals(required)){ - if (fDeleteLineTarget == null) { - fDeleteLineTarget = new DeleteLineTarget(fSourceViewer); - } - return fDeleteLineTarget; - } - - if (IncrementalFindTarget.class.equals(required)) { - if (fIncrementalFindTarget == null) { - IStatusLineManager manager= getStatusLineManager(); - if (manager != null) - fIncrementalFindTarget= (fSourceViewer == null ? null : new IncrementalFindTarget(fSourceViewer, manager)); - } - return fIncrementalFindTarget; - } - - if (IFindReplaceTarget.class.equals(required)) { - if (fFindReplaceTarget == null) { - IFindReplaceTarget target= (fSourceViewer == null ? null : fSourceViewer.getFindReplaceTarget()); - if (target != null) { - fFindReplaceTarget= new FindReplaceTarget(this, target); - if (fFindScopeHighlightColor != null) - fFindReplaceTarget.setScopeHighlightColor(fFindScopeHighlightColor); - } - } - return fFindReplaceTarget; - } - - if (ITextOperationTarget.class.equals(required)) - return (fSourceViewer == null ? null : fSourceViewer.getTextOperationTarget()); - - if (IRewriteTarget.class.equals(required)) { - if (fSourceViewer instanceof ITextViewerExtension) { - ITextViewerExtension extension= (ITextViewerExtension) fSourceViewer; - return extension.getRewriteTarget(); - } - return null; - } - - if (Control.class.equals(required)) - return fSourceViewer != null ? fSourceViewer.getTextWidget() : null; - - return super.getAdapter(required); - } - - /* - * @see IWorkbenchPart#setFocus() - */ - public void setFocus() { - if (fSourceViewer != null && fSourceViewer.getTextWidget() != null) - fSourceViewer.getTextWidget().setFocus(); - } - - /* - * @see ITextEditor#showsHighlightRangeOnly() - */ - public boolean showsHighlightRangeOnly() { - return fShowHighlightRangeOnly; - } - - /* - * @see ITextEditor#showHighlightRangeOnly(boolean) - */ - public void showHighlightRangeOnly(boolean showHighlightRangeOnly) { - fShowHighlightRangeOnly= showHighlightRangeOnly; - } - - /* - * @see ITextEditor#setHighlightRange(int, int, boolean) - */ - public void setHighlightRange(int offset, int length, boolean moveCursor) { - if (fSourceViewer == null) - return; - - if (fShowHighlightRangeOnly) { - if (moveCursor) - fSourceViewer.setVisibleRegion(offset, length); - } else { - IRegion rangeIndication= fSourceViewer.getRangeIndication(); - if (rangeIndication == null || offset != rangeIndication.getOffset() || length != rangeIndication.getLength()) - fSourceViewer.setRangeIndication(offset, length, moveCursor); - } - } - - /* - * @see ITextEditor#getHighlightRange() - */ - public IRegion getHighlightRange() { - if (fSourceViewer == null) - return null; - - if (fShowHighlightRangeOnly) - return getCoverage(fSourceViewer); - - return fSourceViewer.getRangeIndication(); - } - - /* - * @see ITextEditor#resetHighlightRange - */ - public void resetHighlightRange() { - if (fSourceViewer == null) - return; - - if (fShowHighlightRangeOnly) - fSourceViewer.resetVisibleRegion(); - else - fSourceViewer.removeRangeIndication(); - } - - /** - * Adjusts the highlight range so that at least the specified range - * is highlighted. - * <p> - * Subclasses may re-implement this method.</p> - * - * @param offset the offset of the range which at least should be highlighted - * @param length the length of the range which at least should be highlighted - */ - protected void adjustHighlightRange(int offset, int length) { - if (fSourceViewer == null) - return; - - if (fSourceViewer instanceof ITextViewerExtension5) { - ITextViewerExtension5 extension= (ITextViewerExtension5) fSourceViewer; - extension.exposeModelRange(new Region(offset, length)); - } else if (!isVisible(fSourceViewer, offset, length)) { - fSourceViewer.resetVisibleRegion(); - } - } - - /* - * @see ITextEditor#selectAndReveal(int, int) - */ - public void selectAndReveal(int start, int length) { - selectAndReveal(start, length, start, length); - } - - /** - * Selects and reveals the specified ranges in this text editor. - * - * @param selectionStart the offset of the selection - * @param selectionLength the length of the selection - * @param revealStart the offset of the revealed range - * @param revealLength the length of the revealed range - * @since 3.0 - */ - protected void selectAndReveal(int selectionStart, int selectionLength, int revealStart, int revealLength) { - if (fSourceViewer == null) - return; - - ISelection selection= getSelectionProvider().getSelection(); - if (selection instanceof TextSelection) { - TextSelection textSelection= (TextSelection) selection; - if (textSelection.getOffset() != 0 || textSelection.getLength() != 0) - markInNavigationHistory(); - } - - StyledText widget= fSourceViewer.getTextWidget(); - widget.setRedraw(false); - { - adjustHighlightRange(revealStart, revealLength); - fSourceViewer.revealRange(revealStart, revealLength); - - fSourceViewer.setSelectedRange(selectionStart, selectionLength); - - markInNavigationHistory(); - } - widget.setRedraw(true); - } - - /* - * @see org.eclipse.ui.INavigationLocationProvider#createNavigationLocation() - * @since 2.1 - */ - public INavigationLocation createEmptyNavigationLocation() { - return new TextSelectionNavigationLocation(this, false); - } - - /* - * @see org.eclipse.ui.INavigationLocationProvider#createNavigationLocation() - */ - public INavigationLocation createNavigationLocation() { - return new TextSelectionNavigationLocation(this, true); - } - - /** - * Writes a check mark of the given situation into the navigation history. - * @since 2.1 - */ - protected void markInNavigationHistory() { - IWorkbenchPage page= getEditorSite().getPage(); - page.getNavigationHistory().markLocation(this); - } - - /** - * Hook which gets called when the editor has been saved. - * Subclasses may extend. - * @since 2.1 - */ - protected void editorSaved() { - IWorkbenchPage page= getEditorSite().getPage(); - INavigationLocation[] locations= page.getNavigationHistory().getLocations(); - IEditorInput input= getEditorInput(); - for (int i= 0; i < locations.length; i++) { - if (locations[i] instanceof TextSelectionNavigationLocation) { - if(input.equals(locations[i].getInput())) { - TextSelectionNavigationLocation location= (TextSelectionNavigationLocation) locations[i]; - location.partSaved(this); - } - } - } - } - - /* - * @see WorkbenchPart#firePropertyChange(int) - */ - protected void firePropertyChange(int property) { - super.firePropertyChange(property); - updatePropertyDependentActions(); - } - - /* - * @see ITextEditorExtension#setStatusField(IStatusField, String) - * @since 2.0 - */ - public void setStatusField(IStatusField field, String category) { - Assert.isNotNull(category); - if (field != null) { - - if (fStatusFields == null) - fStatusFields= new HashMap(3); - - fStatusFields.put(category, field); - updateStatusField(category); - - } else if (fStatusFields != null) - fStatusFields.remove(category); - - if (fIncrementalFindTarget != null && ITextEditorActionConstants.STATUS_CATEGORY_FIND_FIELD.equals(category)) - fIncrementalFindTarget.setStatusField(field); - } - - /** - * Returns the current status field for the given status category. - * - * @param category the status category - * @return the current status field for the given status category - * @since 2.0 - */ - protected IStatusField getStatusField(String category) { - if (category != null && fStatusFields != null) - return (IStatusField) fStatusFields.get(category); - return null; - } - - /** - * Returns whether this editor is in overwrite or insert mode. - * - * @return <code>true</code> if in insert mode, <code>false</code> for overwrite mode - * @since 2.0 - */ - protected boolean isInInsertMode() { - return !fIsOverwriting; - } - - /* - * @see org.eclipse.ui.texteditor.ITextEditorExtension3#getInsertMode() - * @since 3.0 - */ - public InsertMode getInsertMode() { - return fInsertMode; - } - - /* - * @see org.eclipse.ui.texteditor.ITextEditorExtension3#setInsertMode(org.eclipse.ui.texteditor.ITextEditorExtension3.InsertMode) - * @since 3.0 - */ - public void setInsertMode(InsertMode newMode) { - List legalModes= getLegalInsertModes(); - if (!legalModes.contains(newMode)) - throw new IllegalArgumentException(); - - fInsertMode= newMode; - - handleInsertModeChanged(); - } - - /** - * Returns the set of legal insert modes. If insert modes are configured all defined insert modes - * are legal. - * - * @return the set of legal insert modes - * @since 3.0 - */ - protected List getLegalInsertModes() { - if (fLegalInsertModes == null) { - fLegalInsertModes= new ArrayList(); - fLegalInsertModes.add(SMART_INSERT); - fLegalInsertModes.add(INSERT); - } - return fLegalInsertModes; - } - - private void switchToNextInsertMode() { - - InsertMode mode= getInsertMode(); - List legalModes= getLegalInsertModes(); - - int i= 0; - while (i < legalModes.size()) { - if (legalModes.get(i) == mode) break; - ++ i; - } - - i= (i + 1) % legalModes.size(); - InsertMode newMode= (InsertMode) legalModes.get(i); - setInsertMode(newMode); - } - - private void toggleOverwriteMode() { - if (fIsOverwriteModeEnabled) { - fIsOverwriting= !fIsOverwriting; - fSourceViewer.getTextWidget().invokeAction(ST.TOGGLE_OVERWRITE); - handleInsertModeChanged(); - } - } - - /** - * Configures the given insert mode as legal or illegal. This call is ignored if the set of legal - * input modes would be empty after the call. - * - * @param mode the insert mode to be configured - * @param legal <code>true</code> if the given mode is legal, <code>false</code> otherwise - * @since 3.0 - */ - protected void configureInsertMode(InsertMode mode, boolean legal) { - List legalModes= getLegalInsertModes(); - if (legal) { - if (!legalModes.contains(mode)) - legalModes.add(mode); - } else if (legalModes.size() > 1) { - if (getInsertMode() == mode) - switchToNextInsertMode(); - legalModes.remove(mode); - } - } - - /** - * Sets the overwrite mode enablement. - * - * @param enable <code>true</code> to enable new overwrite mode, - * <code>false</code> to disable - * @since 3.0 - */ - protected void enableOverwriteMode(boolean enable) { - if (fIsOverwriting && !enable) - toggleOverwriteMode(); - fIsOverwriteModeEnabled= enable; - } - - private Caret createOverwriteCaret(StyledText styledText) { - Caret caret= new Caret(styledText, SWT.NULL); - GC gc= new GC(styledText); - // XXX this overwrite box is not proportional-font aware - // take 'a' as a medium sized character - Point charSize= gc.stringExtent("a"); //$NON-NLS-1$ - caret.setSize(charSize.x, styledText.getLineHeight()); - gc.dispose(); - - return caret; - } - - private Caret createInsertCaret(StyledText styledText) { - Caret caret= new Caret(styledText, SWT.NULL); - caret.setSize(getCaretWidthPreference(), styledText.getLineHeight()); - return caret; - } - - private Image createRawInsertModeCaretImage(StyledText styledText) { - - PaletteData caretPalette= new PaletteData(new RGB[] {new RGB (0,0,0), new RGB (255,255,255)}); - int width= getCaretWidthPreference(); - int widthOffset= width - 1; - ImageData imageData = new ImageData(4 + widthOffset, styledText.getLineHeight(), 1, caretPalette); - Display display = styledText.getDisplay(); - Image bracketImage= new Image(display, imageData); - GC gc = new GC (bracketImage); - gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE)); - gc.setLineWidth(1); - int height= imageData.height / 3; - // gap between two bars of one third of the height - // draw boxes using lines as drawing a line of a certain width produces - // rounded corners. - for (int i= 0; i < width ; i++) { - gc.drawLine(i, 0, i, height - 1); - gc.drawLine(i, imageData.height - height, i, imageData.height - 1); - } - - gc.dispose(); - - return bracketImage; - } - - private Caret createRawInsertModeCaret(StyledText styledText) { - // don't draw special raw caret if no smart mode is enabled - if (!getLegalInsertModes().contains(SMART_INSERT)) - return createInsertCaret(styledText); - - Caret caret= new Caret(styledText, SWT.NULL); - Image image= createRawInsertModeCaretImage(styledText); - if (image != null) - caret.setImage(image); - else - caret.setSize(getCaretWidthPreference(), styledText.getLineHeight()); - - return caret; - } - - private int getCaretWidthPreference() { - if (getPreferenceStore() != null && getPreferenceStore().getBoolean(PREFERENCE_WIDE_CARET)) - return WIDE_CARET_WIDTH; - - return SINGLE_CARET_WIDTH; - } - - private void updateCaret() { - - if (getSourceViewer() == null) - return; - - StyledText styledText= getSourceViewer().getTextWidget(); - - InsertMode mode= getInsertMode(); - - styledText.setCaret(null); - disposeNonDefaultCaret(); - - if (getPreferenceStore() == null || !getPreferenceStore().getBoolean(PREFERENCE_USE_CUSTOM_CARETS)) - Assert.isTrue(fNonDefaultCaret == null); - else if (fIsOverwriting) - fNonDefaultCaret= createOverwriteCaret(styledText); - else if (SMART_INSERT == mode) - fNonDefaultCaret= createInsertCaret(styledText); - else if (INSERT == mode) - fNonDefaultCaret= createRawInsertModeCaret(styledText); - - if (fNonDefaultCaret != null) { - styledText.setCaret(fNonDefaultCaret); - fNonDefaultCaretImage= fNonDefaultCaret.getImage(); - } else if (fInitialCaret != styledText.getCaret()) - styledText.setCaret(fInitialCaret); - } - - private void disposeNonDefaultCaret() { - if (fNonDefaultCaretImage != null) { - fNonDefaultCaretImage.dispose(); - fNonDefaultCaretImage= null; - } - - if (fNonDefaultCaret != null) { - fNonDefaultCaret.dispose(); - fNonDefaultCaret= null; - } - } - - /** - * Handles a change of the editor's insert mode. - * Subclasses may extend. - * - * @since 2.0 - */ - protected void handleInsertModeChanged() { - updateInsertModeAction(); - updateCaret(); - updateStatusField(ITextEditorActionConstants.STATUS_CATEGORY_INPUT_MODE); - } - - private void updateInsertModeAction() { - - // this may be called before the part is fully initialized (see configureInsertMode) - // drop out in this case. - if (getSite() == null) - return; - - IAction action= getAction(ITextEditorActionConstants.TOGGLE_INSERT_MODE); - if (action != null) { - action.setEnabled(!fIsOverwriting); - action.setChecked(fInsertMode == SMART_INSERT); - } - } - - /** - * Handles a potential change of the cursor position. - * Subclasses may extend. - * - * @since 2.0 - */ - protected void handleCursorPositionChanged() { - updateStatusField(ITextEditorActionConstants.STATUS_CATEGORY_INPUT_POSITION); - } - - /** - * Updates the status fields for the given category. - * - * @param category - * @since 2.0 - */ - protected void updateStatusField(String category) { - - if (category == null) - return; - - IStatusField field= getStatusField(category); - if (field != null) { - - String text= null; - - if (ITextEditorActionConstants.STATUS_CATEGORY_INPUT_POSITION.equals(category)) - text= getCursorPosition(); - else if (ITextEditorActionConstants.STATUS_CATEGORY_ELEMENT_STATE.equals(category)) - text= isEditorInputReadOnly() ? fReadOnlyLabel : fWritableLabel; - else if (ITextEditorActionConstants.STATUS_CATEGORY_INPUT_MODE.equals(category)) { - InsertMode mode= getInsertMode(); - if (fIsOverwriting) - text= fOverwriteModeLabel; - else if (INSERT == mode) - text= fInsertModeLabel; - else if (SMART_INSERT == mode) - text= fSmartInsertModeLabel; - } - - field.setText(text == null ? fErrorLabel : text); - } - } - - /** - * Updates all status fields. - * - * @since 2.0 - */ - protected void updateStatusFields() { - if (fStatusFields != null) { - Iterator e= fStatusFields.keySet().iterator(); - while (e.hasNext()) - updateStatusField((String) e.next()); - } - } - - /** - * Returns a description of the cursor position. - * - * @return a description of the cursor position - * @since 2.0 - */ - protected String getCursorPosition() { - - if (fSourceViewer == null) - return fErrorLabel; - - StyledText styledText= fSourceViewer.getTextWidget(); - int caret= widgetOffset2ModelOffset(fSourceViewer, styledText.getCaretOffset()); - IDocument document= fSourceViewer.getDocument(); - - if (document == null) - return fErrorLabel; - - try { - - int line= document.getLineOfOffset(caret); - - int lineOffset= document.getLineOffset(line); - int tabWidth= styledText.getTabs(); - int column= 0; - for (int i= lineOffset; i < caret; i++) - if ('\t' == document.getChar(i)) - column += tabWidth - (tabWidth == 0 ? 0 : column % tabWidth); - else - column++; - - fLineLabel.fValue= line + 1; - fColumnLabel.fValue= column + 1; - return MessageFormat.format(fPositionLabelPattern, fPositionLabelPatternArguments); - - } catch (BadLocationException x) { - return fErrorLabel; - } - } - - /* - * @see ITextEditorExtension#isEditorInputReadOnly() - * @since 2.0 - */ - public boolean isEditorInputReadOnly() { - IDocumentProvider provider= getDocumentProvider(); - if (provider instanceof IDocumentProviderExtension) { - IDocumentProviderExtension extension= (IDocumentProviderExtension) provider; - return extension.isReadOnly(getEditorInput()); - } - return true; - } - - /* - * @see ITextEditorExtension2#isEditorInputModifiable() - * @since 2.1 - */ - public boolean isEditorInputModifiable() { - IDocumentProvider provider= getDocumentProvider(); - if (provider instanceof IDocumentProviderExtension) { - IDocumentProviderExtension extension= (IDocumentProviderExtension) provider; - return extension.isModifiable(getEditorInput()); - } - return true; - } - - /* - * @see ITextEditorExtension#addRulerContextMenuListener(IMenuListener) - * @since 2.0 - */ - public void addRulerContextMenuListener(IMenuListener listener) { - fRulerContextMenuListeners.add(listener); - } - - /* - * @see ITextEditorExtension#removeRulerContextMenuListener(IMenuListener) - * @since 2.0 - */ - public void removeRulerContextMenuListener(IMenuListener listener) { - fRulerContextMenuListeners.remove(listener); - } - - /** - * Returns whether this editor can handle the move of the original element - * so that it ends up being the moved element. By default this method - * returns <code>true</code>. Subclasses may reimplement. - * - * @param originalElement the original element - * @param movedElement the moved element - * @return whether this editor can handle the move of the original element - * so that it ends up being the moved element - * @since 2.0 - */ - protected boolean canHandleMove(IEditorInput originalElement, IEditorInput movedElement) { - return true; - } - - /** - * Returns the offset of the given source viewer's document that corresponds - * to the given widget offset or <code>-1</code> if there is no such offset. - * - * @param viewer the source viewer - * @param widgetOffset the widget offset - * @return the corresponding offset in the source viewer's document or <code>-1</code> - * @since 2.1 - */ - protected final static int widgetOffset2ModelOffset(ISourceViewer viewer, int widgetOffset) { - if (viewer instanceof ITextViewerExtension5) { - ITextViewerExtension5 extension= (ITextViewerExtension5) viewer; - return extension.widgetOffset2ModelOffset(widgetOffset); - } - return widgetOffset + viewer.getVisibleRegion().getOffset(); - } - - /** - * Returns the offset of the given source viewer's text widget that corresponds - * to the given model offset or <code>-1</code> if there is no such offset. - * - * @param viewer the source viewer - * @param modelOffset the model offset - * @return the corresponding offset in the source viewer's text widget or <code>-1</code> - * @since 3.0 - */ - protected final static int modelOffset2WidgetOffset(ISourceViewer viewer, int modelOffset) { - if (viewer instanceof ITextViewerExtension5) { - ITextViewerExtension5 extension= (ITextViewerExtension5) viewer; - return extension.modelOffset2WidgetOffset(modelOffset); - } - return modelOffset - viewer.getVisibleRegion().getOffset(); - } - - /** - * Returns the minimal region of the given source viewer's document that completely - * comprises everything that is visible in the viewer's widget. - * - * @param viewer the viewer go return the coverage for - * @return the minimal region of the source viewer's document comprising the contents of the viewer's widget - * @since 2.1 - */ - protected final static IRegion getCoverage(ISourceViewer viewer) { - if (viewer instanceof ITextViewerExtension5) { - ITextViewerExtension5 extension= (ITextViewerExtension5) viewer; - return extension.getModelCoverage(); - } - return viewer.getVisibleRegion(); - } - - /** - * Tells whether the given region is visible in the given source viewer. - * - * @param viewer the source viewer - * @param offset the offset of the region - * @param length the length of the region - * @return <code>true</code> if visible - * @since 2.1 - */ - protected final static boolean isVisible(ISourceViewer viewer, int offset, int length) { - if (viewer instanceof ITextViewerExtension5) { - ITextViewerExtension5 extension= (ITextViewerExtension5) viewer; - IRegion overlap= extension.modelRange2WidgetRange(new Region(offset, length)); - return overlap != null; - } - return viewer.overlapsWithVisibleRegion(offset, length); - } - - /* - * @see org.eclipse.ui.texteditor.ITextEditorExtension3#showChangeInformation(boolean) - * @since 3.0 - */ - public void showChangeInformation(boolean show) { - // do nothing - } - - /* - * @see org.eclipse.ui.texteditor.ITextEditorExtension3#isChangeInformationShowing() - * @since 3.0 - */ - public boolean isChangeInformationShowing() { - return false; - } -}
\ No newline at end of file diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AnnotationPreference.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AnnotationPreference.java deleted file mode 100644 index 2f9339919fc..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AnnotationPreference.java +++ /dev/null @@ -1,1058 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.texteditor; - -import java.util.HashMap; -import java.util.Map; - -import org.osgi.framework.Bundle; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.Platform; - -import org.eclipse.swt.graphics.RGB; - -import org.eclipse.jface.resource.ImageDescriptor; - -import org.eclipse.ui.internal.texteditor.TextEditorPlugin; - - -/** - * An annotation preference provides all the information required for handing - * the preferences for the presentation of annotations of a specified type. The - * type can be changed and retrieved using the <code>getAnnotationType</code> - * and <code>setAnnotationType</code> methods. For each preference, getter and - * setter methods are provided. - * <p> - * Preferences that may be changed by the user also have a corresponding key - * that can be used to obtain the currently set value from an - * <code>IPreferenceStore</code>. - * </p> - * <h3>The following annotation preferences are covered:</h4> - * <h4>Display Preferences controlling how and where annotations are shown</h4> - * <ul> - * <li>as text background highlighting (and respective preference key),</li> - * <li>as text decorations (and respective preference key),</li> - * <li>on the overview ruler (and respective preference key),</li> - * <li>on the overview ruler header,</li> - * <li>on the vertical ruler (and respective preference key),</li> - * </li> - * </ul> - * <h4>Additional Display Preferences</h4> - * <ul> - * <li>the base color for annotations of this type (and respective preference key), - * <li>the style of text decorations that are drawn (and respective preference - * key),</li> - * <li>the annotation image provider,</li> - * <li>the image descriptor,</li> - * <li>the symbolic image name,</li> - * <li>the presentation layer.</li> - * </ul> - * <h4>Navigation Preferences</h4> - * <ul> - * <li>whether included in the "Go to Next Annotation" navigation action (and - * respective preference key),</li> - * <li>whether included in the "Go to Previous Annotation" navigation action - * (and respective preference key),</li> - * <li>whether to be shown in the "Go to Next/Previous Annotation" navigation - * toolbar dropdown (and respective preference key).</li> - * </ul> - * <h4>Preference Page Preferences</h4> - * <ul> - * <li>whether the annotation type should be included on the generic annotation - * preference page,</li> - * <li>preference label.</li> - * </ul> - * - * @since 2.1 - */ -public class AnnotationPreference { - - /* String constants for style enumeration */ - - /** - * Constant defining no decoration for the show in text style preference. - * @since 3.0 - */ - public static final String STYLE_NONE= "NONE"; //$NON-NLS-1$ - /** - * Constant defining squiggly decoration for the show in text style preference. - * @since 3.0 - */ - public static final String STYLE_SQUIGGLES= "SQUIGGLES"; //$NON-NLS-1$ - /** - * Constant defining box decoration for the show in text style preference. - * @since 3.0 - */ - public static final String STYLE_BOX= "BOX"; //$NON-NLS-1$ - /** - * Constant defining underline decoration for the show in text style preference. - * @since 3.0 - */ - public static final String STYLE_UNDERLINE= "UNDERLINE"; //$NON-NLS-1$ - /** - * Constant defining i-beam decoration for the show in text style preference. - * @since 3.0 - */ - public static final String STYLE_IBEAM= "IBEAM"; //$NON-NLS-1$ - - /* IDs for presentation preference attributes */ - - /** - * The image to be used for drawing in the vertical ruler. - * @since 3.0 - */ - protected final static Object IMAGE_DESCRIPTOR= new Object(); - /** - * The preference label. - * @since 3.0 - */ - protected final static Object PREFERENCE_LABEL= new Object(); - /** - * The presentation layer. - * @since 3.0 - */ - protected final static Object PRESENTATION_LAYER= new Object(); - /** - * The symbolic name of the image to be drawn in the vertical ruler. - * @since 3.0 - */ - protected final static Object SYMBOLIC_IMAGE_NAME= new Object(); - /** - * Indicates whether the annotation type contributed to the overview ruler's header. - * @since 3.0 - */ - protected final static Object HEADER_VALUE= new Object(); - /** - * The annotation image provider. - * @since 3.0 - */ - protected final static Object IMAGE_PROVIDER= new Object(); - /** - * The value for the includeOnPreferencePage property. - * @since 3.0 - */ - protected final static Object INCLUDE_ON_PREFERENCE_PAGE= new Object(); - - /* IDs for preference store access and initialization */ - - /** - * The preference key for the visibility inside text. - * @since 3.0 - */ - protected final static Object TEXT_PREFERENCE_KEY= new Object(); - /** - * The visibility inside text. - * @since 3.0 - */ - protected final static Object TEXT_PREFERENCE_VALUE= new Object(); - /** - * The preference key for the presentation color. - * @since 3.0 - */ - protected final static Object COLOR_PREFERENCE_KEY= new Object(); - /** The presentation color. - * @since 3.0 - */ - protected final static Object COLOR_PREFERENCE_VALUE= new Object(); - /** - * The preference key for highlighting inside text. - * @since 3.0 - */ - protected final static Object HIGHLIGHT_PREFERENCE_KEY= new Object(); - /** - * The value for highlighting inside text. - * @since 3.0 - */ - protected final static Object HIGHLIGHT_PREFERENCE_VALUE= new Object(); - /** - * The preference key for go to next navigation enablement. - * @since 3.0 - */ - protected final static Object IS_GO_TO_NEXT_TARGET_KEY= new Object(); - /** - * The value for go to next navigation enablement. - * @since 3.0 - */ - protected final static Object IS_GO_TO_NEXT_TARGET_VALUE= new Object(); - /** - * The preference key for go to previous navigation enablement. - * @since 3.0 - */ - protected final static Object IS_GO_TO_PREVIOUS_TARGET_KEY= new Object(); - /** - * The value for go to previous navigation enablement. - * @since 3.0 - */ - protected final static Object IS_GO_TO_PREVIOUS_TARGET_VALUE= new Object(); - /** - * The preference key for the visibility in the vertical ruler. - * @since 3.0 - */ - protected final static Object VERTICAL_RULER_PREFERENCE_KEY= new Object(); - /** - * The visibility in the vertical ruler. - * @since 3.0 - */ - protected final static Object VERTICAL_RULER_PREFERENCE_VALUE= new Object(); - /** - * The preference key for the visibility in the overview ruler. - * @since 3.0 - */ - protected final static Object OVERVIEW_RULER_PREFERENCE_KEY= new Object(); - /** - * The visibility in the overview ruler. - * @since 3.0 - */ - protected final static Object OVERVIEW_RULER_PREFERENCE_VALUE= new Object(); - /** - * The preference key for the visibility in the next/previous drop down toolbar action. - * @since 3.0 - */ - protected final static Object SHOW_IN_NAVIGATION_DROPDOWN_KEY= new Object(); - /** - * The value for the visibility in the next/previous drop down toolbar action. - * @since 3.0 - */ - protected final static Object SHOW_IN_NAVIGATION_DROPDOWN_VALUE= new Object(); - /** - * The preference key for the decoration style. - * @since 3.0 - */ - protected final static Object TEXT_STYLE_PREFERENCE_KEY= new Object(); - /** - * The value for the text decoration style. - * @since 3.0 - */ - protected final static Object TEXT_STYLE_PREFERENCE_VALUE= new Object(); - - /** - * Array of all supported attributes. - * @since 3.0 - */ - protected final static Object[] ATTRIBUTES= new Object[] { - IMAGE_DESCRIPTOR, - PREFERENCE_LABEL, - PRESENTATION_LAYER, - SYMBOLIC_IMAGE_NAME, - HEADER_VALUE, - IMAGE_PROVIDER, - TEXT_PREFERENCE_KEY, - TEXT_PREFERENCE_VALUE, - COLOR_PREFERENCE_KEY, - COLOR_PREFERENCE_VALUE, - HIGHLIGHT_PREFERENCE_KEY, - HIGHLIGHT_PREFERENCE_VALUE, - IS_GO_TO_NEXT_TARGET_KEY, - IS_GO_TO_NEXT_TARGET_VALUE, - IS_GO_TO_PREVIOUS_TARGET_KEY, - IS_GO_TO_PREVIOUS_TARGET_VALUE, - VERTICAL_RULER_PREFERENCE_KEY, - VERTICAL_RULER_PREFERENCE_VALUE, - OVERVIEW_RULER_PREFERENCE_KEY, - OVERVIEW_RULER_PREFERENCE_VALUE, - SHOW_IN_NAVIGATION_DROPDOWN_KEY, - SHOW_IN_NAVIGATION_DROPDOWN_VALUE, - TEXT_STYLE_PREFERENCE_KEY, - TEXT_STYLE_PREFERENCE_VALUE, - INCLUDE_ON_PREFERENCE_PAGE - }; - - /** The annotation type */ - private Object fAnnotationType; - /** The marker type */ - private String fMarkerType; - /** The marker severity */ - private int fSeverity; - /** - * The annotation image provider. - * @since 3.0 - */ - public IAnnotationImageProvider fAnnotationImageProvider; - /** - * The configuration element from which to create the annotation image provider. - * @since 3.0 - */ - public IConfigurationElement fConfigurationElement; - /** - * The name of the attribute used to load the annotation image provider - * from the configuration element. - * @since 3.0 - */ - public String fAnnotationImageProviderAttribute; - /** - * The map of attributes. - * @since 3.0 - */ - private Map fAttributes= new HashMap(); - - - - /** - * Creates a new uninitialized annotation preference. Note that instances - * with a <code>null</code> annotation type are invalid and should not be - * used. - */ - public AnnotationPreference() { - } - - /** - * Creates a new annotation preference for the given annotation type. - * - * @param annotationType the annotation type - * @param colorKey the preference key for the presentation color - * @param textKey the preference key for the visibility inside text - * @param overviewRulerKey the preference key for the visibility in the - * overview ruler - * @param presentationLayer the presentation layer - */ - public AnnotationPreference(Object annotationType, String colorKey, String textKey, String overviewRulerKey, int presentationLayer) { - fAnnotationType= annotationType; - setValue(COLOR_PREFERENCE_KEY, colorKey); - setValue(TEXT_PREFERENCE_KEY, textKey); - setValue(OVERVIEW_RULER_PREFERENCE_KEY, overviewRulerKey); - setValue(PRESENTATION_LAYER, presentationLayer); - } - - /** - * Sets the given value for the given attribute. - * - * @param attribute the attribute - * @param value the attribute value - * @since 3.0 - */ - protected void setValue(Object attribute, Object value) { - fAttributes.put(attribute, value); - } - - /** - * Sets the given value for the given attribute. - * - * @param attribute the attribute - * @param value the attribute value - * @since 3.0 - */ - protected void setValue(Object attribute, int value) { - fAttributes.put(attribute, new Integer(value)); - } - - /** - * Sets the given value for the given attribute. - * - * @param attribute the attribute - * @param value the attribute value - * @since 3.0 - */ - protected void setValue(Object attribute, boolean value) { - fAttributes.put(attribute, value ? Boolean.TRUE : Boolean.FALSE); - } - - /** - * Returns the value of the given attribute as string. - * - * @param attribute the attribute - * @return the attribute value - * @since 3.0 - */ - protected String getStringValue(Object attribute) { - Object value= fAttributes.get(attribute); - if (value instanceof String) - return (String) value; - return null; - } - - /** - * Returns the value of the given attribute as boolean. - * - * @param attribute the attribute - * @return the attribute value - * @since 3.0 - */ - protected boolean getBooleanValue(Object attribute) { - Object value= fAttributes.get(attribute); - if (value instanceof Boolean) - return ((Boolean) value).booleanValue(); - return false; - } - - /** - * Returns the value of the given attribute as integer. - * - * @param attribute the attribute - * @return the attribute value - * @since 3.0 - */ - protected int getIntegerValue(Object attribute) { - Object value= fAttributes.get(attribute); - if (value instanceof Integer) - return ((Integer) value).intValue(); - return 0; - } - - /** - * Returns the value of the given attribute. - * - * @param attribute the attribute - * @return the attribute value - * @since 3.0 - */ - public Object getValue(Object attribute) { - return fAttributes.get(attribute); - } - - /** - * Returns whether the given attribute is defined. - * - * @param attribute the attribute - * @return <code>true</code> if the attribute has a value <code>false</code> otherwise - * @since 3.0 - */ - public boolean hasValue(Object attribute) { - return fAttributes.get(attribute) != null; - } - - /** - * Returns whether the given string is a preference key. - * - * @param key the string to test - * @return <code>true</code> if the string is a preference key - */ - public boolean isPreferenceKey(String key) { - if (key == null) - return false; - - return key.equals(getStringValue(COLOR_PREFERENCE_KEY)) || - key.equals(getStringValue(OVERVIEW_RULER_PREFERENCE_KEY)) || - key.equals(getStringValue(TEXT_PREFERENCE_KEY)) || - key.equals(getStringValue(HIGHLIGHT_PREFERENCE_KEY)) || - key.equals(getStringValue(TEXT_STYLE_PREFERENCE_KEY)) || - key.equals(getStringValue(VERTICAL_RULER_PREFERENCE_KEY)); - } - - /** - * Returns the annotation type. Should not be null in a completely set up - * instance. - * - * @return the annotation type, <code>null</code> if the receiver has not - * been initialized yet - */ - public Object getAnnotationType() { - return fAnnotationType; - } - - /** - * Returns the marker type. - * - * @return the marker type, or <code>null</code> if none is set - * @deprecated since 3.0 - */ - public String getMarkerType() { - return fMarkerType; - } - - /** - * Returns the marker severity. - * - * @return the marker severity - * @deprecated since 3.0 - */ - public int getSeverity() { - return fSeverity; - } - - /** - * Sets the annotation type. Note that instances with a <code>null</code> - * annotation type are considered invalid and should not be used with the - * framework. - * - * @param annotationType the annotation type - */ - public void setAnnotationType(Object annotationType) { - fAnnotationType= annotationType; - } - - /** - * Sets the marker type. - * - * @param markerType the marker type - */ - public void setMarkerType(String markerType) { - fMarkerType= markerType; - } - - /** - * Sets the marker severity. - * - * @param severity the marker severity - */ - public void setSeverity(int severity) { - fSeverity= severity; - } - - /** - * Returns the preference key for the presentation color. - * - * @return the preference key for the presentation color or <code>null</code> - * if none is set - */ - public String getColorPreferenceKey() { - return getStringValue(COLOR_PREFERENCE_KEY); - } - - /** - * Returns the default presentation color. - * - * @return the default presentation color or <code>null</code> if none is - * set - */ - public RGB getColorPreferenceValue() { - return (RGB) getValue(COLOR_PREFERENCE_VALUE); - } - - /** - * Returns the presentation string for this annotation type. - * - * @return the presentation string for this annotation type or <code>null</code> - * if none is set - */ - public String getPreferenceLabel() { - return getStringValue(PREFERENCE_LABEL); - } - - /** - * Returns the preference key for the visibility in the overview ruler. - * - * @return the preference key for the visibility in the overview ruler or - * <code>null</code> if none is set - */ - public String getOverviewRulerPreferenceKey() { - return getStringValue(OVERVIEW_RULER_PREFERENCE_KEY); - } - - /** - * Returns the default visibility in the overview ruler. - * - * @return the default visibility in the overview ruler - */ - public boolean getOverviewRulerPreferenceValue() { - return getBooleanValue(OVERVIEW_RULER_PREFERENCE_VALUE); - } - - /** - * Returns the preference key for the visibility in the vertical ruler. - * - * @return the preference key for the visibility in the vertical ruler or - * <code>null</code> if none is set - * @since 3.0 - */ - public String getVerticalRulerPreferenceKey() { - return getStringValue(VERTICAL_RULER_PREFERENCE_KEY); - } - - /** - * Returns the default visibility in the vertical ruler. - * - * @return the default visibility in the vertical ruler - * @since 3.0 - */ - public boolean getVerticalRulerPreferenceValue() { - return getBooleanValue(VERTICAL_RULER_PREFERENCE_VALUE); - } - - /** - * Returns the presentation layer. - * - * @return the presentation layer - */ - public int getPresentationLayer() { - return getIntegerValue(PRESENTATION_LAYER); - } - - /** - * Returns the preference key for the visibility inside text. - * - * @return the preference key for the visibility inside text or <code>null</code> - * if none is set - */ - public String getTextPreferenceKey() { - return getStringValue(TEXT_PREFERENCE_KEY); - } - - /** - * Returns the default visibility inside text. - * - * @return the default visibility inside text - */ - public boolean getTextPreferenceValue() { - return getBooleanValue(TEXT_PREFERENCE_VALUE); - } - - /** - * Returns the preference key for highlighting inside text. - * - * @return the preference key for highlighting inside text or <code>null</code> - * if none is set - * @since 3.0 - */ - public String getHighlightPreferenceKey() { - return getStringValue(HIGHLIGHT_PREFERENCE_KEY); - } - - /** - * Returns the default value for highlighting inside text. - * - * @return the default value for highlighting inside text - * @since 3.0 - */ - public boolean getHighlightPreferenceValue() { - return getBooleanValue(HIGHLIGHT_PREFERENCE_VALUE); - } - - /** - * Returns whether the annotation type contributes to the header of the overview ruler. - * - * @return <code>true</code> if the annotation type contributes to the header of the overview ruler - */ - public boolean contributesToHeader() { - return getBooleanValue(HEADER_VALUE); - } - - /** - * Sets the preference key for the presentation color. - * - * @param colorKey the preference key - */ - public void setColorPreferenceKey(String colorKey) { - setValue(COLOR_PREFERENCE_KEY, colorKey); - } - - /** - * Sets the default presentation color. - * - * @param colorValue the default color - */ - public void setColorPreferenceValue(RGB colorValue) { - setValue(COLOR_PREFERENCE_VALUE, colorValue); - } - - /** - * Sets the presentation label of this annotation type. - * - * @param label the presentation label - */ - public void setPreferenceLabel(String label) { - setValue(PREFERENCE_LABEL, label); - } - - /** - * Sets the preference key for the visibility in the overview ruler. - * - * @param overviewRulerKey the preference key - */ - public void setOverviewRulerPreferenceKey(String overviewRulerKey) { - setValue(OVERVIEW_RULER_PREFERENCE_KEY, overviewRulerKey); - } - - /** - * Sets the default visibility in the overview ruler. - * - * @param overviewRulerValue <code>true</code> if visible by default, <code>false</code> otherwise - */ - public void setOverviewRulerPreferenceValue(boolean overviewRulerValue) { - setValue(OVERVIEW_RULER_PREFERENCE_VALUE, overviewRulerValue); - } - - /** - * Sets the preference key for the visibility in the vertical ruler. - * - * @param verticalRulerKey the preference key - * @since 3.0 - */ - public void setVerticalRulerPreferenceKey(String verticalRulerKey) { - setValue(VERTICAL_RULER_PREFERENCE_KEY, verticalRulerKey); - } - - /** - * Sets the default visibility in the vertical ruler. - * - * @param verticalRulerValue <code>true</code> if visible by default, <code>false</code> otherwise - * @since 3.0 - */ - public void setVerticalRulerPreferenceValue(boolean verticalRulerValue) { - setValue(VERTICAL_RULER_PREFERENCE_VALUE, verticalRulerValue); - } - - /** - * Sets the presentation layer. - * - * @param presentationLayer the presentation layer - */ - public void setPresentationLayer(int presentationLayer) { - setValue(PRESENTATION_LAYER, presentationLayer); - } - - /** - * Sets the preference key for the visibility of squiggles inside text. - * - * @param textKey the preference key - */ - public void setTextPreferenceKey(String textKey) { - setValue(TEXT_PREFERENCE_KEY, textKey); - } - - /** - * Sets the default visibility inside text. - * - * @param textValue <code>true</code> if visible by default, <code>false</code> otherwise - */ - public void setTextPreferenceValue(boolean textValue) { - setValue(TEXT_PREFERENCE_VALUE, textValue); - } - - /** - * Sets the preference key for highlighting inside text. - * - * @param highlightKey the preference key - * @since 3.0 - */ - public void setHighlightPreferenceKey(String highlightKey) { - setValue(HIGHLIGHT_PREFERENCE_KEY, highlightKey); - } - - /** - * Sets the default value for highlighting inside text. - * - * @param highlightValue <code>true</code> if highlighted in text by default, <code>false</code> otherwise - * @since 3.0 - */ - public void setHighlightPreferenceValue(boolean highlightValue) { - setValue(HIGHLIGHT_PREFERENCE_VALUE, highlightValue); - } - - /** - * Sets whether the annotation type contributes to the overview ruler's header. - * - * @param contributesToHeader <code>true</code> if in header, <code>false</code> otherwise - */ - public void setContributesToHeader(boolean contributesToHeader) { - setValue(HEADER_VALUE, contributesToHeader); - } - - /** - * Returns the default value for go to next navigation enablement. - * - * @return <code>true</code> if enabled by default - * @since 3.0 - */ - public boolean isGoToNextNavigationTarget() { - return getBooleanValue(IS_GO_TO_NEXT_TARGET_VALUE); - } - - /** - * Sets the default value for go to next navigation enablement. - * - * @param isGoToNextNavigationTarget <code>true</code> if enabled by default - * @since 3.0 - */ - public void setIsGoToNextNavigationTarget(boolean isGoToNextNavigationTarget) { - setValue(IS_GO_TO_NEXT_TARGET_VALUE, isGoToNextNavigationTarget); - } - - /** - * Returns the preference key for go to next navigation enablement. - * - * @return the preference key or <code>null</code> if the key is undefined - * @since 3.0 - */ - public String getIsGoToNextNavigationTargetKey() { - return getStringValue(IS_GO_TO_NEXT_TARGET_KEY); - } - - /** - * Sets the preference key for go to next navigation enablement. - * - * @param isGoToNextNavigationTargetKey <code>true</code> if enabled by default - * @since 3.0 - */ - public void setIsGoToNextNavigationTargetKey(String isGoToNextNavigationTargetKey) { - setValue(IS_GO_TO_NEXT_TARGET_KEY, isGoToNextNavigationTargetKey); - } - - /** - * Returns the default value for go to previous navigation enablement. - * - * @return <code>true</code> if enabled by default - * @since 3.0 - */ - public boolean isGoToPreviousNavigationTarget() { - return getBooleanValue(IS_GO_TO_PREVIOUS_TARGET_VALUE); - } - - /** - * Sets the default value for go to previous navigation enablement. - * - * @param isGoToPreviousNavigationTarget <code>true</code> if enabled by default - * @since 3.0 - */ - public void setIsGoToPreviousNavigationTarget(boolean isGoToPreviousNavigationTarget) { - setValue(IS_GO_TO_PREVIOUS_TARGET_VALUE, isGoToPreviousNavigationTarget); - } - - /** - * Returns the preference key for go to previous navigation enablement. - * - * @return the preference key or <code>null</code> if the key is undefined - * @since 3.0 - */ - public String getIsGoToPreviousNavigationTargetKey() { - return getStringValue(IS_GO_TO_PREVIOUS_TARGET_KEY); - } - - /** - * Sets the preference key for go to previous navigation enablement. - * - * @param isGoToPreviousNavigationTargetKey the preference key - * @since 3.0 - */ - public void setIsGoToPreviousNavigationTargetKey(String isGoToPreviousNavigationTargetKey) { - setValue(IS_GO_TO_PREVIOUS_TARGET_KEY, isGoToPreviousNavigationTargetKey); - } - - /** - * Returns the preference key for the visibility in the next/previous drop down toolbar action. - * - * @return the preference key or <code>null</code> if the key is undefined - * @since 3.0 - */ - public String getShowInNextPrevDropdownToolbarActionKey() { - return getStringValue(SHOW_IN_NAVIGATION_DROPDOWN_KEY); - } - - /** - * Sets the preference key for the visibility in the next/previous drop down toolbar action. - * - * @param showInNextPrevDropdownToolbarActionKey the preference key - * @since 3.0 - */ - public void setShowInNextPrevDropdownToolbarActionKey(String showInNextPrevDropdownToolbarActionKey) { - setValue(SHOW_IN_NAVIGATION_DROPDOWN_KEY, showInNextPrevDropdownToolbarActionKey); - } - - /** - * Returns the default value for the visibility in the next/previous drop down toolbar action. - * - * @return <code>true</code> if enabled by default - * @since 3.0 - */ - public boolean isShowInNextPrevDropdownToolbarAction() { - return getBooleanValue(SHOW_IN_NAVIGATION_DROPDOWN_VALUE); - } - - /** - * Sets the default value for the visibility in the next/previous drop down toolbar action. - * - * @param showInNextPrevDropdownToolbarAction <code>true</code> if enabled by default - * @since 3.0 - */ - public void setShowInNextPrevDropdownToolbarAction(boolean showInNextPrevDropdownToolbarAction) { - setValue(SHOW_IN_NAVIGATION_DROPDOWN_VALUE, showInNextPrevDropdownToolbarAction); - } - - /** - * Sets the preference key for the text style property. - * - * @param key the new key - * @since 3.0 - */ - public void setTextStylePreferenceKey(String key) { - setValue(TEXT_STYLE_PREFERENCE_KEY, key); - } - - /** - * Returns the preference key for the decoration style used when the annotation is shown in text. - * - * @return the preference key for the decoration style or <code>null</code> if the key is undefined - * @since 3.0 - */ - public String getTextStylePreferenceKey() { - return getStringValue(TEXT_STYLE_PREFERENCE_KEY); - } - - /** - * Returns the value for the decoration style used when the annotation is shown in text. - * - * @return the value for the decoration style or <code>null</code> if the key is undefined - * @since 3.0 - */ - public String getTextStyleValue() { - return getStringValue(TEXT_STYLE_PREFERENCE_VALUE); - } - - /** - * Sets the value for the text style property. - * - * @param value the new text decoration style - * @since 3.0 - */ - public void setTextStyleValue(String value) { - if (!STYLE_NONE.equals(value) && !STYLE_BOX.equals(value) - && !STYLE_IBEAM.equals(value) && !STYLE_SQUIGGLES.equals(value) - && !STYLE_UNDERLINE.equals(value)) - throw new IllegalArgumentException(); - - setValue(TEXT_STYLE_PREFERENCE_VALUE, value); - } - - /** - * Returns the image descriptor for the image to be drawn in the vertical ruler. The provided - * image is only used, if <code>getAnnotationImageProvider</code> returns <code>null</code>. - * - * @return the image descriptor or <code>null</code> - * @since 3.0 - */ - public ImageDescriptor getImageDescriptor() { - return (ImageDescriptor) getValue(IMAGE_DESCRIPTOR); - } - - /** - * Sets the image descriptor for the image to be drawn in the vertical ruler. - * - * @param descriptor the image descriptor - * @since 3.0 - */ - public void setImageDescriptor(ImageDescriptor descriptor) { - setValue(IMAGE_DESCRIPTOR, descriptor); - } - - /** - * Returns the symbolic name of the image to be drawn in the vertical ruler. - * The image is only used if <code>getImageDescriptor</code> returns <code>null</code>. - * - * @return the symbolic name of the image or <code>null</code> - * @since 3.0 - */ - public String getSymbolicImageName() { - return getStringValue(SYMBOLIC_IMAGE_NAME); - } - - /** - * Sets the symbolic name of the image to be drawn in the vertical ruler. - * - * @param symbolicImageName the symbolic image name - * @since 3.0 - */ - public void setSymbolicImageName(String symbolicImageName) { - setValue(SYMBOLIC_IMAGE_NAME, symbolicImageName); - } - - /** - * Returns the annotation image provider. If no default annotation image - * provider has been set, this method checks whether the annotation image - * provider data has been set. If so, an annotation image provider is - * created if the configuration element's plug-in is loaded. When an - * annotation image provider has been created successfully, it is set as - * the default annotation image provider. - * - * @return the annotation image provider - * @since 3.0 - */ - public IAnnotationImageProvider getAnnotationImageProvider() { - if (fAnnotationImageProvider == null) { - if (fConfigurationElement != null && fAnnotationImageProviderAttribute != null) { - Bundle bundle= Platform.getBundle( fConfigurationElement.getDeclaringExtension().getNamespace()); - if (bundle != null && bundle.getState() == Bundle.ACTIVE) { - try { - fAnnotationImageProvider= (IAnnotationImageProvider) fConfigurationElement.createExecutableExtension(fAnnotationImageProviderAttribute); - } catch (CoreException x) { - TextEditorPlugin.getDefault().getLog().log(x.getStatus()); - } - } - } - } - return fAnnotationImageProvider; - } - - /** - * Sets the annotation image provider who provides images for annotations - * of the specified annotation type. - * - * @param provider the annotation image provider - * @since 3.0 - */ - public void setAnnotationImageProvider(IAnnotationImageProvider provider) { - fAnnotationImageProvider= provider; - setValue(IMAGE_PROVIDER, provider != null); - } - - /** - * Sets the data needed to create the annotation image provider. - * - * @param configurationElement the configuration element - * @param annotationImageProviderAttribute the attribute of the - * configuration element - * @since 3.0 - */ - public void setAnnotationImageProviderData(IConfigurationElement configurationElement, String annotationImageProviderAttribute) { - fConfigurationElement= configurationElement; - fAnnotationImageProviderAttribute= annotationImageProviderAttribute; - setValue(IMAGE_PROVIDER, annotationImageProviderAttribute != null); - } - - /** - * Sets the property of this annotation preference whether it should be included - * on the default annotation preference page. - * - * @param includeOnPreferencePage the new value - * @since 3.0 - */ - public void setIncludeOnPreferencePage(boolean includeOnPreferencePage) { - setValue(INCLUDE_ON_PREFERENCE_PAGE, includeOnPreferencePage); - } - - /** - * Returns the property of the receiver of whether it should be included on - * the default annotation preference page. - * - * @return the includeOnPreferencePage property - * @since 3.0 - */ - public boolean isIncludeOnPreferencePage() { - Object value= fAttributes.get(INCLUDE_ON_PREFERENCE_PAGE); - if (value instanceof Boolean) - return ((Boolean) value).booleanValue(); - return true; - } - - /** - * Merges the values of the given preference into this preference. Existing - * values will not be overwritten. Subclasses may extend. - * - * @param preference the preference to merge into this preference - * @since 3.0 - */ - public void merge(AnnotationPreference preference) { - if (!getAnnotationType().equals(preference.getAnnotationType())) - return; - - for (int i= 0; i < ATTRIBUTES.length; i++) { - if (!hasValue(ATTRIBUTES[i])) - setValue(ATTRIBUTES[i], preference.getValue(ATTRIBUTES[i])); - } - - if (fAnnotationImageProvider == null) - fAnnotationImageProvider= preference.fAnnotationImageProvider; - if (fConfigurationElement == null) - fConfigurationElement= preference.fConfigurationElement; - if (fAnnotationImageProviderAttribute == null) - fAnnotationImageProviderAttribute= preference.fAnnotationImageProviderAttribute; - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/BasicTextEditorActionContributor.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/BasicTextEditorActionContributor.java deleted file mode 100644 index 75e08446afe..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/BasicTextEditorActionContributor.java +++ /dev/null @@ -1,273 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.texteditor; - - -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.action.IContributionItem; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.IStatusLineManager; - -import org.eclipse.jface.text.Assert; - -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbenchActionConstants; -import org.eclipse.ui.part.EditorActionBarContributor; - - - -/** - * Manages the installation and uninstallation of global actions for - * the same type of editors. - * <p> - * If instantiated and used as-is, this contributor connects to all of the workbench defined - * global editor actions the corresponding actions of the current editor. It also adds addition - * actions for searching and navigation (go to line) as well as a set of status fields.</p> - * <p> - * Subclasses may override the following methods: - * <ul> - * <li><code>contributeToMenu</code> - extend to contribute to menu</li> - * <li><code>contributeToToolBar</code> - reimplement to contribute to toolbar</li> - * <li><code>contributeToStatusLine</code> - reimplement to contribute to status line</li> - * <li><code>setActiveEditor</code> - extend to react to editor changes</li> - * </ul> - * </p> - * @see org.eclipse.ui.texteditor.ITextEditorActionConstants - */ -public class BasicTextEditorActionContributor extends EditorActionBarContributor { - - /** The global actions to be connected with editor actions */ - private final static String[] ACTIONS= { - ITextEditorActionConstants.UNDO, - ITextEditorActionConstants.REDO, - ITextEditorActionConstants.CUT, - ITextEditorActionConstants.COPY, - ITextEditorActionConstants.PASTE, - ITextEditorActionConstants.DELETE, - ITextEditorActionConstants.SELECT_ALL, - ITextEditorActionConstants.FIND, - ITextEditorActionConstants.PRINT, - ITextEditorActionConstants.REVERT - }; - - /** - * Status field definition. - * @since 3.0 - */ - private static class StatusFieldDef { - - private String category; - private String actionId; - private boolean visible; - private int widthInChars; - - private StatusFieldDef(String category, String actionId, boolean visible, int widthInChars) { - Assert.isNotNull(category); - this.category= category; - this.actionId= actionId; - this.visible= visible; - this.widthInChars= widthInChars; - } - } - - /** - * The status fields to be set to the editor - * @since 3.0 - */ - private final static StatusFieldDef[] STATUS_FIELD_DEFS= { - new StatusFieldDef(ITextEditorActionConstants.STATUS_CATEGORY_FIND_FIELD, null, false, EditorMessages.getString("Editor.FindIncremental.reverse.name").length() + 15), //$NON-NLS-1$ - new StatusFieldDef(ITextEditorActionConstants.STATUS_CATEGORY_ELEMENT_STATE, null, true, StatusLineContributionItem.DEFAULT_WIDTH_IN_CHARS), - new StatusFieldDef(ITextEditorActionConstants.STATUS_CATEGORY_INPUT_MODE, ITextEditorActionDefinitionIds.TOGGLE_OVERWRITE, true, StatusLineContributionItem.DEFAULT_WIDTH_IN_CHARS), - new StatusFieldDef(ITextEditorActionConstants.STATUS_CATEGORY_INPUT_POSITION, ITextEditorActionConstants.GOTO_LINE, true, StatusLineContributionItem.DEFAULT_WIDTH_IN_CHARS) - }; - - /** - * The active editor part. - */ - private IEditorPart fActiveEditorPart; - /** - * The find next action. - * @since 2.0 - */ - private RetargetTextEditorAction fFindNext; - /** - * The find previous action. - * @since 2.0 - */ - private RetargetTextEditorAction fFindPrevious; - /** - * The incremental find action. - * @since 2.0 - */ - private RetargetTextEditorAction fIncrementalFind; - /** - * The reverse incremental find action. - * @since 2.1 - */ - private RetargetTextEditorAction fIncrementalFindReverse; - /** - * The go to line action. - */ - private RetargetTextEditorAction fGotoLine; - /** - * The map of status fields. - * @since 2.0 - */ - private Map fStatusFields; - - - /** - * Creates an empty editor action bar contributor. The action bars are - * furnished later via the <code>init</code> method. - * - * @see org.eclipse.ui.IEditorActionBarContributor#init(org.eclipse.ui.IActionBars, org.eclipse.ui.IWorkbenchPage) - */ - public BasicTextEditorActionContributor() { - - fFindNext= new RetargetTextEditorAction(EditorMessages.getResourceBundle(), "Editor.FindNext."); //$NON-NLS-1$ - fFindNext.setActionDefinitionId(ITextEditorActionDefinitionIds.FIND_NEXT); - fFindPrevious= new RetargetTextEditorAction(EditorMessages.getResourceBundle(), "Editor.FindPrevious."); //$NON-NLS-1$ - fFindPrevious.setActionDefinitionId(ITextEditorActionDefinitionIds.FIND_PREVIOUS); - fIncrementalFind= new RetargetTextEditorAction(EditorMessages.getResourceBundle(), "Editor.FindIncremental."); //$NON-NLS-1$ - fIncrementalFind.setActionDefinitionId(ITextEditorActionDefinitionIds.FIND_INCREMENTAL); - fIncrementalFindReverse= new RetargetTextEditorAction(EditorMessages.getResourceBundle(), "Editor.FindIncrementalReverse."); //$NON-NLS-1$ - fIncrementalFindReverse.setActionDefinitionId(ITextEditorActionDefinitionIds.FIND_INCREMENTAL_REVERSE); - fGotoLine= new RetargetTextEditorAction(EditorMessages.getResourceBundle(), "Editor.GotoLine."); //$NON-NLS-1$ - fGotoLine.setActionDefinitionId(ITextEditorActionDefinitionIds.LINE_GOTO); - - fStatusFields= new HashMap(3); - for (int i= 0; i < STATUS_FIELD_DEFS.length; i++) { - StatusFieldDef fieldDef= STATUS_FIELD_DEFS[i]; - fStatusFields.put(fieldDef, new StatusLineContributionItem(fieldDef.category, fieldDef.visible, fieldDef.widthInChars)); - } - } - - /** - * Returns the active editor part. - * - * @return the active editor part - */ - protected final IEditorPart getActiveEditorPart() { - return fActiveEditorPart; - } - - /** - * Returns the action registered with the given text editor. - * - * @param editor the editor, or <code>null</code> - * @param actionId the action id - * @return the action, or <code>null</code> if none - */ - protected final IAction getAction(ITextEditor editor, String actionId) { - return (editor == null || actionId == null ? null : editor.getAction(actionId)); - } - - /** - * The method installs the global action handlers for the given text editor. - * <p> - * This method cannot be overridden by subclasses.</p> - * - * @param part the active editor part - * @since 2.0 - */ - private void doSetActiveEditor(IEditorPart part) { - - if (fActiveEditorPart == part) - return; - - if (fActiveEditorPart instanceof ITextEditorExtension) { - ITextEditorExtension extension= (ITextEditorExtension) fActiveEditorPart; - for (int i= 0; i < STATUS_FIELD_DEFS.length; i++) - extension.setStatusField(null, STATUS_FIELD_DEFS[i].category); - } - - fActiveEditorPart= part; - ITextEditor editor= (part instanceof ITextEditor) ? (ITextEditor) part : null; - - IActionBars actionBars= getActionBars(); - if (actionBars != null) { - for (int i= 0; i < ACTIONS.length; i++) - actionBars.setGlobalActionHandler(ACTIONS[i], getAction(editor, ACTIONS[i])); - } - - fFindNext.setAction(getAction(editor, ITextEditorActionConstants.FIND_NEXT)); - fFindPrevious.setAction(getAction(editor, ITextEditorActionConstants.FIND_PREVIOUS)); - fIncrementalFind.setAction(getAction(editor, ITextEditorActionConstants.FIND_INCREMENTAL)); - fIncrementalFindReverse.setAction(getAction(editor, ITextEditorActionConstants.FIND_INCREMENTAL_REVERSE)); - fGotoLine.setAction(getAction(editor, ITextEditorActionConstants.GOTO_LINE)); - - for (int i= 0; i < STATUS_FIELD_DEFS.length; i++) { - if (fActiveEditorPart instanceof ITextEditorExtension) { - StatusLineContributionItem statusField= (StatusLineContributionItem) fStatusFields.get(STATUS_FIELD_DEFS[i]); - statusField.setActionHandler(getAction(editor, STATUS_FIELD_DEFS[i].actionId)); - ITextEditorExtension extension= (ITextEditorExtension) fActiveEditorPart; - extension.setStatusField(statusField, STATUS_FIELD_DEFS[i].category); - } - } - } - - /** - * The <code>BasicTextEditorActionContributor</code> implementation of this - * <code>IEditorActionBarContributor</code> method installs the global - * action handler for the given text editor by calling a private helper - * method. - * <p> - * Subclasses may extend.</p> - * - * @param part {@inheritDoc} - */ - public void setActiveEditor(IEditorPart part) { - doSetActiveEditor(part); - } - - /* - * @see EditorActionBarContributor#contributeToMenu(IMenuManager) - */ - public void contributeToMenu(IMenuManager menu) { - - IMenuManager editMenu= menu.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT); - if (editMenu != null) { - editMenu.prependToGroup(IWorkbenchActionConstants.FIND_EXT, fIncrementalFindReverse); - editMenu.prependToGroup(IWorkbenchActionConstants.FIND_EXT, fIncrementalFind); - editMenu.prependToGroup(IWorkbenchActionConstants.FIND_EXT, fFindPrevious); - editMenu.prependToGroup(IWorkbenchActionConstants.FIND_EXT, fFindNext); - } - - IMenuManager navigateMenu= menu.findMenuUsingPath(IWorkbenchActionConstants.M_NAVIGATE); - if (navigateMenu != null) { - navigateMenu.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, fGotoLine); - } - } - - /* - * @see EditorActionBarContributor#contributeToStatusLine(org.eclipse.jface.action.IStatusLineManager) - * @since 2.0 - */ - public void contributeToStatusLine(IStatusLineManager statusLineManager) { - super.contributeToStatusLine(statusLineManager); - for (int i= 0; i < STATUS_FIELD_DEFS.length; i++) - statusLineManager.add((IContributionItem)fStatusFields.get(STATUS_FIELD_DEFS[i])); - } - - /* - * @see org.eclipse.ui.IEditorActionBarContributor#dispose() - * @since 2.0 - */ - public void dispose() { - doSetActiveEditor(null); - super.dispose(); - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/CaseAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/CaseAction.java deleted file mode 100644 index 15915bd196b..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/CaseAction.java +++ /dev/null @@ -1,112 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.texteditor; - -import java.util.ResourceBundle; - -import org.eclipse.swt.custom.StyledText; -import org.eclipse.swt.graphics.Point; - -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.source.ISourceViewer; - -/** - * Action that converts the current selection to lower case or upper case. - * @since 3.0 - */ -public class CaseAction extends TextEditorAction implements IUpdate { - - /** <code>true</code> if this action converts to upper case, <code>false</code> otherwise. */ - private boolean fToUpper; - - /** - * Creates and initializes the action for the given text editor. - * The action configures its visual representation from the given resource - * bundle. - * - * @param bundle the resource bundle - * @param prefix a prefix to be prepended to the various resource keys - * (described in <code>ResourceAction</code> constructor), or <code>null</code> if none - * @param editor the text editor - * @param toUpper <code>true</code> if this is an uppercase action, <code>false</code> otherwise. - * - * @see ResourceAction#ResourceAction(ResourceBundle, String) - */ - public CaseAction(ResourceBundle bundle, String prefix, AbstractTextEditor editor, boolean toUpper) { - super(bundle, prefix, editor); - fToUpper= toUpper; - update(); - } - - /* - * @see org.eclipse.jface.action.IAction#run() - */ - public void run() { - ITextEditor editor= getTextEditor(); - if (editor == null) - return; - - if (!validateEditorInputState()) - return; - - ISourceViewer viewer= ((AbstractTextEditor) editor).getSourceViewer(); - if (viewer == null) - return; - - IDocument document= viewer.getDocument(); - if (document == null) - return; - - StyledText st= viewer.getTextWidget(); - if (st == null) - return; - - Point sel= viewer.getSelectedRange(); - if (sel == null) - return; - - try { - // if the selection is empty, we select the word / string using the viewer's - // double-click strategy - if (sel.y == 0) { - - // TODO find a better way to do this although there are multiple partitionings on a single document - -// String partition= getContentType(viewer, document, sel.x); -// SourceViewerConfiguration svc= fEditor.getSourceViewerConfiguration(); // never null when viewer instantiated -// ITextDoubleClickStrategy dcs= svc.getDoubleClickStrategy(viewer, partition); -// if (dcs != null) { -// dcs.doubleClicked(viewer); -// sel= viewer.getSelectedRange(); -// } - - if (sel.y == 0) - return; // if the selection is still empty, we're done - } - - String target= document.get(sel.x, sel.y); - String replacement= (fToUpper ? target.toUpperCase() : target.toLowerCase()); - if (!target.equals(replacement)) { - document.replace(sel.x, target.length(), replacement); - } - } catch (BadLocationException x) { - // ignore and return - return; - } - - // reinstall selection and move it into view - viewer.setSelectedRange(sel.x, sel.y); - // don't use the viewer's reveal feature in order to avoid jumping around - st.showSelection(); - } - -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConfigurationElementSorter.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConfigurationElementSorter.java deleted file mode 100644 index a6d986f2d13..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConfigurationElementSorter.java +++ /dev/null @@ -1,167 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.texteditor; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Comparator; -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.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.text.Assert; -import org.eclipse.osgi.util.ManifestElement; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleException; -import org.osgi.framework.Constants; - -/** - * Allows to sort an array based on their elements' configuration elements - * according to the prerequisite relation of their defining plug-ins. - * <p> - * This class may be subclassed. - * </p> - * - * @since 3.0 - */ -public abstract class ConfigurationElementSorter { - - /** - * Sorts the given array based on its elements' configuration elements - * according to the prerequisite relation of their defining plug-ins. - * - * @param elements the array to be sorted - */ - public final void sort(Object[] elements) { - Arrays.sort(elements, new ConfigurationElementComparator(elements)); - } - - /** - * Returns the configuration element for the given object. - * - * @param object the object - * @return the object's configuration element, must not be <code>null</code> - */ - public abstract IConfigurationElement getConfigurationElement(Object object); - - /** - * Compare configuration elements according to the prerequisite relation - * of their defining plug-ins. - */ - private class ConfigurationElementComparator implements Comparator { - - private Map fDescriptorMapping; - private Map fPrereqsMapping; - - public ConfigurationElementComparator(Object[] elements) { - Assert.isNotNull(elements); - initialize(elements); - } - - /* - * @see Comparator#compare(java.lang.Object, java.lang.Object) - * @since 2.0 - */ - public int compare(Object object0, Object object1) { - - if (dependsOn(object0, object1)) - return -1; - - if (dependsOn(object1, object0)) - return +1; - - return 0; - } - - /** - * Returns whether one configuration element depends on the other element. - * This is done by checking the dependency chain of the defining plug-ins. - * - * @param element0 the first element - * @param element1 the second element - * @return <code>true</code> if <code>element0</code> depends on <code>element1</code>. - * @since 2.0 - */ - private boolean dependsOn(Object element0, Object element1) { - if (element0 == null || element1 == null) - return false; - - String pluginDesc0= (String)fDescriptorMapping.get(element0); - String pluginDesc1= (String)fDescriptorMapping.get(element1); - - // performance tuning - code below would give same result - if (pluginDesc0.equals(pluginDesc1)) - return false; - - Set prereqUIds0= (Set)fPrereqsMapping.get(pluginDesc0); - - return prereqUIds0.contains(pluginDesc1); - } - - /** - * Initialize this comparator. - * - * @param elements an array of Java editor hover descriptors - */ - private void initialize(Object[] elements) { - int length= elements.length; - fDescriptorMapping= new HashMap(length); - fPrereqsMapping= new HashMap(length); - Set fBundleSet= new HashSet(length); - - for (int i= 0; i < length; i++) { - IExtension extension = getConfigurationElement(elements[i]).getDeclaringExtension(); - Bundle bundle = Platform.getBundle(extension.getNamespace()); - fDescriptorMapping.put(elements[i], bundle.getSymbolicName()); - fBundleSet.add(bundle); - } - - Iterator iter= fBundleSet.iterator(); - while (iter.hasNext()) { - Bundle bundle= (Bundle)iter.next(); - List toTest= new ArrayList(fBundleSet); - toTest.remove(bundle); - Set prereqUIds= new HashSet(Math.max(0, toTest.size() - 1)); - fPrereqsMapping.put(bundle.getSymbolicName(), prereqUIds); - - String requires = (String)bundle.getHeaders().get(Constants.REQUIRE_BUNDLE); - ManifestElement[] manifestElements; - try { - manifestElements = ManifestElement.parseHeader(Constants.REQUIRE_BUNDLE, requires); - } catch (BundleException e) { - continue; - } - - int i= 0; - while (i < manifestElements.length && !toTest.isEmpty()) { - String prereqUId= manifestElements[i].getValue(); - for (int j= 0; j < toTest.size();) { - Bundle toTest_j= (Bundle)toTest.get(j); - if (toTest_j.getSymbolicName().equals(prereqUId)) { - toTest.remove(toTest_j); - prereqUIds.add(toTest_j.getSymbolicName()); - } else - j++; - } - i++; - } - } - } - - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ContentAssistAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ContentAssistAction.java deleted file mode 100644 index 1b59c5e2b6a..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ContentAssistAction.java +++ /dev/null @@ -1,122 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.texteditor; - - -import java.util.ResourceBundle; - -import org.eclipse.swt.custom.BusyIndicator; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; - -import org.eclipse.jface.text.ITextOperationTarget; -import org.eclipse.jface.text.ITextOperationTargetExtension; -import org.eclipse.jface.text.source.ISourceViewer; - -import org.eclipse.ui.IWorkbenchPartSite; - - -/** - * A content assist action which gets its target from its text editor. - * <p> - * The action is initially associated with a text editor via the constructor, - * but can subsequently be changed using <code>setEditor</code>.</p> - * <p> - * If this class is used as is, it works by asking the text editor for its text operation target - * (using <code>getAdapter(ITextOperationTarget.class)</code> and runs the content assist - * operation on this target. - * </p> - * @since 2.0 - */ -public final class ContentAssistAction extends TextEditorAction { - - /** The text operation target */ - private ITextOperationTarget fOperationTarget; - - /** - * Creates and initializes the action for the given text editor. - * The action configures its visual representation from the given resource - * bundle. The action works by asking the text editor at the time for its - * text operation target adapter (using - * <code>getAdapter(ITextOperationTarget.class)</code>. The action runs the - * content assist operation on this target. - * - * @param bundle the resource bundle - * @param prefix a prefix to be prepended to the various resource keys - * (described in <code>ResourceAction</code> constructor), or - * <code>null</code> if none - * @param editor the text editor - * @see ResourceAction#ResourceAction(ResourceBundle, String) - */ - public ContentAssistAction(ResourceBundle bundle, String prefix, ITextEditor editor) { - super(bundle, prefix, editor); - } - - /** - * Runs the content assist operation on the editor's text operation target. - */ - public void run() { - if (fOperationTarget != null) { - - ITextEditor editor= getTextEditor(); - if (editor != null && validateEditorInputState()) { - - Display display= null; - - IWorkbenchPartSite site= editor.getSite(); - Shell shell= site.getShell(); - if (shell != null && !shell.isDisposed()) - display= shell.getDisplay(); - - BusyIndicator.showWhile(display, new Runnable() { - public void run() { - fOperationTarget.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS); - } - }); - } - } - } - - /** - * The <code>ContentAssistAction</code> implementation of this - * <code>IUpdate</code> method discovers the operation through the current - * editor's <code>ITextOperationTarget</code> adapter, and sets the - * enabled state accordingly. - */ - public void update() { - - ITextEditor editor= getTextEditor(); - - if (fOperationTarget == null && editor!= null) - fOperationTarget= (ITextOperationTarget) editor.getAdapter(ITextOperationTarget.class); - - if (fOperationTarget == null) { - setEnabled(false); - return; - } - - if (fOperationTarget instanceof ITextOperationTargetExtension) { - ITextOperationTargetExtension targetExtension= (ITextOperationTargetExtension) fOperationTarget; - targetExtension.enableOperation(ISourceViewer.CONTENTASSIST_PROPOSALS, canModifyEditor()); - } - - setEnabled(fOperationTarget.canDoOperation(ISourceViewer.CONTENTASSIST_PROPOSALS)); - } - - /** - * @see TextEditorAction#setEditor(ITextEditor) - */ - public void setEditor(ITextEditor editor) { - super.setEditor(editor); - fOperationTarget= null; - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConvertLineDelimitersAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConvertLineDelimitersAction.java deleted file mode 100644 index e612e2928cd..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConvertLineDelimitersAction.java +++ /dev/null @@ -1,273 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.texteditor; - - -import java.lang.reflect.InvocationTargetException; -import java.util.Map; -import java.util.ResourceBundle; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.NullProgressMonitor; - -import org.eclipse.swt.custom.BusyIndicator; -import org.eclipse.swt.widgets.Shell; - -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.IDocumentExtension; -import org.eclipse.jface.text.IRegion; -import org.eclipse.jface.text.IRewriteTarget; -import org.eclipse.jface.text.TextUtilities; - - -/** - * An action to convert line delimiters of a text editor document to a - * particular line delimiter. - * - * @since 2.0 - */ -public class ConvertLineDelimitersAction extends TextEditorAction { - - /** The target line delimiter. */ - private final String fLineDelimiter; - - /** - * Creates a line delimiter conversion action. - * - * @param editor the editor - * @param lineDelimiter the target line delimiter to convert the editor's document to - */ - public ConvertLineDelimitersAction(ITextEditor editor, String lineDelimiter) { - this(EditorMessages.getResourceBundle(), "dummy", editor, lineDelimiter); //$NON-NLS-1$ - } - - /** - * Creates a line delimiter conversion action. - * - * @param bundle the resource bundle - * @param prefix the prefix for the resource bundle lookup - * @param editor the editor - * @param lineDelimiter the target line delimiter to convert the editor's document to - */ - public ConvertLineDelimitersAction(ResourceBundle bundle, String prefix, ITextEditor editor, String lineDelimiter) { - super(bundle, prefix, editor); - fLineDelimiter= lineDelimiter; - - String platformLineDelimiter= System.getProperty("line.separator"); //$NON-NLS-1$ - setText(EditorMessages.getString(getLabelKey(fLineDelimiter, platformLineDelimiter))); - - update(); - } - - /* - * @see org.eclipse.jface.action.Action#run() - */ - public void run() { - - try { - - ITextEditor editor= getTextEditor(); - if (editor == null) - return; - - if (!validateEditorInputState()) - return; - - Object adapter= editor.getAdapter(IRewriteTarget.class); - if (adapter instanceof IRewriteTarget) { - - IRewriteTarget target= (IRewriteTarget) adapter; - IDocument document= target.getDocument(); - if (document != null) { - Shell shell= getTextEditor().getSite().getShell(); - ConvertRunnable runnable= new ConvertRunnable(target, fLineDelimiter); - - if (document.getNumberOfLines() < 40) { - BusyIndicator.showWhile(shell.getDisplay(), runnable); - - } else { - ProgressMonitorDialog dialog= new ProgressMonitorDialog(shell); - dialog.run(false, true, runnable); - } - } - } - - } catch (InterruptedException e) { - // action cancelled - - } catch (InvocationTargetException e) { - // should not happen - } - } - - /** - * A runnable that converts all line delimiters of a document to <code>lineDelimiter</code>. - */ - private static class ConvertRunnable implements IRunnableWithProgress, Runnable { - - /** The rewrite target */ - private final IRewriteTarget fRewriteTarget; - /** The line delimiter to which to convert to */ - private final String fLineDelimiter; - - /** - * Returns a new runnable for converting all line delimiters in - * the <code>rewriteTarget</code> to <code>lineDelimter</code>. - * @param rewriteTarget - * @param lineDelimiter - */ - public ConvertRunnable(IRewriteTarget rewriteTarget, String lineDelimiter) { - fRewriteTarget= rewriteTarget; - fLineDelimiter= lineDelimiter; - } - - /* - * @see IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor) - */ - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - - IDocument document= fRewriteTarget.getDocument(); - final int lineCount= document.getNumberOfLines(); - monitor.beginTask(EditorMessages.getString("Editor.ConvertLineDelimiter.title"), lineCount); //$NON-NLS-1$ - - fRewriteTarget.setRedraw(false); - fRewriteTarget.beginCompoundChange(); - - if (document instanceof IDocumentExtension) - ((IDocumentExtension) document).startSequentialRewrite(true); - - Map partitioners= TextUtilities.removeDocumentPartitioners(document); - - try { - for (int i= 0; i < lineCount; i++) { - if (monitor.isCanceled()) - throw new InterruptedException(); - - final String delimiter= document.getLineDelimiter(i); - if (delimiter != null && delimiter.length() > 0 && !delimiter.equals(fLineDelimiter)) { - IRegion region= document.getLineInformation(i); - document.replace(region.getOffset() + region.getLength(), delimiter.length(), fLineDelimiter); - } - - monitor.worked(1); - } - - } catch (BadLocationException e) { - throw new InvocationTargetException(e); - - } finally { - - if (partitioners != null) - TextUtilities.addDocumentPartitioners(document, partitioners); - - if (document instanceof IDocumentExtension) - ((IDocumentExtension) document).stopSequentialRewrite(); - - fRewriteTarget.endCompoundChange(); - fRewriteTarget.setRedraw(true); - - monitor.done(); - } - } - - /* - * @see Runnable#run() - */ - public void run() { - try { - run(new NullProgressMonitor()); - - } catch (InterruptedException e) { - // should not happen - - } catch (InvocationTargetException e) { - // should not happen - } - } - } - -// /** -// * Returns whether the given document uses only the given line delimiter. -// * @param document the document to check -// * @param lineDelimiter the line delimiter to check for -// */ -// private static boolean usesLineDelimiterExclusively(IDocument document, String lineDelimiter) { -// -// try { -// final int lineCount= document.getNumberOfLines(); -// for (int i= 0; i < lineCount; i++) { -// final String delimiter= document.getLineDelimiter(i); -// if (delimiter != null && delimiter.length() > 0 && !delimiter.equals(lineDelimiter)) -// return false; -// } -// -// } catch (BadLocationException e) { -// return false; -// } -// -// return true; -// } - - /** - * Computes and returns the key to be used to lookup the action's label in - * its resource bundle. - * - * @param lineDelimiter the line delimiter - * @param platformLineDelimiter the platform line delimiter - * @return the key used to lookup the action's label - */ - private static String getLabelKey(String lineDelimiter, String platformLineDelimiter) { - if (lineDelimiter.equals(platformLineDelimiter)) { - - if (lineDelimiter.equals("\r\n")) //$NON-NLS-1$ - return "Editor.ConvertLineDelimiter.toWindows.default.label"; //$NON-NLS-1$ - - if (lineDelimiter.equals("\n")) //$NON-NLS-1$ - return "Editor.ConvertLineDelimiter.toUNIX.default.label"; //$NON-NLS-1$ - - if (lineDelimiter.equals("\r")) //$NON-NLS-1$ - return "Editor.ConvertLineDelimiter.toMac.default.label"; //$NON-NLS-1$ - - } else { - - if (lineDelimiter.equals("\r\n")) //$NON-NLS-1$ - return "Editor.ConvertLineDelimiter.toWindows.label"; //$NON-NLS-1$ - - if (lineDelimiter.equals("\n")) //$NON-NLS-1$ - return "Editor.ConvertLineDelimiter.toUNIX.label"; //$NON-NLS-1$ - - if (lineDelimiter.equals("\r")) //$NON-NLS-1$ - return "Editor.ConvertLineDelimiter.toMac.label"; //$NON-NLS-1$ - } - - return null; - } - - /** - * Internally sets the enable state of this action. - */ - private boolean doEnable() { - return canModifyEditor(); - } - - /* - * @see IUpdate#update() - */ - public void update() { - super.update(); - setEnabled(doEnable()); - } - -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/DefaultRangeIndicator.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/DefaultRangeIndicator.java deleted file mode 100644 index c42d70d6b2a..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/DefaultRangeIndicator.java +++ /dev/null @@ -1,175 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.texteditor; - - -import org.eclipse.jface.text.source.Annotation; -import org.eclipse.jface.text.source.IAnnotationPresentation; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.ImageData; -import org.eclipse.swt.graphics.PaletteData; -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.Control; -import org.eclipse.swt.widgets.Display; - - -/** - * Specialized annotation to indicate a particular range of text lines. - * <p> - * This class may be instantiated; it is not intended to be subclassed. - * This class is instantiated automatically by <code>AbstractTextEditor</code>. - * </p> - */ -public class DefaultRangeIndicator extends Annotation implements IAnnotationPresentation { - - /** The color palette data of this range indicator */ - private static PaletteData fgPaletteData; - /** The image of this range indicator */ - private Image fImage; - - /** - * Creates a new range indicator. - */ - public DefaultRangeIndicator() { - } - - /* - * @see org.eclipse.jface.text.source.IAnnotationPresentation#paint(org.eclipse.swt.graphics.GC, org.eclipse.swt.widgets.Canvas, org.eclipse.swt.graphics.Rectangle) - */ - public void paint(GC gc, Canvas canvas, Rectangle bounds) { - - Point canvasSize= canvas.getSize(); - - int x= 0; - int y= bounds.y; - int w= canvasSize.x; - int h= bounds.height; - int b= 1; - - if (y + h > canvasSize.y) - h= canvasSize.y - y; - - if (y < 0) { - h= h + y; - y= 0; - } - - if (h <= 0) - return; - - Image image = getImage(canvas); - gc.drawImage(image, 0, 0, w, h, x, y, w, h); - - gc.setBackground(canvas.getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION)); - gc.fillRectangle(x, bounds.y, w, b); - gc.fillRectangle(x, bounds.y + bounds.height - b, w, b); - } - - /* - * @see org.eclipse.jface.text.source.IAnnotationPresentation#getLayer() - */ - public int getLayer() { - return IAnnotationPresentation.DEFAULT_LAYER; - } - - /** - * Returns the image of this range indicator. - * - * @param control the control - * @return an image - */ - private Image getImage(Control control) { - if (fImage == null) { - fImage= createImage(control.getDisplay(), control.getSize()); - - control.addDisposeListener(new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - if (fImage != null && !fImage.isDisposed()) { - fImage.dispose(); - fImage= null; - } - } - }); - } else { - Rectangle imageRectangle= fImage.getBounds(); - Point controlSize= control.getSize(); - - if (imageRectangle.width < controlSize.x || imageRectangle.height < controlSize.y) { - fImage.dispose(); - fImage= createImage(control.getDisplay(), controlSize); - } - } - - return fImage; - } - - /** - * Creates and returns a new SWT image with the given size on - * the given display which is used as this range indicator's image. - * - * @param display the display on which to create the image - * @param size the image size - * @return a new image - */ - private static Image createImage(Display display, Point size) { - - int width= size.x; - int height= size.y; - - if (fgPaletteData == null) - fgPaletteData= createPalette(display); - - ImageData imageData= new ImageData(width, height, 1, fgPaletteData); - - for (int y= 0; y < height; y++) - for (int x= 0; x < width; x++) - imageData.setPixel(x, y, (x + y) % 2); - - return new Image(display, imageData); - } - - /** - * Creates and returns a new color palette data. - * - * @param display - * @return the new color palette data - */ - private static PaletteData createPalette(Display display) { - Color c1; - Color c2; - - if (false) { - // range lighter - c1= display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND); - c2= display.getSystemColor(SWT.COLOR_LIST_BACKGROUND); - } else { - // range darker - c1= display.getSystemColor(SWT.COLOR_LIST_SELECTION); - c2= display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND); - } - - RGB rgbs[]= new RGB[] { - new RGB(c1.getRed(), c1.getGreen(), c1.getBlue()), - new RGB(c2.getRed(), c2.getGreen(), c2.getBlue())}; - - return new PaletteData(rgbs); - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/DeleteLineAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/DeleteLineAction.java deleted file mode 100644 index 1323af7e18e..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/DeleteLineAction.java +++ /dev/null @@ -1,179 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.texteditor; - - -import java.util.ResourceBundle; - -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.ITextSelection; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionProvider; - -/** - * An action to delete a whole line, the fraction of the line that is left from the cursor - * or the fraction that is right from the cursor. - * - * @since 2.0 - */ -public class DeleteLineAction extends TextEditorAction { - - /** - * Delete the whole line. - */ - public static final int WHOLE= 0; - /** - * Delete to the beginning of line. - */ - public static final int TO_BEGINNING= 1; - /** - * Delete to the end of line. - */ - public static final int TO_END= 2; - - /** - * The type of deletion. - */ - private final int fType; - /** - * Should the deleted line be copied to the clipboard. - * @since 2.1 - */ - private final boolean fCopyToClipboard; - /** The deletion target. - * @since 2.1 - */ - private DeleteLineTarget fTarget; - - /** - * Creates a line delimiter conversion action. - * - * @param bundle the resource bundle for UI strings - * @param prefix the prefix for the property keys into <code>bundle</code> - * @param editor the editor - * @param type the line deletion type, must be one of - * <code>WHOLE_LINE</code>, <code>TO_BEGINNING</code> or <code>TO_END</code> - */ - public DeleteLineAction(ResourceBundle bundle, String prefix, ITextEditor editor, int type) { - this(bundle, prefix, editor, type, true); - } - - /** - * Creates a line deletion action. - * - * @param bundle the resource bundle for UI strings - * @param prefix the prefix for the property keys into <code>bundle</code> - * @param editor the editor - * @param type the line deletion type, must be one of - * <code>WHOLE_LINE</code>, <code>TO_BEGINNING</code> or <code>TO_END</code> - * @param copyToClipboard if <code>true</code>, the contents of the deleted line are copied to the clipboard - * @since 2.1 - */ - public DeleteLineAction(ResourceBundle bundle, String prefix, ITextEditor editor, int type, boolean copyToClipboard) { - super(bundle, prefix, editor); - fType= type; - fCopyToClipboard= copyToClipboard; - update(); - } - - /** - * Returns the editor's document. - * - * @param editor the editor - * @return the editor's document - */ - private static IDocument getDocument(ITextEditor editor) { - - IDocumentProvider documentProvider= editor.getDocumentProvider(); - if (documentProvider == null) - return null; - - IDocument document= documentProvider.getDocument(editor.getEditorInput()); - if (document == null) - return null; - - return document; - } - - /** - * Returns the editor's selection. - * - * @param editor the editor - * @return the editor's selection - */ - private static ITextSelection getSelection(ITextEditor editor) { - - ISelectionProvider selectionProvider= editor.getSelectionProvider(); - if (selectionProvider == null) - return null; - - ISelection selection= selectionProvider.getSelection(); - if (!(selection instanceof ITextSelection)) - return null; - - return (ITextSelection) selection; - } - - /* - * @see IAction#run() - */ - public void run() { - - if (fTarget == null) - return; - - ITextEditor editor= getTextEditor(); - if (editor == null) - return; - - if (!validateEditorInputState()) - return; - - IDocument document= getDocument(editor); - if (document == null) - return; - - ITextSelection selection= getSelection(editor); - if (selection == null) - return; - - try { - fTarget.deleteLine(document, selection.getOffset(), fType, fCopyToClipboard); - } catch (BadLocationException e) { - // should not happen - } - } - - /* - * @see IUpdate#update() - */ - public void update() { - - super.update(); - if (!isEnabled()) - return; - - if (!canModifyEditor()) { - setEnabled(false); - return; - } - - ITextEditor editor= getTextEditor(); - if (editor != null) - fTarget= (DeleteLineTarget) editor.getAdapter(DeleteLineTarget.class); - else - fTarget= null; - - setEnabled(fTarget != null); - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/DeleteLineTarget.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/DeleteLineTarget.java deleted file mode 100644 index 1a76e1f445d..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/DeleteLineTarget.java +++ /dev/null @@ -1,353 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.texteditor; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; - -import org.eclipse.swt.SWTError; -import org.eclipse.swt.custom.StyledText; -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.events.FocusEvent; -import org.eclipse.swt.events.FocusListener; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.events.MouseListener; - -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.Region; -import org.eclipse.jface.text.TextEvent; - -import org.eclipse.ui.internal.texteditor.TextEditorPlugin; - -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.SelectionChangedEvent; - - -/** - * A delete line target. - * @since 2.1 - */ -class DeleteLineTarget { - - /** - * A clipboard which concatenates subsequent delete line actions. - */ - private static class DeleteLineClipboard implements MouseListener, ModifyListener, ISelectionChangedListener, ITextListener, FocusListener { - - /** The text viewer. */ - private final ITextViewer fViewer; - /* - * This is a hack to stop a string of deletions when the user moves - * the caret. This kludge is necessary since: - * 1) Moving the caret does not fire a selection event - * 2) There is no support in StyledText for a CaretListener - * 3) The AcceleratorScope and KeybindingService classes are internal - * - * This kludge works by comparing the offset of the caret to the offset - * recorded the last time the action was run. If they differ, we do not - * continue the session. - * - * @see #saveState - * @see #checkState - */ - /** The last known offset of the caret */ - private int fIndex= -1; - /** The clip board. */ - private Clipboard fClipboard; - /** A string buffer. */ - private final StringBuffer fBuffer= new StringBuffer(); - /** The delete flag indicates if a deletion is in progress. */ - private boolean fDeleting; - - /** - * Creates the clipboard. - * - * @param viewer the text viewer - */ - public DeleteLineClipboard(ITextViewer viewer) { - Assert.isNotNull(viewer); - fViewer= viewer; - } - - /** - * Returns the text viewer. - * - * @return the text viewer - */ - public ITextViewer getViewer() { - return fViewer; - } - - /** - * Saves the current state, to be compared later using - * <code>checkState</code>. - */ - private void saveState() { - fIndex= fViewer.getTextWidget().getCaretOffset(); - } - - /** - * Checks that the state has not changed since it was saved. - * - * @return returns <code>true</code> if the current state is the same as - * when it was last saved. - */ - private boolean hasSameState() { - return fIndex == fViewer.getTextWidget().getCaretOffset(); - } - - /** - * Checks the state of the clipboard. - */ - public void checkState() { - - if (fClipboard == null) { - StyledText text= fViewer.getTextWidget(); - if (text == null) - return; - - fViewer.getSelectionProvider().addSelectionChangedListener(this); - text.addFocusListener(this); - text.addMouseListener(this); - text.addModifyListener(this); - - fClipboard= new Clipboard(text.getDisplay()); - fBuffer.setLength(0); - - } else if (!hasSameState()) { - fBuffer.setLength(0); - } - } - - /** - * Appends the given string to this clipboard. - * - * @param deltaString the string to append - */ - public void append(String deltaString) { - fBuffer.append(deltaString); - String string= fBuffer.toString(); - Transfer[] dataTypes= new Transfer[] { TextTransfer.getInstance() }; - Object[] data= new Object[] { string }; - fClipboard.setContents(data, dataTypes); - } - - /** - * Uninstalls this action. - */ - private void uninstall() { - - if (fClipboard == null) - return; - - StyledText text= fViewer.getTextWidget(); - if (text == null) - return; - - fViewer.getSelectionProvider().removeSelectionChangedListener(this); - text.removeFocusListener(this); - text.removeMouseListener(this); - text.removeModifyListener(this); - - fClipboard.dispose(); - fClipboard= null; - } - - /** - * Mark whether a deletion is in progress. - * - * @param deleting <code>true</code> if a deletion is in progress - */ - public void setDeleting(boolean deleting) { - fDeleting= deleting; - } - - /* - * @see org.eclipse.swt.events.MouseListener#mouseDoubleClick(MouseEvent) - */ - public void mouseDoubleClick(MouseEvent e) { - uninstall(); - } - - /* - * @see org.eclipse.swt.events.MouseListener#mouseDown(MouseEvent) - */ - public void mouseDown(MouseEvent e) { - uninstall(); - } - - /* - * @see org.eclipse.swt.events.MouseListener#mouseUp(MouseEvent) - */ - public void mouseUp(MouseEvent e) { - uninstall(); - } - - /* - * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(SelectionChangedEvent) - */ - public void selectionChanged(SelectionChangedEvent event) { - uninstall(); - } - - /* - * @see org.eclipse.swt.events.FocusListener#focusGained(FocusEvent) - */ - public void focusGained(FocusEvent e) { - uninstall(); - } - - /* - * @see org.eclipse.swt.events.FocusListener#focusLost(FocusEvent) - */ - public void focusLost(FocusEvent e) { - uninstall(); - } - - /* - * @see org.eclipse.jface.text.ITextListener#textChanged(TextEvent) - */ - public void textChanged(TextEvent event) { - uninstall(); - } - - /* - * @see org.eclipse.swt.events.ModifyListener#modifyText(ModifyEvent) - */ - public void modifyText(ModifyEvent e) { - if (!fDeleting) - uninstall(); - } - } - - /** - * The clipboard manager. - */ - private final DeleteLineClipboard fClipboard; - - /** - * Creates a new target. - * - * @param viewer the viewer that the new target operates on - */ - public DeleteLineTarget(ITextViewer viewer) { - fClipboard= new DeleteLineClipboard(viewer); - } - - /** - * Returns the document's delete region specified by position and type. - * - * @param document the document - * @param position the position - * @param type the line deletion type, must be one of - * <code>WHOLE_LINE</code>, <code>TO_BEGINNING</code> or <code>TO_END</code> - * @return the document's delete region - * @throws BadLocationException - */ - private static IRegion getDeleteRegion(IDocument document, int position, int type) throws BadLocationException { - - int line= document.getLineOfOffset(position); - int offset= 0; - int length= 0; - - switch (type) { - case DeleteLineAction.WHOLE: - offset= document.getLineOffset(line); - length= document.getLineLength(line); - break; - - case DeleteLineAction.TO_BEGINNING: - offset= document.getLineOffset(line); - length= position - offset; - break; - - case DeleteLineAction.TO_END: - offset= position; - - IRegion lineRegion= document.getLineInformation(line); - int end= lineRegion.getOffset() + lineRegion.getLength(); - - if (position == end) { - String lineDelimiter= document.getLineDelimiter(line); - length= lineDelimiter == null ? 0 : lineDelimiter.length(); - - } else { - length= end - offset; - } - break; - - default: - throw new IllegalArgumentException(); - } - - return new Region(offset, length); - } - - /** - * Deletes the specified fraction of the line of the given offset. - * - * @param document the document - * @param position the offset - * @param type the line deletion type, must be one of - * <code>WHOLE_LINE</code>, <code>TO_BEGINNING</code> or <code>TO_END</code> - * @param copyToClipboard <code>true</code> if the deleted line should be copied to the clipboard - * @throws BadLocationException if position is not valid in the given document - */ - public void deleteLine(IDocument document, int position, int type, boolean copyToClipboard) throws BadLocationException { - - IRegion deleteRegion= getDeleteRegion(document, position, type); - int offset= deleteRegion.getOffset(); - int length= deleteRegion.getLength(); - - if (length == 0) - return; - - if (copyToClipboard) { - - fClipboard.checkState(); - try { - fClipboard.append(document.get(offset, length)); - } catch (SWTError e) { - if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD) - throw e; - // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=59459 - // don't delete if copy to clipboard fails, rather log & abort - - // log - Status status= new Status(IStatus.ERROR, TextEditorPlugin.PLUGIN_ID, e.code, EditorMessages.getString("Editor.error.clipboard.copy.failed.message"), e); //$NON-NLS-1$ - TextEditorPlugin.getDefault().getLog().log(status); - - fClipboard.uninstall(); - return; // don't delete - } - - fClipboard.setDeleting(true); - document.replace(offset, length, null); - fClipboard.setDeleting(false); - - fClipboard.saveState(); - - } else { - document.replace(offset, length, null); - } - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/EditorMessages.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/EditorMessages.java deleted file mode 100644 index 98732b73940..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/EditorMessages.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.ui.texteditor; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -class EditorMessages { - - private static final String RESOURCE_BUNDLE= "org.eclipse.ui.texteditor.EditorMessages";//$NON-NLS-1$ - - private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE); - - private EditorMessages() { - } - - 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.workbench.texteditor/src/org/eclipse/ui/texteditor/EditorMessages.properties b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/EditorMessages.properties deleted file mode 100644 index 98ad8574d45..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/EditorMessages.properties +++ /dev/null @@ -1,426 +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 -############################################################################### - - -## Errors ## - -Editor.error.no_provider=Text editor does not have a document provider - -Editor.error.save.title=Save problems -Editor.error.save.message=Save could not be completed. - -Editor.error.save.deleted.title=Cannot Save -Editor.error.save.deleted.message=The file has been deleted. - -Editor.error.init= Editor could not be initialized. - -Editor.error.save.outofsync.title=Update conflict -Editor.error.save.outofsync.message=The file has been changed on the file system. Do you want to overwrite the changes? - -Editor.error.activated.outofsync.title=File Changed -Editor.error.activated.outofsync.message=The file has been changed on the file system. Do you want to load the changes? - -Editor.error.activated.deleted.save.title=File Deleted -Editor.error.activated.deleted.save.message=The file has been deleted from the file system. Do you want to save your changes or close the editor without saving? -Editor.error.activated.deleted.save.button.save=Save -Editor.error.activated.deleted.save.button.close=Close -Editor.error.activated.deleted.close.title=File Deleted -Editor.error.activated.deleted.close.message=The file has been deleted from the file system. This editor will be closed. - -Editor.error.refresh.outofsync.title=Problems loading File -Editor.error.refresh.outofsync.message=The file could not be loaded from the file system. - -Editor.error.revert.title=Problems while reverting to saved state -Editor.error.revert.message=Could not revert to saved state. -Editor.error.setinput.title=Problem opening -Editor.error.setinput.message=Cannot open input element: -Editor.error.no_input=Unable to read text editor input -Editor.error.invalid_input=Invalid text editor input - -Editor.error.validateEdit.title= Problems editing file -Editor.error.validateEdit.message= The file cannot be edited. - -AbstractDocumentProvider.error.save.inuse=File is either open in another editor or in use by another operation. - - - -## Actions ## - -Editor.Undo.label=&Undo -Editor.Undo.tooltip=Undo -Editor.Undo.image= -Editor.Undo.description=Undo - -Editor.Redo.label=&Redo -Editor.Redo.tooltip=Redo -Editor.Redo.image= -Editor.Redo.description=Redo - -Editor.Cut.label=Cu&t -Editor.Cut.tooltip=Cut -Editor.Cut.image= -Editor.Cut.description=Cut - -Editor.Copy.label=&Copy -Editor.Copy.tooltip=Copy -Editor.Copy.image= -Editor.Copy.description=Copy - -Editor.Paste.label=&Paste -Editor.Paste.tooltip=Paste -Editor.Paste.image= -Editor.Paste.description=Paste - -Editor.Delete.label=&Delete -Editor.Delete.tooltip=Delete -Editor.Delete.image= -Editor.Delete.description=Delete - -Editor.Print.label=&Print -Editor.Print.tooltip=Print -Editor.Print.image= -Editor.Print.description=Print - -Editor.SelectAll.label=Select &All -Editor.SelectAll.tooltip=Select All -Editor.SelectAll.image= -Editor.SelectAll.description=Select All - -Editor.ShiftRight.label=Sh&ift Right -Editor.ShiftRight.tooltip=Shift Right -Editor.ShiftRight.image= -Editor.ShiftRight.description=Shift Right - -Editor.ShiftLeft.label=S&hift Left -Editor.ShiftLeft.tooltip=Shift Left -Editor.ShiftLeft.image= -Editor.ShiftLeft.description=Shift Left - -Editor.delete.line.submenu.label=D&elete Line - -Editor.DeleteLine.label=&Whole -Editor.DeleteLine.tooltip=Delete Line -Editor.DeleteLine.image= -Editor.DeleteLine.description=Delete Line - -Editor.CutLine.label=&Whole -Editor.CutLine.tooltip=Cut Line -Editor.CutLine.image= -Editor.CutLine.description=Cut Line - -Editor.DeleteLineToBeginning.label=To &Beginning -Editor.DeleteLineToBeginning.tooltip=Delete Line to Beginning -Editor.DeleteLineToBeginning.image= -Editor.DeleteLineToBeginning.description=Delete Line to Beginning - -Editor.CutLineToBeginning.label=To &Beginning -Editor.CutLineToBeginning.tooltip=Cut Line to Beginning -Editor.CutLineToBeginning.image= -Editor.CutLineToBeginning.description=Cut Line to Beginning - -Editor.DeleteLineToEnd.label=To &End -Editor.DeleteLineToEnd.tooltip=Delete Line to End -Editor.DeleteLineToEnd.image= -Editor.DeleteLineToEnd.description=Delete Line to End - -Editor.CutLineToEnd.label=To &End -Editor.CutLineToEnd.tooltip=Cut Line to End -Editor.CutLineToEnd.image= -Editor.CutLineToEnd.description=Cut Line to End - -Editor.mark.status.message.mark.set=Mark set -Editor.mark.status.message.mark.cleared=Mark cleared -Editor.mark.status.message.mark.swapped=Mark swapped -Editor.mark.status.error.message.mark.not.set=Mark not set -Editor.mark.status.error.message.mark.not.visible=Mark not in visible region - -Editor.mark.submenu.label=&Mark - -Editor.SetMark.label=&Set -Editor.SetMark.tooltip=Set Mark -Editor.SetMark= -Editor.SetMark.description=Set Mark - -Editor.ClearMark.label=&Clear -Editor.ClearMark.tooltip=Clear Mark -Editor.ClearMark= -Editor.ClearMark.description=Clear Mark - -Editor.SwapMark.label=S&wap -Editor.SwapMark.tooltip=Swap Mark -Editor.SwapMark= -Editor.SwapMark.description=Swap Mark - -Editor.ToggleInsertMode.label=Sma&rt Insert Mode -Editor.ToggleInsertMode.tooltip=Toggle Smart Insert Mode -Editor.ToggleInsertMode.image= -Editor.ToggleInsertMode.description= Toggles smart insert mode - -Editor.FindReplace.label=&Find/Replace... -Editor.FindReplace.tooltip=Find/Replace -Editor.FindReplace.image= -Editor.FindReplace.description=Find/Replace - -Editor.FindNext.label=Find &Next -Editor.FindNext.tooltip=Find Next -Editor.FindNext.image= -Editor.FindNext.description=Find Next - -Editor.FindPrevious.label=Find Pre&vious -Editor.FindPrevious.tooltip=Find Previous -Editor.FindPrevious.image= -Editor.FindPrevious.description=Find Previous - -Editor.FindIncremental.label=&Incremental Find Next -Editor.FindIncremental.tooltip=Incremental Find Next -Editor.FindIncremental.image= -Editor.FindIncremental.description=Incremental Find Next - -# Incremental Find Status field -Editor.FindIncremental.name= Incremental Find -Editor.FindIncremental.reverse.name= Reverse Incremental Find -Editor.FindIncremental.not_found.pattern={0}{1} {2} not found -Editor.FindIncremental.found.pattern={0}{1}: {2} -Editor.FindIncremental.render.tab=<TAB> -# The following two properties must end in a space -Editor.FindIncremental.wrapped=Wrapped -Editor.FindIncremental.reverse=Reverse - -Editor.FindIncrementalReverse.label=Incre&mental Find Previous -Editor.FindIncrementalReverse.tooltip=Incremental Find Previous -Editor.FindIncrementalReverse.image= -Editor.FindIncrementalReverse.description=Incremental Find Previous - -Editor.Save.label=&Save -Editor.Save.tooltip=Save -Editor.Save.image= -Editor.Save.description=Save - -Editor.Revert.label=Re&vert File -Editor.Revert.tooltip=Revert File to Saved Version -Editor.Revert.image= -Editor.Revert.description=Reverts file contents to version on disk - -Editor.GotoLine.label=&Go to Line... -Editor.GotoLine.tooltip=Go to Line -Editor.GotoLine.image= -Editor.GotoLine.description=Go to Line -Editor.GotoLine.dialog.title=Go to Line -Editor.GotoLine.dialog.message=Enter line number (1..{0}): -Editor.GotoLine.dialog.invalid_input=Not a number -Editor.GotoLine.dialog.invalid_range=Line number out of range - -Editor.ConvertLineDelimiter.title=Converting line delimiters... -Editor.ConvertLineDelimiter.toWindows.label=CRLF (&Windows) -Editor.ConvertLineDelimiter.toWindows.default.label=CRLF (&Windows) [default] -Editor.ConvertLineDelimiter.toUNIX.label=LF (&UNIX, MacOS X) -Editor.ConvertLineDelimiter.toUNIX.default.label=LF (&UNIX, MacOS X) [default] -Editor.ConvertLineDelimiter.toMac.label=CR (Classic &MacOS) -Editor.ConvertLineDelimiter.toMac.default.label=CR (Classic &MacOS) [default] - -Editor.MoveLines.IllegalMove.status= Move not possible - Uncheck "Show Source of Selected Element Only" to see the entire document - -Editor.SmartEnter.label=Insert line below current line -Editor.SmartEnter.tooltip=Add a New Line Below the Current Line -Editor.SmartEnter.image= -Editor.SmartEnter.description=Adds a new line below the current line - -Editor.SmartEnterInverse.label=Insert line above current line -Editor.SmartEnterInverse.tooltip=Add a New Line Above the Current Line -Editor.SmartEnterInverse.image= -Editor.SmartEnterInverse.description=Adds a new line above the current line - -Editor.MoveLinesUp.label=Move Lines Up -Editor.MoveLinesUp.tooltip=Move the Selected Lines Up -Editor.MoveLinesUp.image= -Editor.MoveLinesUp.description=Moves the selected lines up - -Editor.MoveLinesDown.label=Move Lines Down -Editor.MoveLinesDown.tooltip=Move the Selected Lines Down -Editor.MoveLinesDown.image= -Editor.MoveLinesDown.description=Moves the selected lines down - -Editor.UpperCase.label=To Upper Case -Editor.UpperCase.tooltip=Change the Selection to Upper Case -Editor.UpperCase.image= -Editor.UpperCase.description=Changes the selection to upper case - -Editor.LowerCase.label=To Lower Case -Editor.LowerCase.tooltip=Change the Selection to Lower Case -Editor.LowerCase.image= -Editor.LowerCase.description=Changes the selection to lower case - - -## Status line ## - -Editor.statusline.state.readonly.label=Read-Only -Editor.statusline.state.writable.label=Writable -Editor.statusline.mode.insert.label=Insert -Editor.statusline.mode.overwrite.label=Overwrite -Editor.statusline.mode.smartinsert.label=Smart Insert -Editor.statusline.position.pattern={0} : {1} -Editor.statusline.error.label=? - -## Overwrite action # -Editor.ToggleOverwriteMode.label= Toggle Overwrite Mode -Editor.ToggleOverwriteMode.tooltip= Toggle Overwrite Mode -Editor.ToggleOverwriteMode.image= -Editor.ToggleOverwriteMode.description= Toggles overwrite / insert behaviour - -## Others ## - -WorkbenchChainedTextFontFieldEditor.defaultWorkbenchTextFont=<Using Workbench Text Font> - -FindReplace.title= Find/Replace -FindReplace.Find.label=&Find: -FindReplace.Replace.label=R&eplace With: -FindReplace.Direction=Direction -FindReplace.ForwardRadioButton.label=F&orward -FindReplace.BackwardRadioButton.label=&Backward -FindReplace.Scope=Scope -FindReplace.GlobalRadioButton.label=A&ll -FindReplace.SelectedRangeRadioButton.label=Selec&ted Lines -FindReplace.Options=Options -FindReplace.CaseCheckBox.label=&Case Sensitive -FindReplace.WrapCheckBox.label=Wra&p Search -FindReplace.WholeWordCheckBox.label=&Whole Word -FindReplace.IncrementalCheckBox.label=&Incremental -FindReplace.RegExCheckbox.label= Regular e&xpressions -FindReplace.FindNextButton.label=Fi&nd -FindReplace.ReplaceFindButton.label=Replace/Fin&d -FindReplace.ReplaceSelectionButton.label=&Replace -FindReplace.ReplaceAllButton.label=Replace &All -FindReplace.CloseButton.label=Close -FindReplace.Status.noMatch.label=String Not Found -FindReplace.Status.replacement.label=1 Match replaced -FindReplace.Status.replacements.label={0} matches replaced - -FindNext.Status.noMatch.label=String Not Found - -AbstractDocumentProvider.ok=OK -AbstractDocumentProvider.error=ERROR -FindReplaceDialog.read_only=Cannot replace. File is read-only. -MarkRegionTarget.markNotSet=mark not set -MarkRegionTarget.markNotVisible=mark not in visible region - -## Content Assist for regular expressions ## -FindReplace.regExContentAssist.displayString.\\\\= Backslash -FindReplace.regExContentAssist.additionalInfo.\\\\= \\\\ -FindReplace.regExContentAssist.displayString.\\0= Octal charcter code -FindReplace.regExContentAssist.additionalInfo.\\0= \\0 -FindReplace.regExContentAssist.displayString.\\x= Hex character code -FindReplace.regExContentAssist.additionalInfo.\\x= \\x -FindReplace.regExContentAssist.displayString.\\u= Hex code for double-byte character -FindReplace.regExContentAssist.additionalInfo.\\u= \\\u0075 -FindReplace.regExContentAssist.displayString.\\t= Tab -FindReplace.regExContentAssist.additionalInfo.\\t= \\t -FindReplace.regExContentAssist.displayString.\\n= Newline -FindReplace.regExContentAssist.additionalInfo.\\n= \\n -FindReplace.regExContentAssist.displayString.\\r= CR -FindReplace.regExContentAssist.additionalInfo.\\r= \\r -FindReplace.regExContentAssist.displayString.\\f= FF -FindReplace.regExContentAssist.additionalInfo.\\f= \\f -FindReplace.regExContentAssist.displayString.\\a= Beep -FindReplace.regExContentAssist.additionalInfo.\\a= \\a -FindReplace.regExContentAssist.displayString.\\e= Esc -FindReplace.regExContentAssist.additionalInfo.\\e= \\e -FindReplace.regExContentAssist.displayString.\\c= Control character -FindReplace.regExContentAssist.additionalInfo.\\c= \\c -FindReplace.regExContentAssist.displayString..= Any character -FindReplace.regExContentAssist.additionalInfo..= . -FindReplace.regExContentAssist.displayString.\\d= A digit -FindReplace.regExContentAssist.additionalInfo.\\d= \\d -FindReplace.regExContentAssist.displayString.\\D= Not a digit -FindReplace.regExContentAssist.additionalInfo.\\D= \\D -FindReplace.regExContentAssist.displayString.\\s= A whitespace -FindReplace.regExContentAssist.additionalInfo.\\s= \\s -FindReplace.regExContentAssist.displayString.\\S= Not a whitespace -FindReplace.regExContentAssist.additionalInfo.\\S= \\S -FindReplace.regExContentAssist.displayString.\\w= Alphanumeric -FindReplace.regExContentAssist.additionalInfo.\\w= \\w -FindReplace.regExContentAssist.displayString.\\W= Not an alphanumeric -FindReplace.regExContentAssist.additionalInfo.\\W= \\W -FindReplace.regExContentAssist.displayString.?= Greedy match 0 or 1 times -FindReplace.regExContentAssist.additionalInfo.?= ? -FindReplace.regExContentAssist.displayString.*= Greedy match 0 or more times -FindReplace.regExContentAssist.additionalInfo.*= * -FindReplace.regExContentAssist.displayString.+= Greedy match 1 or more times -FindReplace.regExContentAssist.additionalInfo.+= + -FindReplace.regExContentAssist.displayString.{n}= Greedy match exactly n times -FindReplace.regExContentAssist.additionalInfo.{n}= {n} -FindReplace.regExContentAssist.displayString.{n,}= Greedy match >= n times -FindReplace.regExContentAssist.additionalInfo.{n,}= {n,} -FindReplace.regExContentAssist.displayString.{n,m}= Greedy match >= n times but <= m times -FindReplace.regExContentAssist.additionalInfo.{n,m}= {n,m} -FindReplace.regExContentAssist.displayString.??= Match 0 or 1 times (left to right) -FindReplace.regExContentAssist.additionalInfo.??= ?? -FindReplace.regExContentAssist.displayString.*?= Match 0 or more times (left to right) -FindReplace.regExContentAssist.additionalInfo.*?= *? -FindReplace.regExContentAssist.displayString.+?= Match 1 or more times (left to right) -FindReplace.regExContentAssist.additionalInfo.+?= +? -FindReplace.regExContentAssist.displayString.{n}?= Match exactly n times (left to right) -FindReplace.regExContentAssist.additionalInfo.{n}?= {n}? -FindReplace.regExContentAssist.displayString.{n,}?= Match >= n times (left to right) -FindReplace.regExContentAssist.additionalInfo.{n,}?= {n,}? -FindReplace.regExContentAssist.displayString.{n,m}?= Match >= n times but <= m times (left to right) -FindReplace.regExContentAssist.additionalInfo.{n,m}?= {n,m}? -FindReplace.regExContentAssist.displayString.?+= Match 0 or 1 times compared to full text -FindReplace.regExContentAssist.additionalInfo.?+= ?+ -FindReplace.regExContentAssist.displayString.*+= Match 0 or more times compared to full text -FindReplace.regExContentAssist.additionalInfo.*+= *+ -FindReplace.regExContentAssist.displayString.++= Match 1 or more times compared to full text -FindReplace.regExContentAssist.additionalInfo.++= ++ -FindReplace.regExContentAssist.displayString.{n}+= Match exactly n times compared to full text -FindReplace.regExContentAssist.additionalInfo.{n}+= {n}+ -FindReplace.regExContentAssist.displayString.{n,}+= Match >= n times compared to full text -FindReplace.regExContentAssist.additionalInfo.{n,}+= {n,}+ -FindReplace.regExContentAssist.displayString.{n,m}+= Match >= n times but <= m times compared to full text -FindReplace.regExContentAssist.additionalInfo.{n,m}+= {n,m}+ -FindReplace.regExContentAssist.displayString.UV= U and V -FindReplace.regExContentAssist.additionalInfo.UV= UV -FindReplace.regExContentAssist.displayString.U|V= U or V -FindReplace.regExContentAssist.additionalInfo.U|V= U|V -FindReplace.regExContentAssist.displayString.(U)= Mark U as capturing group -FindReplace.regExContentAssist.additionalInfo.(U)= (U) -FindReplace.regExContentAssist.displayString.\\i= Find field: Match of the capturing group i -FindReplace.regExContentAssist.additionalInfo.\\i= \\i -FindReplace.regExContentAssist.displayString.$i= Replace field: Match of the capturing group i -FindReplace.regExContentAssist.additionalInfo.$i= $i -FindReplace.regExContentAssist.displayString.\\= Quote next character -FindReplace.regExContentAssist.additionalInfo.\\= \\ -FindReplace.regExContentAssist.displayString.\\Q= Start quoting -FindReplace.regExContentAssist.additionalInfo.\\Q= \\Q -FindReplace.regExContentAssist.displayString.\\E= End quoting -FindReplace.regExContentAssist.additionalInfo.\\E= \\E -FindReplace.regExContentAssist.displayString.[ecq]= Character set -FindReplace.regExContentAssist.additionalInfo.[ecq]= Example: [ecq] -FindReplace.regExContentAssist.displayString.[^ecq]= Excluded character set -FindReplace.regExContentAssist.additionalInfo.[^ecq]= Example: [^ecq] -FindReplace.regExContentAssist.displayString.[e-q]= Character range -FindReplace.regExContentAssist.additionalInfo.[e-q]= Example: [e-q] -FindReplace.regExContentAssist.displayString.&&= Intersection of character sets -FindReplace.regExContentAssist.additionalInfo.&&= Example: [e-q&&[def]] -FindReplace.regExContentAssist.displayString.^= Line start -FindReplace.regExContentAssist.additionalInfo.^= ^ -FindReplace.regExContentAssist.displayString.$= Line end -FindReplace.regExContentAssist.additionalInfo.$= $ -FindReplace.regExContentAssist.displayString.\\b= Word beginning or end -FindReplace.regExContentAssist.additionalInfo.\\b= \\b -FindReplace.regExContentAssist.displayString.\\B= Not a word beginning or end -FindReplace.regExContentAssist.additionalInfo.\\B= \\B -FindReplace.regExContentAssist.displayString.\\A= Start of input -FindReplace.regExContentAssist.additionalInfo.\\A= \\A -FindReplace.regExContentAssist.displayString.\\G= Previous match's end -FindReplace.regExContentAssist.additionalInfo.\\G= \\G -FindReplace.regExContentAssist.displayString.\\Z= \\Z -FindReplace.regExContentAssist.additionalInfo.\\Z= \\Z -FindReplace.regExContentAssist.displayString.\\z= End of input -FindReplace.regExContentAssist.additionalInfo.\\z= \\z diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/EditorStatusLine.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/EditorStatusLine.java deleted file mode 100644 index ef1ee8298e0..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/EditorStatusLine.java +++ /dev/null @@ -1,140 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.texteditor; - -import org.eclipse.swt.graphics.Image; - -import org.eclipse.jface.text.Assert; - -import org.eclipse.jface.action.IStatusLineManager; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.SelectionChangedEvent; - -/** - * An editor status line. - * The selection provider of the editor triggers the status line to be cleared. - * @since 2.1 - */ -class EditorStatusLine implements IEditorStatusLine { - - /** - * Clears the status line on selection changed. - */ - private class StatusLineClearer implements ISelectionChangedListener { - /* - * @see ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) - */ - public void selectionChanged(SelectionChangedEvent event) { - fStatusLineManager.setErrorMessage(null, null); - fStatusLineManager.setMessage(null, null); - - Assert.isTrue(this == fStatusLineClearer); - uninstallStatusLineClearer(); - } - } - - /** The status line manager. */ - private final IStatusLineManager fStatusLineManager; - - /** The selection provider. */ - private final ISelectionProvider fSelectionProvider; - - /** The status line clearer, <code>null</code> if not installed. */ - private StatusLineClearer fStatusLineClearer; - - /** - * Constructor for EditorStatusLine. - * - * @param statusLineManager the status line manager - * @param selectionProvider the selection provider - */ - public EditorStatusLine(IStatusLineManager statusLineManager, ISelectionProvider selectionProvider) { - - Assert.isNotNull(statusLineManager); - Assert.isNotNull(selectionProvider); - - fStatusLineManager= statusLineManager; - fSelectionProvider= selectionProvider; - } - - /** - * Returns the status line manager. - * - * @return the status line manager - */ - public IStatusLineManager getStatusLineManager() { - return fStatusLineManager; - } - - /** - * Returns the selection provider. - * - * @return the selection provider - */ - public ISelectionProvider getSelectionProvider() { - return fSelectionProvider; - } - - /* - * @see org.eclipse.ui.texteditor.IStatusLine#setMessage(boolean, String, Image) - */ - public void setMessage(boolean error, String message, Image image) { - - if (error) - fStatusLineManager.setErrorMessage(image, message); - else { - // Clear error message - fStatusLineManager.setErrorMessage(null, null); - - fStatusLineManager.setMessage(image, message); - } - - if (isMessageEmpty(message)) - uninstallStatusLineClearer(); - else - installStatusLineClearer(); - } - - /** - * Returns whether this given string is empty. - * - * @param message a string - * @return <code>true</code> if the string is <code>null</code>, has 0 length or only white space characters. - */ - private static boolean isMessageEmpty(String message) { - return message == null || message.trim().length() == 0; - } - - /** - * Uninstalls the status line clearer. - */ - private void uninstallStatusLineClearer() { - if (fStatusLineClearer == null) - return; - - fSelectionProvider.removeSelectionChangedListener(fStatusLineClearer); - fStatusLineClearer= null; - } - - /** - * Installs the status line clearer. - */ - private void installStatusLineClearer() { - if (fStatusLineClearer != null) - return; - - StatusLineClearer statusLineClearer= new StatusLineClearer(); - fSelectionProvider.addSelectionChangedListener(statusLineClearer); - fStatusLineClearer= statusLineClearer; - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindNextAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindNextAction.java deleted file mode 100644 index 12d50a257f7..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindNextAction.java +++ /dev/null @@ -1,398 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.texteditor; - - -import java.util.ArrayList; -import java.util.List; -import java.util.ResourceBundle; -import java.util.regex.PatternSyntaxException; - -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.Shell; - -import org.eclipse.jface.action.IStatusLineManager; -import org.eclipse.jface.dialogs.IDialogSettings; - -import org.eclipse.jface.text.IFindReplaceTarget; -import org.eclipse.jface.text.IFindReplaceTargetExtension3; -import org.eclipse.jface.text.TextUtilities; - -import org.eclipse.ui.IEditorActionBarContributor; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.internal.texteditor.TextEditorPlugin; -import org.eclipse.ui.part.EditorActionBarContributor; - - -/** - * An action which finds the next/previous occurrence of the last search or the - * current selection if present. - * <p> - * This class may be instantiated; it is not intended to be subclassed. - * </p> - * - * @since 2.0 - */ -public class FindNextAction extends ResourceAction implements IUpdate { - - /** The action's target */ - private IFindReplaceTarget fTarget; - /** The part the action is bound to */ - private IWorkbenchPart fWorkbenchPart; - /** The workbench window */ - private IWorkbenchWindow fWorkbenchWindow; - /** The dialog settings to retrieve the last search */ - private IDialogSettings fDialogSettings; - /** The find history as initially given in the dialog settings. */ - private List fFindHistory= new ArrayList(); - /** The find string as initially given in the dialog settings. */ - private String fFindString; - /** The search direction as initially given in the dialog settings. */ - private boolean fForward; - /** The wrapping flag as initially given in the dialog settings. */ - private boolean fWrapInit; - /** The case flag as initially given in the dialog settings. */ - private boolean fCaseInit; - /** The whole word flag as initially given in the dialog settings. */ - private boolean fWholeWordInit; - /** - * The regExSearch flag as initially given in the dialog settings. - * - * @since 3.0 - */ - private boolean fRegExSearch; - /** - * The last selection set by find/replace. - * - * @since 3.0 - */ - private String fSelection; - - /** - * Creates a new find/replace action for the given workbench part. - * The action configures its visual representation from the given - * resource bundle. - * - * @param bundle the resource bundle - * @param prefix a prefix to be prepended to the various resource keys - * (described in <code>ResourceAction</code> constructor), or - * <code>null</code> if none - * @param workbenchPart the workbench part - * @param forward the search direction - * @see ResourceAction#ResourceAction(ResourceBundle, String) - */ - public FindNextAction(ResourceBundle bundle, String prefix, IWorkbenchPart workbenchPart, boolean forward) { - super(bundle, prefix); - fWorkbenchPart= workbenchPart; - fForward= forward; - update(); - } - - /** - * Creates a new find/replace action for the given workbench window. - * The action configures its visual representation from the given - * resource bundle. - * - * @param bundle the resource bundle - * @param prefix a prefix to be prepended to the various resource keys - * (described in <code>ResourceAction</code> constructor), or - * <code>null</code> if none - * @param workbenchWindow the workbench window - * @param forward the search direction - * @see ResourceAction#ResourceAction(ResourceBundle, String) - * - * @deprecated use FindReplaceAction(ResourceBundle, String, IWorkbenchPart, boolean) instead - */ - public FindNextAction(ResourceBundle bundle, String prefix, IWorkbenchWindow workbenchWindow, boolean forward) { - super(bundle, prefix); - fWorkbenchWindow= workbenchWindow; - fForward= forward; - update(); - } - - /** - * Returns the find string based on the selection or the find history. - * @return the find string - */ - private String getFindString() { - String string= getSelectionString(); - - if ((string == null || fRegExSearch && string.equals(fSelection)) && !fFindHistory.isEmpty()) - string= (String) fFindHistory.get(0); - - return string; - } - - /** - * Returns the status line manager of the active editor. - * @return the status line manager of the active editor - */ - private IStatusLineManager getStatusLineManager() { - - IEditorPart editor= fWorkbenchPart.getSite().getPage().getActiveEditor(); - if (editor == null) - return null; - - IEditorActionBarContributor contributor= editor.getEditorSite().getActionBarContributor(); - if (contributor instanceof EditorActionBarContributor) { - return ((EditorActionBarContributor) contributor).getActionBars().getStatusLineManager(); - } - return null; - } - - /** - * Sets the "no matches found" error message to the status line. - * - * @since 3.0 - */ - private void statusNotFound() { - fWorkbenchPart.getSite().getShell().getDisplay().beep(); - - IStatusLineManager manager= getStatusLineManager(); - if (manager == null) - return; - - manager.setMessage(EditorMessages.getString("FindNext.Status.noMatch.label")); //$NON-NLS-1$ - } - - /** - * Clears the status line. - */ - private void statusClear() { - IStatusLineManager manager= getStatusLineManager(); - if (manager == null) - return; - - manager.setErrorMessage(""); //$NON-NLS-1$ - manager.setMessage(""); //$NON-NLS-1$ - } - - /* - * @see IAction#run() - */ - public void run() { - if (fTarget != null) { - readConfiguration(); - - fFindString= getFindString(); - if (fFindString == null) { - statusNotFound(); - return; - } - - statusClear(); - if (!findNext(fFindString, fForward, fCaseInit, fWrapInit, fWholeWordInit && !fRegExSearch, fRegExSearch)) - statusNotFound(); - - writeConfiguration(); - } - } - - /* - * @see IUpdate#update() - */ - public void update() { - - if (fWorkbenchPart == null && fWorkbenchWindow != null) - fWorkbenchPart= fWorkbenchWindow.getPartService().getActivePart(); - - if (fWorkbenchPart != null) - fTarget= (IFindReplaceTarget) fWorkbenchPart.getAdapter(IFindReplaceTarget.class); - else - fTarget= null; - - setEnabled(fTarget != null && fTarget.canPerformFind()); - } - - /* - * @see FindReplaceDialog#findIndex(String, int, boolean, boolean, boolean, boolean) - * @since 3.0 - */ - private int findIndex(String findString, int startPosition, boolean forwardSearch, boolean caseSensitive, boolean wrapSearch, boolean wholeWord, boolean regExSearch) { - - if (forwardSearch) { - if (wrapSearch) { - int index= findAndSelect(startPosition, findString, true, caseSensitive, wholeWord, regExSearch); - if (index == -1) { - beep(); - index= findAndSelect(-1, findString, true, caseSensitive, wholeWord, regExSearch); - } - return index; - } - return findAndSelect(startPosition, findString, true, caseSensitive, wholeWord, regExSearch); - } - - // backward - if (wrapSearch) { - int index= findAndSelect(startPosition - 1, findString, false, caseSensitive, wholeWord, regExSearch); - if (index == -1) { - beep(); - index= findAndSelect(-1, findString, false, caseSensitive, wholeWord, regExSearch); - } - return index; - } - return findAndSelect(startPosition - 1, findString, false, caseSensitive, wholeWord, regExSearch); - } - - /** - * Returns whether the specified search string can be found using the given options. - * - * @param findString the string to search for - * @param forwardSearch the search direction - * @param caseSensitive should the search honor cases - * @param wrapSearch should the search wrap to the start/end if end/start reached - * @param wholeWord does the find string represent a complete word - * @param regExSearch if <code>true</code> findString represents a regular expression - * @return <code>true</code> if the find string can be found using the given options - * @since 3.0 - */ - private boolean findNext(String findString, boolean forwardSearch, boolean caseSensitive, boolean wrapSearch, boolean wholeWord, boolean regExSearch) { - - Point r= fTarget.getSelection(); - int findReplacePosition= r.x; - if (forwardSearch) - findReplacePosition += r.y; - - int index= findIndex(findString, findReplacePosition, forwardSearch, caseSensitive, wrapSearch, wholeWord, regExSearch); - - if (index != -1) - return true; - - return false; - } - - private void beep() { - Shell shell= null; - if (fWorkbenchPart != null) - shell= fWorkbenchPart.getSite().getShell(); - else if (fWorkbenchWindow != null) - shell= fWorkbenchWindow.getShell(); - - if (shell != null && !shell.isDisposed()) - shell.getDisplay().beep(); - } - - /** - * 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 forwardSearch the direction of the search - * @param caseSensitive <code>true</code> performs a case sensitive search, <code>false</code> an insensitive search - * @param wholeWord if <code>true</code> only occurrences are reported in which the findString stands as a word by itself - * @param regExSearch if <code>true</code> findString represents a regular expression - * @return the position of the specified string, or -1 if the string has not been found - * @since 3.0 - */ - private int findAndSelect(int offset, String findString, boolean forwardSearch, boolean caseSensitive, boolean wholeWord, boolean regExSearch) { - if (fTarget instanceof IFindReplaceTargetExtension3) - try { - return ((IFindReplaceTargetExtension3)fTarget).findAndSelect(offset, findString, forwardSearch, caseSensitive, wholeWord, regExSearch); - } catch (PatternSyntaxException ex) { - return -1; - } - else - return fTarget.findAndSelect(offset, findString, forwardSearch, caseSensitive, wholeWord); - } - - //--------------- configuration handling -------------- - - /** - * Returns the dialog settings object used to share state - * between several find/replace dialogs. - * - * @return the dialog settings to be used - */ - private IDialogSettings getDialogSettings() { - IDialogSettings settings= TextEditorPlugin.getDefault().getDialogSettings(); - fDialogSettings= settings.getSection(FindReplaceDialog.class.getName()); - if (fDialogSettings == null) - fDialogSettings= settings.addNewSection(FindReplaceDialog.class.getName()); - return fDialogSettings; - } - - /** - * Initializes itself from the dialog settings with the same state - * as at the previous invocation. - */ - private void readConfiguration() { - IDialogSettings s= getDialogSettings(); - - fWrapInit= s.getBoolean("wrap"); //$NON-NLS-1$ - fCaseInit= s.getBoolean("casesensitive"); //$NON-NLS-1$ - fWholeWordInit= s.getBoolean("wholeword"); //$NON-NLS-1$ - fRegExSearch= s.getBoolean("isRegEx"); //$NON-NLS-1$ - fSelection= s.get("selection"); //$NON-NLS-1$ - - String[] findHistory= s.getArray("findhistory"); //$NON-NLS-1$ - if (findHistory != null) { - fFindHistory.clear(); - for (int i= 0; i < findHistory.length; i++) - fFindHistory.add(findHistory[i]); - } - } - - /** - * Stores its current configuration in the dialog store. - */ - private void writeConfiguration() { - if (fFindString == null) - return; - - IDialogSettings s= getDialogSettings(); - - String selection= fTarget.getSelectionText(); - if (selection == null) - selection= ""; //$NON-NLS-1$ - s.put("selection", selection); //$NON-NLS-1$ - - if (!fFindHistory.isEmpty() && fFindString.equals(fFindHistory.get(0))) - return; - - int index= fFindHistory.indexOf(fFindString); - if (index != -1) - fFindHistory.remove(index); - fFindHistory.add(0, fFindString); - - while (fFindHistory.size() > 8) - fFindHistory.remove(8); - String[] names= new String[fFindHistory.size()]; - fFindHistory.toArray(names); - s.put("findhistory", names); //$NON-NLS-1$ - } - - /** - * Returns the actual selection of the find replace target. - * - * @return the actual selection of the find replace target - */ - private String getSelectionString() { - - /* - * 1GF86V3: ITPUI:WINNT - Internal errors using Find/Replace Dialog - * Now uses TextUtilities rather than focusing on '\n' - */ - String selection= fTarget.getSelectionText(); - if (selection != null && selection.length() > 0) { - int[] info= TextUtilities.indexOf(TextUtilities.DELIMITERS, selection, 0); - if (info[0] > 0) - return selection.substring(0, info[0]); - else if (info[0] == -1) - return selection; - } - return null; - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceAction.java deleted file mode 100644 index 6b23619e883..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceAction.java +++ /dev/null @@ -1,250 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.texteditor; - - -import java.util.ResourceBundle; - -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -import org.eclipse.swt.widgets.Shell; - -import org.eclipse.jface.text.IFindReplaceTarget; - -import org.eclipse.ui.IPartListener; -import org.eclipse.ui.IPartService; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchPartSite; -import org.eclipse.ui.IWorkbenchWindow; - - -/** - * An action which opens a Find/Replace dialog. - * The dialog while open, tracks the active workbench part - * and retargets itself to the active find/replace target. - * <p> - * This class may be instantiated; it is not intended to be subclassed. - * </p> - * - * @see IFindReplaceTarget - */ -public class FindReplaceAction extends ResourceAction implements IUpdate { - - /** - * Represents the "global" find/replace dialog. It tracks the active - * part and retargets the find/replace dialog accordingly. The find/replace - * target is retrieved from the active part using - * <code>getAdapter(IFindReplaceTarget.class)</code>. - * <p> - * The stub has the same life cycle as the find/replace dialog.</p> - */ - class FindReplaceDialogStub implements IPartListener, DisposeListener { - - /** The workbench part */ - private IWorkbenchPart fPart; - /** The previous workbench part */ - private IWorkbenchPart fPreviousPart; - /** The previous find/replace target */ - private IFindReplaceTarget fPreviousTarget; - - /** The workbench window */ - private IWorkbenchWindow fWindow; - /** The find/replace dialog */ - private FindReplaceDialog fDialog; - - /** - * Creates a new find/replace dialog accessor anchored at the given part site. - * @param site the part site - */ - public FindReplaceDialogStub(IWorkbenchPartSite site) { - - fWindow= site.getWorkbenchWindow(); - - fDialog= new FindReplaceDialog(site.getShell()); - fDialog.create(); - fDialog.getShell().addDisposeListener(this); - - IPartService service= fWindow.getPartService(); - service.addPartListener(this); - partActivated(service.getActivePart()); - } - - /** - * Returns the find/replace dialog. - * @return the find/replace dialog - */ - public FindReplaceDialog getDialog() { - return fDialog; - } - - /* - * @see IPartListener#partActivated(IWorkbenchPart) - */ - public void partActivated(IWorkbenchPart part) { - - IFindReplaceTarget target= part == null ? null : (IFindReplaceTarget) part.getAdapter(IFindReplaceTarget.class); - fPreviousPart= fPart; - fPart= target == null ? null : part; - - if (fPreviousTarget != target) { - fPreviousTarget= target; - if (fDialog != null) { - boolean isEditable= false; - if (fPart instanceof ITextEditorExtension2) { - ITextEditorExtension2 extension= (ITextEditorExtension2) fPart; - isEditable= extension.isEditorInputModifiable(); - } - fDialog.updateTarget(target, isEditable); - } - } - } - - /* - * @see IPartListener#partClosed(IWorkbenchPart) - */ - public void partClosed(IWorkbenchPart part) { - - if (part == fPreviousPart) { - fPreviousPart= null; - fPreviousTarget= null; - } - - if (part == fPart) - partActivated(null); - } - - /* - * @see DisposeListener#widgetDisposed(DisposeEvent) - */ - public void widgetDisposed(DisposeEvent event) { - - if (fgFindReplaceDialogStub == this) - fgFindReplaceDialogStub= null; - - if (fWindow != null) { - fWindow.getPartService().removePartListener(this); - fWindow= null; - } - fDialog= null; - fPart= null; - fPreviousPart= null; - fPreviousTarget= null; - } - - /* - * @see IPartListener#partOpened(IWorkbenchPart) - */ - public void partOpened(IWorkbenchPart part) {} - - /* - * @see IPartListener#partDeactivated(IWorkbenchPart) - */ - public void partDeactivated(IWorkbenchPart part) {} - - /* - * @see IPartListener#partBroughtToTop(IWorkbenchPart) - */ - public void partBroughtToTop(IWorkbenchPart part) {} - } - - - /** Lister for disabling the dialog on editor close */ - private static FindReplaceDialogStub fgFindReplaceDialogStub; - /** The action's target */ - private IFindReplaceTarget fTarget; - /** The part the action is bound to */ - private IWorkbenchPart fWorkbenchPart; - /** The workbench window */ - private IWorkbenchWindow fWorkbenchWindow; - - /** - * Creates a new find/replace action for the given workbench part. - * The action configures its visual representation from the given - * resource bundle. - * - * @param bundle the resource bundle - * @param prefix a prefix to be prepended to the various resource keys - * (described in <code>ResourceAction</code> constructor), or - * <code>null</code> if none - * @param workbenchPart the workbench part - * @see ResourceAction#ResourceAction(ResourceBundle, String) - */ - public FindReplaceAction(ResourceBundle bundle, String prefix, IWorkbenchPart workbenchPart) { - super(bundle, prefix); - fWorkbenchPart= workbenchPart; - update(); - } - - /** - * Creates a new find/replace action for the given workbench window. - * The action configures its visual representation from the given - * resource bundle. - * - * @param bundle the resource bundle - * @param prefix a prefix to be prepended to the various resource keys - * (described in <code>ResourceAction</code> constructor), or - * <code>null</code> if none - * @param workbenchWindow the workbench window - * @see ResourceAction#ResourceAction(ResourceBundle, String) - * - * @deprecated use FindReplaceAction(ResourceBundle, String, IWorkbenchPart) instead - */ - public FindReplaceAction(ResourceBundle bundle, String prefix, IWorkbenchWindow workbenchWindow) { - super(bundle, prefix); - fWorkbenchWindow= workbenchWindow; - update(); - } - - /* - * @see IAction#run() - */ - public void run() { - if (fTarget == null) - return; - - if (fgFindReplaceDialogStub != null) { - Shell shell= fWorkbenchPart.getSite().getShell(); - FindReplaceDialog dialog= fgFindReplaceDialogStub.getDialog(); - if (dialog != null && shell != dialog.getParentShell()) { - fgFindReplaceDialogStub= null; // here to avoid timing issues - dialog.close(); - } - } - - if (fgFindReplaceDialogStub == null) - fgFindReplaceDialogStub= new FindReplaceDialogStub(fWorkbenchPart.getSite()); - - boolean isEditable= false; - if (fWorkbenchPart instanceof ITextEditorExtension2) - isEditable= ((ITextEditorExtension2) fWorkbenchPart).isEditorInputModifiable(); - - FindReplaceDialog dialog= fgFindReplaceDialogStub.getDialog(); - dialog.updateTarget(fTarget, isEditable); - dialog.open(); - } - - /* - * @see IUpdate#update() - */ - public void update() { - - if (fWorkbenchPart == null && fWorkbenchWindow != null) - fWorkbenchPart= fWorkbenchWindow.getPartService().getActivePart(); - - if (fWorkbenchPart != null) - fTarget= (IFindReplaceTarget) fWorkbenchPart.getAdapter(IFindReplaceTarget.class); - else - fTarget= null; - - setEnabled(fTarget != null && fTarget.canPerformFind()); - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceDialog.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceDialog.java deleted file mode 100644 index 98cc467c65c..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceDialog.java +++ /dev/null @@ -1,1814 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.texteditor; - - -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.List; -import java.util.regex.PatternSyntaxException; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.BusyIndicator; -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.events.SelectionListener; -import org.eclipse.swt.events.ShellAdapter; -import org.eclipse.swt.events.ShellEvent; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.graphics.Rectangle; -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.Group; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; - -import org.eclipse.jface.contentassist.SubjectControlContentAssistant; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.resource.JFaceColors; - -import org.eclipse.jface.text.DefaultInformationControl; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.IFindReplaceTarget; -import org.eclipse.jface.text.IFindReplaceTargetExtension; -import org.eclipse.jface.text.IFindReplaceTargetExtension3; -import org.eclipse.jface.text.IInformationControl; -import org.eclipse.jface.text.IInformationControlCreator; -import org.eclipse.jface.text.IRegion; -import org.eclipse.jface.text.Region; -import org.eclipse.jface.text.TextUtilities; -import org.eclipse.jface.text.contentassist.IContentAssistProcessor; -import org.eclipse.jface.text.contentassist.IContentAssistant; - -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.contentassist.ContentAssistHandler; -import org.eclipse.ui.help.WorkbenchHelp; -import org.eclipse.ui.internal.texteditor.TextEditorPlugin; - - - -/** - * Find/Replace dialog. The dialog is opened on a particular - * target but can be re-targeted. Internally used by the <code>FindReplaceAction</code> - */ -class FindReplaceDialog extends Dialog { - - /** - * Updates the find replace dialog on activation changes. - */ - class ActivationListener extends ShellAdapter { - /* - * @see ShellListener#shellActivated(ShellEvent) - */ - public void shellActivated(ShellEvent e) { - - String oldText= fFindField.getText(); // XXX workaround for 10766 - List oldList= new ArrayList(); - oldList.addAll(fFindHistory); - - readConfiguration(); - - - fFindField.removeModifyListener(fFindModifyListener); - - updateCombo(fFindField, fFindHistory); - if (!fFindHistory.equals(oldList) && !fFindHistory.isEmpty()) - fFindField.setText((String) fFindHistory.get(0)); - else - fFindField.setText(oldText); - if (findFieldHadFocus()) - fFindField.setSelection(new Point(0, fFindField.getText().length())); - fFindField.addModifyListener(fFindModifyListener); - - fActiveShell= (Shell)e.widget; - updateButtonState(); - - if (findFieldHadFocus() && getShell() == fActiveShell && !fFindField.isDisposed()) - fFindField.setFocus(); - } - - /** - * Returns <code>true</code> if the find field had focus, - * <code>false</code> if it did not. - * - * @return <code>true</code> if the find field had focus, - * <code>false</code> if it did not - */ - private boolean findFieldHadFocus() { - /* - * See bug 45447. Under GTK and Motif, the focus of the find field - * is already gone when shellDeactivated is called. On the other - * hand focus has already been restored when shellActivated is - * called. - * - * Therefore, we select and give focus if either - * fGiveFocusToFindField is true or the find field has focus. - */ - return fGiveFocusToFindField || okToUse(fFindField) && fFindField.isFocusControl(); - } - - /* - * @see ShellListener#shellDeactivated(ShellEvent) - */ - public void shellDeactivated(ShellEvent e) { - fGiveFocusToFindField= fFindField.isFocusControl(); - - storeSettings(); - - fGlobalRadioButton.setSelection(true); - fSelectedRangeRadioButton.setSelection(false); - fUseSelectedLines= false; - - if (fTarget != null && (fTarget instanceof IFindReplaceTargetExtension)) - ((IFindReplaceTargetExtension) fTarget).setScope(null); - - fOldScope= null; - - fActiveShell= null; - updateButtonState(); - } - } - - /** - * Modify listener to update the search result in case of incremental search. - * @since 2.0 - */ - private class FindModifyListener implements ModifyListener { - - /* - * @see ModifyListener#modifyText(ModifyEvent) - */ - public void modifyText(ModifyEvent e) { - if (isIncrementalSearch() && !isRegExSearchAvailableAndChecked()) { - if (fFindField.getText().equals("") && fTarget != null) { //$NON-NLS-1$ - // empty selection at base location - int offset= fIncrementalBaseLocation.x; - - if (isForwardSearch() && !fNeedsInitialFindBeforeReplace || !isForwardSearch() && fNeedsInitialFindBeforeReplace) - offset= offset + fIncrementalBaseLocation.y; - - fNeedsInitialFindBeforeReplace= false; - findAndSelect(offset, "", isForwardSearch(), isCaseSensitiveSearch(), isWholeWordSearch(), isRegExSearchAvailableAndChecked()); //$NON-NLS-1$ - } else { - performSearch(false); - } - } - - updateButtonState(!isIncrementalSearch()); - } - } - - /** The size of the dialogs search history. */ - private static final int HISTORY_SIZE= 5; - - private Point fLocation; - private Point fIncrementalBaseLocation; - private boolean fWrapInit, fCaseInit, fWholeWordInit, fForwardInit, fGlobalInit, fIncrementalInit; - /** - * Tells whether an initial find operation is needed - * before the replace operation. - * @since 3.0 - */ - private boolean fNeedsInitialFindBeforeReplace; - /** - * Initial value for telling whether the search string is a regular expression. - * @since 3.0 - */ - boolean fIsRegExInit; - - private List fFindHistory; - private List fReplaceHistory; - private IRegion fOldScope; - - private boolean fIsTargetEditable; - private IFindReplaceTarget fTarget; - private Shell fParentShell; - private Shell fActiveShell; - - private final ActivationListener fActivationListener= new ActivationListener(); - private final ModifyListener fFindModifyListener= new FindModifyListener(); - - private Label fReplaceLabel, fStatusLabel; - private Button fForwardRadioButton, fGlobalRadioButton, fSelectedRangeRadioButton; - private Button fCaseCheckBox, fWrapCheckBox, fWholeWordCheckBox, fIncrementalCheckBox; - - /** - * Checkbox for selecting whether the search string is a regular expression. - * @since 3.0 - */ - private Button fIsRegExCheckBox; - - private Button fReplaceSelectionButton, fReplaceFindButton, fFindNextButton, fReplaceAllButton; - Combo fFindField, fReplaceField; - private Rectangle fDialogPositionInit; - - private IDialogSettings fDialogSettings; - /** - * Tells whether the target supports regular expressions. - * <code>true</code> if the target supports regular expressions - * @since 3.0 - */ - private boolean fIsTargetSupportingRegEx; - /** - * Tells whether fUseSelectedLines radio is checked. - * @since 3.0 - */ - private boolean fUseSelectedLines; - /** - * The content assist handler for the find combo. - * @since 3.0 - */ - private ContentAssistHandler fFindContentAssistHandler; - /** - * The content assist handler for the replace combo. - * @since 3.0 - */ - private ContentAssistHandler fReplaceContentAssistHandler; - /** - * Content assist's proposal popup background color. - * @since 3.0 - */ - private Color fProposalPopupBackgroundColor; - /** - * Content assist's proposal popup foreground color. - * @since 3.0 - */ - private Color fProposalPopupForegroundColor; - /** - * <code>true</code> if the find field should receive focus the next time - * the dialog is activated, <code>false</code> otherwise. - * @since 3.0 - */ - private boolean fGiveFocusToFindField= true; - - - - /** - * Creates a new dialog with the given shell as parent. - * @param parentShell the parent shell - */ - public FindReplaceDialog(Shell parentShell) { - super(parentShell); - - fParentShell= null; - fTarget= null; - - fDialogPositionInit= null; - fFindHistory= new ArrayList(HISTORY_SIZE - 1); - fReplaceHistory= new ArrayList(HISTORY_SIZE - 1); - - fWrapInit= false; - fCaseInit= false; - fIsRegExInit= false; - fWholeWordInit= false; - fIncrementalInit= false; - fGlobalInit= true; - fForwardInit= true; - - readConfiguration(); - - setShellStyle(SWT.CLOSE | SWT.MODELESS | SWT.BORDER | SWT.TITLE); - setBlockOnOpen(false); - } - - /** - * Returns this dialog's parent shell. - * @return the dialog's parent shell - */ - public Shell getParentShell() { - return super.getParentShell(); - } - - - /** - * Returns <code>true</code> if control can be used. - * - * @param control the control to be checked - * @return <code>true</code> if control can be used - */ - private boolean okToUse(Control control) { - return control != null && !control.isDisposed(); - } - - /* - * @see org.eclipse.jface.window.Window#create() - */ - public void create() { - - super.create(); - - Shell shell= getShell(); - shell.addShellListener(fActivationListener); - if (fLocation != null) - shell.setLocation(fLocation); - - // set help context - WorkbenchHelp.setHelp(shell, IAbstractTextEditorHelpContextIds.FIND_REPLACE_DIALOG); - - // fill in combo contents - fFindField.removeModifyListener(fFindModifyListener); - updateCombo(fFindField, fFindHistory); - fFindField.addModifyListener(fFindModifyListener); - updateCombo(fReplaceField, fReplaceHistory); - - // get find string - initFindStringFromSelection(); - - // set dialog position - if (fDialogPositionInit != null) - shell.setBounds(fDialogPositionInit); - - shell.setText(EditorMessages.getString("FindReplace.title")); //$NON-NLS-1$ - // shell.setImage(null); - } - - /** - * Create the button section of the find/replace dialog. - * - * @param parent the parent composite - * @return the button section - */ - private Composite createButtonSection(Composite parent) { - - Composite panel= new Composite(parent, SWT.NULL); - GridLayout layout= new GridLayout(); - layout.numColumns= -2; - layout.makeColumnsEqualWidth= true; - panel.setLayout(layout); - - fFindNextButton= makeButton(panel, "FindReplace.FindNextButton.label", 102, true, new SelectionAdapter() { //$NON-NLS-1$ - public void widgetSelected(SelectionEvent e) { - if (isIncrementalSearch() && !isRegExSearchAvailableAndChecked()) - initIncrementalBaseLocation(); - - fNeedsInitialFindBeforeReplace= false; - performSearch(); - updateFindHistory(); - fFindNextButton.setFocus(); - } - }); - setGridData(fFindNextButton, GridData.FILL, true, GridData.FILL, false); - - fReplaceFindButton= makeButton(panel, "FindReplace.ReplaceFindButton.label", 103, false, new SelectionAdapter() { //$NON-NLS-1$ - public void widgetSelected(SelectionEvent e) { - if (fNeedsInitialFindBeforeReplace) - performSearch(); - if (performReplaceSelection()) - performSearch(); - updateFindAndReplaceHistory(); - fReplaceFindButton.setFocus(); - } - }); - setGridData(fReplaceFindButton, GridData.FILL, true, GridData.FILL, false); - - fReplaceSelectionButton= makeButton(panel, "FindReplace.ReplaceSelectionButton.label", 104, false, new SelectionAdapter() { //$NON-NLS-1$ - public void widgetSelected(SelectionEvent e) { - if (fNeedsInitialFindBeforeReplace) - performSearch(); - performReplaceSelection(); - updateFindAndReplaceHistory(); - fFindNextButton.setFocus(); - } - }); - setGridData(fReplaceSelectionButton, GridData.FILL, true, GridData.FILL, false); - - fReplaceAllButton= makeButton(panel, "FindReplace.ReplaceAllButton.label", 105, false, new SelectionAdapter() { //$NON-NLS-1$ - public void widgetSelected(SelectionEvent e) { - performReplaceAll(); - updateFindAndReplaceHistory(); - fFindNextButton.setFocus(); - } - }); - setGridData(fReplaceAllButton, GridData.FILL, true, GridData.FILL, false); - - // Make the all the buttons the same size as the Remove Selection button. - fReplaceAllButton.setEnabled(isEditable()); - - return panel; - } - - /** - * Creates the options configuration section of the find replace dialog. - * - * @param parent the parent composite - * @return the options configuration section - */ - private Composite createConfigPanel(Composite parent) { - - Composite panel= new Composite(parent, SWT.NULL); - GridLayout layout= new GridLayout(); - layout.numColumns= 2; - layout.makeColumnsEqualWidth= true; - panel.setLayout(layout); - - Composite directionGroup= createDirectionGroup(panel); - setGridData(directionGroup, GridData.FILL, true, GridData.FILL, false); - Composite scopeGroup= createScopeGroup(panel); - setGridData(scopeGroup, GridData.FILL, true, GridData.FILL, false); - - Composite optionsGroup= createOptionsGroup(panel); - setGridData(optionsGroup, GridData.FILL, true, GridData.FILL, false); - GridData data= (GridData) optionsGroup.getLayoutData(); - data.horizontalSpan= 2; - optionsGroup.setLayoutData(data); - - return panel; - } - - /* - * @see org.eclipse.jface.window.Window#createContents(org.eclipse.swt.widgets.Composite) - */ - protected Control createContents(Composite parent) { - - Composite panel= new Composite(parent, SWT.NULL); - GridLayout layout= new GridLayout(); - layout.numColumns= 1; - layout.makeColumnsEqualWidth= true; - panel.setLayout(layout); - - Composite inputPanel= createInputPanel(panel); - setGridData(inputPanel, GridData.FILL, true, GridData.CENTER, false); - - Composite configPanel= createConfigPanel(panel); - setGridData(configPanel, GridData.FILL, true, GridData.CENTER, true); - - Composite buttonPanelB= createButtonSection(panel); - setGridData(buttonPanelB, GridData.FILL, true, GridData.CENTER, false); - - Composite statusBar= createStatusAndCloseButton(panel); - setGridData(statusBar, GridData.FILL, true, GridData.CENTER, false); - - updateButtonState(); - - applyDialogFont(panel); - - // Setup content assistants for find and replace combos - fProposalPopupBackgroundColor= new Color(getShell().getDisplay(), new RGB(254, 241, 233)); - fProposalPopupForegroundColor= new Color(getShell().getDisplay(), new RGB(0, 0, 0)); - - return panel; - } - - private void setContentAssistsEnablement(boolean enable) { - if (enable) { - if (fFindContentAssistHandler == null) { - fFindContentAssistHandler= ContentAssistHandler.createHandlerForCombo(fFindField, createContentAssistant()); - fReplaceContentAssistHandler= ContentAssistHandler.createHandlerForCombo(fReplaceField, createContentAssistant()); - } - fFindContentAssistHandler.setEnabled(true); - fReplaceContentAssistHandler.setEnabled(true); - - } else { - if (fFindContentAssistHandler == null) - return; - fFindContentAssistHandler.setEnabled(false); - fReplaceContentAssistHandler.setEnabled(false); - } - } - - /** - * Creates the direction defining part of the options defining section - * of the find replace dialog. - * - * @param parent the parent composite - * @return the direction defining part - */ - private Composite createDirectionGroup(Composite parent) { - - Composite panel= new Composite(parent, SWT.NONE); - GridLayout layout= new GridLayout(); - layout.marginWidth= 0; - layout.marginHeight= 0; - panel.setLayout(layout); - - Group group= new Group(panel, SWT.SHADOW_ETCHED_IN); - group.setText(EditorMessages.getString("FindReplace.Direction")); //$NON-NLS-1$ - GridLayout groupLayout= new GridLayout(); - group.setLayout(groupLayout); - group.setLayoutData(new GridData(GridData.FILL_BOTH)); - - SelectionListener selectionListener= new SelectionListener() { - public void widgetSelected(SelectionEvent e) { - if (isIncrementalSearch() && !isRegExSearchAvailableAndChecked()) - initIncrementalBaseLocation(); - } - - public void widgetDefaultSelected(SelectionEvent e) { - } - }; - - fForwardRadioButton= new Button(group, SWT.RADIO | SWT.LEFT); - fForwardRadioButton.setText(EditorMessages.getString("FindReplace.ForwardRadioButton.label")); //$NON-NLS-1$ - setGridData(fForwardRadioButton, GridData.BEGINNING, false, GridData.CENTER, false); - fForwardRadioButton.addSelectionListener(selectionListener); - - Button backwardRadioButton= new Button(group, SWT.RADIO | SWT.LEFT); - backwardRadioButton.setText(EditorMessages.getString("FindReplace.BackwardRadioButton.label")); //$NON-NLS-1$ - setGridData(backwardRadioButton, GridData.BEGINNING, false, GridData.CENTER, false); - backwardRadioButton.addSelectionListener(selectionListener); - - backwardRadioButton.setSelection(!fForwardInit); - fForwardRadioButton.setSelection(fForwardInit); - - return panel; - } - - /** - * Creates the scope defining part of the find replace dialog. - * - * @param parent the parent composite - * @return the scope defining part - * @since 2.0 - */ - private Composite createScopeGroup(Composite parent) { - - Composite panel= new Composite(parent, SWT.NONE); - GridLayout layout= new GridLayout(); - layout.marginWidth= 0; - layout.marginHeight= 0; - panel.setLayout(layout); - - Group group= new Group(panel, SWT.SHADOW_ETCHED_IN); - group.setText(EditorMessages.getString("FindReplace.Scope")); //$NON-NLS-1$ - GridLayout groupLayout= new GridLayout(); - group.setLayout(groupLayout); - group.setLayoutData(new GridData(GridData.FILL_BOTH)); - - fGlobalRadioButton= new Button(group, SWT.RADIO | SWT.LEFT); - fGlobalRadioButton.setText(EditorMessages.getString("FindReplace.GlobalRadioButton.label")); //$NON-NLS-1$ - setGridData(fGlobalRadioButton, GridData.BEGINNING, false, GridData.CENTER, false); - fGlobalRadioButton.setSelection(fGlobalInit); - fGlobalRadioButton.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent e) { - if (!fGlobalRadioButton.getSelection() || !fUseSelectedLines) - return; - fUseSelectedLines= false; - useSelectedLines(false); - } - - public void widgetDefaultSelected(SelectionEvent e) { - } - }); - - fSelectedRangeRadioButton= new Button(group, SWT.RADIO | SWT.LEFT); - fSelectedRangeRadioButton.setText(EditorMessages.getString("FindReplace.SelectedRangeRadioButton.label")); //$NON-NLS-1$ - setGridData(fSelectedRangeRadioButton, GridData.BEGINNING, false, GridData.CENTER, false); - fSelectedRangeRadioButton.setSelection(!fGlobalInit); - fUseSelectedLines= !fGlobalInit; - fSelectedRangeRadioButton.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent e) { - if (!fSelectedRangeRadioButton.getSelection() || fUseSelectedLines) - return; - fUseSelectedLines= true; - useSelectedLines(true); - } - - public void widgetDefaultSelected(SelectionEvent e) { - } - }); - - return panel; - } - - /** - * Tells the dialog to perform searches only in the scope given by the actually selected lines. - * @param selectedLines <code>true</code> if selected lines should be used - * @since 2.0 - */ - private void useSelectedLines(boolean selectedLines) { - if (isIncrementalSearch() && !isRegExSearchAvailableAndChecked()) - initIncrementalBaseLocation(); - - if (fTarget == null || !(fTarget instanceof IFindReplaceTargetExtension)) - return; - - IFindReplaceTargetExtension extensionTarget= (IFindReplaceTargetExtension) fTarget; - - if (selectedLines) { - - IRegion scope; - if (fOldScope == null) { - Point lineSelection= extensionTarget.getLineSelection(); - scope= new Region(lineSelection.x, lineSelection.y); - } else { - scope= fOldScope; - fOldScope= null; - } - - int offset= isForwardSearch() - ? scope.getOffset() - : scope.getOffset() + scope.getLength(); - - extensionTarget.setSelection(offset, 0); - extensionTarget.setScope(scope); - } else { - fOldScope= extensionTarget.getScope(); - extensionTarget.setScope(null); - } - } - - /** - * Creates the panel where the user specifies the text to search - * for and the optional replacement text. - * - * @param parent the parent composite - * @return the input panel - */ - private Composite createInputPanel(Composite parent) { - - ModifyListener listener= new ModifyListener() { - public void modifyText(ModifyEvent e) { - updateButtonState(); - } - }; - - Composite panel= new Composite(parent, SWT.NULL); - GridLayout layout= new GridLayout(); - layout.numColumns= 2; - panel.setLayout(layout); - - Label findLabel= new Label(panel, SWT.LEFT); - findLabel.setText(EditorMessages.getString("FindReplace.Find.label")); //$NON-NLS-1$ - setGridData(findLabel, GridData.BEGINNING, false, GridData.CENTER, false); - - fFindField= new Combo(panel, SWT.DROP_DOWN | SWT.BORDER); - setGridData(fFindField, GridData.FILL, true, GridData.CENTER, false); - fFindField.addModifyListener(fFindModifyListener); - - fReplaceLabel= new Label(panel, SWT.LEFT); - fReplaceLabel.setText(EditorMessages.getString("FindReplace.Replace.label")); //$NON-NLS-1$ - setGridData(fReplaceLabel, GridData.BEGINNING, false, GridData.CENTER, false); - - fReplaceField= new Combo(panel, SWT.DROP_DOWN | SWT.BORDER); - setGridData(fReplaceField, GridData.FILL, true, GridData.CENTER, false); - fReplaceField.addModifyListener(listener); - - return panel; - } - - /** - * Creates the functional options part of the options defining - * section of the find replace dialog. - * - * @param parent the parent composite - * @return the options group - */ - private Composite createOptionsGroup(Composite parent) { - - Composite panel= new Composite(parent, SWT.NULL); - GridLayout layout= new GridLayout(); - layout.marginWidth= 0; - layout.marginHeight= 0; - panel.setLayout(layout); - - Group group= new Group(panel, SWT.SHADOW_NONE); - group.setText(EditorMessages.getString("FindReplace.Options")); //$NON-NLS-1$ - GridLayout groupLayout= new GridLayout(); - groupLayout.numColumns= 2; - groupLayout.makeColumnsEqualWidth= true; - group.setLayout(groupLayout); - group.setLayoutData(new GridData(GridData.FILL_BOTH)); - - SelectionListener selectionListener= new SelectionListener() { - public void widgetSelected(SelectionEvent e) { - storeSettings(); - } - - public void widgetDefaultSelected(SelectionEvent e) { - } - }; - - fCaseCheckBox= new Button(group, SWT.CHECK | SWT.LEFT); - fCaseCheckBox.setText(EditorMessages.getString("FindReplace.CaseCheckBox.label")); //$NON-NLS-1$ - setGridData(fCaseCheckBox, GridData.BEGINNING, false, GridData.CENTER, false); - fCaseCheckBox.setSelection(fCaseInit); - fCaseCheckBox.addSelectionListener(selectionListener); - - fWrapCheckBox= new Button(group, SWT.CHECK | SWT.LEFT); - fWrapCheckBox.setText(EditorMessages.getString("FindReplace.WrapCheckBox.label")); //$NON-NLS-1$ - setGridData(fWrapCheckBox, GridData.BEGINNING, false, GridData.CENTER, false); - fWrapCheckBox.setSelection(fWrapInit); - fWrapCheckBox.addSelectionListener(selectionListener); - - fWholeWordCheckBox= new Button(group, SWT.CHECK | SWT.LEFT); - fWholeWordCheckBox.setText(EditorMessages.getString("FindReplace.WholeWordCheckBox.label")); //$NON-NLS-1$ - setGridData(fWholeWordCheckBox, GridData.BEGINNING, false, GridData.CENTER, false); - fWholeWordCheckBox.setSelection(fWholeWordInit); - fWholeWordCheckBox.addSelectionListener(selectionListener); - - fIncrementalCheckBox= new Button(group, SWT.CHECK | SWT.LEFT); - fIncrementalCheckBox.setText(EditorMessages.getString("FindReplace.IncrementalCheckBox.label")); //$NON-NLS-1$ - setGridData(fIncrementalCheckBox, GridData.BEGINNING, false, GridData.CENTER, false); - fIncrementalCheckBox.setSelection(fIncrementalInit); - fIncrementalCheckBox.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent e) { - if (isIncrementalSearch() && !isRegExSearch()) - initIncrementalBaseLocation(); - - storeSettings(); - } - - public void widgetDefaultSelected(SelectionEvent e) { - } - }); - - fIsRegExCheckBox= new Button(group, SWT.CHECK | SWT.LEFT); - fIsRegExCheckBox.setText(EditorMessages.getString("FindReplace.RegExCheckbox.label")); //$NON-NLS-1$ - setGridData(fIsRegExCheckBox, GridData.BEGINNING, false, GridData.CENTER, false); - ((GridData)fIsRegExCheckBox.getLayoutData()).horizontalSpan= 2; - fIsRegExCheckBox.setSelection(fIsRegExInit); - fIsRegExCheckBox.addSelectionListener(new SelectionAdapter() { - /* - * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) - */ - public void widgetSelected(SelectionEvent e) { - boolean newState= fIsRegExCheckBox.getSelection(); - fIncrementalCheckBox.setEnabled(!newState); - updateButtonState(); - storeSettings(); - setContentAssistsEnablement(newState); - } - }); - fWholeWordCheckBox.setEnabled(!isRegExSearchAvailableAndChecked()); - fWholeWordCheckBox.addSelectionListener(new SelectionAdapter() { - /* - * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) - */ - public void widgetSelected(SelectionEvent e) { - updateButtonState(); - } - }); - fIncrementalCheckBox.setEnabled(!isRegExSearchAvailableAndChecked()); - return panel; - } - - /** - * Creates the status and close section of the dialog. - * - * @param parent the parent composite - * @return the status and close button - */ - private Composite createStatusAndCloseButton(Composite parent) { - - Composite panel= new Composite(parent, SWT.NULL); - GridLayout layout= new GridLayout(); - layout.numColumns= 2; - layout.marginWidth= 0; - layout.marginHeight= 0; - panel.setLayout(layout); - - fStatusLabel= new Label(panel, SWT.LEFT); - setGridData(fStatusLabel, GridData.FILL, true, GridData.CENTER, false); - - String label= EditorMessages.getString("FindReplace.CloseButton.label"); //$NON-NLS-1$ - Button closeButton= createButton(panel, 101, label, false); - setGridData(closeButton, GridData.END, false, GridData.END, false); - - return panel; - } - - /* - * @see Dialog#buttonPressed - */ - protected void buttonPressed(int buttonID) { - if (buttonID == 101) - close(); - } - - - - // ------- action invocation --------------------------------------- - - /** - * Returns the position of the specified search string, or <code>-1</code> if the string can - * not be found when searching using the given options. - * - * @param findString the string to search for - * @param startPosition the position at which to start the search - * @param forwardSearch the direction of the search - * @param caseSensitive should the search be case sensitive - * @param wrapSearch should the search wrap to the start/end if arrived at the end/start - * @param wholeWord does the search string represent a complete word - * @param regExSearch if <code>true</code> findString represents a regular expression - * @return the occurrence of the find string following the options or <code>-1</code> if nothing found - * @since 3.0 - */ - private int findIndex(String findString, int startPosition, boolean forwardSearch, boolean caseSensitive, boolean wrapSearch, boolean wholeWord, boolean regExSearch) { - - if (forwardSearch) { - if (wrapSearch) { - int index= findAndSelect(startPosition, findString, true, caseSensitive, wholeWord, regExSearch); - if (index == -1) { - if (okToUse(getShell()) && !isIncrementalSearch()) - getShell().getDisplay().beep(); - index= findAndSelect(-1, findString, true, caseSensitive, wholeWord, regExSearch); - } - return index; - } - return findAndSelect(startPosition, findString, true, caseSensitive, wholeWord, regExSearch); - } - - // backward - if (wrapSearch) { - int index= findAndSelect(startPosition - 1, findString, false, caseSensitive, wholeWord, regExSearch); - if (index == -1) { - if (okToUse(getShell()) && !isIncrementalSearch()) - getShell().getDisplay().beep(); - index= findAndSelect(-1, findString, false, caseSensitive, wholeWord, regExSearch); - } - return index; - } - return findAndSelect(startPosition - 1, findString, false, caseSensitive, wholeWord, regExSearch); - } - - /** - * 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 forwardSearch the direction of the search - * @param caseSensitive <code>true</code> performs a case sensitive search, <code>false</code> an insensitive search - * @param wholeWord if <code>true</code> only occurrences are reported in which the findString stands as a word by itself - * @param regExSearch if <code>true</code> findString represents a regular expression - * @return the position of the specified string, or -1 if the string has not been found - * @since 3.0 - */ - private int findAndSelect(int offset, String findString, boolean forwardSearch, boolean caseSensitive, boolean wholeWord, boolean regExSearch) { - if (fTarget instanceof IFindReplaceTargetExtension3) - return ((IFindReplaceTargetExtension3)fTarget).findAndSelect(offset, findString, forwardSearch, caseSensitive, wholeWord, regExSearch); - else - return fTarget.findAndSelect(offset, findString, forwardSearch, caseSensitive, wholeWord); - } - - /** - * Replaces the selection with <code>replaceString</code>. If - * <code>regExReplace</code> is <code>true</code>, - * <code>replaceString</code> is a regex replace pattern which will get - * expanded if the underlying target supports it. Returns the region of the - * inserted text; note that the returned selection covers the expanded - * pattern in case of regex replace. - * - * @param replaceString the replace string (or a regex pattern) - * @param regExReplace <code>true</code> if <code>replaceString</code> - * is a pattern - * @return the selection after replacing, i.e. the inserted text - * @since 3.0 - */ - Point replaceSelection(String replaceString, boolean regExReplace) { - if (fTarget instanceof IFindReplaceTargetExtension3) - ((IFindReplaceTargetExtension3)fTarget).replaceSelection(replaceString, regExReplace); - else - fTarget.replaceSelection(replaceString); - - return fTarget.getSelection(); - } - - /** - * Returns whether the specified search string can be found using the given options. - * - * @param findString the string to search for - * @param forwardSearch the direction of the search - * @param caseSensitive should the search be case sensitive - * @param wrapSearch should the search wrap to the start/end if arrived at the end/start - * @param wholeWord does the search string represent a complete word - * @param incremental is this an incremental search - * @param regExSearch if <code>true</code> findString represents a regular expression - * @return <code>true</code> if the search string can be found using the given options - * - * @since 3.0 - */ - private boolean findNext(String findString, boolean forwardSearch, boolean caseSensitive, boolean wrapSearch, boolean wholeWord, boolean incremental, boolean regExSearch) { - - if (fTarget == null) - return false; - - Point r= null; - if (incremental) - r= fIncrementalBaseLocation; - else - r= fTarget.getSelection(); - - int findReplacePosition= r.x; - if (forwardSearch && !fNeedsInitialFindBeforeReplace || !forwardSearch && fNeedsInitialFindBeforeReplace) - findReplacePosition += r.y; - - fNeedsInitialFindBeforeReplace= false; - - int index= findIndex(findString, findReplacePosition, forwardSearch, caseSensitive, wrapSearch, wholeWord, regExSearch); - - if (index != -1) - return true; - - return false; - } - - /** - * Returns the dialog's boundaries. - * @return the dialog's boundaries - */ - private Rectangle getDialogBoundaries() { - if (okToUse(getShell())) { - return getShell().getBounds(); - } else { - return fDialogPositionInit; - } - } - - /** - * Returns the dialog's history. - * @return the dialog's history - */ - private List getFindHistory() { - return fFindHistory; - } - - // ------- accessors --------------------------------------- - - /** - * Retrieves the string to search for from the appropriate text input field and returns it. - * @return the search string - */ - private String getFindString() { - if (okToUse(fFindField)) { - return fFindField.getText(); - } - return ""; //$NON-NLS-1$ - } - - /** - * Returns the dialog's replace history. - * @return the dialog's replace history - */ - private List getReplaceHistory() { - return fReplaceHistory; - } - - /** - * Retrieves the replacement string from the appropriate text input field and returns it. - * @return the replacement string - */ - private String getReplaceString() { - if (okToUse(fReplaceField)) { - return fReplaceField.getText(); - } - return ""; //$NON-NLS-1$ - } - - // ------- init / close --------------------------------------- - - /** - * Returns the actual selection of the find replace target. - * @return the selection of the target - */ - private String getSelectionString() { - String selection= fTarget.getSelectionText(); - if (selection != null && selection.length() > 0) { - int[] info= TextUtilities.indexOf(TextUtilities.DELIMITERS, selection, 0); - if (info[0] > 0) - return selection.substring(0, info[0]); - else if (info[0] == -1) - return selection; - } - return null; - } - - /** - * @see org.eclipse.jface.window.Window#close() - */ - public boolean close() { - handleDialogClose(); - return super.close(); - } - - /** - * Removes focus changed listener from browser and stores settings for re-open. - */ - private void handleDialogClose() { - - // remove listeners - if (okToUse(fFindField)) { - fFindField.removeModifyListener(fFindModifyListener); - } - - if (fParentShell != null) { - fParentShell.removeShellListener(fActivationListener); - fParentShell= null; - } - - getShell().removeShellListener(fActivationListener); - - // store current settings in case of re-open - storeSettings(); - - if (fTarget != null && fTarget instanceof IFindReplaceTargetExtension) - ((IFindReplaceTargetExtension) fTarget).endSession(); - - setContentAssistsEnablement(false); - fFindContentAssistHandler= null; - fReplaceContentAssistHandler= null; - - fProposalPopupBackgroundColor.dispose(); - fProposalPopupForegroundColor.dispose(); - - // prevent leaks - fActiveShell= null; - fTarget= null; - - } - - /** - * Writes the current selection to the dialog settings. - * @since 3.0 - */ - private void writeSelection() { - if (fTarget == null) - return; - String selection= fTarget.getSelectionText(); - if (selection == null) - selection= ""; //$NON-NLS-1$ - - IDialogSettings s= getDialogSettings(); - s.put("selection", selection); //$NON-NLS-1$ - } - - /** - * Stores the current state in the dialog settings. - * @since 2.0 - */ - private void storeSettings() { - fDialogPositionInit= getDialogBoundaries(); - fWrapInit= isWrapSearch(); - fWholeWordInit= isWholeWordSetting(); - fCaseInit= isCaseSensitiveSearch(); - fIsRegExInit= isRegExSearch(); - fIncrementalInit= isIncrementalSearch(); - fForwardInit= isForwardSearch(); - - writeConfiguration(); - } - - /** - * Initializes the string to search for and the appropriate - * text inout field based on the selection found in the - * action's target. - */ - private void initFindStringFromSelection() { - if (fTarget != null && okToUse(fFindField)) { - String selection= getSelectionString(); - fFindField.removeModifyListener(fFindModifyListener); - if (selection != null) { - fFindField.setText(selection); - if (!selection.equals(fTarget.getSelectionText())) { - useSelectedLines(true); - fGlobalRadioButton.setSelection(false); - fSelectedRangeRadioButton.setSelection(true); - fUseSelectedLines= true; - } - } else { - if ("".equals(fFindField.getText())) { //$NON-NLS-1$ - if (fFindHistory.size() > 0) - fFindField.setText((String) fFindHistory.get(0)); - else - fFindField.setText(""); //$NON-NLS-1$ - } - } - fFindField.setSelection(new Point(0, fFindField.getText().length())); - fFindField.addModifyListener(fFindModifyListener); - } - } - - /** - * Initializes the anchor used as starting point for incremental searching. - * @since 2.0 - */ - private void initIncrementalBaseLocation() { - if (fTarget != null && isIncrementalSearch() && !isRegExSearchAvailableAndChecked()) { - fIncrementalBaseLocation= fTarget.getSelection(); - } else { - fIncrementalBaseLocation= new Point(0, 0); - } - } - - // ------- history --------------------------------------- - - /** - * Retrieves and returns the option case sensitivity from the appropriate check box. - * @return <code>true</code> if case sensitive - */ - private boolean isCaseSensitiveSearch() { - if (okToUse(fCaseCheckBox)) { - return fCaseCheckBox.getSelection(); - } - return fCaseInit; - } - - /** - * Retrieves and returns the regEx option from the appropriate check box. - * - * @return <code>true</code> if case sensitive - * @since 3.0 - */ - private boolean isRegExSearch() { - if (okToUse(fIsRegExCheckBox)) { - return fIsRegExCheckBox.getSelection(); - } - return fIsRegExInit; - } - - /** - * If the target supports regular expressions search retrieves and returns - * regEx option from appropriate check box. - * - * @return <code>true</code> if regEx is available and checked - * @since 3.0 - */ - private boolean isRegExSearchAvailableAndChecked() { - if (okToUse(fIsRegExCheckBox)) { - return fIsTargetSupportingRegEx && fIsRegExCheckBox.getSelection(); - } - return fIsRegExInit; - } - - /** - * Retrieves and returns the option search direction from the appropriate check box. - * @return <code>true</code> if searching forward - */ - private boolean isForwardSearch() { - if (okToUse(fForwardRadioButton)) { - return fForwardRadioButton.getSelection(); - } - return fForwardInit; - } - - /** - * Retrieves and returns the option search whole words from the appropriate check box. - * @return <code>true</code> if searching for whole words - */ - private boolean isWholeWordSetting() { - if (okToUse(fWholeWordCheckBox)) { - return fWholeWordCheckBox.getSelection(); - } - return fWholeWordInit; - } - - /** - * Returns <code>true</code> if searching should be restricted to entire - * words, <code>false</code> if not. This is the case if the respective - * checkbox is turned on, regex is off, and the checkbox is enabled, i.e. - * the current find string is an entire word. - * - * @return <code>true</code> if the search is restricted to whole words - */ - private boolean isWholeWordSearch() { - return isWholeWordSetting() && !isRegExSearchAvailableAndChecked() && (okToUse(fWholeWordCheckBox) ? fWholeWordCheckBox.isEnabled() : true); - } - - /** - * Retrieves and returns the option wrap search from the appropriate check box. - * @return <code>true</code> if wrapping while searching - */ - private boolean isWrapSearch() { - if (okToUse(fWrapCheckBox)) { - return fWrapCheckBox.getSelection(); - } - return fWrapInit; - } - - /** - * Retrieves and returns the option incremental search from the appropriate check box. - * @return <code>true</code> if incremental search - * @since 2.0 - */ - private boolean isIncrementalSearch() { - if (okToUse(fIncrementalCheckBox)) { - return fIncrementalCheckBox.getSelection(); - } - return fIncrementalInit; - } - - /** - * Creates a button. - * @param parent the parent control - * @param key the key to lookup the button label - * @param id the button id - * @param dfltButton is this button the default button - * @param listener a button pressed listener - * @return the new button - */ - private Button makeButton(Composite parent, String key, int id, boolean dfltButton, SelectionListener listener) { - String label= EditorMessages.getString(key); - Button b= createButton(parent, id, label, dfltButton); - b.addSelectionListener(listener); - return b; - } - - /** - * Returns the status line manager of the active editor or <code>null</code> if there is no such editor. - * @return the status line manager of the active editor - */ - private IEditorStatusLine getStatusLineManager() { - IWorkbenchWindow window= PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (window == null) - return null; - - IWorkbenchPage page= window.getActivePage(); - if (page == null) - return null; - - IEditorPart editor= page.getActiveEditor(); - if (editor == null) - return null; - - return (IEditorStatusLine) editor.getAdapter(IEditorStatusLine.class); - } - - /** - * Sets the given status message in the status line. - * - * @param error <code>true</code> if it is an error - * @param message the error message - */ - private void statusMessage(boolean error, String message) { - fStatusLabel.setText(message); - - if (error) - fStatusLabel.setForeground(JFaceColors.getErrorText(fStatusLabel.getDisplay())); - else - fStatusLabel.setForeground(null); - - IEditorStatusLine statusLine= getStatusLineManager(); - if (statusLine != null) - statusLine.setMessage(error, message, null); - - if (error) - getShell().getDisplay().beep(); - } - - /** - * Sets the given error message in the status line. - * @param message the message - */ - private void statusError(String message) { - statusMessage(true, message); - } - - /** - * Sets the given message in the status line. - * @param message the message - */ - private void statusMessage(String message) { - statusMessage(false, message); - } - - /** - * Replaces all occurrences of the user's findString with - * the replace string. Indicate to the user the number of replacements - * that occur. - */ - private void performReplaceAll() { - - int replaceCount= 0; - final String replaceString= getReplaceString(); - final String findString= getFindString(); - - if (findString != null && findString.length() > 0) { - - class ReplaceAllRunnable implements Runnable { - public int numberOfOccurrences; - public void run() { - numberOfOccurrences= replaceAll(findString, replaceString == null ? "" : replaceString, isForwardSearch(), isCaseSensitiveSearch(), isWrapSearch(), isWholeWordSearch(), isRegExSearchAvailableAndChecked()); //$NON-NLS-1$ - } - } - - try { - ReplaceAllRunnable runnable= new ReplaceAllRunnable(); - BusyIndicator.showWhile(fActiveShell.getDisplay(), runnable); - replaceCount= runnable.numberOfOccurrences; - - if (replaceCount != 0) { - if (replaceCount == 1) { // not plural - statusMessage(EditorMessages.getString("FindReplace.Status.replacement.label")); //$NON-NLS-1$ - } else { - String msg= EditorMessages.getString("FindReplace.Status.replacements.label"); //$NON-NLS-1$ - msg= MessageFormat.format(msg, new Object[] {String.valueOf(replaceCount)}); - statusMessage(msg); - } - } else { - statusMessage(EditorMessages.getString("FindReplace.Status.noMatch.label")); //$NON-NLS-1$ - } - } catch (PatternSyntaxException ex) { - statusError(ex.getLocalizedMessage()); - } catch (IllegalStateException ex) { - // we don't keep state in this dialog - } - } - writeSelection(); - updateButtonState(); - } - - /** - * Validates the state of the find/replace target. - * @return <code>true</code> if target can be changed, <code>false</code> otherwise - * @since 2.1 - */ - private boolean validateTargetState() { - - if (fTarget instanceof IFindReplaceTargetExtension2) { - IFindReplaceTargetExtension2 extension= (IFindReplaceTargetExtension2) fTarget; - if (!extension.validateTargetState()) { - statusError(EditorMessages.getString("FindReplaceDialog.read_only")); //$NON-NLS-1$ - updateButtonState(); - return false; - } - } - return isEditable(); - } - - /** - * Replaces the current selection of the target with the user's - * replace string. - * - * @return <code>true</code> if the operation was successful - */ - private boolean performReplaceSelection() { - - if (!validateTargetState()) - return false; - - String replaceString= getReplaceString(); - if (replaceString == null) - replaceString= ""; //$NON-NLS-1$ - - boolean replaced; - try { - replaceSelection(replaceString, isRegExSearchAvailableAndChecked()); - replaced= true; - writeSelection(); - } catch (PatternSyntaxException ex) { - statusError(ex.getLocalizedMessage()); - replaced= false; - } catch (IllegalStateException ex) { - replaced= false; - } - - updateButtonState(); - return replaced; - } - - /** - * Locates the user's findString in the text of the target. - */ - private void performSearch() { - performSearch(isIncrementalSearch() && !isRegExSearchAvailableAndChecked()); - } - - /** - * Locates the user's findString in the text of the target. - * - * @param mustInitIncrementalBaseLocation <code>true</code> if base location must be initialized - * @since 3.0 - */ - private void performSearch(boolean mustInitIncrementalBaseLocation) { - - if (mustInitIncrementalBaseLocation) - initIncrementalBaseLocation(); - - String findString= getFindString(); - - if (findString != null && findString.length() > 0) { - - try { - boolean somethingFound= findNext(findString, isForwardSearch(), isCaseSensitiveSearch(), isWrapSearch(), isWholeWordSearch(), isIncrementalSearch() && !isRegExSearchAvailableAndChecked(), isRegExSearchAvailableAndChecked()); - if (somethingFound) { - statusMessage(""); //$NON-NLS-1$ - } else { - statusMessage(EditorMessages.getString("FindReplace.Status.noMatch.label")); //$NON-NLS-1$ - } - } catch (PatternSyntaxException ex) { - statusError(ex.getLocalizedMessage()); - } catch (IllegalStateException ex) { - // we don't keep state in this dialog - } - } - writeSelection(); - updateButtonState(); - } - - /** - * Replaces all occurrences of the user's findString with - * the replace string. Returns the number of replacements - * that occur. - * - * @param findString the string to search for - * @param replaceString the replacement string - * @param forwardSearch the search direction - * @param caseSensitive should the search be case sensitive - * @param wrapSearch should search wrap to start/end if end/start is reached - * @param wholeWord does the search string represent a complete word - * @param regExSearch if <code>true</code> findString represents a regular expression - * @return the number of occurrences - * - * @since 3.0 - */ - private int replaceAll(String findString, String replaceString, boolean forwardSearch, boolean caseSensitive, boolean wrapSearch, boolean wholeWord, boolean regExSearch) { - - int replaceCount= 0; - int findReplacePosition= 0; - - if (wrapSearch) { // search the whole text - findReplacePosition= 0; - forwardSearch= true; - } else if (fTarget.getSelectionText() != null) { - // the cursor is set to the end or beginning of the selected text - Point selection= fTarget.getSelection(); - findReplacePosition= selection.x; - } - - if (!validateTargetState()) - return replaceCount; - - if (fTarget instanceof IFindReplaceTargetExtension) - ((IFindReplaceTargetExtension) fTarget).setReplaceAllMode(true); - - try { - int index= 0; - while (index != -1) { - index= findAndSelect(findReplacePosition, findString, forwardSearch, caseSensitive, wholeWord, regExSearch); - if (index != -1) { // substring not contained from current position - Point selection= replaceSelection(replaceString, regExSearch); - replaceCount++; - - if (forwardSearch) - findReplacePosition= selection.x + selection.y; - else { - findReplacePosition= selection.x - 1; - if (findReplacePosition == -1) - break; - } - } - } - } finally { - if (fTarget instanceof IFindReplaceTargetExtension) - ((IFindReplaceTargetExtension) fTarget).setReplaceAllMode(false); - } - - return replaceCount; - } - - // ------- UI creation --------------------------------------- - - /** - * Attaches the given layout specification to the <code>component</code>. - * - * @param component the component - * @param horizontalAlignment horizontal alignment - * @param grabExcessHorizontalSpace grab excess horizontal space - * @param verticalAlignment vertical alignment - * @param grabExcessVerticalSpace grab excess vertical space - */ - private void setGridData(Control component, int horizontalAlignment, boolean grabExcessHorizontalSpace, int verticalAlignment, boolean grabExcessVerticalSpace) { - GridData gd= new GridData(); - gd.horizontalAlignment= horizontalAlignment; - gd.grabExcessHorizontalSpace= grabExcessHorizontalSpace; - gd.verticalAlignment= verticalAlignment; - gd.grabExcessVerticalSpace= grabExcessVerticalSpace; - component.setLayoutData(gd); - } - - /** - * Updates the enabled state of the buttons. - */ - private void updateButtonState() { - updateButtonState(false); - } - - /** - * Updates the enabled state of the buttons. - * - * @param disableReplace <code>true</code> if replace button must be disabled - * @since 3.0 - */ - private void updateButtonState(boolean disableReplace) { - if (okToUse(getShell()) && okToUse(fFindNextButton)) { - String selectedText= null; - if (fTarget != null) { - selectedText= fTarget.getSelectionText(); - } - - boolean selection= (selectedText != null && selectedText.length() > 0); - - boolean enable= fTarget != null && (fActiveShell == fParentShell || fActiveShell == getShell()); - String str= getFindString(); - boolean findString= str != null && str.length() > 0; - - boolean wholeWord= isWord(str) && !isRegExSearchAvailableAndChecked(); - fWholeWordCheckBox.setEnabled(wholeWord); - - fFindNextButton.setEnabled(enable && findString); - fReplaceSelectionButton.setEnabled(!disableReplace && enable && isEditable() && selection && (!fNeedsInitialFindBeforeReplace || !isRegExSearchAvailableAndChecked())); - fReplaceFindButton.setEnabled(!disableReplace && enable && isEditable() && findString && selection && (!fNeedsInitialFindBeforeReplace || !isRegExSearchAvailableAndChecked())); - fReplaceAllButton.setEnabled(enable && isEditable() && findString); - } - } - - /** - * Tests whether each character in the given - * string is a letter. - * - * @param str - * @return <code>true</code> if the given string is a word - * @since 3.0 - */ - private boolean isWord(String str) { - if (str == null || str.length() == 0) - return false; - - for (int i= 0; i < str.length(); i++) { - if (!Character.isJavaIdentifierPart(str.charAt(i))) - return false; - } - return true; - } - - /** - * Updates the given combo with the given content. - * @param combo combo to be updated - * @param content to be put into the combo - */ - private void updateCombo(Combo combo, List content) { - combo.removeAll(); - for (int i= 0; i < content.size(); i++) { - combo.add(content.get(i).toString()); - } - } - - // ------- open / reopen --------------------------------------- - - /** - * Called after executed find/replace action to update the history. - */ - private void updateFindAndReplaceHistory() { - updateFindHistory(); - if (okToUse(fReplaceField)) { - updateHistory(fReplaceField, fReplaceHistory); - } - - } - - /** - * Called after executed find action to update the history. - */ - private void updateFindHistory() { - if (okToUse(fFindField)) { - fFindField.removeModifyListener(fFindModifyListener); - updateHistory(fFindField, fFindHistory); - fFindField.addModifyListener(fFindModifyListener); - } - } - - /** - * Updates the combo with the history. - * @param combo to be updated - * @param history to be put into the combo - */ - private void updateHistory(Combo combo, List history) { - String findString= combo.getText(); - int index= history.indexOf(findString); - if (index != 0) { - if (index != -1) { - history.remove(index); - } - history.add(0, findString); - updateCombo(combo, history); - combo.setText(findString); - } - } - - /** - * Returns whether the target is editable. - * @return <code>true</code> if target is editable - */ - private boolean isEditable() { - boolean isEditable= (fTarget == null ? false : fTarget.isEditable()); - return fIsTargetEditable && isEditable; - } - - /** - * Updates this dialog because of a different target. - * @param target the new target - * @param isTargetEditable <code>true</code> if the new target can be modifed - * @since 2.0 - */ - public void updateTarget(IFindReplaceTarget target, boolean isTargetEditable) { - - fIsTargetEditable= isTargetEditable; - fNeedsInitialFindBeforeReplace= true; - - if (target != fTarget) { - if (fTarget != null && fTarget instanceof IFindReplaceTargetExtension) - ((IFindReplaceTargetExtension) fTarget).endSession(); - - fTarget= target; - if (target != null) - fIsTargetSupportingRegEx= target instanceof IFindReplaceTargetExtension3; - - if (fTarget != null && fTarget instanceof IFindReplaceTargetExtension) { - ((IFindReplaceTargetExtension) fTarget).beginSession(); - - fGlobalInit= true; - fGlobalRadioButton.setSelection(fGlobalInit); - fSelectedRangeRadioButton.setSelection(!fGlobalInit); - fUseSelectedLines= !fGlobalInit; - } - } - - if (okToUse(fIsRegExCheckBox)) - fIsRegExCheckBox.setEnabled(fIsTargetSupportingRegEx); - - if (okToUse(fWholeWordCheckBox)) - fWholeWordCheckBox.setEnabled(!isRegExSearchAvailableAndChecked()); - - if (okToUse(fIncrementalCheckBox)) - fIncrementalCheckBox.setEnabled(!isRegExSearchAvailableAndChecked()); - - if (okToUse(fReplaceLabel)) { - fReplaceLabel.setEnabled(isEditable()); - fReplaceField.setEnabled(isEditable()); - initFindStringFromSelection(); - initIncrementalBaseLocation(); - updateButtonState(); - } - - // see pr 51073 - fGiveFocusToFindField= true; - - setContentAssistsEnablement(isRegExSearchAvailableAndChecked()); - } - - /** - * Sets the parent shell of this dialog to be the given shell. - * - * @param shell the new parent shell - */ - public void setParentShell(Shell shell) { - if (shell != fParentShell) { - - if (fParentShell != null) - fParentShell.removeShellListener(fActivationListener); - - fParentShell= shell; - fParentShell.addShellListener(fActivationListener); - } - - fActiveShell= shell; - } - - - //--------------- configuration handling -------------- - - /** - * Returns the dialog settings object used to share state - * between several find/replace dialogs. - * - * @return the dialog settings to be used - */ - private IDialogSettings getDialogSettings() { - IDialogSettings settings= TextEditorPlugin.getDefault().getDialogSettings(); - fDialogSettings= settings.getSection(getClass().getName()); - if (fDialogSettings == null) - fDialogSettings= settings.addNewSection(getClass().getName()); - return fDialogSettings; - } - - /** - * Initializes itself from the dialog settings with the same state - * as at the previous invocation. - */ - private void readConfiguration() { - IDialogSettings s= getDialogSettings(); - - try { - int x= s.getInt("x"); //$NON-NLS-1$ - int y= s.getInt("y"); //$NON-NLS-1$ - fLocation= new Point(x, y); - } catch (NumberFormatException e) { - fLocation= null; - } - - fWrapInit= s.getBoolean("wrap"); //$NON-NLS-1$ - fCaseInit= s.getBoolean("casesensitive"); //$NON-NLS-1$ - fWholeWordInit= s.getBoolean("wholeword"); //$NON-NLS-1$ - fIncrementalInit= s.getBoolean("incremental"); //$NON-NLS-1$ - fIsRegExInit= s.getBoolean("isRegEx"); //$NON-NLS-1$ - - String[] findHistory= s.getArray("findhistory"); //$NON-NLS-1$ - if (findHistory != null) { - List history= getFindHistory(); - history.clear(); - for (int i= 0; i < findHistory.length; i++) - history.add(findHistory[i]); - } - - String[] replaceHistory= s.getArray("replacehistory"); //$NON-NLS-1$ - if (replaceHistory != null) { - List history= getReplaceHistory(); - history.clear(); - for (int i= 0; i < replaceHistory.length; i++) - history.add(replaceHistory[i]); - } - } - - /** - * Stores its current configuration in the dialog store. - */ - private void writeConfiguration() { - IDialogSettings s= getDialogSettings(); - - Point location= getShell().getLocation(); - s.put("x", location.x); //$NON-NLS-1$ - s.put("y", location.y); //$NON-NLS-1$ - - s.put("wrap", fWrapInit); //$NON-NLS-1$ - s.put("casesensitive", fCaseInit); //$NON-NLS-1$ - s.put("wholeword", fWholeWordInit); //$NON-NLS-1$ - s.put("incremental", fIncrementalInit); //$NON-NLS-1$ - s.put("isRegEx", fIsRegExInit); //$NON-NLS-1$ - List history= getFindHistory(); - while (history.size() > 8) - history.remove(8); - String[] names= new String[history.size()]; - history.toArray(names); - s.put("findhistory", names); //$NON-NLS-1$ - - history= getReplaceHistory(); - while (history.size() > 8) - history.remove(8); - names= new String[history.size()]; - history.toArray(names); - s.put("replacehistory", names); //$NON-NLS-1$ - } - - // ------------- content assistant ----------------- - - /** - * Create a new regex content assistant. - * - * @return a new configured content assistant - * @since 3.0 - */ - private SubjectControlContentAssistant createContentAssistant() { - final SubjectControlContentAssistant contentAssistant= new SubjectControlContentAssistant(); - - contentAssistant.setRestoreCompletionProposalSize(getSettings("FindReplaceDialog.completion_proposal_size")); //$NON-NLS-1$ - - IContentAssistProcessor processor= new RegExContentAssistProcessor(); - contentAssistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE); - - contentAssistant.enableAutoActivation(isRegExSearchAvailableAndChecked()); - contentAssistant.setProposalSelectorBackground(fProposalPopupBackgroundColor); - contentAssistant.setProposalSelectorForeground(fProposalPopupForegroundColor); - - contentAssistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE); - contentAssistant.setInformationControlCreator(new IInformationControlCreator() { - /* - * @see org.eclipse.jface.text.IInformationControlCreator#createInformationControl(org.eclipse.swt.widgets.Shell) - */ - public IInformationControl createInformationControl(Shell parent) { - return new DefaultInformationControl(parent); - }}); - - return contentAssistant; - } - - private IDialogSettings getSettings(String sectionName) { - IDialogSettings pluginDialogSettings= TextEditorPlugin.getDefault().getDialogSettings(); - IDialogSettings settings= pluginDialogSettings.getSection(sectionName); - if (settings == null) - settings= pluginDialogSettings.addNewSection(sectionName); - - return settings; - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceTarget.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceTarget.java deleted file mode 100644 index 6146bcc40a3..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceTarget.java +++ /dev/null @@ -1,222 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.texteditor; - -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Point; - -import org.eclipse.jface.text.IFindReplaceTarget; -import org.eclipse.jface.text.IFindReplaceTargetExtension; -import org.eclipse.jface.text.IFindReplaceTargetExtension3; -import org.eclipse.jface.text.IRegion; - -/** - * Internal find/replace target wrapping the editor's source viewer. - * @since 2.1 - */ -class FindReplaceTarget implements IFindReplaceTarget, IFindReplaceTargetExtension, IFindReplaceTargetExtension2, IFindReplaceTargetExtension3 { - - /** The editor */ - private AbstractTextEditor fEditor; - /** The find/replace target */ - private IFindReplaceTarget fTarget; - - /** - * Creates a new find/replace target. - * - * @param editor the editor - * @param target the wrapped find/replace target - */ - public FindReplaceTarget(AbstractTextEditor editor, IFindReplaceTarget target) { - fEditor= editor; - fTarget= target; - } - - /** - * Returns the wrapped find/replace target. - * - * @return the wrapped find/replace target - */ - private IFindReplaceTarget getTarget() { - return fTarget; - } - - /** - * Returns the find/replace target extension. - * - * @return the find/replace target extension - */ - private IFindReplaceTargetExtension getExtension() { - if (fTarget instanceof IFindReplaceTargetExtension) - return (IFindReplaceTargetExtension) fTarget; - return null; - } - - /* - * @see org.eclipse.jface.text.IFindReplaceTarget#canPerformFind() - */ - public boolean canPerformFind() { - if (getTarget() != null) - return getTarget().canPerformFind(); - return false; - } - - /* - * @see org.eclipse.jface.text.IFindReplaceTarget#findAndSelect(int, java.lang.String, boolean, boolean, boolean) - */ - public int findAndSelect(int offset, String findString, boolean searchForward, boolean caseSensitive, boolean wholeWord) { - if (getTarget() != null) - return getTarget().findAndSelect(offset, findString, searchForward, caseSensitive, wholeWord); - return -1; - } - - /* - * @see org.eclipse.jface.text.IFindReplaceTargetExtension3#findAndSelect(int, String, boolean, boolean, boolean, boolean) - * @since 3.0 - */ - public int findAndSelect(int offset, String findString, boolean searchForward, boolean caseSensitive, boolean wholeWord, boolean regExSearch) { - if (getTarget() instanceof IFindReplaceTargetExtension3) - return ((IFindReplaceTargetExtension3)getTarget()).findAndSelect(offset, findString, searchForward, caseSensitive, wholeWord, regExSearch); - - // fallback - if (!regExSearch && getTarget() != null) - return getTarget().findAndSelect(offset, findString, searchForward, caseSensitive, wholeWord); - - return -1; - } - - /* - * @see org.eclipse.jface.text.IFindReplaceTarget#getSelection() - */ - public Point getSelection() { - if (getTarget() != null) - return getTarget().getSelection(); - return null; - } - - /* - * @see org.eclipse.jface.text.IFindReplaceTarget#getSelectionText() - */ - public String getSelectionText() { - if (getTarget() != null) - return getTarget().getSelectionText(); - return null; - } - - /* - * @see org.eclipse.jface.text.IFindReplaceTarget#isEditable() - */ - public boolean isEditable() { - if (getTarget() != null) { - if (getTarget().isEditable()) - return true; - return fEditor.isEditorInputModifiable(); - } - return false; - } - - /* - * @see org.eclipse.jface.text.IFindReplaceTarget#replaceSelection(java.lang.String) - */ - public void replaceSelection(String text) { - if (getTarget() != null) - getTarget().replaceSelection(text); - } - - /* - * @see org.eclipse.jface.text.IFindReplaceTargetExtension3#replaceSelection(String, boolean) - * @since 3.0 - */ - public void replaceSelection(String text, boolean regExReplace) { - if (getTarget() instanceof IFindReplaceTargetExtension3) { - ((IFindReplaceTargetExtension3)getTarget()).replaceSelection(text, regExReplace); - return; - } - - // fallback - if (!regExReplace && getTarget() != null) - getTarget().replaceSelection(text); - } - - /* - * @see org.eclipse.jface.text.IFindReplaceTargetExtension#beginSession() - */ - public void beginSession() { - if (getExtension() != null) - getExtension().beginSession(); - } - - /* - * @see org.eclipse.jface.text.IFindReplaceTargetExtension#endSession() - */ - public void endSession() { - if (getExtension() != null) - getExtension().endSession(); - } - - /* - * @see org.eclipse.jface.text.IFindReplaceTargetExtension#getScope() - */ - public IRegion getScope() { - if (getExtension() != null) - return getExtension().getScope(); - return null; - } - - /* - * @see org.eclipse.jface.text.IFindReplaceTargetExtension#setScope(org.eclipse.jface.text.IRegion) - */ - public void setScope(IRegion scope) { - if (getExtension() != null) - getExtension().setScope(scope); - } - - /* - * @see org.eclipse.jface.text.IFindReplaceTargetExtension#getLineSelection() - */ - public Point getLineSelection() { - if (getExtension() != null) - return getExtension().getLineSelection(); - return null; - } - - /* - * @see org.eclipse.jface.text.IFindReplaceTargetExtension#setSelection(int, int) - */ - public void setSelection(int offset, int length) { - if (getExtension() != null) - getExtension().setSelection(offset, length); - } - - /* - * @see org.eclipse.jface.text.IFindReplaceTargetExtension#setScopeHighlightColor(org.eclipse.swt.graphics.Color) - */ - public void setScopeHighlightColor(Color color) { - if (getExtension() != null) - getExtension().setScopeHighlightColor(color); - } - - /* - * @see org.eclipse.jface.text.IFindReplaceTargetExtension#setReplaceAllMode(boolean) - */ - public void setReplaceAllMode(boolean replaceAll) { - if (getExtension() != null) - getExtension().setReplaceAllMode(replaceAll); - } - - /* - * @see org.eclipse.ui.texteditor.IFindReplaceTargetExtension2#validateTargetState() - */ - public boolean validateTargetState() { - return fEditor.validateEditorInputState(); - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/GotoLineAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/GotoLineAction.java deleted file mode 100644 index 6eeeb3ca18e..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/GotoLineAction.java +++ /dev/null @@ -1,188 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.texteditor; - - -import java.text.MessageFormat; -import java.util.ResourceBundle; - -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; - -import org.eclipse.jface.dialogs.IInputValidator; -import org.eclipse.jface.dialogs.InputDialog; -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.window.Window; - -import org.eclipse.ui.IWorkbenchPage; - - -/** - * Action for jumping to a particular line if the editor's text viewer. - * The user is requested to enter the line number into an input dialog. - * The action is initially associated with a text editor via the constructor, - * but that can be subsequently changed using <code>setEditor</code>. - * <p> - * The following keys, prepended by the given option prefix, - * are used for retrieving resources from the given bundle: - * <ul> - * <li><code>"dialog.invalid_range"</code> - to indicate an invalid line number</li> - * <li><code>"dialog.invalid_input"</code> - to indicate an invalid line number format</li> - * <li><code>"dialog.title"</code> - the input dialog's title</li> - * <li><code>"dialog.message"</code> - the input dialog's message</li> - * </ul> - * This class may be instantiated; it is not intended to be subclassed. - * </p> - */ -public class GotoLineAction extends TextEditorAction { - - /** - * Validates whether the text found in the input field of the - * dialog forms a valid line number. A number is valid if it is - * one to which can be jumped. - */ - class NumberValidator implements IInputValidator { - - /* - * @see IInputValidator#isValid(String) - */ - public String isValid(String input) { - - if (input == null || input.length() == 0) - return " "; //$NON-NLS-1$ - - try { - int i= Integer.parseInt(input); - if (i <= 0 || fLastLine < i) - return fBundle.getString(fPrefix + "dialog.invalid_range"); //$NON-NLS-1$ - - } catch (NumberFormatException x) { - return fBundle.getString(fPrefix + "dialog.invalid_input"); //$NON-NLS-1$ - } - - return null; - } - } - - /** - * Standard input dialog which additionally sets the focus to the - * text input field. Workaround for <code>InputDialog</code> issue. - * 1GIJZOO: ITPSRCEDIT:ALL - Gotodialog's edit field has no initial focus - * @since 2.0 - */ - class GotoLineDialog extends InputDialog { - - /* - * @see InputDialog#InputDialog(org.eclipse.swt.widgets.Shell, java.lang.String, java.lang.String, java.lang.String, org.eclipse.jface.dialogs.IInputValidator) - */ - public GotoLineDialog(Shell parent, String title, String message, String initialValue, IInputValidator validator) { - super(parent, title, message, initialValue, validator); - } - - /* - * @see InputDialog#createDialogArea(Composite) - */ - protected Control createDialogArea(Composite parent) { - Control result= super.createDialogArea(parent); - getText().setFocus(); - applyDialogFont(result); - return result; - } - } - - /** The biggest valid line number of the presented document */ - private int fLastLine; - /** This action's resource bundle */ - private ResourceBundle fBundle; - /** This action's prefix used for accessing the resource bundle */ - private String fPrefix; - - /** - * Creates a new action for the given text editor. The action configures its - * visual representation from the given resource bundle. - * - * @param bundle the resource bundle - * @param prefix a prefix to be prepended to the various resource keys - * (described in <code>ResourceAction</code> constructor), or - * <code>null</code> if none - * @param editor the text editor - * @see TextEditorAction#TextEditorAction(ResourceBundle, String, ITextEditor) - */ - public GotoLineAction(ResourceBundle bundle, String prefix, ITextEditor editor) { - super(bundle, prefix, editor); - fBundle= bundle; - fPrefix= prefix; - } - - /** - * Jumps to the given line. - * - * @param line the line to jump to - */ - private void gotoLine(int line) { - - ITextEditor editor= getTextEditor(); - - IDocumentProvider provider= editor.getDocumentProvider(); - IDocument document= provider.getDocument(editor.getEditorInput()); - try { - - int start= document.getLineOffset(line); - editor.selectAndReveal(start, 0); - - IWorkbenchPage page= editor.getSite().getPage(); - page.activate(editor); - - } catch (BadLocationException x) { - // ignore - } - } - - /* - * @see Action#run() - */ - public void run() { - try { - - ITextEditor editor= getTextEditor(); - - if (editor == null) - return; - - IDocumentProvider docProvider= editor.getDocumentProvider(); - if (docProvider == null) - return; - - IDocument document= docProvider.getDocument(editor.getEditorInput()); - if (document == null) - return; - - fLastLine= document.getLineOfOffset(document.getLength()) + 1; - - String title= fBundle.getString(fPrefix + "dialog.title"); //$NON-NLS-1$ - String message= MessageFormat.format(fBundle.getString(fPrefix + "dialog.message"), new Object[] {new Integer(fLastLine)}); //$NON-NLS-1$ - - GotoLineDialog d= new GotoLineDialog(editor.getSite().getShell(), title, message, "", new NumberValidator()); //$NON-NLS-1$ - if (d.open() == Window.OK) { - try { - int line= Integer.parseInt(d.getValue()); - gotoLine(line - 1); - } catch (NumberFormatException x) { - } - } - - } catch (BadLocationException x) { - } - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IAbstractTextEditorHelpContextIds.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IAbstractTextEditorHelpContextIds.java deleted file mode 100644 index ecc1beed85d..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IAbstractTextEditorHelpContextIds.java +++ /dev/null @@ -1,301 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.texteditor; - - -import org.eclipse.ui.PlatformUI; - - -/** - * Help context ids for the text editor. - * <p> - * This interface contains constants only; it is not intended to be implemented. - * </p> - */ -public interface IAbstractTextEditorHelpContextIds { - - /** - * The string with which all other defined ids are prefixed to construct help context ids. - * Value: <code>"org.eclipse.ui."</code> - */ - public static final String PREFIX= PlatformUI.PLUGIN_ID + "."; //$NON-NLS-1$ - - /** - * The string which is appended to action ids to construct help context ids. - * Value: <code>"_action_context"</code> - */ - public static final String ACTION_POSTFIX= "_action_context"; //$NON-NLS-1$ - - /** - * Help context id for the action. - * Value: <code>"org.eclipse.ui.undo_action_context"</code> - */ - public static final String UNDO_ACTION= PREFIX + ITextEditorActionConstants.UNDO + ACTION_POSTFIX; - - /** - * Help context id for the action. - * Value: <code>"org.eclipse.ui.redo_action_context"</code> - */ - public static final String REDO_ACTION= PREFIX + ITextEditorActionConstants.REDO + ACTION_POSTFIX; - - /** - * Help context id for the action. - * Value: <code>"org.eclipse.ui.cut_action_context"</code> - */ - public static final String CUT_ACTION= PREFIX + ITextEditorActionConstants.CUT + ACTION_POSTFIX; - - /** - * Help context id for the action. - * Value: <code>"org.eclipse.ui.copy_action_context"</code> - */ - public static final String COPY_ACTION= PREFIX + ITextEditorActionConstants.COPY + ACTION_POSTFIX; - - /** - * Help context id for the action. - * Value: <code>"org.eclipse.ui.paste_action_context"</code> - */ - public static final String PASTE_ACTION= PREFIX + ITextEditorActionConstants.PASTE + ACTION_POSTFIX; - - /** - * Help context id for the action. - * Value: <code>"org.eclipse.ui.delete_action_context"</code> - */ - public static final String DELETE_ACTION= PREFIX + ITextEditorActionConstants.DELETE + ACTION_POSTFIX; - - /** - * Help context id for the action. - * Value: <code>"org.eclipse.ui.DeleteLine_action_context"</code> - * @since 2.0 - */ - public static final String DELETE_LINE_ACTION= PREFIX + ITextEditorActionConstants.DELETE_LINE + ACTION_POSTFIX; - - /** - * Help context id for the action. - * Value: <code>"org.eclipse.ui.CutLine_action_context"</code> - * @since 2.1 - */ - public static final String CUT_LINE_ACTION= PREFIX + ITextEditorActionConstants.CUT_LINE + ACTION_POSTFIX; - - /** - * Help context id for the action. - * Value: <code>"org.eclipse.ui.DeleteLineToBeginning_action_context"</code> - * @since 2.0 - */ - public static final String DELETE_LINE_TO_BEGINNING_ACTION= PREFIX + ITextEditorActionConstants.DELETE_LINE_TO_BEGINNING + ACTION_POSTFIX; - - /** - * Help context id for the action. - * Value: <code>"org.eclipse.ui.CutLineToBeginning_action_context"</code> - * @since 2.1 - */ - public static final String CUT_LINE_TO_BEGINNING_ACTION= PREFIX + ITextEditorActionConstants.CUT_LINE_TO_BEGINNING + ACTION_POSTFIX; - - /** - * Help context id for the action. - * Value: <code>"org.eclipse.ui.DeleteLineToEnd_action_context"</code> - * @since 2.0 - */ - public static final String DELETE_LINE_TO_END_ACTION= PREFIX + ITextEditorActionConstants.DELETE_LINE_TO_END + ACTION_POSTFIX; - - /** - * Help context id for the action. - * Value: <code>"org.eclipse.ui.CutLineToEnd_action_context"</code> - * @since 2.1 - */ - public static final String CUT_LINE_TO_END_ACTION= PREFIX + ITextEditorActionConstants.CUT_LINE_TO_END + ACTION_POSTFIX; - - /** - * Help context id for the action. - * Value: <code>"org.eclipse.ui.SetMark_action_context"</code> - * @since 2.0 - */ - public static final String SET_MARK_ACTION= PREFIX + ITextEditorActionConstants.SET_MARK + ACTION_POSTFIX; - - /** - * Help context id for the action. - * Value: <code>"org.eclipse.ui.ClearMark_action_context"</code> - * @since 2.0 - */ - public static final String CLEAR_MARK_ACTION= PREFIX + ITextEditorActionConstants.CLEAR_MARK + ACTION_POSTFIX; - - /** - * Help context id for the action. - * Value: <code>"org.eclipse.ui.SwapMark_action_context"</code> - * @since 2.0 - */ - public static final String SWAP_MARK_ACTION= PREFIX + ITextEditorActionConstants.SWAP_MARK + ACTION_POSTFIX; - - /** - * Help context id for the action. - * Value: <code>"org.eclipse.ui.selectAll_action_context"</code> - */ - public static final String SELECT_ALL_ACTION= PREFIX + ITextEditorActionConstants.SELECT_ALL + ACTION_POSTFIX; - - /** - * Help context id for the action. - * Value: <code>"org.eclipse.ui.ShiftRight_action_context"</code> - */ - public static final String SHIFT_RIGHT_ACTION= PREFIX + ITextEditorActionConstants.SHIFT_RIGHT + ACTION_POSTFIX; - - /** - * Help context id for the action. - * Value: <code>"org.eclipse.ui.ShiftLeft_action_context"</code> - */ - public static final String SHIFT_LEFT_ACTION= PREFIX + ITextEditorActionConstants.SHIFT_LEFT + ACTION_POSTFIX; - - /** - * Help context id for the action. - * Value: <code>"org.eclipse.ui.find_action_context"</code> - */ - public static final String FIND_ACTION= PREFIX + ITextEditorActionConstants.FIND + ACTION_POSTFIX; - - /** - * Help context id for the action. - * Value: <code>"org.eclipse.ui.FindNext_action_context"</code> - * @since 2.0 - */ - public static final String FIND_NEXT_ACTION= PREFIX + ITextEditorActionConstants.FIND_NEXT + ACTION_POSTFIX; - - /** - * Help context id for the action. - * Value: <code>"org.eclipse.ui.FindPrevious_action_context"</code> - * @since 2.0 - */ - public static final String FIND_PREVIOUS_ACTION= PREFIX + ITextEditorActionConstants.FIND_PREVIOUS + ACTION_POSTFIX; - - /** - * Help context id for the action. - * Value: <code>"org.eclipse.ui.FindIncremental_action_context"</code> - * @since 2.0 - */ - public static final String FIND_INCREMENTAL_ACTION= PREFIX + ITextEditorActionConstants.FIND_INCREMENTAL + ACTION_POSTFIX; - /** - * Help context id for the action. - * Value: <code>"org.eclipse.ui.FindIncrementalReverse_action_context"</code> - * @since 2.1 - */ - public static final String FIND_INCREMENTAL_REVERSE_ACTION= PREFIX + ITextEditorActionConstants.FIND_INCREMENTAL_REVERSE + ACTION_POSTFIX; - - /** - * Help context id for the action. - * Value: <code>"org.eclipse.ui.bookmark_action_context"</code> - * @deprecated in 3.0 Use <code>org.eclipse.ui.texteditor.ITextEditorHelpContextIds.BOOKMARK_ACTION</code> instead. - */ - public static final String BOOKMARK_ACTION= PREFIX + ITextEditorActionConstants.BOOKMARK + ACTION_POSTFIX; - - /** - * Help context id for the action. - * Value: <code>"org.eclipse.ui.addTask_action_context"</code> - * @deprecated in 3.0 Use <code>org.eclipse.ui.texteditor.ITextEditorHelpContextIds.ADD_TASK_ACTION</code> instead. - */ - public static final String ADD_TASK_ACTION= PREFIX + ITextEditorActionConstants.ADD_TASK + ACTION_POSTFIX; - - /** - * Help context id for the action. - * Value: <code>"org.eclipse.ui.save_action_context"</code> - */ - public static final String SAVE_ACTION= PREFIX + ITextEditorActionConstants.SAVE + ACTION_POSTFIX; - - /** - * Help context id for the action. - * Value: <code>"org.eclipse.ui.revert_action_context"</code> - */ - public static final String REVERT_TO_SAVED_ACTION= PREFIX + ITextEditorActionConstants.REVERT_TO_SAVED + ACTION_POSTFIX; - - /** - * Help context id for the action. - * Value: <code>"org.eclipse.ui.GotoLine_action_context"</code> - */ - public static final String GOTO_LINE_ACTION= PREFIX + ITextEditorActionConstants.GOTO_LINE + ACTION_POSTFIX; - - /** - * Help context id for the action. - * Value: <code>"org.eclipse.ui.print_action_context"</code> - */ - public static final String PRINT_ACTION= PREFIX + ITextEditorActionConstants.PRINT + ACTION_POSTFIX; - - /** - * Help context id for the action. - * Value: <code>"org.eclipse.ui.ConvertLineDelimitersToWindows_action_context"</code> - * @since 2.0 - */ - public static final String CONVERT_LINE_DELIMITERS_TO_WINDOWS= PREFIX + ITextEditorActionConstants.CONVERT_LINE_DELIMITERS_TO_WINDOWS + ACTION_POSTFIX; - - /** - * Help context id for the action. - * Value: <code>"org.eclipse.ui.ConvertLineDelimitersToUNIX_action_context"</code> - * @since 2.0 - */ - public static final String CONVERT_LINE_DELIMITERS_TO_UNIX= PREFIX + ITextEditorActionConstants.CONVERT_LINE_DELIMITERS_TO_UNIX + ACTION_POSTFIX; - - /** - * Help context id for the action. - * Value: <code>"org.eclipse.ui.ConvertLineDelimitersToMAC_action_context"</code> - * @since 2.0 - */ - public static final String CONVERT_LINE_DELIMITERS_TO_MAC= PREFIX + ITextEditorActionConstants.CONVERT_LINE_DELIMITERS_TO_MAC + ACTION_POSTFIX; - - /** - * Help context id for the action. - * Value: <code>"org.eclipse.ui.find_replace_dialog_context"</code> - */ - public static final String FIND_REPLACE_DIALOG= PREFIX + "find_replace_dialog_context"; //$NON-NLS-1$ - - /** - * Help context id for the action. - * Value: <code>"org.eclipse.ui.goto_last_edit_position_action_context"</code> - * @since 2.1 - */ - public static final String GOTO_LAST_EDIT_POSITION_ACTION= PREFIX + "goto_last_edit_position" + ACTION_POSTFIX; //$NON-NLS-1$ - - /** - * Help context id for the action. - * Value: <code>"org.eclipse.ui.move_lines_action_context"</code> - * @since 3.0 - */ - public static final String MOVE_LINES_ACTION= PREFIX + "move_lines" + ACTION_POSTFIX; //$NON-NLS-1$ - - /** - * Help context id for the action. - * Value: <code>"org.eclipse.ui.copy_lines_action_context"</code> - * @since 3.0 - */ - public static final String COPY_LINES_ACTION= PREFIX + "copy_lines" + ACTION_POSTFIX; //$NON-NLS-1$; - - /** - * Help context id for the action. - * Value: <code>"org.eclipse.ui.upper_case_action_context"</code> - * @since 3.0 - */ - public static final String UPPER_CASE_ACTION= PREFIX + "upper_case" + ACTION_POSTFIX; //$NON-NLS-1$ - - /** - * Help context id for the action. - * Value: <code>"org.eclipse.ui.lower_case_action_context"</code> - * @since 3.0 - */ - public static final String LOWER_CASE_ACTION= PREFIX + "lower_case" + ACTION_POSTFIX; //$NON-NLS-1$ - - /** - * Help context id for the action. - * Value: <code>"org.eclipse.ui.smart_enter_action_context"</code> - * @since 3.0 - */ - public static final String SMART_ENTER_ACTION= PREFIX + "smart_enter" + ACTION_POSTFIX; //$NON-NLS-1$; - - /** - * Help context id for the smart insert mode toggle action. - * Value: <code>"org.eclipse.ui.toggle_insert_mode_action_context"</code> - * @since 3.0 - */ - public static final String TOGGLE_INSERT_MODE_ACTION= PREFIX + "toggle_insert_mode" + ACTION_POSTFIX; //$NON-NLS-1$;; -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IAnnotationImageProvider.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IAnnotationImageProvider.java deleted file mode 100644 index e6c6fae2871..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IAnnotationImageProvider.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.texteditor; - -import org.eclipse.swt.graphics.Image; - -import org.eclipse.jface.resource.ImageDescriptor; - -import org.eclipse.jface.text.source.Annotation; - -/** - * Provides an image for a given annotation. - * - * @since 3.0 - */ -public interface IAnnotationImageProvider { - - /** - * Returns the image for the given annotation or <code>null</code>. The - * returned image is managed by this annotation image provided. If the - * annotation image provider does not support managed images, clients have - * to manage the annotation images. For that, clients first ask for the - * image descriptor id for a given annotation (<code>getImageDescriptorId(Annotation)</code>) - * as then for the image descriptor. The image descriptor id should be used - * to manage the annotation images using an <code>ImageRegistry</code>. - * - * @param annotation the annotation - * @return the managed image - */ - Image getManagedImage(Annotation annotation); - - /** - * Returns the image descriptor id of the image for the given annotation. - * - * @param annotation the annotation - * @return the image descriptor id - */ - String getImageDescriptorId(Annotation annotation); - - /** - * Returns the image descriptor for the given symbolic name. - * - * @param imageDescritporId the image descriptor id - * @return the image descriptor - */ - ImageDescriptor getImageDescriptor(String imageDescritporId); -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IDocumentProvider.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IDocumentProvider.java deleted file mode 100644 index ba8bc31662c..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IDocumentProvider.java +++ /dev/null @@ -1,220 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.texteditor; - - - - -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.source.IAnnotationModel; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; - - - -/** - * A document provider maps between domain elements and documents. A document provider has the - * following responsibilities: - * <ul> - * <li>create an annotation model of a domain model element - * <li>create and manage a textual representation, i.e., a document, of a domain model element - * <li>create and save the content of domain model elements based on given documents - * <li>update the documents this document provider manages for domain model elements to changes - * directly applied to those domain model elements - * <li>notify all element state listeners about changes directly applied to domain model elements - * this document provider manages a document for, i.e. the document provider must know which changes - * of a domain model element are to be interpreted as element moves, deletes, etc. - * </ul> - * Text editors use document providers to bridge the gap between their input elements and the - * documents they work on. A single document provider may be shared between multiple editors; the - * methods take the editors' input elements as a parameter. - * <p> - * This interface may be implemented by clients; or subclass the standard abstract base class - * <code>AbstractDocumentProvider</code>. - * </p> - * <p> - * In order to provided backward compatibility for clients of <code>IDocumentProvider</code>, - * extension interfaces are used to provide a means of evolution. The following extension interfaces - * exist: - * <ul> - * <li>{@link org.eclipse.ui.texteditor.IDocumentProviderExtension} since version 2.0 introducing - * state validation, extended read-only handling and synchronization.</li> - * <li>{@link org.eclipse.ui.texteditor.IDocumentProviderExtension2} since version 2.1 introducing - * adding support for a global progress monitor.</li> - * <li>{@link org.eclipse.ui.texteditor.IDocumentProviderExtension3} since version 3.0 adding - * a predicate for querying synchronization state.</li> - * </ul> - * </p> - * - * @see org.eclipse.jface.text.IDocument - * @see org.eclipse.ui.texteditor.AbstractDocumentProvider - * @see org.eclipse.ui.texteditor.IDocumentProviderExtension - * @see org.eclipse.ui.texteditor.IDocumentProviderExtension2 - * @see org.eclipse.ui.texteditor.IDocumentProviderExtension3 - */ -public interface IDocumentProvider { - - /** - * Connects the given element to this document provider. This tells the provider - * that caller of this method is interested to work with the document provided for - * the given domain model element. By counting the invocations of this method and - * <code>disconnect(Object)</code> this provider can assume to know the - * correct number of clients working with the document provided for that - * domain model element. <p> - * The given element must not be <code>null</code>. - * - * @param element the element - * @exception CoreException if the textual representation or the annotation model - * of the element could not be created - */ - void connect(Object element) throws CoreException; - - /** - * Disconnects the given element from this document provider. This tells the provider - * that the caller of this method is no longer interested in working with the document - * provided for the given domain model element. By counting the invocations of - * <code>connect(Object)</code> and of this method this provider can assume to - * know the correct number of clients working with the document provided for that - * domain model element. <p> - * The given element must not be <code>null</code>. - * - * @param element the element - */ - void disconnect(Object element); - - /** - * Returns the document for the given element. Usually the document contains - * a textual presentation of the content of the element, or is the element itself. - * - * @param element the element, or <code>null</code> - * @return the document, or <code>null</code> if none - */ - IDocument getDocument(Object element); - - /** - * Resets the given element's document to its last saved state. - * Element state listeners are notified both before (<code>elementContentAboutToBeReplaced</code>) - * and after (<code>elementContentReplaced</code>) the content is changed. - * - * @param element the element, or <code>null</code> - * @exception CoreException if document could not be reset for the given element - */ - void resetDocument(Object element) throws CoreException; - - /** - * Saves the given document provided for the given element. - * - * @param monitor a progress monitor to report progress and request cancellation - * @param element the element, or <code>null</code> - * @param document the document - * @param overwrite indicates whether overwrite should be performed - * while saving the given element if necessary - * @exception CoreException if document could not be stored to the given element - */ - void saveDocument(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite) throws CoreException; - - /** - * Returns the modification stamp of the given element. - * - * @param element the element - * @return the modification stamp of the given element - */ - long getModificationStamp(Object element); - - /** - * Returns the time stamp of the last synchronization of - * the given element and it's provided document. - * - * @param element the element - * @return the synchronization stamp of the given element - */ - long getSynchronizationStamp(Object element); - - /** - * Returns whether the given element has been deleted. - * - * @param element the element - * @return <code>true</code> if the element has been deleted - */ - boolean isDeleted(Object element); - - /** - * Returns whether the document provided for the given element must be saved. - * - * @param element the element, or <code>null</code> - * @return <code>true</code> if the document must be saved, and - * <code>false</code> otherwise (including the element is <code>null</code>) - */ - boolean mustSaveDocument(Object element); - - /** - * Returns whether the document provided for the given element differs from - * its original state which would required that it be saved. - * - * @param element the element, or <code>null</code> - * @return <code>true</code> if the document can be saved, and - * <code>false</code> otherwise (including the element is <code>null</code>) - */ - boolean canSaveDocument(Object element); - - /** - * Returns the annotation model for the given element. - * - * @param element the element, or <code>null</code> - * @return the annotation model, or <code>null</code> if none - */ - IAnnotationModel getAnnotationModel(Object element); - - /** - * Informs this document provider about upcoming changes of the given element. - * The changes might cause change notifications specific for the type of the given element. - * If this provider manages a document for the given element, the document provider - * must not change the document because of the notifications received after <code> - * aboutToChange</code> has been and before <code>changed</code> is called. In this case, - * it is assumed that the document is already up to date, e.g., a save operation is a - * typical case. <p> - * The concrete nature of the change notification depends on the concrete type of the - * given element. If the element is, e.g., an <code>IResource</code> the notification - * is a resource delta. - * - * @param element the element, or <code>null</code> - */ - void aboutToChange(Object element); - - /** - * Informs this document provider that the given element has been changed. - * All notifications have been sent out. If this provider manages a document - * for the given element, the document provider must from now on change the - * document on the receipt of change notifications. The concrete nature of the change - * notification depends on the concrete type of the given element. If the element is, - * e.g., an <code>IResource</code> the notification is a resource delta. - * - * @param element the element, or <code>null</code> - */ - void changed(Object element); - - /** - * Adds the given element state listener to this document provider. - * Has no effect if an identical listener is already registered. - * - * @param listener the listener - */ - void addElementStateListener(IElementStateListener listener); - - /** - * Removes the given element state listener from this document provider. - * Has no affect if an identical listener is not registered. - * - * @param listener the listener - */ - void removeElementStateListener(IElementStateListener listener); -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IDocumentProviderExtension.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IDocumentProviderExtension.java deleted file mode 100644 index a065d82006f..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IDocumentProviderExtension.java +++ /dev/null @@ -1,115 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.texteditor; - - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; - - -/** - * Extension interface for {@link IDocumentProvider}. It adds the following - * functions: - * <ul> - * <li> dealing with immutable domain elements - * <li> state validation - * <li> persistent status of domain element operations - * <li> extended synchronization support - * </ul> - * @since 2.0 - */ -public interface IDocumentProviderExtension { - - /** - * Returns whether the document provider thinks that the given element is read-only. - * If this method returns <code>true</code>, <code>saveDocument</code> could fail. - * This method does not say anything about the document constructed from the given - * element. If the given element is not connected to this document provider, the return - * value is undefined. Document providers are allowed to use a cache to answer this - * question, i.e. there can be a difference between the "real" state of the element and - * the return value. - * - * @param element the element - * @return <code>true</code> if the given element is read-only, <code>false</code> otherwise - */ - boolean isReadOnly(Object element); - - /** - * Returns whether the document provider thinks that the given element can persistently be modified. - * This is orthogonal to <code>isReadOnly</code> as read-only elements may be modifiable and - * writable elements may not be modifiable. If the given element is not connected to this document - * provider, the result is undefined. Document providers are allowed to use a cache to answer this - * question, i.e. there can be a difference between the "real" state of the element and the return - * value. - * - * @param element the element - * @return <code>true</code> if the given element is modifiable, <code>false</code> otherwise - */ - boolean isModifiable(Object element); - - /** - * Validates the state of the given element. This method may change the "real" state of the - * element. If using, it also updates the internal caches, so that this method may also change - * the results returned by <code>isReadOnly</code> and <code>isModifiable</code>. If the - * given element is not connected to this document provider, the effect is undefined. - * - * @param element the element - * @param computationContext the context in which the computation is performed, e.g., a SWT shell - * @exception CoreException if validating fails - */ - void validateState(Object element, Object computationContext) throws CoreException; - - /** - * Returns whether the state of the given element has been validated. - * - * @param element the element - * @return <code>true</code> if the state has been validated - */ - boolean isStateValidated(Object element); - - /** - * Updates the state cache for the given element. This method may change the result returned - * by <code>isReadOnly</code> and <code>isModifiable</code>. If the given element is not - * connected to this document provider, the effect is undefined. - * - * @param element the element - * @exception CoreException if validating fails - */ - void updateStateCache(Object element) throws CoreException; - - /** - * Marks the document managed for the given element as saveable. I.e. - * <code>canBeSaved(element)</code> will return <code>true</code> - * afterwards. - * - * @param element the element - */ - void setCanSaveDocument(Object element); - - /** - * Returns the status of the given element. - * - * @param element the element - * @return the status of the given element - */ - IStatus getStatus(Object element); - - /** - * Synchronizes the document provided for the given element with the - * given element. After that call <code>getSynchronizationTimeStamp</code> - * and <code>getModificationTimeStamp</code> return the same value. - * - * @param element the element - * @exception CoreException if the synchronization could not be performed - */ - void synchronize(Object element) throws CoreException; -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IDocumentProviderExtension2.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IDocumentProviderExtension2.java deleted file mode 100644 index 20b92748fab..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IDocumentProviderExtension2.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.ui.texteditor; - - -import org.eclipse.core.runtime.IProgressMonitor; - -/** - * Extension interface for {@link org.eclipse.ui.texteditor.IDocumentProvider}. It adds the following - * functions: - * <ul> - * <li> global temporary progress monitor - * </ul> - * @since 2.1 - */ -public interface IDocumentProviderExtension2 { - - /** - * Sets this providers progress monitor. - * @param progressMonitor - */ - void setProgressMonitor(IProgressMonitor progressMonitor); - - /** - * Returns this providers progress monitor. - * @return IProgressMonitor - */ - IProgressMonitor getProgressMonitor(); -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IDocumentProviderExtension3.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IDocumentProviderExtension3.java deleted file mode 100644 index 938c44c836a..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IDocumentProviderExtension3.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.texteditor; - - -/** - * Extension interface for {@link org.eclipse.ui.texteditor.IDocumentProvider}. The method - * <code>isSynchronized</code> replaces the original <code>getSynchronizationStamp</code> method. - * - * @since 3.0 - */ -public interface IDocumentProviderExtension3 { - - /** - * Returns whether the information provided for the given element is in sync with the element. - * - * @param element the element - * @return <code>true</code> if the information is in sync with the element, <code>false</code> otherwise - */ - boolean isSynchronized(Object element); -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IEditorStatusLine.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IEditorStatusLine.java deleted file mode 100644 index 5f691718066..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IEditorStatusLine.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.texteditor; - -import org.eclipse.swt.graphics.Image; - -/** - * An interface to use the status line of an editor. - * - * @since 2.1 - */ -public interface IEditorStatusLine { - /** - * Sets the image and message to be displayed on the status line. - * <p> - * The error flag indicates that the message is an error message. - * If the error flag is set, a potential non-error message is overridden. - * If the error message is <code>null</code>, the non-error message is displayed. - * </p> - * - * @param error indicates that the message is an error message - * @param message the message to set (may be <code>null</code> to clear the message) - * @param image the image to set (may be <code>null</code> to clear the image) - */ - void setMessage(boolean error, String message, Image image); - -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IElementStateListener.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IElementStateListener.java deleted file mode 100644 index 5156a880664..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IElementStateListener.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.texteditor; - - -/** - * Interface for parties interested in standardized element changes. These - * changes are: - * <ul> - * <li> dirty state changes - * <li> content replacements - * <li> moves - * <li> deletions - * </ul> - * The notifications sent to the element state listeners inform about those standardized, - * abstract changes. The concrete change applied might differ from the one the listeners - * are notified about, but should be interpreted as the one the listeners receive. - * <p> - * In order to provided backward compatibility for clients of <code>IElementStateListener</code>, - * extension interfaces are used to provide a means of evolution. The following extension interface - * exists: - * <ul> - * <li>{@link org.eclipse.ui.texteditor.IElementStateListenerExtension} since version 2.0 introducing - * state validation events.</li> - * </ul> - * </p> - * - * @see org.eclipse.ui.texteditor.IElementStateListenerExtension - */ -public interface IElementStateListener { - - /** - * Notifies that the dirty state of the given element has changed. - * - * @param element the element - * @param isDirty the new dirty state - */ - void elementDirtyStateChanged(Object element, boolean isDirty); - - /** - * Notifies that the content of the given element is about to be replaced. - * - * @param element the element - */ - void elementContentAboutToBeReplaced(Object element); - - /** - * Notifies that the content of the given element has been replaced. - * - * @param element the element - */ - void elementContentReplaced(Object element); - - /** - * Notifies that the given element has been deleted. - * - * @param element the element - */ - void elementDeleted(Object element); - - /** - * Notifies that the element has moved. If <code>movedElement</code> - * is <code>null</code> it is similar to <code>elementDeleted(originalElement)</code>. - * - * @param originalElement the element before the move - * @param movedElement the element after the move - */ - void elementMoved(Object originalElement, Object movedElement); -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IElementStateListenerExtension.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IElementStateListenerExtension.java deleted file mode 100644 index 1aa526f09ac..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IElementStateListenerExtension.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.ui.texteditor; - -/** - * Extension interface for {@link org.eclipse.ui.texteditor.IElementStateListener}. - * It adds - * <ul> - * <li> state validation notification - * <li>a notion of session, i.e. a notification about an upcoming element change and error handling. - * </ul> - * @since 2.0 - */ -public interface IElementStateListenerExtension { - - /** - * Notifies that the state validation of the given element has changed. - * - * @param element the element - * @param isStateValidated the flag indicating whether state validation is done - */ - void elementStateValidationChanged(Object element, boolean isStateValidated); - - /** - * Notifies that the given element is currently being changed. This method may - * be sent from a non-ui thread. - * - * @param element the element - */ - void elementStateChanging(Object element); - - /** - * Notifies that changing the given element has failed. - * - * @param element the element - */ - void elementStateChangeFailed(Object element); -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IFindReplaceTargetExtension2.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IFindReplaceTargetExtension2.java deleted file mode 100644 index 92359e656c8..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IFindReplaceTargetExtension2.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.texteditor; - -/** - * Extension interface for {@link org.eclipse.jface.text.IFindReplaceTarget}. - * Extends the find replace target with the concept of state validation. - * - * @since 2.1 - */ -public interface IFindReplaceTargetExtension2 { - - /** - * Validates the state of this target. The predominate intent of this method - * is to take any action probably necessary to ensure that the target can - * persistently be changed. - * - * @return <code>true</code> if the target was validated, <code>false</code> otherwise - */ - boolean validateTargetState(); -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IReadOnlyDependent.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IReadOnlyDependent.java deleted file mode 100644 index 72a7e5c7a11..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IReadOnlyDependent.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.ui.texteditor; - - - -/** - * Extension interface for actions. Actions implementing this interface not - * only manage an enable/disable state but also manage a "hypothetical" - * enable state, depending on whether the target they work on is writable - * or read-only. - * @since 2.0 - */ -public interface IReadOnlyDependent { - - /** - * Returns whether the actions would be enabled if its target - * would be enabled given the writable state described by <code>isWritable</code>. - * <code>isEnabled()</code> and <code>isEnabled(boolean)</code> holds the following - * invariants: - * isEnabled() == false, if isEnabled(true) == false || isEnabled(false) == false - * isEnabled() == true, if isEnabled(true) == true || isEnabled(false) == true - * - * @param isWritable - * @return the hypothetical enable state of the action - */ - boolean isEnabled(boolean isWritable); -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ISchedulingRuleProvider.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ISchedulingRuleProvider.java deleted file mode 100644 index a9c40e11968..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ISchedulingRuleProvider.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.texteditor; - -import org.eclipse.core.runtime.jobs.ISchedulingRule; - -/** - * A scheduling rule provider provides a scheduling rule which - * can be used when running operations. - * - * @since 3.0 - */ -public interface ISchedulingRuleProvider { - - /** - * Returns the scheduling rule. - * - * @return a scheduling rule or <code>null</code> if none - */ - ISchedulingRule getSchedulingRule(); -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IStatusField.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IStatusField.java deleted file mode 100644 index ae6a1e445fc..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IStatusField.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.texteditor; - - -import org.eclipse.swt.graphics.Image; - - -/** - * Interface of a status field of a text editor. The field that shows up in the - * workbench's status line if the contributing editor is active. - * <p> - * In order to provided backward compatibility for clients of - * <code>IStatusField</code>, extension interfaces are used to provide a - * means of evolution. The following extension interface exists: - * <ul> - * <li>{@link org.eclipse.ui.texteditor.IStatusFieldExtension} since - * version 3.0 introducing error text, tooltips and visibility control.</li> - * </ul> - * </p> - * - * @see org.eclipse.ui.texteditor.IStatusFieldExtension - * @since 2.0 - */ -public interface IStatusField { - - /** - * Sets the text of this status field. - * - * @param text the text shown in the status field - */ - void setText(String text); - - /** - * Sets the image of this status field. - * - * @param image the image shown in the status field - */ - void setImage(Image image); -} - diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IStatusFieldExtension.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IStatusFieldExtension.java deleted file mode 100644 index 4bf91b93c2f..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IStatusFieldExtension.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.texteditor; - -import org.eclipse.swt.graphics.Image; - -/** - * Extends {@link org.eclipse.ui.texteditor.IStatusField} with the following - * concepts: - * <ul> - * <li>set error text and image</li> - * <li>set tool tip</li> - * <li>control visibility</li> - * </ul> - * - * @since 3.0 - */ -public interface IStatusFieldExtension { - /** - * Sets the text of this status field. - * <p> - * The error text overrides the current text until the error - * text is cleared (set to <code>null</code>). - * </p> - * - * @param text the error text shown in the status field or <code>null</code> to clear - * @see IStatusField#setText(String) - */ - void setErrorText(String text); - - /** - * Sets the error image of this status field. - * <p> - * The error image overrides the current image until the error - * image is cleared (set to <code>null</code>). - * </p> - * - * @param image the error image shown in the status field or <code>null</code> to clear - * @see IStatusField#setImage(Image) - */ - void setErrorImage(Image image); - - /** - * Sets tool tip text for this status field. - * - * @param string the new tool tip text or <code>null</code> to clear - */ - void setToolTipText (String string); - - /** - * Sets whether this status field is visible within the status line. - * - * @param visible <code>true</code> if this item should be visible, <code>false</code> otherwise - */ - void setVisible(boolean visible); -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditor.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditor.java deleted file mode 100644 index 5a6b3dcfbb6..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditor.java +++ /dev/null @@ -1,198 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.texteditor; - - - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.text.IRegion; -import org.eclipse.jface.viewers.ISelectionProvider; - -import org.eclipse.ui.IEditorPart; - - -/** - * Interface to a text editor. This interface defines functional extensions to - * <code>IEditorPart</code> as well as the configuration capabilities of a - * text editor. - * <p> - * Text editors are configured with an <code>IDocumentProvider</code> which - * delivers a textual presentation (<code>IDocument</code>) of the editor's - * input. The editor works on the document and forwards all input element - * related calls, such as <code>save</code>, to the document provider. The - * provider also delivers the input's annotation model which is used to control - * the editor's vertical ruler. - * </p> - * <p> - * Clients may implement this interface from scratch, but the recommended way is - * to subclass the abstract base class <code>AbstractTextEditor</code>. - * </p> - * <p> - * In order to provided backward compatibility for clients of - * <code>ITextEditor</code>, extension interfaces are used to provide a means - * of evolution. The following extension interfaces exist: - * <ul> - * <li>{@link org.eclipse.ui.texteditor.ITextEditorExtension} since version 2.0 - * introducing status fields, read-only state and ruler context menu - * listeners.</li> - * <li>{@link org.eclipse.ui.texteditor.ITextEditorExtension2} since version 2.1 - * introducing modifiable state for the editor input and validate state - * handling.</li> - * <li>{@link org.eclipse.ui.texteditor.ITextEditorExtension3} since version 3.0 - * adding input state and change information control.</li> - * </ul> - * </p> - * - * @see org.eclipse.ui.texteditor.IDocumentProvider - * @see org.eclipse.jface.text.source.IAnnotationModel - * @see org.eclipse.ui.texteditor.ITextEditorExtension - * @see org.eclipse.ui.texteditor.ITextEditorExtension2 - * @see org.eclipse.ui.texteditor.ITextEditorExtension3 - */ -public interface ITextEditor extends IEditorPart { - - /** - * Returns this text editor's document provider. - * - * @return the document provider - */ - IDocumentProvider getDocumentProvider(); - - /** - * Closes this text editor after optionally saving changes. - * - * @param save <code>true</code> if unsaved changed should be saved, and - * <code>false</code> if unsaved changed should be discarded - */ - void close(boolean save); - - /** - * Returns whether the text in this text editor can be changed by the user. - * - * @return <code>true</code> if it can be edited, and <code>false</code> if it is read-only - */ - boolean isEditable(); - - /** - * Abandons all modifications applied to this text editor's input element's - * textual presentation since the last save operation. - */ - void doRevertToSaved(); - - /** - * Installs the given action under the given action id. - * - * @param actionID the action id - * @param action the action, or <code>null</code> to clear it - * @see #getAction(String) - */ - void setAction(String actionID, IAction action); - - /** - * Returns the action installed under the given action id. - * - * @param actionId the action id - * @return the action, or <code>null</code> if none - * @see #setAction(String, IAction) - */ - IAction getAction(String actionId); - - /** - * Sets the given activation code for the specified action. If - * there is an activation code already registered, it is replaced. - * The activation code consists of the same information as - * a <code>KeyEvent</code>. If the activation code is triggered - * and the associated action is enabled, the action is performed - * and the triggering <code>KeyEvent</code> is considered consumed. - * If the action is disabled, the <code>KeyEvent</code> is passed - * on unmodified. Thus, action activation codes and action accelerators - * differ in their model of event consumption. The key code parameter - * can be <code>-1</code> to indicate a wild card. The state mask - * parameter can be SWT.DEFAULT to indicate a wild card. - * - * @param actionId the action id - * @param activationCharacter the activation code character - * @param activationKeyCode the activation code key code or <code>-1</code> for wild card - * @param activationStateMask the activation code state mask or <code>SWT.DEFAULT</code> for wild card - */ - void setActionActivationCode(String actionId, char activationCharacter, int activationKeyCode, int activationStateMask); - - /** - * Removes any installed activation code for the specified action. - * If no activation code is installed, this method does not have - * any effect. - * - * @param actionId the action id - */ - void removeActionActivationCode(String actionId); - - /** - * Returns whether this text editor is configured to show only the - * highlighted range of the text. - * - * @return <code>true</code> if only the highlighted range is shown, and - * <code>false</code> if this editor shows the entire text of the document - * @see #showHighlightRangeOnly(boolean) - */ - boolean showsHighlightRangeOnly(); - - /** - * Configures this text editor to show only the highlighted range of the - * text. - * - * @param showHighlightRangeOnly <code>true</code> if only the highlighted - * range is shown, and <code>false</code> if this editor shows the entire - * text of the document - * @see #showsHighlightRangeOnly() - */ - void showHighlightRangeOnly(boolean showHighlightRangeOnly); - - /** - * Sets the highlighted range of this text editor to the specified region. - * - * @param offset the offset of the highlighted range - * @param length the length of the highlighted range - * @param moveCursor <code>true</code> if the cursor should be moved to - * the start of the highlighted range, and <code>false</code> to leave - * the cursor unaffected - * @see #getHighlightRange() - */ - void setHighlightRange(int offset, int length, boolean moveCursor); - - /** - * Returns the highlighted range of this text editor. - * - * @return the highlighted range - * @see #setHighlightRange(int, int, boolean) - */ - IRegion getHighlightRange(); - - /** - * Resets the highlighted range of this text editor. - */ - void resetHighlightRange(); - - /** - * Returns this text editor's selection provider. Repeated calls to this - * method return the same selection provider. - * - * @return the selection provider - */ - ISelectionProvider getSelectionProvider(); - - /** - * Selects and reveals the specified range in this text editor. - * - * @param offset the offset of the selection - * @param length the length of the selection - */ - void selectAndReveal(int offset, int length); -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorActionConstants.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorActionConstants.java deleted file mode 100644 index 401f7591c2b..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorActionConstants.java +++ /dev/null @@ -1,418 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.texteditor; - - -import org.eclipse.ui.IWorkbenchActionConstants; -import org.eclipse.ui.actions.ActionFactory; - - -/** - * Defines the names of those actions which are preregistered with the - * <code>AbstractTextEditor</code>. <code>RULER_DOUBLE_CLICK</code> defines - * the action which is registered as being executed when the editor's - * ruler has been double clicked. This interface extends the set of names - * available from <code>IWorkbenchActionConstants</code>. It also defines the - * names of the menu groups in a text editor's context menu. - */ -public interface ITextEditorActionConstants extends IWorkbenchActionConstants { - - /** - * Context menu group for undo/redo related actions. - * Value: <code>"group.undo"</code> - */ - static final String GROUP_UNDO= "group.undo"; //$NON-NLS-1$ - - /** - * Context menu group for copy/paste related actions. - * Value: <code>"group.copy"</code> - */ - static final String GROUP_COPY= "group.copy"; //$NON-NLS-1$ - - /** - * Context menu group for text manipulation actions. - * Value: <code>"group.edit"</code> - */ - static final String GROUP_EDIT= "group.edit"; //$NON-NLS-1$ - - /** - * Context menu group for print related actions. - * Value: <code>"group.print"</code> - */ - static final String GROUP_PRINT= "group.print"; //$NON-NLS-1$ - - /** - * Context menu group for find/replace related actions. - * Value: <code>"group.find"</code> - */ - static final String GROUP_FIND= "group.find"; //$NON-NLS-1$ - - /** - * Context menu group for save related actions. - * Value: <code>"group.save"</code> - */ - static final String GROUP_SAVE= "group.save"; //$NON-NLS-1$ - - /** - * Context menu group for actions which do not fit in one of the other categories. - * Value: <code>"group.rest"</code> - */ - static final String GROUP_REST= "group.rest"; //$NON-NLS-1$ - - /** - * Name of the action for shifting text blocks to the right. - * Value: <code>"ShiftRight"</code> - */ - static final String SHIFT_RIGHT= "ShiftRight"; //$NON-NLS-1$ - - /** - * Name of the action for shifting text blocks to the right, triggered by the TAB key. - * Value: <code>"ShiftRightTab"</code> - * @since 3.0 - */ - static final String SHIFT_RIGHT_TAB= "ShiftRightTab"; //$NON-NLS-1$ - - /** - * Name of the action for shifting text blocks to the left. - * Value: <code>"ShiftLeft"</code> - */ - static final String SHIFT_LEFT= "ShiftLeft"; //$NON-NLS-1$ - - /** - * Name of the action to delete the current line. - * Value: <code>"DeleteLine"</code> - * @since 2.0 - */ - static final String DELETE_LINE= "DeleteLine"; //$NON-NLS-1$ - - /** - * Name of the action to cut the current line. - * Value: <code>"CutLine"</code> - * @since 2.1 - */ - static final String CUT_LINE= "CutLine"; //$NON-NLS-1$ - - /** - * Name of the action to delete line to beginning. - * Value: <code>"DeleteLineToBeginning"</code> - * @since 2.0 - */ - static final String DELETE_LINE_TO_BEGINNING= "DeleteLineToBeginning"; //$NON-NLS-1$ - - /** - * Name of the action to cut line to beginning. - * Value: <code>"CutLineToBeginning"</code> - * @since 2.1 - */ - static final String CUT_LINE_TO_BEGINNING= "CutLineToBeginning"; //$NON-NLS-1$ - - /** - * Name of the action to delete line to end. - * Value: <code>"DeleteLineToEnd"</code> - * @since 2.0 - */ - static final String DELETE_LINE_TO_END= "DeleteLineToEnd"; //$NON-NLS-1$ - - /** - * Name of the action to cut line to end. - * Value: <code>"CutLineToEnd"</code> - * @since 2.1 - */ - static final String CUT_LINE_TO_END= "CutLineToEnd"; //$NON-NLS-1$ - - /** - * Name of the action to set the mark. - * Value: <code>"SetMark"</code> - * @since 2.0 - */ - static final String SET_MARK= "SetMark"; //$NON-NLS-1$ - - /** - * Name of the action to set the mark. - * Value: <code>"ClearMark"</code> - * @since 2.0 - */ - static final String CLEAR_MARK= "ClearMark"; //$NON-NLS-1$ - - /** - * Name of the action to swap the mark with the cursor position. - * Value: <code>"SwapMark"</code> - * @since 2.0 - */ - static final String SWAP_MARK= "SwapMark"; //$NON-NLS-1$ - - /** - * Name of the action to jump to a certain text line. - * Value: <code>"GotoLine"</code> - */ - static final String GOTO_LINE= "GotoLine"; //$NON-NLS-1$ - - /** - * Name of the action to insert a new line below the current position. - * Value: <code>"SmartEnter"</code> - * @since 3.0 - */ - static final String SMART_ENTER= "SmartEnter"; //$NON-NLS-1$ - - /** - * Name of the action to insert a new line above the current position. - * Value: <code>"SmartEnterInverse"</code> - * @since 3.0 - */ - static final String SMART_ENTER_INVERSE= "SmartEnterInverse"; //$NON-NLS-1$ - - /** - * Name of the action to move lines upwards - * Value: <code>"MoveLineUp"</code> - * @since 3.0 - */ - static final String MOVE_LINE_UP= "MoveLineUp"; //$NON-NLS-1$ - - /** - * Name of the action to move lines downwards - * Value: <code>"MoveLineDown"</code> - * @since 3.0 - */ - static final String MOVE_LINE_DOWN= "MoveLineDown"; //$NON-NLS-1$ - - /** - * Name of the action to copy lines upwards - * Value: <code>"CopyLineUp"</code> - * @since 3.0 - */ - static final String COPY_LINE_UP= "CopyLineUp"; //$NON-NLS-1$; - - /** - * Name of the action to copy lines downwards - * Value: <code>"CopyLineDown"</code> - * @since 3.0 - */ - static final String COPY_LINE_DOWN= "CopyLineDown"; //$NON-NLS-1$; - - /** - * Name of the action to turn a selection to upper case - * Value: <code>"UpperCase"</code> - * @since 3.0 - */ - static final String UPPER_CASE= "UpperCase"; //$NON-NLS-1$ - - /** - * Name of the action to turn a selection to lower case - * Value: <code>"LowerCase"</code> - * @since 3.0 - */ - static final String LOWER_CASE= "LowerCase"; //$NON-NLS-1$ - - /** - * Name of the action to find next. - * Value: <code>"FindNext"</code> - * @since 2.0 - */ - static final String FIND_NEXT= "FindNext"; //$NON-NLS-1$ - - /** - * Name of the action to find previous. - * Value: <code>"FindPrevious"</code> - * @since 2.0 - */ - static final String FIND_PREVIOUS= "FindPrevious"; //$NON-NLS-1$ - - /** - * Name of the action to incremental find. - * Value: <code>"FindIncremental"</code> - * @since 2.0 - */ - static final String FIND_INCREMENTAL= "FindIncremental"; //$NON-NLS-1$ - /** - * Name of the action to incremental find reverse. - * Value: <code>"FindIncrementalReverse"</code> - * @since 2.1 - */ - static final String FIND_INCREMENTAL_REVERSE= "FindIncrementalReverse"; //$NON-NLS-1$ - - /** - * Name of the action to convert line delimiters to Windows. - * Value: <code>"ConvertLineDelimitersToWindows"</code> - * @since 2.0 - */ - static final String CONVERT_LINE_DELIMITERS_TO_WINDOWS= "ConvertLineDelimitersToWindows"; //$NON-NLS-1$ - - /** - * Name of the action to convert line delimiters to UNIX. - * Value: <code>"ConvertLineDelimitersToUNIX"</code> - * @since 2.0 - */ - static final String CONVERT_LINE_DELIMITERS_TO_UNIX= "ConvertLineDelimitersToUNIX"; //$NON-NLS-1$ - - /** - * Name of the action to convert line delimiters to MAC. - * Value: <code>"ConvertLineDelimitersToMAC"</code> - * @since 2.0 - */ - static final String CONVERT_LINE_DELIMITERS_TO_MAC= "ConvertLineDelimitersToMAC"; //$NON-NLS-1$ - - /** - * Name of the ruler action performed when double clicking the editor's vertical ruler. - * Value: <code>"RulerDoubleClick"</code> - */ - static final String RULER_DOUBLE_CLICK= "RulerDoubleClick"; //$NON-NLS-1$ - - /** - * Name of the ruler action performed when clicking the editor's vertical ruler. - * Value: <code>"RulerClick"</code> - * @since 2.0 - */ - static final String RULER_CLICK= "RulerClick"; //$NON-NLS-1$ - - /** - * Name of the ruler action to manage tasks. - * Value: <code>"ManageTasks"</code> - */ - static final String RULER_MANAGE_TASKS= "ManageTasks"; //$NON-NLS-1$ - - /** - * Name of the ruler action to manage bookmarks. - * Value: <code>"ManageBookmarks"</code> - */ - static final String RULER_MANAGE_BOOKMARKS= "ManageBookmarks"; //$NON-NLS-1$ - - - /** - * Status line category "input position". - * Value: <code>"InputPosition"</code> - * @since 2.0 - */ - static final String STATUS_CATEGORY_INPUT_POSITION= "InputPosition"; //$NON-NLS-1$ - - /** - * Status line category "input mode". - * Value: <code>"InputMode"</code> - * @since 2.0 - */ - static final String STATUS_CATEGORY_INPUT_MODE= "InputMode"; //$NON-NLS-1$ - - /** - * Status line category "element state". - * Value: <code>"ElementState"</code> - * @since 2.0 - */ - static final String STATUS_CATEGORY_ELEMENT_STATE= "ElementState"; //$NON-NLS-1$ - - /** - * Status line category "findField". - * Value: <code>"findField"</code> - * @since 3.0 - */ - static final String STATUS_CATEGORY_FIND_FIELD= "findField"; //$NON-NLS-1$ - - /** - * Name of standard Copy global action in the Edit menu. - * Value <code>"copy"</code> - * @since 3.0 - * @see org.eclipse.ui.actions.ActionFactory#COPY - */ - static final String COPY= ActionFactory.COPY.getId(); - - /** - * Name of standard Cut global action in the Edit menu. - * Value <code>"cut"</code> - * @since 3.0 - * @see org.eclipse.ui.actions.ActionFactory#CUT - */ - static final String CUT= ActionFactory.CUT.getId(); - - /** - * Name of standard Delete global action in the Edit menu. - * Value <code>"delete"</code> - * @since 3.0 - * @see org.eclipse.ui.actions.ActionFactory#DELETE - */ - static final String DELETE= ActionFactory.DELETE.getId(); - - /** - * Name of standard Find global action in the Edit menu. - * Value <code>"find"</code> - * @since 3.0 - * @see org.eclipse.ui.actions.ActionFactory#FIND - */ - static final String FIND= ActionFactory.FIND.getId(); - - /** - * Name of standard Paste global action in the Edit menu. - * Value <code>"paste"</code> - * @since 3.0 - * @see org.eclipse.ui.actions.ActionFactory#PASTE - */ - static final String PASTE= ActionFactory.PASTE.getId(); - - /** - * Name of standard Print global action in the File menu. - * Value <code>"print"</code> - * @since 3.0 - * @see org.eclipse.ui.actions.ActionFactory#PRINT - */ - static final String PRINT= ActionFactory.PRINT.getId(); - - /** - * Name of standard Redo global action in the Edit menu. - * Value <code>"redo"</code> - * @since 3.0 - * @see org.eclipse.ui.actions.ActionFactory#REDO - */ - static final String REDO= ActionFactory.REDO.getId(); - - /** - * Name of standard Undo global action in the Edit menu. - * Value <code>"undo"</code> - * @since 3.0 - * @see org.eclipse.ui.actions.ActionFactory#UNDO - */ - static final String UNDO= ActionFactory.UNDO.getId(); - - /** - * Name of standard Save global action in the File menu. - * Value <code>"save"</code> - * @since 3.0 - * @see org.eclipse.ui.actions.ActionFactory#SAVE - */ - static final String SAVE= ActionFactory.SAVE.getId(); - - /** - * Name of standard Select All global action in the Edit menu. - * Value <code>"selectAll"</code> - * @since 3.0 - * @see org.eclipse.ui.actions.ActionFactory#SELECT_ALL - */ - static final String SELECT_ALL= ActionFactory.SELECT_ALL.getId(); - - /** - * Name of standard Revert global action in the File menu. - * Value <code>"revert"</code> - * @since 3.0 - * @see org.eclipse.ui.actions.ActionFactory#REVERT - */ - static final String REVERT= ActionFactory.REVERT.getId(); - - /** - * Name of the action for re-establishing the state after the - * most recent save operation. - * Value: <code>"ITextEditorActionConstants.REVERT"</code> - */ - static final String REVERT_TO_SAVED= REVERT; - - /** - * Name of the action for toggling the smart insert mode. - * Value: <code>"ToggleInsertMode"</code> - * @since 3.0 - */ - static final String TOGGLE_INSERT_MODE= "TOGGLE_INSERT_MODE"; //$NON-NLS-1$ -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorActionDefinitionIds.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorActionDefinitionIds.java deleted file mode 100644 index afd38f8aa00..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorActionDefinitionIds.java +++ /dev/null @@ -1,450 +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 - * Chris.Dennis@invidi.com - http://bugs.eclipse.org/bugs/show_bug.cgi?id=29027 - *******************************************************************************/ -package org.eclipse.ui.texteditor; - -/** - * Defines the definitions ids for the text editor actions. These actions are - * navigation, selection, and modification actions. - * @since 2.0 - */ -public interface ITextEditorActionDefinitionIds extends IWorkbenchActionDefinitionIds { - - // edit - - /** - * Action definition id of the edit delete line action. - * Value: <code>"org.eclipse.ui.edit.text.delete.line"</code> - */ - public static final String DELETE_LINE= "org.eclipse.ui.edit.text.delete.line"; //$NON-NLS-1$ - - /** - * Action definition id of the edit cut line action. - * Value: <code>"org.eclipse.ui.edit.text.cut.line"</code> - * @since 2.1 - */ - public static final String CUT_LINE= "org.eclipse.ui.edit.text.cut.line"; //$NON-NLS-1$ - - /** - * Action definition id of the edit delete line to beginning action. - * Value: <code>"org.eclipse.ui.edit.text.delete.line.to.beginning"</code> - */ - public static final String DELETE_LINE_TO_BEGINNING= "org.eclipse.ui.edit.text.delete.line.to.beginning"; //$NON-NLS-1$ - - /** - * Action definition id of the edit cut line to beginning action. - * Value: <code>"org.eclipse.ui.edit.text.cut.line.to.beginning"</code> - * @since 2.1 - */ - public static final String CUT_LINE_TO_BEGINNING= "org.eclipse.ui.edit.text.cut.line.to.beginning"; //$NON-NLS-1$ - - /** - * Action definition id of the edit delete line to end action. - * Value: <code>"org.eclipse.ui.edit.text.delete.line.to.end"</code> - */ - public static final String DELETE_LINE_TO_END= "org.eclipse.ui.edit.text.delete.line.to.end"; //$NON-NLS-1$ - - /** - * Action definition id of the edit cut line to end action. - * Value: <code>"org.eclipse.ui.edit.text.cut.line.to.end"</code> - * @since 2.1 - */ - public static final String CUT_LINE_TO_END= "org.eclipse.ui.edit.text.cut.line.to.end"; //$NON-NLS-1$ - - /** - * Action definition id of the edit set mark action. - * Value: <code>"org.eclipse.ui.edit.text.set.mark"</code> - */ - public static final String SET_MARK= "org.eclipse.ui.edit.text.set.mark"; //$NON-NLS-1$ - - /** - * Action definition id of the edit clear mark action. - * Value: <code>"org.eclipse.ui.edit.text.clear.mark"</code> - */ - public static final String CLEAR_MARK= "org.eclipse.ui.edit.text.clear.mark"; //$NON-NLS-1$ - - /** - * Action definition id of the edit swap mark action. - * Value: <code>"org.eclipse.ui.edit.text.swap.mark"</code> - */ - public static final String SWAP_MARK= "org.eclipse.ui.edit.text.swap.mark"; //$NON-NLS-1$ - - /** - * Action definition id of the smart enter action. - * Value: <code>"org.eclipse.ui.edit.text.smartEnter"</code> - * @since 3.0 - */ - public static final String SMART_ENTER= "org.eclipse.ui.edit.text.smartEnter"; //$NON-NLS-1$ - - /** - * Action definition id of the smart enter (inverse) action. - * Value: <code>"org.eclipse.ui.edit.text.smartEnterInverse"</code> - * @since 3.0 - */ - public static final String SMART_ENTER_INVERSE= "org.eclipse.ui.edit.text.smartEnterInverse"; //$NON-NLS-1$ - - /** - * Action definition id of the move lines upwards action. - * Value: <code>"org.eclipse.ui.edit.text.moveLineUp"</code> - * @since 3.0 - */ - public static final String MOVE_LINES_UP= "org.eclipse.ui.edit.text.moveLineUp"; //$NON-NLS-1$ - - /** - * Action definition id of the move lines downwards action. - * Value: <code>"org.eclipse.ui.edit.text.moveLineDown"</code> - * @since 3.0 - */ - public static final String MOVE_LINES_DOWN= "org.eclipse.ui.edit.text.moveLineDown"; //$NON-NLS-1$ - - /** - * Action definition id of the copy lines upwards action. - * Value: <code>"org.eclipse.ui.edit.text.copyLineUp"</code> - * @since 3.0 - */ - public static final String COPY_LINES_UP= "org.eclipse.ui.edit.text.copyLineUp"; //$NON-NLS-1$; - - /** - * Action definition id of the copy lines downwards action. - * Value: <code>"org.eclipse.ui.edit.text.copyLineDown"</code> - * @since 3.0 - */ - public static final String COPY_LINES_DOWN= "org.eclipse.ui.edit.text.copyLineDown"; //$NON-NLS-1$; - - /** - * Action definition id of the upper case action. - * Value: <code>"org.eclipse.ui.edit.text.upperCase"</code> - * @since 3.0 - */ - public static final String UPPER_CASE= "org.eclipse.ui.edit.text.upperCase"; //$NON-NLS-1$ - - /** - * Action definition id of the lower case action. - * Value: <code>"org.eclipse.ui.edit.text.lowerCase"</code> - * @since 3.0 - */ - public static final String LOWER_CASE= "org.eclipse.ui.edit.text.lowerCase"; //$NON-NLS-1$ - - - // navigation - - /** - * Action definition id of the navigate goto previous line action. - * Value: <code>"org.eclipse.ui.edit.text.goto.lineUp"</code> - */ - public static final String LINE_UP= "org.eclipse.ui.edit.text.goto.lineUp"; //$NON-NLS-1$ - - /** - * Action definition id of the navigate goto next line action. - * Value: <code>"org.eclipse.ui.edit.text.goto.lineDown"</code> - */ - public static final String LINE_DOWN= "org.eclipse.ui.edit.text.goto.lineDown"; //$NON-NLS-1$ - - /** - * Action definition id of the navigate goto line start action. - * Value: <code>"org.eclipse.ui.edit.text.goto.lineStart"</code> - */ - public static final String LINE_START= "org.eclipse.ui.edit.text.goto.lineStart"; //$NON-NLS-1$ - - /** - * Action definition id of the navigate goto line end action. - * Value: <code>"org.eclipse.ui.edit.text.goto.lineEnd"</code> - */ - public static final String LINE_END= "org.eclipse.ui.edit.text.goto.lineEnd"; //$NON-NLS-1$ - - /** - * Action definition id of the navigate goto line action. - * Value: <code>"org.eclipse.ui.edit.text.goto.line"</code> - */ - public static final String LINE_GOTO= "org.eclipse.ui.edit.text.goto.line"; //$NON-NLS-1$ - - /** - * Action definition id of the navigate goto previous column action. - * Value: <code>"org.eclipse.ui.edit.text.goto.columnPrevious"</code> - */ - public static final String COLUMN_PREVIOUS= "org.eclipse.ui.edit.text.goto.columnPrevious"; //$NON-NLS-1$ - - /** - * Action definition id of the navigate goto next column action. - * Value: <code>"org.eclipse.ui.edit.text.goto.columnNext"</code> - */ - public static final String COLUMN_NEXT= "org.eclipse.ui.edit.text.goto.columnNext"; //$NON-NLS-1$ - - /** - * Action definition id of the navigate goto previous page action. - * Value: <code>"org.eclipse.ui.edit.text.goto.pageUp"</code> - */ - public static final String PAGE_UP= "org.eclipse.ui.edit.text.goto.pageUp"; //$NON-NLS-1$ - - /** - * Action definition id of the navigate goto next page action. - * Value: <code>"org.eclipse.ui.edit.text.goto.pageDown"</code> - */ - public static final String PAGE_DOWN= "org.eclipse.ui.edit.text.goto.pageDown"; //$NON-NLS-1$ - - /** - * Action definition id of the navigate goto previous word action. - * Value: <code>"org.eclipse.ui.edit.text.goto.wordPrevious"</code> - */ - public static final String WORD_PREVIOUS= "org.eclipse.ui.edit.text.goto.wordPrevious"; //$NON-NLS-1$ - - /** - * Action definition id of the navigate goto next word action. - * Value: <code>"org.eclipse.ui.edit.text.goto.wordNext"</code> - */ - public static final String WORD_NEXT= "org.eclipse.ui.edit.text.goto.wordNext"; //$NON-NLS-1$ - - /** - * Action definition id of the navigate goto text start action. - * Value: <code>"org.eclipse.ui.edit.text.goto.textStart"</code> - */ - public static final String TEXT_START= "org.eclipse.ui.edit.text.goto.textStart"; //$NON-NLS-1$ - - /** - * Action definition id of the navigate goto text end action. - * Value: <code>"org.eclipse.ui.edit.text.goto.textEnd"</code> - */ - public static final String TEXT_END= "org.eclipse.ui.edit.text.goto.textEnd"; //$NON-NLS-1$ - - /** - * Action definition id of the navigate goto start of window action. - * Value: <code>"org.eclipse.ui.edit.text.goto.windowStart"</code> - */ - public static final String WINDOW_START= "org.eclipse.ui.edit.text.goto.windowStart"; //$NON-NLS-1$ - - /** - * Action definition id of the navigate goto end of window action. - * Value: <code>"org.eclipse.ui.edit.text.goto.windowEnd"</code> - */ - public static final String WINDOW_END= "org.eclipse.ui.edit.text.goto.windowEnd"; //$NON-NLS-1$ - - /** - * Action definition id of the navigate scroll line up action. - * Value: <code>"org.eclipse.ui.edit.text.scroll.lineUp"</code> - */ - public static final String SCROLL_LINE_UP= "org.eclipse.ui.edit.text.scroll.lineUp"; //$NON-NLS-1$ - - /** - * Action definition id of the navigate scroll line down action. - * Value: <code>"org.eclipse.ui.edit.text.scroll.lineDown"</code> - */ - public static final String SCROLL_LINE_DOWN= "org.eclipse.ui.edit.text.scroll.lineDown"; //$NON-NLS-1$ - - - // selection - - /** - * Action definition id of the select line up action. - * Value: <code>"org.eclipse.ui.edit.text.select.lineUp"</code> - */ - public static final String SELECT_LINE_UP= "org.eclipse.ui.edit.text.select.lineUp"; //$NON-NLS-1$ - - /** - * Action definition id of the select line down action. - * Value: <code>"org.eclipse.ui.edit.text.select.lineDown"</code> - */ - public static final String SELECT_LINE_DOWN= "org.eclipse.ui.edit.text.select.lineDown"; //$NON-NLS-1$ - - /** - * Action definition id of the select line start action. - * Value: <code>"org.eclipse.ui.edit.text.select.lineStart"</code> - */ - public static final String SELECT_LINE_START= "org.eclipse.ui.edit.text.select.lineStart"; //$NON-NLS-1$ - - /** - * Action definition id of the select line end action. - * Value: <code>"org.eclipse.ui.edit.text.select.lineEnd"</code> - */ - public static final String SELECT_LINE_END= "org.eclipse.ui.edit.text.select.lineEnd"; //$NON-NLS-1$ - - /** - * Action definition id of the select previous column action. - * Value: <code>"org.eclipse.ui.edit.text.select.columnPrevious"</code> - */ - public static final String SELECT_COLUMN_PREVIOUS= "org.eclipse.ui.edit.text.select.columnPrevious"; //$NON-NLS-1$ - - /** - * Action definition id of the select next column action. - * Value: <code>"org.eclipse.ui.edit.text.select.columnNext"</code> - */ - public static final String SELECT_COLUMN_NEXT= "org.eclipse.ui.edit.text.select.columnNext"; //$NON-NLS-1$ - - /** - * Action definition id of the select page up action. - * Value: <code>"org.eclipse.ui.edit.text.select.pageUp"</code> - */ - public static final String SELECT_PAGE_UP= "org.eclipse.ui.edit.text.select.pageUp"; //$NON-NLS-1$ - - /** - * Action definition id of the select page down action. - * Value: <code>"org.eclipse.ui.edit.text.select.pageDown"</code> - */ - public static final String SELECT_PAGE_DOWN= "org.eclipse.ui.edit.text.select.pageDown"; //$NON-NLS-1$ - - /** - * Action definition id of the select previous word action. - * Value: <code>"org.eclipse.ui.edit.text.select.wordPrevious"</code> - */ - public static final String SELECT_WORD_PREVIOUS= "org.eclipse.ui.edit.text.select.wordPrevious"; //$NON-NLS-1$ - - /** - * Action definition id of the select next word action. - * Value: <code>"org.eclipse.ui.edit.text.select.wordNext"</code> - */ - public static final String SELECT_WORD_NEXT= "org.eclipse.ui.edit.text.select.wordNext"; //$NON-NLS-1$ - - /** - * Action definition id of the select text start action. - * Value: <code>"org.eclipse.ui.edit.text.select.textStart"</code> - */ - public static final String SELECT_TEXT_START= "org.eclipse.ui.edit.text.select.textStart"; //$NON-NLS-1$ - - /** - * Action definition id of the select text end action. - * Value: <code>"org.eclipse.ui.edit.text.select.textEnd"</code> - */ - public static final String SELECT_TEXT_END= "org.eclipse.ui.edit.text.select.textEnd"; //$NON-NLS-1$ - - /** - * Action definition id of the select window start action. - * Value: <code>"org.eclipse.ui.edit.text.select.windowStart"</code> - */ - public static final String SELECT_WINDOW_START= "org.eclipse.ui.edit.text.select.windowStart"; //$NON-NLS-1$ - - /** - * Action definition id of the select window end action. - * Value: <code>"org.eclipse.ui.edit.text.select.windowEnd"</code> - */ - public static final String SELECT_WINDOW_END= "org.eclipse.ui.edit.text.select.windowEnd"; //$NON-NLS-1$ - - - // modification - - /** - * Action definition id of the edit delete previous character action. - * Value: <code>"org.eclipse.ui.edit.text.deletePrevious"</code> - */ - public static final String DELETE_PREVIOUS= "org.eclipse.ui.edit.text.deletePrevious"; //$NON-NLS-1$ - - /** - * Action definition id of the edit delete next character action. - * Value: <code>"org.eclipse.ui.edit.text.deleteNext"</code> - */ - public static final String DELETE_NEXT= "org.eclipse.ui.edit.text.deleteNext"; //$NON-NLS-1$ - - /** - * Action definition id of the edit delete previous word action. - * Value: <code>"org.eclipse.ui.edit.text.deletePreviousWord"</code> - * @since 2.1 - */ - public static final String DELETE_PREVIOUS_WORD= "org.eclipse.ui.edit.text.deletePreviousWord"; //$NON-NLS-1$ - - /** - * Action definition id of the edit delete next word action. - * Value: <code>"org.eclipse.ui.edit.text.deleteNextWord"</code> - * @since 2.1 - */ - public static final String DELETE_NEXT_WORD= "org.eclipse.ui.edit.text.deleteNextWord"; //$NON-NLS-1$ - - /** - * Action definition id of the edit shift right action. - * Value: <code>"org.eclipse.ui.edit.text.shiftRight"</code> - */ - public static final String SHIFT_RIGHT= "org.eclipse.ui.edit.text.shiftRight"; //$NON-NLS-1$ - - /** - * Action definition id of the edit shift left action. - * Value: <code>"org.eclipse.ui.edit.text.shiftLeft"</code> - */ - public static final String SHIFT_LEFT= "org.eclipse.ui.edit.text.shiftLeft"; //$NON-NLS-1$ - - /** - * Action definition id of the edit convert to window's line delimiter action. - * Value: <code>"org.eclipse.ui.edit.text.convert.lineDelimiters.toWindows"</code> - */ - public static final String CONVERT_LINE_DELIMITERS_TO_WINDOWS= "org.eclipse.ui.edit.text.convert.lineDelimiters.toWindows"; //$NON-NLS-1$ - - /** - * Action definition id of the edit convert to unix line delimiter action. - * Value: <code>"org.eclipse.ui.edit.text.convert.lineDelimiters.toUNIX"</code> - */ - public static final String CONVERT_LINE_DELIMITERS_TO_UNIX= "org.eclipse.ui.edit.text.convert.lineDelimiters.toUNIX"; //$NON-NLS-1$ - - /** - * Action definition id of the edit convert to mac line delimiter action. - * Value: <code>"org.eclipse.ui.edit.text.convert.lineDelimiters.toMac"</code> - */ - public static final String CONVERT_LINE_DELIMITERS_TO_MAC= "org.eclipse.ui.edit.text.convert.lineDelimiters.toMac"; //$NON-NLS-1$ - - - // miscellaneous - - /** - * Action definition id of the toggle input mode action. - * Value: <code>"org.eclipse.ui.edit.text.toggleOverwrite"</code> - */ - public static final String TOGGLE_OVERWRITE= "org.eclipse.ui.edit.text.toggleOverwrite"; //$NON-NLS-1$ - - /** - * Action definition id of toggle show selected element only action. - * Value: <code>"org.eclipse.ui.edit.text.toggleShowSelectedElementOnly"</code> - * @since 3.0 - */ - public static final String TOGGLE_SHOW_SELECTED_ELEMENT_ONLY= "org.eclipse.ui.edit.text.toggleShowSelectedElementOnly"; //$NON-NLS-1$ - - /** - * Action definition id of the show ruler context menu action. - * Value: <code>"org.eclipse.ui.edit.text.showRulerContextMenu"</code> - */ - public static final String SHOW_RULER_CONTEXT_MENU= "org.eclipse.ui.edit.text.showRulerContextMenu"; //$NON-NLS-1$ - - /** - * Action definition id of go to last edit position action. - * Value: <code>"org.eclipse.ui.edit.text.gotoLastEditPosition"</code> - * @since 2.1 - */ - public static final String GOTO_LAST_EDIT_POSITION= "org.eclipse.ui.edit.text.gotoLastEditPosition"; //$NON-NLS-1$ - - /** - * Action definition id of go to next annotation action. - * Value: <code>"org.eclipse.ui.edit.text.gotoNextAnnotation"</code> - * @since 3.0 - */ - public static final String GOTO_NEXT_ANNOTATION= "org.eclipse.ui.edit.text.gotoNextAnnotation"; //$NON-NLS-1$ - - /** - * Action definition id of go to previous annotation action. - * Value: <code>"org.eclipse.ui.edit.text.gotoPreviousAnnotation"</code> - * @since 3.0 - */ - public static final String GOTO_PREVIOUS_ANNOTATION= "org.eclipse.ui.edit.text.gotoPreviousAnnotation"; //$NON-NLS-1$ - - /** - * Action definition ID of the edit -> content assist proposal action - * Value: <code>"org.eclipse.ui.edit.text.contentAssist.proposals"</code>). - * @since 2.1 - */ - public static final String CONTENT_ASSIST_PROPOSALS= "org.eclipse.ui.edit.text.contentAssist.proposals"; //$NON-NLS-1$ - - /** - * Action definition ID of the edit -> content assist context information action - * Value: <code>"org.eclipse.ui.edit.text.contentAssist.contextInformation"</code>). - * @since 2.1 - */ - public static final String CONTENT_ASSIST_CONTEXT_INFORMATION= "org.eclipse.ui.edit.text.contentAssist.contextInformation"; //$NON-NLS-1$ - - /** - * Action definition ID of the edit -> smart insert mode action - * Value: <code>"org.eclipse.ui.edit.text.toggleInsertMode"</code>). - * @since 3.0 - */ - public static final String TOGGLE_INSERT_MODE= "org.eclipse.ui.edit.text.toggleInsertMode"; //$NON-NLS-1$ -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorDropTargetListener.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorDropTargetListener.java deleted file mode 100644 index f831e5e3d78..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorDropTargetListener.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.ui.texteditor; - -import org.eclipse.swt.dnd.DropTargetListener; -import org.eclipse.swt.dnd.Transfer; - -/** - * Interface to be implemented by SWT drop target listeners to be used with - * <code>AbstractTextEditor</code>. - * <p> - * This interface is not part of the official API. - * - * @since 3.0 - */ -public interface ITextEditorDropTargetListener extends DropTargetListener { - - /** - * Returns the list of <code>Transfer</code> agents that are supported by this listener. - * - * @return the list of transfer agents supported by this listener - */ - Transfer[] getTransfers(); -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorExtension.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorExtension.java deleted file mode 100644 index 6901191369c..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorExtension.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.texteditor; - - -import org.eclipse.jface.action.IMenuListener; - - -/** - * Extension interface for {@link org.eclipse.ui.texteditor.ITextEditor}. Adds - * the following functions: - * <ul> - * <li> status fields - * <li> read-only state of the editor's input - * <li> ruler context menu listeners. - * </ul> - * - * @since 2.0 - */ -public interface ITextEditorExtension { - - /** - * Informs the editor which status field is to be used when posting status - * information in the given category. - * - * @param field the status field to be used - * @param category the status information category - * @see ITextEditorActionConstants - */ - void setStatusField(IStatusField field, String category); - - /** - * Returns whether the editor's input is read-only. The semantics of - * this method is orthogonal to <code>isEditable</code> as it talks about the - * editor input, i.e. the domain element, and <b>not</b> about the editor - * document. - * - * @return <code>true</code> if the editor input is read-only - */ - boolean isEditorInputReadOnly(); - - /** - * Adds a ruler context menu listener to the editor. - * - * @param listener the listener - */ - void addRulerContextMenuListener(IMenuListener listener); - - /** - * Removes a ruler context menu listener from the editor. - * - * @param listener the listener - */ - void removeRulerContextMenuListener(IMenuListener listener); -} - diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorExtension2.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorExtension2.java deleted file mode 100644 index 94dae67b943..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorExtension2.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.ui.texteditor; - -/** - * Extension interface for {@link org.eclipse.ui.texteditor.ITextEditor}. Adds - * the following functions: - * <ul> - * <li>modifiable state of the editor's input - * <li>validate state of editor input - * </ul> - * - * @since 2.1 - */ -public interface ITextEditorExtension2 { - - /** - * Returns whether the editor's input can be persistently be modified. - * This is orthogonal to <code>ITextEditorExtension.isEditorInputReadOnly</code> as read-only elements may be modifiable and - * writable elements may not be modifiable. If the given element is not connected to this document - * provider, the result is undefined. Document providers are allowed to use a cache to answer this - * question, i.e. there can be a difference between the "real" state of the element and the return - * value. - * - * @return <code>true</code> if the editor input is modifiable - */ - boolean isEditorInputModifiable(); - - /** - * Validates the state of the given editor input. The predominate intent - * of this method is to take any action probably necessary to ensure that - * the input can persistently be changed. - * - * @return <code>true</code> if the input was validated, <code>false</code> otherwise - */ - boolean validateEditorInputState(); - -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorExtension3.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorExtension3.java deleted file mode 100644 index 1ce89a4fc55..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorExtension3.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.texteditor; - -/** - * Extension interface for {@link org.eclipse.ui.texteditor.ITextEditor}. Adds - * the following functions: - * <ul> - * <li>insert mode management - * </ul> - * <p> - * - * @since 3.0 - */ -public interface ITextEditorExtension3 { - - /** - * Constitutes entities to enumerate the editor insert modes. - */ - public static class InsertMode { - private InsertMode() { - } - }; - - /** - * Represents the non-smart insert mode. - */ - final static InsertMode INSERT= new InsertMode(); - /** - * Represents the smart insert mode. - */ - final static InsertMode SMART_INSERT= new InsertMode(); - - - /** - * Returns the current input mode of this editor. - * - * @return the current input mode of this editor - */ - InsertMode getInsertMode(); - - /** - * Sets the insert mode of this editor. - * - * @param mode the new insert mode - * @exception IllegalArgumentException if <code>mode</code> is not a legal insert mode for this editor - */ - void setInsertMode(InsertMode mode); - - /** - * Sets the display of quick diff information. - * - * @param show <code>true</code> if quick diff information should be shown, <code>false</code> otherwise - */ - void showChangeInformation(boolean show); - - /** - * Returns the quick diff display state. - * - * @return <code>true</code> if quick diff info is displayed, <code>false</code> otherwise - */ - boolean isChangeInformationShowing(); -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IUpdate.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IUpdate.java deleted file mode 100644 index cbcf99285b0..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IUpdate.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.texteditor; - - - -/** - * Indicates the support of an update method. - */ -public interface IUpdate { - - /** - * Requests that this object update itself. - */ - void update(); -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IWorkbenchActionDefinitionIds.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IWorkbenchActionDefinitionIds.java deleted file mode 100644 index a3332b6c3fb..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IWorkbenchActionDefinitionIds.java +++ /dev/null @@ -1,147 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.ui.texteditor; - - -/** - * Defines the definitions ids for workbench actions. - * @since 2.0 - */ -public interface IWorkbenchActionDefinitionIds { - - // workbench file actions - - /** - * Action definition id of the file print action. - * Value: <code>"org.eclipse.ui.file.print"</code> - */ - public static final String PRINT= "org.eclipse.ui.file.print"; //$NON-NLS-1$ - - /** - * Action definition id of the file save action. - * Value: <code>"org.eclipse.ui.file.save"</code> - */ - public static final String SAVE= "org.eclipse.ui.file.save"; //$NON-NLS-1$ - - /** - * Action definition id of the file revert action. - * Value: <code>"org.eclipse.ui.edit.revertToSaved"</code> - */ - public static final String REVERT_TO_SAVED= "org.eclipse.ui.edit.revertToSaved"; //$NON-NLS-1$ - - - - // workbench edit actions - - /** - * Action definition id of the edit cut action. - * Value: <code>"org.eclipse.ui.edit.cut"</code> - */ - public static final String CUT= "org.eclipse.ui.edit.cut"; //$NON-NLS-1$ - - /** - * Action definition id of the edit copy action. - * Value: <code>"org.eclipse.ui.edit.copy"</code> - */ - public static final String COPY= "org.eclipse.ui.edit.copy"; //$NON-NLS-1$ - - /** - * Action definition id of the edit past action. - * Value: <code>"org.eclipse.ui.edit.paste"</code> - */ - public static final String PASTE= "org.eclipse.ui.edit.paste"; //$NON-NLS-1$ - - /** - * Action definition id of the edit undo action. - * Value: <code>"org.eclipse.ui.edit.undo"</code> - */ - public static final String UNDO= "org.eclipse.ui.edit.undo"; //$NON-NLS-1$ - - /** - * Action definition id of the edit redo action. - * Value: <code>"org.eclipse.ui.edit.redo"</code> - */ - public static final String REDO= "org.eclipse.ui.edit.redo"; //$NON-NLS-1$ - - /** - * Action definition id of the edit delete action. - * Value: <code>"org.eclipse.ui.edit.delete"</code> - */ - public static final String DELETE= "org.eclipse.ui.edit.delete"; //$NON-NLS-1$ - - /** - * Action definition id of the edit select all action. - * Value: <code>"org.eclipse.ui.edit.selectAll"</code> - */ - public static final String SELECT_ALL= "org.eclipse.ui.edit.selectAll"; //$NON-NLS-1$ - - /** - * Action definition id of the edit find/replace action. - * Value: <code>"org.eclipse.ui.edit.findReplace"</code> - */ - public static final String FIND_REPLACE= "org.eclipse.ui.edit.findReplace"; //$NON-NLS-1$ - - /** - * Action definition id of the edit add bookmark action. - * Value: <code>"org.eclipse.ui.edit.addBookmark"</code> - */ - public static final String ADD_BOOKMARK= "org.eclipse.ui.edit.addBookmark"; //$NON-NLS-1$ - - /** - * Action definition id of the edit add task action. - * Value: <code>"org.eclipse.ui.edit.addTask"</code> - */ - public static final String ADD_TASK= "org.eclipse.ui.edit.addTask"; //$NON-NLS-1$ - - - // future workbench edit actions - - /** - * Action definition id of the edit find next action. - * Value: <code>"org.eclipse.ui.edit.findNext"</code> - */ - public static final String FIND_NEXT= "org.eclipse.ui.edit.findNext"; //$NON-NLS-1$ - /** - * Action definition id of the edit find previous action. - * Value: <code>"org.eclipse.ui.edit.findPrevious"</code> - */ - public static final String FIND_PREVIOUS= "org.eclipse.ui.edit.findPrevious"; //$NON-NLS-1$ - /** - * Action definition id of the edit incremental find action. - * Value: <code>"org.eclipse.ui.edit.findIncremental"</code> - */ - public static final String FIND_INCREMENTAL= "org.eclipse.ui.edit.findIncremental"; //$NON-NLS-1$ - /** - * Action definition id of the edit incremental find reverse action. - * Value: <code>"org.eclipse.ui.edit.findIncrementalReverse"</code> - * - * @since 2.1 - */ - public static final String FIND_INCREMENTAL_REVERSE= "org.eclipse.ui.edit.findIncrementalReverse"; //$NON-NLS-1$ - - - /** - * The command identifier for the "move" action that typically appears in - * the file menu. - * Value: <code>"org.eclipse.ui.edit.move"</code> - * @since 3.0 - */ - public static final String MOVE = "org.eclipse.ui.edit.move"; //$NON-NLS-1$ - /** - * The command identifier for the "rename" action that typically appears in - * the file menu. - * Value: <code>"org.eclipse.ui.edit.rename"</code> - * @since 3.0 - */ - public static final String RENAME = "org.eclipse.ui.edit.rename"; //$NON-NLS-1$ -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IncrementalFindAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IncrementalFindAction.java deleted file mode 100644 index 4c0b8030c9f..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IncrementalFindAction.java +++ /dev/null @@ -1,119 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.texteditor; - - -import java.util.ResourceBundle; - -import org.eclipse.jface.text.IFindReplaceTarget; -import org.eclipse.jface.text.IFindReplaceTargetExtension; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchWindow; - - -/** - * An action which enters the incremental find mode a la emacs. - * <p> - * This class may be instantiated; it is not intended to be subclassed. - * </p> - * @since 2.0 - */ -public class IncrementalFindAction extends ResourceAction implements IUpdate { - - /** The action's target */ - private IFindReplaceTarget fTarget; - /** The part the action is bound to */ - private IWorkbenchPart fWorkbenchPart; - /** The workbench window */ - private IWorkbenchWindow fWorkbenchWindow; - /** - * The direction to run the incremental find - * @since 2.1 - */ - private boolean fForward; - - /** - * Creates a new incremental find action for the given workbench part. - * The action configures its visual representation from the given - * resource bundle. - * - * @param bundle the resource bundle - * @param prefix a prefix to be prepended to the various resource keys - * (described in <code>ResourceAction</code> constructor), or - * <code>null</code> if none - * @param workbenchPart the workbench part - * @param forward <code>true</code> if the search direction is forward - * @see ResourceAction#ResourceAction(ResourceBundle, String) - * @since 2.1 - */ - public IncrementalFindAction(ResourceBundle bundle, String prefix, IWorkbenchPart workbenchPart, boolean forward) { - super(bundle, prefix); - fWorkbenchPart= workbenchPart; - fForward= forward; - update(); - } - - /** - * Creates a new incremental find action for the given workbench window. - * The action configures its visual representation from the given - * resource bundle. - * - * @param bundle the resource bundle - * @param prefix a prefix to be prepended to the various resource keys - * (described in <code>ResourceAction</code> constructor), or - * <code>null</code> if none - * @param workbenchWindow the workbench window - * @param forward <code>true</code> if the search direction is forward - * @see ResourceAction#ResourceAction(ResourceBundle, String) - * - * @deprecated use FindReplaceAction(ResourceBundle, String, IWorkbenchPart, boolean) instead - * @since 2.1 - */ - public IncrementalFindAction(ResourceBundle bundle, String prefix, IWorkbenchWindow workbenchWindow, boolean forward) { - super(bundle, prefix); - fWorkbenchWindow= workbenchWindow; - fForward= forward; - update(); - } - - /* - * @see IAction#run() - */ - public void run() { - - if (fTarget == null) - return; - - if (fTarget instanceof IncrementalFindTarget) - ((IncrementalFindTarget) fTarget).setDirection(fForward); - - if (fTarget instanceof IFindReplaceTargetExtension) - ((IFindReplaceTargetExtension) fTarget).beginSession(); - } - - /* - * @see IUpdate#update() - */ - public void update() { - - if (fWorkbenchPart == null && fWorkbenchWindow != null) - fWorkbenchPart= fWorkbenchWindow.getPartService().getActivePart(); - - if (fWorkbenchPart != null) - fTarget= (IFindReplaceTarget) fWorkbenchPart.getAdapter(IncrementalFindTarget.class); - else - fTarget= null; - - setEnabled(fTarget != null && fTarget.canPerformFind()); - } - -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IncrementalFindTarget.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IncrementalFindTarget.java deleted file mode 100644 index 9788291f3cf..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IncrementalFindTarget.java +++ /dev/null @@ -1,786 +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 - * Felix Pahl (fpahl@web.de) - fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=51820 - *******************************************************************************/ - -package org.eclipse.ui.texteditor; - -import java.text.MessageFormat; -import java.util.Stack; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.StyledText; -import org.eclipse.swt.custom.VerifyKeyListener; -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.jface.action.IStatusLineManager; -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.text.Assert; -import org.eclipse.jface.text.IFindReplaceTarget; -import org.eclipse.jface.text.IFindReplaceTargetExtension; -import org.eclipse.jface.text.IRegion; -import org.eclipse.jface.text.ITextListener; -import org.eclipse.jface.text.ITextSelection; -import org.eclipse.jface.text.ITextViewer; -import org.eclipse.jface.text.ITextViewerExtension; -import org.eclipse.jface.text.TextEvent; - -/** - * An incremental find target. Replace is always disabled. - * @since 2.0 - */ -class IncrementalFindTarget implements IFindReplaceTarget, IFindReplaceTargetExtension, VerifyKeyListener, MouseListener, FocusListener, ISelectionChangedListener, ITextListener { - - /** The string representing rendered tab */ - private final static String TAB= EditorMessages.getString("Editor.FindIncremental.render.tab"); //$NON-NLS-1$ - /** - * The string representing "Reverse Incremental Find" - * @since 3.0 - */ - private final static String FIELD_NAME= EditorMessages.getString("Editor.FindIncremental.name"); //$NON-NLS-1$ - /** - * The string representing "Incremental Find" - * @since 3.0 - */ - private final static String REVERSE_FIELD_NAME= EditorMessages.getString("Editor.FindIncremental.reverse.name"); //$NON-NLS-1$ - /** - * The string representing reverse - * @since 2.1 - */ - private final static String REVERSE= EditorMessages.getString("Editor.FindIncremental.reverse"); //$NON-NLS-1$ - /** - * The string representing wrapped - * @since 2.1 - */ - private final static String WRAPPED= EditorMessages.getString("Editor.FindIncremental.wrapped"); //$NON-NLS-1$ - /** The text viewer to operate on */ - private final ITextViewer fTextViewer; - /** The status line manager for output */ - private final IStatusLineManager fStatusLine; - /** The find replace target to delegate find requests */ - private final IFindReplaceTarget fTarget; - /** The current find string */ - private StringBuffer fFindString= new StringBuffer(); - /** The position of the first upper case character, -1 if none */ - private int fCasePosition; - /** - * The position in the stack of the first wrap search, -1 if none - * @since 2.1 - */ - private int fWrapPosition; - /** The position of the last successful find */ - private int fCurrentIndex; - /** A flag indicating if last find was successful */ - private boolean fFound; - /** - * A flag indicating if the last search was forward - * @since 2.1 - */ - private boolean fForward= true; - /** A flag indicating listeners are installed. */ - private boolean fInstalled; - /** - * A flag indicating that a search is currently active. - * Used to ignore selection callbacks generated by the incremental search itself. - * @since 2.1 - */ - private boolean fSearching; - /** The current find stack */ - private Stack fSessionStack; - /** - * The previous search string - * @since 2.1 - */ - private String fPrevFindString= ""; //$NON-NLS-1$ - /** - * The previous position of the first upper case character, -1 if none - * @since 3.0 - */ - private int fPrevCasePosition= -1; - /** - * The find status field. - * @since 3.0 - */ - private IStatusField fStatusField; - /** - * Tells whether the status field implements - * <code>IStatusFieldExtension</code>. - * @see IStatusFieldExtension - * @since 3.0 - */ - private boolean fIsStatusFieldExtension; - - /** - * Data structure for a search result. - * @since 2.1 - */ - private class SearchResult { - int selection, length, index, findLength; - boolean found, forward; - - /** - * Creates a new search result data object and fills - * it with the current values of this target. - */ - public SearchResult() { - Point p= fTarget.getSelection(); - selection= p.x; - length= p.y; - index= fCurrentIndex; - findLength= fFindString.length(); - found= fFound; - forward= fForward; - } - - } - - /** - * Stores the search result. - */ - private void saveState() { - fSessionStack.push(new SearchResult()); - } - - /** - * Restores the search result. - * - * @since 2.1 - */ - private void restoreState() { - - StyledText text= fTextViewer.getTextWidget(); - if (text == null || text.isDisposed()) - return; - - SearchResult searchResult= null; - if (!fSessionStack.empty()) - searchResult= (SearchResult) fSessionStack.pop(); - - if (searchResult == null) { - text.getDisplay().beep(); - return; - } - - text.setSelectionRange(searchResult.selection, searchResult.length); - text.showSelection(); - - // relies on the contents of the StringBuffer - fFindString.setLength(searchResult.findLength); - fCurrentIndex= searchResult.index; - fFound= searchResult.found; - fForward= searchResult.forward; - - // Recalculate the indices - if (fFindString.length() < fCasePosition) - fCasePosition= -1; - if (fSessionStack.size() < fWrapPosition) - fWrapPosition= -1; - } - - /** - * Sets the direction for the next search. - * This can be called before <code>beginSession</code> to set the initial search direction. - * @param forward <code>true</code> if the next search should be forward - * @see #beginSession() - * @since 2.1 - */ - public void setDirection(boolean forward) { - fForward= forward; - } - - /** - * Creates an instance of an incremental find target. - * @param viewer the text viewer to operate on - * @param manager the status line manager for output - */ - public IncrementalFindTarget(ITextViewer viewer, IStatusLineManager manager) { - Assert.isNotNull(viewer); - Assert.isNotNull(manager); - fTextViewer= viewer; - fStatusLine= manager; - fTarget= viewer.getFindReplaceTarget(); - } - - /* - * @see IFindReplaceTarget#canPerformFind() - */ - public boolean canPerformFind() { - return fTarget.canPerformFind(); - } - - /* - * @see IFindReplaceTarget#findAndSelect(int, String, boolean, boolean, boolean) - */ - public int findAndSelect(int offset, String findString, boolean searchForward, boolean caseSensitive, boolean wholeWord) { - return fTarget.findAndSelect(offset, findString, searchForward, caseSensitive, wholeWord); - } - - /* - * @see IFindReplaceTarget#getSelection() - */ - public Point getSelection() { - return fTarget.getSelection(); - } - - /* - * @see IFindReplaceTarget#getSelectionText() - */ - public String getSelectionText() { - return fTarget.getSelectionText(); - } - - /* - * @see IFindReplaceTarget#isEditable() - */ - public boolean isEditable() { - return false; - } - - /* - * @see IFindReplaceTarget#replaceSelection(String) - */ - public void replaceSelection(String text) { - } - - /* - * @see IFindReplaceTargetExtension#beginSession() - */ - public void beginSession() { - fSearching= true; - - // Workaround since some accelerators get handled directly by the OS - if (fInstalled) { - saveState(); - repeatSearch(fForward); - updateStatus(); - fSearching= false; - return; - } - - fFindString.setLength(0); - fSessionStack= new Stack(); - fCasePosition= -1; - fWrapPosition= -1; - fFound= true; - - // clear initial selection - StyledText text= fTextViewer.getTextWidget(); - if (text != null && !text.isDisposed()) { - fCurrentIndex= text.getCaretOffset(); - text.setSelection(fCurrentIndex); - } else { - fCurrentIndex= 0; - } - - install(); - - // Set the mark - if (fTextViewer instanceof ITextViewerExtension) - ((ITextViewerExtension) fTextViewer).setMark(fCurrentIndex); - - updateStatus(); - - if (fTarget instanceof IFindReplaceTargetExtension) - ((IFindReplaceTargetExtension) fTarget).beginSession(); - - fSearching= false; - } - - /* - * @see IFindReplaceTargetExtension#endSession() - */ - public void endSession() { - if (fTarget instanceof IFindReplaceTargetExtension) - ((IFindReplaceTargetExtension) fTarget).endSession(); - - // will uninstall itself - } - - /* - * @see IFindReplaceTargetExtension#getScope() - */ - public IRegion getScope() { - return null; - } - - /* - * @see IFindReplaceTargetExtension#setGlobal(boolean) - */ - public void setGlobal(boolean global) { - } - - /* - * @see IFindReplaceTargetExtension#setScope(IRegion) - */ - public void setScope(IRegion scope) { - } - - /* - * @see IFindReplaceTargetExtension#setReplaceAllMode(boolean) - */ - public void setReplaceAllMode(boolean replaceAll) { - } - - /** - * Installs this target. I.e. adds all required listeners. - */ - private void install() { - - if (fInstalled) - return; - - StyledText text= fTextViewer.getTextWidget(); - if (text == null) - return; - - text.addMouseListener(this); - text.addFocusListener(this); - fTextViewer.addTextListener(this); - - ISelectionProvider selectionProvider= fTextViewer.getSelectionProvider(); - if (selectionProvider != null) - selectionProvider.addSelectionChangedListener(this); - - if (fTextViewer instanceof ITextViewerExtension) - ((ITextViewerExtension) fTextViewer).prependVerifyKeyListener(this); - else - text.addVerifyKeyListener(this); - - fInstalled= true; - } - - /** - * Uninstalls itself. I.e. removes all listeners installed in <code>install</code>. - */ - private void uninstall() { - - fTextViewer.removeTextListener(this); - - ISelectionProvider selectionProvider= fTextViewer.getSelectionProvider(); - if (selectionProvider != null) - selectionProvider.removeSelectionChangedListener(this); - - StyledText text= fTextViewer.getTextWidget(); - if (text != null) { - text.removeMouseListener(this); - text.removeFocusListener(this); - } - - if (fTextViewer instanceof ITextViewerExtension) { - ((ITextViewerExtension) fTextViewer).removeVerifyKeyListener(this); - - } else { - if (text != null) - text.removeVerifyKeyListener(this); - } - - fInstalled= false; - } - - /** - * Updates the status line. - * @since 2.1 - */ - private void updateStatus() { - - if (!fInstalled) - return; - - String string= fFindString.toString(); - String wrapPrefix= fWrapPosition == -1 ? "" : WRAPPED; //$NON-NLS-1$ - String reversePrefix= fForward ? "" : REVERSE; //$NON-NLS-1$ - - if (!fFound) { - String pattern= EditorMessages.getString("Editor.FindIncremental.not_found.pattern"); //$NON-NLS-1$ - statusError(MessageFormat.format(pattern, new Object[] { reversePrefix, wrapPrefix, string })); - - } else if (string.length() == 0) { - if (fForward) - statusMessage(FIELD_NAME); - else - statusMessage(REVERSE_FIELD_NAME); - } else if (!fForward || fWrapPosition > -1) { - String pattern= EditorMessages.getString("Editor.FindIncremental.found.pattern"); //$NON-NLS-1$ - statusMessage(MessageFormat.format(pattern, new Object[] { reversePrefix, wrapPrefix, string })); - } else { - statusMessage(string); - } - } - - /* - * @see VerifyKeyListener#verifyKey(VerifyEvent) - */ - public void verifyKey(VerifyEvent event) { - - if (!event.doit) - return; - - fSearching= true; - if (event.character == 0) { - - switch (event.keyCode) { - - // ALT, CTRL, ARROW_LEFT, ARROW_RIGHT == leave - case SWT.ARROW_LEFT: - case SWT.ARROW_RIGHT: - case SWT.HOME: - case SWT.END: - case SWT.PAGE_DOWN: - case SWT.PAGE_UP: - leave(); - break; - - case SWT.ARROW_DOWN: - saveState(); - setDirection(true); - repeatSearch(fForward); - event.doit= false; - break; - - case SWT.ARROW_UP: - saveState(); - setDirection(false); - repeatSearch(fForward); - event.doit= false; - break; - } - - // event.character != 0 - } else { - - switch (event.character) { - - // ESC, CR = quit - case 0x1B: - case 0x0D: - leave(); - event.doit= false; - break; - - // backspace and delete - case 0x08: - case 0x7F: - restoreState(); - event.doit= false; - break; - - default: - if (event.stateMask == 0 || event.stateMask == SWT.SHIFT || event.stateMask == (SWT.ALT | SWT.CTRL)) { // SWT.ALT | SWT.CTRL covers AltGr (see bug 43049) - saveState(); - addCharSearch(event.character); - event.doit= false; - } - break; - } - } - updateStatus(); - fSearching= false; - } - - /** - * Repeats the last search while possibly changing the direction. - * - * @param forward <code>true</code> iff the next search should be forward - * @return if the search was successful - * @since 2.1 - */ - private boolean repeatSearch(boolean forward) { - if (fFindString.length() == 0) { - fFindString= new StringBuffer(fPrevFindString); - fCasePosition= fPrevCasePosition; - } - - String string= fFindString.toString(); - if (string.length() == 0) { - fFound= true; - return true; - } - - StyledText text= fTextViewer.getTextWidget(); - // Cannot use fTarget.getSelection since that does not return which side of the - // selection the caret is on. - int startIndex= text.getCaretOffset(); - if (!forward) - startIndex -= 1; - - // Check to see if a wrap is necessary - if (!fFound && (fForward == forward)) { - startIndex= -1; - if (fWrapPosition == -1) - fWrapPosition= fSessionStack.size(); - } - fForward = forward; - - // Find the string - text.setRedraw(false); - int index= fTarget.findAndSelect(startIndex, string, fForward, fCasePosition != -1, false); - - // Set the caret on the left if the search is reversed - if (!forward) { - Point p= fTarget.getSelection(); - text.setSelectionRange(p.x + p.y, -p.y); - p= null; - } - text.setRedraw(true); - - // Take appropriate action - boolean found = (index != -1); - if (!found && fFound) { - text= fTextViewer.getTextWidget(); - if (text != null && !text.isDisposed()) - text.getDisplay().beep(); - } - - if (found) - fCurrentIndex= startIndex; - - fFound= found; - return found; - } - - /** - * Adds the given character to the search string and repeats the search with the last parameters. - * - * @param c the character to append to the search pattern - * @return <code>true</code> the search found a match - * @since 2.1 - */ - private boolean addCharSearch(char c) { - // Add char to pattern - if (fCasePosition == -1 && Character.isUpperCase(c) && Character.toLowerCase(c) != c) - fCasePosition= fFindString.length(); - - fFindString.append(c); - String string= fFindString.toString(); - StyledText text= fTextViewer.getTextWidget(); - - text.setRedraw(false); - int index= fTarget.findAndSelect(fCurrentIndex, string, fForward, fCasePosition != -1, false); - - // Set the caret on the left if the search is reversed - if (!fForward) { - Point p= fTarget.getSelection(); - text.setSelectionRange(p.x + p.y, -p.y); - } - text.setRedraw(true); - - // Take appropriate action - boolean found = (index != -1); - if (!found && fFound) { - text= fTextViewer.getTextWidget(); - if (text != null && !text.isDisposed()) - text.getDisplay().beep(); - } - - fFound= found; - return found; - } - - /** - * Leaves this incremental search session. - */ - private void leave() { - if (fFindString.length() != 0) { - fPrevFindString= fFindString.toString(); - fPrevCasePosition= fCasePosition; - } - statusClear(); - uninstall(); - fSessionStack = null; - } - - /* - * @see ITextListener#textChanged(TextEvent) - */ - public void textChanged(TextEvent event) { - if (event.getDocumentEvent() != null) - leave(); - } - - /* - * @see MouseListener##mouseDoubleClick(MouseEvent) - */ - public void mouseDoubleClick(MouseEvent e) { - leave(); - } - - /* - * @see MouseListener#mouseDown(org.eclipse.swt.events.MouseEvent) - */ - public void mouseDown(MouseEvent e) { - leave(); - } - - /* - * @see MouseListener#mouseUp(org.eclipse.swt.events.MouseEvent) - */ - public void mouseUp(MouseEvent e) { - leave(); - } - - /* - * @see FocusListener#focusGained(org.eclipse.swt.events.FocusEvent) - */ - public void focusGained(FocusEvent e) { - leave(); - } - - /* - * @see FocusListener#focusLost(org.eclipse.swt.events.FocusEvent) - */ - public void focusLost(FocusEvent e) { - leave(); - } - - /** - * Sets the given string as status message, clears the status error message. - * @param string the status message - */ - private void statusMessage(String string) { - if (fStatusField != null) { - if (fIsStatusFieldExtension) { - ((IStatusFieldExtension)fStatusField).setErrorText(null); - fStatusField.setText(escapeTabs(string)); - ((IStatusFieldExtension)fStatusField).setVisible(true); - fStatusLine.update(true); - } else { - fStatusLine.setErrorMessage(null); - fStatusField.setText(escapeTabs(string)); - } - } else { - fStatusLine.setErrorMessage(null); - fStatusLine.setMessage(escapeTabs(string)); - } - } - - /** - * Sets the status error message, clears the status message. - * @param string the status error message - */ - private void statusError(String string) { - if (fStatusField != null) { - if (fIsStatusFieldExtension) { - ((IStatusFieldExtension)fStatusField).setErrorText(escapeTabs(string)); - fStatusField.setText(""); //$NON-NLS-1$ - ((IStatusFieldExtension)fStatusField).setVisible(true); - fStatusLine.update(true); - } else { - fStatusLine.setErrorMessage(escapeTabs(string)); - fStatusField.setText(""); //$NON-NLS-1$ - } - } else { - fStatusLine.setErrorMessage(escapeTabs(string)); - fStatusLine.setMessage(null); - } - } - - /** - * Clears the status message and the status error message. - */ - private void statusClear() { - if (fStatusField != null) { - if (fIsStatusFieldExtension) { - fStatusField.setText(""); //$NON-NLS-1$ - ((IStatusFieldExtension)fStatusField).setErrorText(null); - ((IStatusFieldExtension)fStatusField).setVisible(false); - fStatusLine.update(true); - } else { - fStatusField.setText(""); //$NON-NLS-1$ - fStatusLine.setErrorMessage(null); - } - } else { - fStatusLine.setErrorMessage(null); - fStatusLine.setMessage(null); - } - } - - /** - * Translates all tab characters into a proper status line presentation. - * @param string the string in which to translate the tabs - * @return the given string with all tab characters replace with a proper status line presentation - */ - private String escapeTabs(String string) { - StringBuffer buffer= new StringBuffer(); - - int begin= 0; - int end= string.indexOf('\t', begin); - - while (end >= 0) { - buffer.append(string.substring(begin, end)); - buffer.append(TAB); - begin= end + 1; - end= string.indexOf('\t', begin); - } - buffer.append(string.substring(begin)); - - return buffer.toString(); - } - - /* - * @see IFindReplaceTargetExtension#getLineSelection() - */ - public Point getLineSelection() { - if (fTarget instanceof IFindReplaceTargetExtension) - return ((IFindReplaceTargetExtension) fTarget).getLineSelection(); - - return null; // XXX should not return null - } - - /* - * @see IFindReplaceTargetExtension#setSelection(int, int) - */ - public void setSelection(int offset, int length) { - if (fTarget instanceof IFindReplaceTargetExtension) - ((IFindReplaceTargetExtension) fTarget).setSelection(offset, length); - } - - /* - * @see IFindReplaceTargetExtension#setScopeHighlightColor(Color) - */ - public void setScopeHighlightColor(Color color) { - } - - /* - * @see ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) - * @since 2.1 - */ - public void selectionChanged(SelectionChangedEvent e) { - boolean ignore= false; - ISelection selection= e.getSelection(); - if (selection instanceof ITextSelection) { - ITextSelection textSelection= (ITextSelection)selection; - Point range= getSelection(); - ignore= textSelection.getOffset() + textSelection.getLength() == range.x + range.y; - } - if (!fSearching && !ignore) - leave(); - } - - /** - * Sets the find status field for this incremental find target. - * - * @param statusField the status field - * @since 3.0 - */ - void setStatusField(IStatusField statusField) { - fStatusField= statusField; - fIsStatusFieldExtension= fStatusField instanceof IStatusFieldExtension; - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/InfoForm.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/InfoForm.java deleted file mode 100644 index ce30ca85a9f..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/InfoForm.java +++ /dev/null @@ -1,229 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.ui.texteditor; - - -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.ScrolledComposite; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -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.jface.resource.JFaceResources; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; - - -/** - * A form consisting of a title, a banner, and a info text. Banner and info text are - * separated by a separator line. This form must be handled like a SWT widget. - * - * @since 2.0 - * @deprecated since 3.0. there is no replacement, use org.eclipse.ui.forms to define a component with a similar look and function. - */ -public class InfoForm { - - /** The form's root widget */ - private ScrolledComposite fScrolledComposite; - /** The background color */ - private Color fBackgroundColor; - /** The foreground color */ - private Color fForegroundColor; - /** The separator's color */ - private Color fSeparatorColor; - /** The form header */ - private Label fHeader; - /** The form banner */ - private Label fBanner; - /** The form text */ - private Label fText; - /** The preference change listener */ - private IPropertyChangeListener fPropertyChangeListener; - - /** - * Creates a new info form. - * @param parent the parent composite - */ - public InfoForm(Composite parent) { - - Display display= parent.getDisplay(); - fBackgroundColor= display.getSystemColor(SWT.COLOR_LIST_BACKGROUND); - fForegroundColor= display.getSystemColor(SWT.COLOR_LIST_FOREGROUND); - fSeparatorColor= new Color(display, 152, 170, 203); - - fPropertyChangeListener= new IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - handlePropertyChange(event); - } - }; - JFaceResources.getFontRegistry().addListener(fPropertyChangeListener); - - fScrolledComposite= new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL); - fScrolledComposite.setAlwaysShowScrollBars(false); - fScrolledComposite.setExpandHorizontal(true); - fScrolledComposite.setExpandVertical(true); - fScrolledComposite.addDisposeListener(new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - JFaceResources.getFontRegistry().removeListener(fPropertyChangeListener); - fScrolledComposite= null; - fSeparatorColor.dispose(); - fSeparatorColor= null; - fHeader= null; - fBanner= null; - fText= null; - } - }); - - Composite composite= createComposite(fScrolledComposite); - composite.setLayout(new GridLayout()); - - fHeader= createHeader(composite, null); - createLabel(composite, null); - createLabel(composite, null); - - fBanner= createBanner(composite, null); - - Composite separator= createCompositeSeparator(composite); - GridData data= new GridData(GridData.FILL_HORIZONTAL); - data.heightHint= 2; - separator.setLayoutData(data); - - fText= createLabel(composite, null); - createLabel(composite, null); - - fScrolledComposite.setContent(composite); - fScrolledComposite.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT)); - - createActionControls(composite); - } - - /** - * Hook method for creating an appropriate action control. - * @param parent the action control's parent control - */ - protected void createActionControls(Composite parent) { - } - - /** - * Returns the control of this form. - * @return the root control of this form - */ - public Control getControl() { - return fScrolledComposite; - } - - /** - * Sets the header text of this info form. - * @param header the header text - */ - public void setHeaderText(String header) { - fHeader.setText(header); - } - - /** - * Sets the banner text of this info form. - * @param banner the banner text - */ - public void setBannerText(String banner) { - fBanner.setText(banner); - } - - /** - * Sets the info of this info form - * @param info the info text - */ - public void setInfo(String info) { - fText.setText(info); - } - - /* - * @see IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) - */ - protected void handlePropertyChange(PropertyChangeEvent event) { - - if (fHeader != null) - fHeader.setFont(JFaceResources.getHeaderFont()); - - if (fBanner != null) - fBanner.setFont(JFaceResources.getBannerFont()); - - Control control= fScrolledComposite.getContent(); - fScrolledComposite.setMinSize(control.computeSize(SWT.DEFAULT, SWT.DEFAULT)); - fScrolledComposite.setContent(control); - - fScrolledComposite.layout(true); - fScrolledComposite.redraw(); - } - - /* - * @see org.eclipse.update.ui.forms.internal.FormWidgetFactory#createComposite(Composite) - */ - private Composite createComposite(Composite parent) { - Composite composite = new Composite(parent, SWT.NONE); - composite.setBackground(fBackgroundColor); - return composite; - } - - /* - * @see org.eclipse.update.ui.forms.internal.FormWidgetFactory#createCompositeSeparator(Composite) - */ - private Composite createCompositeSeparator(Composite parent) { - Composite composite = new Composite(parent, SWT.NONE); - composite.setBackground(fSeparatorColor); - return composite; - } - - /* - * @see org.eclipse.update.ui.forms.internal.FormWidgetFactory#createLabel(Composite, String) - */ - private Label createLabel(Composite parent, String text) { - Label label = new Label(parent, SWT.NONE); - if (text != null) - label.setText(text); - label.setBackground(fBackgroundColor); - label.setForeground(fForegroundColor); - return label; - } - - /* - * @see org.eclipse.update.ui.forms.internal.FormWidgetFactory#createHeader(Composite, String) - */ - private Label createHeader(Composite parent, String text) { - Label label = new Label(parent, SWT.NONE); - if (text != null) - label.setText(text); - label.setBackground(fBackgroundColor); - label.setForeground(fForegroundColor); - label.setFont(JFaceResources.getHeaderFont()); - return label; - } - - /* - * @see org.eclipse.update.ui.forms.internal.FormWidgetFactory#createBanner(Composite, String) - */ - private Label createBanner(Composite parent, String text) { - Label label = new Label(parent, SWT.NONE); - if (text != null) - label.setText(text); - label.setBackground(fBackgroundColor); - label.setForeground(fForegroundColor); - label.setFont(JFaceResources.getBannerFont()); - return label; - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/InsertLineAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/InsertLineAction.java deleted file mode 100644 index 4d9260c1459..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/InsertLineAction.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 - * Chris.Dennis@invidi.com - http://bugs.eclipse.org/bugs/show_bug.cgi?id=29027 - *******************************************************************************/ -package org.eclipse.ui.texteditor; - -import java.util.ResourceBundle; - -import org.eclipse.jface.text.Assert; -import org.eclipse.jface.text.source.ISourceViewer; -import org.eclipse.swt.custom.StyledText; - -/** - * This action implements smart return. - * Instead of breaking the line where we are, we do the following: - * <p><b>Smart Enter</b> - * <ul> - * <li> if the caret is on a line containing any non-whitespace, a line is inserted below the - * current one and the caret moved to it,</li> - * <li> if the caret is on a whitespace-only line, a line is inserted below the current line, - * but the caret stays in its position.</li> - * </ul> - * </p> - * <p><b>Smart Enter Inverse</b> - * <ul> - * <li> if the caret is on a line containing any non-whitespace, we insert a line above the - * current one and move the caret to it (i.e. it stays at the same offset in the widget),</li> - * <li> if the caret is on a whitespace-only line, a line is inserted above the current line, - * but the caret stays in its logical position (i.e., it gets shifted one line down in the - * document, but keeps its position relative to the content following the caret).</li> - * </ul> - * </p> - * @since 3.0 - */ -public class InsertLineAction extends TextEditorAction { - - /** - * <code>true</code> if this action inserts a line above the current (Smart Enter Inverse), - * <code>false</code> otherwise - */ - protected boolean fAbove; - - /** - * Creates a new smart enter action. - * @param bundle the resource bundle - * @param prefix the prefix to use to get properties from <code>bundle</code> - * @param textEditor the editor that the action acts upon - * @param above whether new lines are inserted above or below the caret's line. - */ - public InsertLineAction(ResourceBundle bundle, String prefix, ITextEditor textEditor, boolean above) { - super(bundle, prefix, textEditor); - fAbove= above; - } - - /* - * @see org.eclipse.ui.texteditor.TextEditorAction#update() - */ - public void update() { - super.update(); - if (isEnabled()) - setEnabled(canModifyEditor()); - } - - /* - * @see org.eclipse.jface.action.IAction#run() - */ - public void run() { - ITextEditor ed= getTextEditor(); - if (!(ed instanceof AbstractTextEditor)) - return; - - if (!validateEditorInputState()) - return; - - AbstractTextEditor editor= (AbstractTextEditor) ed; - ISourceViewer sv= editor.getSourceViewer(); - if (sv == null) - return; - - StyledText st= sv.getTextWidget(); - if (st == null || st.isDisposed()) - return; - - // get current line - int caretOffset= st.getCaretOffset(); - int lineNumber= st.getLineAtOffset(caretOffset); - int lineOffset= st.getOffsetAtLine(lineNumber); - int lineLength= getLineLength(st, lineNumber, lineOffset); - - // insert a new line relative to the current, depending on fAbove - String line= st.getTextRange(lineOffset, lineLength); - boolean whiteSpace= isWhitespace(line); - String delimiter= st.getLineDelimiter(); - - int insertionPoint; // where the new line should be inserted - - if (fAbove) { - if (whiteSpace) - insertionPoint= caretOffset; - else - insertionPoint= lineOffset + getIndentationLength(line); - } else { - insertionPoint= lineOffset + lineLength; - } - - // operating directly on the widget we get all the auto-indentation for free - st.replaceTextRange(insertionPoint, 0, delimiter); - - int newCaretOffset= -1; - if (fAbove && !whiteSpace) { - newCaretOffset= - st.getOffsetAtLine(lineNumber) + getLineLength(st, lineNumber, lineOffset); - } else if (fAbove || !whiteSpace) { - int nextLine= lineNumber + 1; - int nextLineOffset= st.getOffsetAtLine(nextLine); - int nextLineLength= getLineLength(st, nextLine, nextLineOffset); - newCaretOffset= nextLineOffset + nextLineLength; - } - if (newCaretOffset != -1) { - st.setCaretOffset(newCaretOffset); - st.showSelection(); - } - } - - /** - * Determines the length of a line without the terminating line delimiter - * @param st the StyledText widget - * @param lineNumber the number of the line - * @param lineOffset the line's offset - * @return the length of the line without terminating delimiter - */ - private int getLineLength(StyledText st, int lineNumber, int lineOffset) { - int lineLength; - if (st.getLineCount() == lineNumber + 1) { // end of display area, no next line - lineLength= st.getCharCount() - lineOffset; - } else { - lineLength= st.getOffsetAtLine(lineNumber + 1); // next line offset - lineLength -= lineOffset; - lineLength -= st.getLineDelimiter().length(); // subtract line delimiter - } - return lineLength; - } - - /** - * Computes the indentation of a line. - * @param line - a non <code>null</code> string - * @return the number of whitespace characters at the beginning of <code>line</code> - */ - private int getIndentationLength(String line) { - Assert.isNotNull(line); - int pos; - for (pos= 0; pos < line.length(); pos++) { - if (!Character.isWhitespace(line.charAt(pos))) - break; - } - return pos; - } - - /** - * Checks if a string consists only of whitespace. - * @param string - * @return <code>true</code> if <code>string</code> consists of whitespace only, - * <code>false</code> otherwise. - */ - private boolean isWhitespace(String string) { - if (string == null) - return true; - return string.trim().length() == 0; - } -}
\ No newline at end of file diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/MarkAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/MarkAction.java deleted file mode 100644 index ee34788b687..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/MarkAction.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.texteditor; - - -import java.util.ResourceBundle; - -import org.eclipse.jface.text.IMarkRegionTarget; - -/** - * An action to handle emacs-like marked regions. - * - * @since 2.0 - */ -public class MarkAction extends TextEditorAction { - - /** Sets the mark. */ - public static final int SET_MARK= 0; - /** Clears the mark. */ - public static final int CLEAR_MARK= 1; - /** Swaps the mark and the cursor position. */ - public static final int SWAP_MARK= 2; - - /** The mark action type. */ - private final int fType; - - /** - * Constructor for MarkAction. - * - * @param bundle the resource bundle - * @param prefix a prefix to be prepended to the various resource keys - * (described in <code>ResourceAction</code> constructor), or - * <code>null</code> if none - * @param editor the text editor - * @param type the mark action type, must be one of - * <code>SET_MARK</code>, <code>CLEAR_MARK</code> or <code>SWAP_MARK</code>. - */ - public MarkAction(ResourceBundle bundle, String prefix, ITextEditor editor, int type) { - super(bundle, prefix, editor); - fType= type; - } - - /* - * @see IAction#run() - */ - public void run() { - - ITextEditor editor= getTextEditor(); - if (editor == null) - return; - - IMarkRegionTarget target= (IMarkRegionTarget) editor.getAdapter(IMarkRegionTarget.class); - if (target == null) - return; - - switch (fType) { - case SET_MARK: - target.setMarkAtCursor(true); - break; - - case CLEAR_MARK: - target.setMarkAtCursor(false); - break; - - case SWAP_MARK: - target.swapMarkAndCursor(); - break; - } - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/MarkRegionTarget.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/MarkRegionTarget.java deleted file mode 100644 index 410c5ed35c8..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/MarkRegionTarget.java +++ /dev/null @@ -1,125 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.texteditor; - - -import org.eclipse.swt.graphics.Point; - -import org.eclipse.jface.action.IStatusLineManager; -import org.eclipse.jface.text.IMarkRegionTarget; -import org.eclipse.jface.text.IRegion; -import org.eclipse.jface.text.ITextViewer; -import org.eclipse.jface.text.ITextViewerExtension; -import org.eclipse.jface.text.ITextViewerExtension5; - -/** - * Default implementation of <code>IMarkRegionTarget</code> using <code>ITextViewer</code> - * and <code>IStatusLineManager</code>. - * - * @since 2.0 - */ -public class MarkRegionTarget implements IMarkRegionTarget { - - /** The text viewer. */ - private final ITextViewer fViewer; - /** The status line. */ - private final IStatusLineManager fStatusLine; - - /** - * Creates a MarkRegionTaret. - * - * @param viewer the text viewer - * @param manager the status line manager - */ - public MarkRegionTarget(ITextViewer viewer, IStatusLineManager manager) { - fViewer= viewer; - fStatusLine= manager; - } - - /* - * @see IMarkregion#setMarkAtCursor(boolean) - */ - public void setMarkAtCursor(boolean set) { - - if (!(fViewer instanceof ITextViewerExtension)) - return; - - ITextViewerExtension viewerExtension= ((ITextViewerExtension) fViewer); - - if (set) { - Point selection= fViewer.getSelectedRange(); - viewerExtension.setMark(selection.x); - - fStatusLine.setErrorMessage(""); //$NON-NLS-1$ - fStatusLine.setMessage(EditorMessages.getString("Editor.mark.status.message.mark.set")); //$NON-NLS-1$ - - } else { - viewerExtension.setMark(-1); - - fStatusLine.setErrorMessage(""); //$NON-NLS-1$ - fStatusLine.setMessage(EditorMessages.getString("Editor.mark.status.message.mark.cleared")); //$NON-NLS-1$ - } - } - - /* - * @see IMarkregion#swapMarkAndCursor() - */ - public void swapMarkAndCursor() { - - if (!(fViewer instanceof ITextViewerExtension)) - return; - - ITextViewerExtension viewerExtension= ((ITextViewerExtension) fViewer); - - int markPosition= viewerExtension.getMark(); - if (markPosition == -1) { - fStatusLine.setErrorMessage(EditorMessages.getString("MarkRegionTarget.markNotSet")); //$NON-NLS-1$ - fStatusLine.setMessage(""); //$NON-NLS-1$ - return; - } - - if (!isVisible(fViewer, markPosition)) { - fStatusLine.setErrorMessage(EditorMessages.getString("MarkRegionTarget.markNotVisible")); //$NON-NLS-1$ - fStatusLine.setMessage(""); //$NON-NLS-1$ - return; - } - - Point selection= fViewer.getSelectedRange(); - viewerExtension.setMark(selection.x); - - fViewer.setSelectedRange(markPosition, 0); - fViewer.revealRange(markPosition, 0); - - fStatusLine.setErrorMessage(""); //$NON-NLS-1$ - fStatusLine.setMessage(EditorMessages.getString("Editor.mark.status.message.mark.swapped")); //$NON-NLS-1$ - } - - /** - * Tells whether the given offset is visible in the given text viewer. - * - * @param viewer the text viewer - * @param offset the offset to check - * @return <code>true</code> if the given offset is visible in the given text viewer - * - * @since 2.1 - */ - protected final static boolean isVisible(ITextViewer viewer, int offset) { - if (viewer instanceof ITextViewerExtension5) { - ITextViewerExtension5 extension= (ITextViewerExtension5) viewer; - return extension.modelOffset2WidgetOffset(offset) >= 0; - } else { - IRegion region= viewer.getVisibleRegion(); - int vOffset= region.getOffset(); - return (vOffset <= offset && offset <= vOffset + region.getLength()); - } - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/MoveLinesAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/MoveLinesAction.java deleted file mode 100644 index e4ad192df81..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/MoveLinesAction.java +++ /dev/null @@ -1,504 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.texteditor; - -import java.util.ResourceBundle; - -import org.eclipse.swt.custom.StyledText; -import org.eclipse.swt.custom.VerifyKeyListener; -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.Point; -import org.eclipse.swt.widgets.Event; - -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.IRegion; -import org.eclipse.jface.text.IRewriteTarget; -import org.eclipse.jface.text.ITextSelection; -import org.eclipse.jface.text.ITextViewer; -import org.eclipse.jface.text.ITextViewerExtension5; -import org.eclipse.jface.text.TextSelection; -import org.eclipse.jface.text.source.ISourceViewer; - -/** - * Action for moving selected lines in an editor. - * @since 3.0 - */ -public class MoveLinesAction extends TextEditorAction { - - /** - * Detects the end of a compound edit command. The user is assumed to have ended the command - * when - * <ul> - * <li>entering any text with a different key combination than the one used to move / copy</li> - * <li>clicking anywhere in the editor</li> - * <li>the viewer loses focus</li> - * <li>the underlying document gets changed due to anything but this action</li> - * </ul> - */ - private class ExitStrategy implements VerifyKeyListener, MouseListener, FocusListener, IDocumentListener { - - /** - * The widget this instance is registered with for <code>VerifyKey</code>-, <code>Mouse</code>- - * and <code>FocusEvent</code>s, or <code>null</code> if not registered. - */ - private StyledText fWidgetEventSource; - /** - * The document this instance is registered with for <code>DocumentEvent</code>s, - * or <code>null</code> if not registered. - */ - private IDocument fDocumentEventSource; - /** - * Indicates whether there are any pending registrations.<br/> - * Invariant: <code>fIsInstalled || (fWidgetEventSource == fDocumentEventSource == null)</code> - */ - private boolean fIsInstalled; - - /** - * Installs the exit strategy with all event sources. - */ - public void install() { - if (fIsInstalled) - uninstall(); - fIsInstalled= true; - - ISourceViewer viewer= fEditor.getSourceViewer(); - if (viewer == null) - return; - - fWidgetEventSource= viewer.getTextWidget(); - if (fWidgetEventSource == null) - return; - - fWidgetEventSource.addVerifyKeyListener(this); - fWidgetEventSource.addMouseListener(this); - fWidgetEventSource.addFocusListener(this); - - fDocumentEventSource= viewer.getDocument(); - if (fDocumentEventSource != null) - fDocumentEventSource.addDocumentListener(this); - } - - /** - * Uninstalls the exit strategy with all event sources it was previously registered with. - */ - public void uninstall() { - if (fWidgetEventSource != null) { - fWidgetEventSource.removeVerifyKeyListener(this); - fWidgetEventSource.removeMouseListener(this); - fWidgetEventSource.removeFocusListener(this); - fWidgetEventSource= null; - } - if (fDocumentEventSource != null) { - fDocumentEventSource.removeDocumentListener(this); - fDocumentEventSource= null; - } - fIsInstalled= false; - } - - public void verifyKey(VerifyEvent event) { - if (event.stateMask != fStateMask) { - endCompoundEdit(); - } - } - - public void mouseDoubleClick(MouseEvent e) { - endCompoundEdit(); - } - - public void mouseDown(MouseEvent e) { - endCompoundEdit(); - } - - public void mouseUp(MouseEvent e) {} - - public void focusLost(FocusEvent e) { - endCompoundEdit(); - } - - public void focusGained(FocusEvent e) {} - - public void documentAboutToBeChanged(DocumentEvent event) { - // don't do this since it will break interaction between the moveUp and moveDown actions. -// if (!fDescription.correspondsTo(event)) endCompoundEdit(); - } - - public void documentChanged(DocumentEvent event) {} - } - - /* keys */ - - /** Key for status message upon illegal move. <p>Value {@value}</p> */ - private static final String ILLEGAL_MOVE= "Editor.MoveLines.IllegalMove.status"; //$NON-NLS-1$ - - /* state variables - define what this action does */ - - /** <code>true</code> if lines are shifted upwards, <code>false</code> otherwise. */ - private final boolean fUpwards; - /** <code>true</code> if lines are to be copied instead of moved. */ - private final boolean fCopy; - /** The editor we are working on. */ - private final AbstractTextEditor fEditor; - - /* compound members of this action */ - - /** The exit strategy that will detect the ending of a compound edit */ - private final ExitStrategy fExitStrategy= new ExitStrategy(); - - /* process variables - may change in every run() */ - - /** - * Set to <code>true</code> by <code>getMovingSelection</code> if the resulting selection - * should include the last delimiter. - */ - private boolean fAddDelimiter; - /** <code>true</code> if a compound move / copy is going on. */ - private boolean fEditInProgress= false; - /** stateMask for this action - if it changes, the edition is considered to be ended */ - private int fStateMask; -// /** Description of the last edition triggered by this action */ -// private EditDescription fDescription= new EditDescription(); - - /** - * Creates and initializes the action for the given text editor. - * The action configures its visual representation from the given resource - * bundle. - * - * @param bundle the resource bundle - * @param prefix a prefix to be prepended to the various resource keys - * (described in <code>ResourceAction</code> constructor), or <code>null</code> if none - * @param editor the text editor - * @param upwards <code>true</code>if the selected lines should be moved upwards, - * <code>false</code> if downwards - * @param copy if <code>true</code>, the action will copy lines instead of moving them - * @see TextEditorAction#TextEditorAction(ResourceBundle, String, ITextEditor) - */ - public MoveLinesAction(ResourceBundle bundle, String prefix, AbstractTextEditor editor, boolean upwards, boolean copy) { - super(bundle, prefix, editor); - fEditor= editor; - fUpwards= upwards; - fCopy= copy; - update(); - } - - /** - * Ends the compound change. - */ - private void beginCompoundEdit() { - if (fEditInProgress || fEditor == null) - return; - - fEditInProgress= true; - - fExitStrategy.install(); - - IRewriteTarget target= (IRewriteTarget)fEditor.getAdapter(IRewriteTarget.class); - if (target != null) { - target.beginCompoundChange(); - } - } - - /** - * Checks if <code>selection</code> is contained by the visible region of <code>viewer</code>. - * As a special case, a selection is considered contained even if it extends over the visible - * region, but the extension stays on a partially contained line and contains only white space. - * - * @param selection the selection to be checked - * @param viewer the viewer displaying a visible region of <code>selection</code>'s document. - * @return <code>true</code>, if <code>selection</code> is contained, <code>false</code> otherwise. - */ - private boolean containedByVisibleRegion(ITextSelection selection, ISourceViewer viewer) { - int min= selection.getOffset(); - int max= min + selection.getLength(); - IDocument document= viewer.getDocument(); - - IRegion visible; - if (viewer instanceof ITextViewerExtension5) - visible= ((ITextViewerExtension5) viewer).getModelCoverage(); - else - visible= viewer.getVisibleRegion(); - - int visOffset= visible.getOffset(); - try { - if (visOffset > min) { - if (document.getLineOfOffset(visOffset) != selection.getStartLine()) - return false; - if (!isWhitespace(document.get(min, visOffset - min))) { - showStatus(); - return false; - } - } - int visEnd= visOffset + visible.getLength(); - if (visEnd < max) { - if (document.getLineOfOffset(visEnd) != selection.getEndLine()) - return false; - if (!isWhitespace(document.get(visEnd, max - visEnd))) { - showStatus(); - return false; - } - } - return true; - } catch (BadLocationException e) { - } - return false; - } - - /** - * Ends the compound change. - */ - private void endCompoundEdit() { - if (!fEditInProgress || fEditor == null) - return; - - fExitStrategy.uninstall(); - - IRewriteTarget target= (IRewriteTarget)fEditor.getAdapter(IRewriteTarget.class); - if (target != null) { - target.endCompoundChange(); - } - - fEditInProgress= false; - } - - /** - * Given a selection on a document, computes the lines fully or partially covered by - * <code>selection</code>. A line in the document is considered covered if - * <code>selection</code> comprises any characters on it, including the terminating delimiter. - * <p>Note that the last line in a selection is not considered covered if the selection only - * comprises the line delimiter at its beginning (that is considered part of the second last - * line). - * As a special case, if the selection is empty, a line is considered covered if the caret is - * at any position in the line, including between the delimiter and the start of the line. The - * line containing the delimiter is not considered covered in that case. - * </p> - * - * @param document the document <code>selection</code> refers to - * @param selection a selection on <code>document</code> - * @param viewer the <code>ISourceViewer</code> displaying <code>document</code> - * @return a selection describing the range of lines (partially) covered by - * <code>selection</code>, without any terminating line delimiters - * @throws BadLocationException if the selection is out of bounds (when the underlying document has changed during the call) - */ - private ITextSelection getMovingSelection(IDocument document, ITextSelection selection, ISourceViewer viewer) throws BadLocationException { - int low= document.getLineOffset(selection.getStartLine()); - int endLine= selection.getEndLine(); - int high= document.getLineOffset(endLine) + document.getLineLength(endLine); - - // get everything up to last line without its delimiter - String delim= document.getLineDelimiter(endLine); - if (delim != null) - high -= delim.length(); - - // the new selection will cover the entire lines being moved, except for the last line's - // delimiter. The exception to this rule is an empty last line, which will stay covered - // including its delimiter - if (delim != null && document.getLineLength(endLine) == delim.length()) - fAddDelimiter= true; - else - fAddDelimiter= false; - - return new TextSelection(document, low, high - low); - } - - /** - * Computes the region of the skipped line given the text block to be moved. If - * <code>fUpwards</code> is <code>true</code>, the line above <code>selection</code> - * is selected, otherwise the line below. - * - * @param document the document <code>selection</code> refers to - * @param selection the selection on <code>document</code> that will be moved. - * @return the region comprising the line that <code>selection</code> will be moved over, without its terminating delimiter. - */ - private ITextSelection getSkippedLine(IDocument document, ITextSelection selection) { - int skippedLineN= (fUpwards ? selection.getStartLine() - 1 : selection.getEndLine() + 1); - if (skippedLineN < 0 || skippedLineN >= document.getNumberOfLines()) - return null; - try { - IRegion line= document.getLineInformation(skippedLineN); - return new TextSelection(document, line.getOffset(), line.getLength()); - } catch (BadLocationException e) { - // only happens on concurrent modifications - return null; - } - } - - /** - * Checks for white space in a string. - * - * @param string the string to be checked or <code>null</code> - * @return <code>true</code> if <code>string</code> contains only white space or is - * <code>null</code>, <code>false</code> otherwise - */ - private boolean isWhitespace(String string) { - return string == null ? true : string.trim().length() == 0; - } - - /* - * @see org.eclipse.jface.action.IAction#run() - */ - public void runWithEvent(Event event) { - - updateShortCut(event); - - // get involved objects - if (fEditor == null) - return; - - if (!validateEditorInputState()) - return; - - ISourceViewer viewer= fEditor.getSourceViewer(); - if (viewer == null) - return; - - IDocument document= viewer.getDocument(); - if (document == null) - return; - - StyledText widget= viewer.getTextWidget(); - if (widget == null) - return; - - // get selection - Point p= viewer.getSelectedRange(); - if (p == null) - return; - - ITextSelection sel= new TextSelection(document, p.x, p.y); - - ITextSelection skippedLine= getSkippedLine(document, sel); - if (skippedLine == null) - return; - - try { - - ITextSelection movingArea= getMovingSelection(document, sel, viewer); - - // if either the skipped line or the moving lines are outside the widget's - // visible area, bail out - if (!containedByVisibleRegion(movingArea, viewer) || !containedByVisibleRegion(skippedLine, viewer)) - return; - - // get the content to be moved around: the moving (selected) area and the skipped line - String moving= movingArea.getText(); - String skipped= skippedLine.getText(); - if (moving == null || skipped == null) - return; - - String delim; - String insertion; - int offset, deviation; - if (fUpwards) { - delim= document.getLineDelimiter(skippedLine.getEndLine()); - Assert.isNotNull(delim); - if (fCopy) { - insertion= moving + delim; - offset= movingArea.getOffset(); - deviation= 0; - } else { - insertion= moving + delim + skipped; - offset= skippedLine.getOffset(); - deviation= -skippedLine.getLength() - delim.length(); - } - } else { - delim= document.getLineDelimiter(movingArea.getEndLine()); - Assert.isNotNull(delim); - if (fCopy) { - insertion= moving + delim; - offset= skippedLine.getOffset(); - deviation= movingArea.getLength() + delim.length(); - } else { - insertion= skipped + delim + moving; - offset= movingArea.getOffset(); - deviation= skipped.length() + delim.length(); - } - } - - // modify the document - beginCompoundEdit(); - if (fCopy) { -// fDescription= new EditDescription(offset, 0, insertion.length()); - document.replace(offset, 0, insertion); - } else { -// fDescription= new EditDescription(offset, insertion.length(), insertion.length()); - document.replace(offset, insertion.length(), insertion); - } - - // move the selection along - int selOffset= movingArea.getOffset() + deviation; - int selLength= movingArea.getLength() + (fAddDelimiter ? delim.length() : 0); - if (! (viewer instanceof ITextViewerExtension5)) - selLength= Math.min(selLength, viewer.getVisibleRegion().getOffset() + viewer.getVisibleRegion().getLength() - selOffset); - else { - // TODO need to check what is necessary in the projection case - } - selectAndReveal(viewer, selOffset, selLength); - } catch (BadLocationException x) { - // won't happen without concurrent modification - bail out - return; - } - } - - /** - * Saves the state mask of <code>event</code> for comparison with the next event in order to - * detect key changes in the set of keys pressed by the user. - * - * @param event the event that triggered this action - */ - private void updateShortCut(Event event) { - fStateMask= event.stateMask; - } - - /** - * Performs similar to AbstractTextEditor.selectAndReveal, but does not update - * the viewers highlight area. - * - * @param viewer the viewer that we want to select on - * @param offset the offset of the selection - * @param length the length of the selection - */ - private void selectAndReveal(ITextViewer viewer, int offset, int length) { - // invert selection to avoid jumping to the end of the selection in st.showSelection() - viewer.setSelectedRange(offset + length, -length); - //viewer.revealRange(offset, length); // will trigger jumping - StyledText st= viewer.getTextWidget(); - if (st != null) - st.showSelection(); // only minimal scrolling - } - - /** - * Displays information in the status line why a line move is not possible - */ - private void showStatus() { - IEditorStatusLine status= (IEditorStatusLine) fEditor.getAdapter(IEditorStatusLine.class); - if (status == null) - return; - status.setMessage(false, EditorMessages.getString(ILLEGAL_MOVE), null); - } - - /* - * @see org.eclipse.ui.texteditor.IUpdate#update() - */ - public void update() { - super.update(); - - if (isEnabled()) - setEnabled(canModifyEditor()); - - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/PropagatingFontFieldEditor.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/PropagatingFontFieldEditor.java deleted file mode 100644 index 0701f917056..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/PropagatingFontFieldEditor.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.texteditor; - - - -import org.eclipse.swt.widgets.Composite; - - -/** - * @deprecated use WorkbenchChainedTextFontFieldEditor - */ -public final class PropagatingFontFieldEditor extends WorkbenchChainedTextFontFieldEditor { - - /** - * @deprecated use WorkbenchChainedTextFontFieldEditor - */ - public PropagatingFontFieldEditor(String name, String labelText, Composite parent) { - super(name, labelText, parent); - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/RegExContentAssistProcessor.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/RegExContentAssistProcessor.java deleted file mode 100644 index a40fa8e66a9..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/RegExContentAssistProcessor.java +++ /dev/null @@ -1,356 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.texteditor; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.jface.contentassist.ISubjectControlContentAssistProcessor; -import org.eclipse.jface.contentassist.IContentAssistSubjectControl; -import org.eclipse.jface.contentassist.SubjectControlContextInformationValidator; - -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.ITextViewer; -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.IContextInformation; -import org.eclipse.jface.text.contentassist.IContextInformationValidator; - -/** - * Content assist processor for regular expressions. - * - * @since 3.0 - */ -final class RegExContentAssistProcessor implements IContentAssistProcessor, ISubjectControlContentAssistProcessor { - - /** - * The available proposal strings. - */ - private final static HashMap fgProposalStrings= new HashMap(); - - /** - * The available proposal keys. - */ - private final static ArrayList fgProposalKeys= new ArrayList(); - - - static { - - //---------- Proposal Keys ---------- - - fgProposalKeys.add("\\\\"); //$NON-NLS-1$ - fgProposalKeys.add("\\0"); //$NON-NLS-1$ - fgProposalKeys.add("\\x"); //$NON-NLS-1$ - fgProposalKeys.add("\\u"); //$NON-NLS-1$ - fgProposalKeys.add("\\t"); //$NON-NLS-1$ - fgProposalKeys.add("\\n"); //$NON-NLS-1$ - fgProposalKeys.add("\\r"); //$NON-NLS-1$ - fgProposalKeys.add("\\f"); //$NON-NLS-1$ - fgProposalKeys.add("\\a"); //$NON-NLS-1$ - fgProposalKeys.add("\\e"); //$NON-NLS-1$ - fgProposalKeys.add("\\c"); //$NON-NLS-1$ - - fgProposalKeys.add("."); //$NON-NLS-1$ - fgProposalKeys.add("\\d"); //$NON-NLS-1$ - fgProposalKeys.add("\\D"); //$NON-NLS-1$ - fgProposalKeys.add("\\s"); //$NON-NLS-1$ - fgProposalKeys.add("\\S"); //$NON-NLS-1$ - fgProposalKeys.add("\\w"); //$NON-NLS-1$ - fgProposalKeys.add("\\W"); //$NON-NLS-1$ - - fgProposalKeys.add("^"); //$NON-NLS-1$ - fgProposalKeys.add("$"); //$NON-NLS-1$ - fgProposalKeys.add("\\b"); //$NON-NLS-1$ - fgProposalKeys.add("\\B"); //$NON-NLS-1$ - fgProposalKeys.add("\\A"); //$NON-NLS-1$ - fgProposalKeys.add("\\G"); //$NON-NLS-1$ -// fgProposalKeys.add("\\Z"); //$NON-NLS-1$ - fgProposalKeys.add("\\z"); //$NON-NLS-1$ - - fgProposalKeys.add("?"); //$NON-NLS-1$ - fgProposalKeys.add("*"); //$NON-NLS-1$ - fgProposalKeys.add("+"); //$NON-NLS-1$ - fgProposalKeys.add("{n}"); //$NON-NLS-1$ - fgProposalKeys.add("{n,}"); //$NON-NLS-1$ - fgProposalKeys.add("{n,m}"); //$NON-NLS-1$ - - fgProposalKeys.add("??"); //$NON-NLS-1$ - fgProposalKeys.add("*?"); //$NON-NLS-1$ - fgProposalKeys.add("+?"); //$NON-NLS-1$ - fgProposalKeys.add("{n}?"); //$NON-NLS-1$ - fgProposalKeys.add("{n,}?"); //$NON-NLS-1$ - fgProposalKeys.add("{n,m}?"); //$NON-NLS-1$ - - fgProposalKeys.add("?+"); //$NON-NLS-1$ - fgProposalKeys.add("*+"); //$NON-NLS-1$ - fgProposalKeys.add("++"); //$NON-NLS-1$ - fgProposalKeys.add("{n}+"); //$NON-NLS-1$ - fgProposalKeys.add("{n,}+"); //$NON-NLS-1$ - fgProposalKeys.add("{n,m}+"); //$NON-NLS-1$ - - fgProposalKeys.add("UV"); //$NON-NLS-1$ - fgProposalKeys.add("U|V"); //$NON-NLS-1$ - fgProposalKeys.add("(U)"); //$NON-NLS-1$ - - fgProposalKeys.add("\\i"); //$NON-NLS-1$ - fgProposalKeys.add("$i"); //$NON-NLS-1$ - - fgProposalKeys.add("\\"); //$NON-NLS-1$ - fgProposalKeys.add("\\Q"); //$NON-NLS-1$ - fgProposalKeys.add("\\E"); //$NON-NLS-1$ - - fgProposalKeys.add("[ecq]"); //$NON-NLS-1$ - fgProposalKeys.add("[^ecq]"); //$NON-NLS-1$ - fgProposalKeys.add("[e-q]"); //$NON-NLS-1$ - fgProposalKeys.add("&&"); //$NON-NLS-1$ - -// fgProposalKeys.add("\\p{Lower}"); //$NON-NLS-1$ -// fgProposalKeys.add("\\p{Upper}"); //$NON-NLS-1$ -// fgProposalKeys.add("\\p{ASCII}"); //$NON-NLS-1$ -// fgProposalKeys.add("\\p{Alpha}"); //$NON-NLS-1$ -// fgProposalKeys.add("\\p{Digit}"); //$NON-NLS-1$ -// fgProposalKeys.add("\\p{Alnum}"); //$NON-NLS-1$ -// fgProposalKeys.add("\\p{Punct}"); //$NON-NLS-1$ -// fgProposalKeys.add("\\p{Graph}"); //$NON-NLS-1$ -// fgProposalKeys.add("\\p{Print}"); //$NON-NLS-1$ -// fgProposalKeys.add("\\p{Blank}"); //$NON-NLS-1$ -// fgProposalKeys.add("\\p{Cntrl}"); //$NON-NLS-1$ -// fgProposalKeys.add("\\p{XDigit}"); //$NON-NLS-1$ -// fgProposalKeys.add("\\p{Space}"); //$NON-NLS-1$ -// -// fgProposalKeys.add("\\p{InGreek}"); //$NON-NLS-1$ -// fgProposalKeys.add("\\p{Lu}"); //$NON-NLS-1$ -// fgProposalKeys.add("\\p{Sc}"); //$NON-NLS-1$ -// fgProposalKeys.add("\\P{InGreek}"); //$NON-NLS-1$ -// fgProposalKeys.add("[\\p{L}&&[^\\p{Lu}]"); //$NON-NLS-1$ - -// fgProposalKeys.add("(?idmsux-idmsux)"); //$NON-NLS-1$ -// fgProposalKeys.add("(?idmsux-idmsux:U)"); //$NON-NLS-1$ - -// fgProposalKeys.add("(?:U)"); //$NON-NLS-1$ -// fgProposalKeys.add("(?=U)"); //$NON-NLS-1$ -// fgProposalKeys.add("(?!U)"); //$NON-NLS-1$ -// fgProposalKeys.add("(?<=U)"); //$NON-NLS-1$ -// fgProposalKeys.add("(?<!U)"); //$NON-NLS-1$ -// fgProposalKeys.add("(?>U)"); //$NON-NLS-1$ - - //---------- Proposals ---------- - - fgProposalStrings.put("\\\\", "\\\\"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("\\0", "\\0"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("\\x", "\\x"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("\\u", "\\u"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("\\t", "\\t"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("\\n", "\\n"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("\\r", "\\r"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("\\f", "\\f"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("\\a", "\\a"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("\\e", "\\e"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("\\c", "\\c"); //$NON-NLS-1$ //$NON-NLS-2$ - - fgProposalStrings.put(".", "."); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("\\d", "\\d"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("\\D", "\\D"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("\\s", "\\s"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("\\S", "\\S"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("\\w", "\\w"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("\\W", "\\W"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("^", "^"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("$", "$"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("\\b", "\\b"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("\\B", "\\B"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("\\A", "\\A"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("\\G", "\\G"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("\\Z", "\\Z"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("\\z", "\\z"); //$NON-NLS-1$ //$NON-NLS-2$ - - fgProposalStrings.put("?", "?"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("*", "*"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("+", "+"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("{n}", "{}"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("{n,}", "{,}"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("{n,m}", "{,}"); //$NON-NLS-1$ //$NON-NLS-2$ - - fgProposalStrings.put("??", "??"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("*?", "*?"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("+?", "+?"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("{n}?", "{}?"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("{n,}?", "{,}?"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("{n,m}?", "{,}?"); //$NON-NLS-1$ //$NON-NLS-2$ - - fgProposalStrings.put("?+", "?+"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("*+", "*+"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("++", "++"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("{n}+", "{}+"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("{n,}+", "{,}+"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("{n,m}+", "{,}+"); //$NON-NLS-1$ //$NON-NLS-2$ - - fgProposalStrings.put("UV", ""); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("U|V", "|"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("(U)", "()"); //$NON-NLS-1$ //$NON-NLS-2$ - - fgProposalStrings.put("\\i", "\\"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("$i", "$"); //$NON-NLS-1$ //$NON-NLS-2$ - - fgProposalStrings.put("\\", "\\"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("\\Q", "\\Q"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("\\E", "\\E"); //$NON-NLS-1$ //$NON-NLS-2$ - - fgProposalStrings.put("[ecq]", "[]"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("[^ecq]", "^"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("[e-q]", "[]"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("&&", "&&"); //$NON-NLS-1$ //$NON-NLS-2$ - - fgProposalStrings.put("\\p{Lower}", "\\p{Lower}"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("\\p{Upper}", "\\p{Upper}"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("\\p{ASCII}", "\\p{ASCII}"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("\\p{Alpha}", "\\p{Alpha}"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("\\p{Digit}", "\\p{Digit}"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("\\p{Alnum}", "\\p{Alnum}"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("\\p{Punct}", "\\p{Punct}"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("\\p{Graph}", "\\p{Graph}"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("\\p{Print}", "\\p{Print}"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("\\p{Blank}", "\\p{Blank}"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("\\p{Cntrl}", "\\p{Cntrl}"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("\\p{XDigit}", "\\p{XDigit}"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("\\p{Space}", "\\p{Space}"); //$NON-NLS-1$ //$NON-NLS-2$ - - fgProposalStrings.put("\\p{InGreek}", "\\p{InGreek}"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("\\p{Lu}", "\\p{Lu}"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("\\p{Sc}", "\\p{Sc}"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("\\P{InGreek}", "\\P{InGreek}"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("[\\p{L}&&[^\\p{Lu}]","[\\p{L}&&[^\\p{Lu}]"); //$NON-NLS-1$ //$NON-NLS-2$ - - fgProposalStrings.put("(?:U)", "(?:)"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("(?idmsux-idmsux)", "(?)"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("(?idmsux-idmsux:U)", "(?:)"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("(?=U)", "(?=)"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("(?!U)", "(?!)"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("(?<=U)", "(?<=)"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("(?<!U)", "(?<!)"); //$NON-NLS-1$ //$NON-NLS-2$ - fgProposalStrings.put("(?>U)", "(?>)"); //$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * The context information validator. - */ - private IContextInformationValidator fValidator= new SubjectControlContextInformationValidator(this); - - /* - * @see IContentAssistProcessor#computeCompletionProposals(ITextViewer, int) - */ - public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) { - return computeCompletionProposals((IContentAssistSubjectControl)null, documentOffset); - } - - /* - * @see IContentAssistProcessor#computeContextInformation(ITextViewer, int) - */ - public IContextInformation[] computeContextInformation(ITextViewer viewer, int documentOffset) { - return computeContextInformation((IContentAssistSubjectControl)null, documentOffset); - } - - /* - * @see IContentAssistProcessor#getCompletionProposalAutoActivationCharacters() - */ - public char[] getCompletionProposalAutoActivationCharacters() { - return new char[] {'\\', '[', '('}; - } - - /* - * @see IContentAssistProcessor#getContextInformationAutoActivationCharacters() - */ - public char[] getContextInformationAutoActivationCharacters() { - return new char[] { }; - - } - - /* - * @see IContentAssistProcessor#getContextInformationValidator() - */ - public IContextInformationValidator getContextInformationValidator() { - return fValidator; - } - - /* - * @see IContentAssistProcessor#getErrorMessage() - */ - public String getErrorMessage() { - return null; - } - - /* - * @see ISubjectControlContentAssistProcessor#computeCompletionProposals(IContentAssistSubjectControl, int) - */ - public ICompletionProposal[] computeCompletionProposals(IContentAssistSubjectControl contentAssistSubjectControl, int documentOffset) { - List results= new ArrayList(fgProposalKeys.size()); - Iterator iter= fgProposalKeys.iterator(); - while (iter.hasNext()) - addProposal((String)iter.next(), contentAssistSubjectControl, documentOffset, results, true); - - if (results.isEmpty()) { - iter= fgProposalKeys.iterator(); - while (iter.hasNext()) - addProposal((String)iter.next(), contentAssistSubjectControl, documentOffset, results, false); - } - - return (ICompletionProposal[])results.toArray(new ICompletionProposal[results.size()]); - } - - /* - * @see ISubjectControlContentAssistProcessor#computeContextInformation(IContentAssistSubjectControl, int) - */ - public IContextInformation[] computeContextInformation(IContentAssistSubjectControl contentAssistSubjectControl, int documentOffset) { - return null; - } - - private void addProposal(String proposalKey, IContentAssistSubjectControl contentAssistSubjectControl, int documentOffset, List results, boolean filter) { - String proposal= (String)fgProposalStrings.get(proposalKey); - - // compute correct replacement - if (filter) { - String selection= null; - try { - selection = contentAssistSubjectControl.getDocument().get(documentOffset - 1, 1); - } catch (BadLocationException e) { - return ; - } - if (selection == null || selection.length() == 0 || proposal.length() == 0 || proposal.charAt(0) != selection.charAt(0)) - return; - - proposal= proposal.substring(1); - } - - String displayString= getString(proposalKey, "displayString"); //$NON-NLS-1$ - String additionalInfo= getString(proposalKey, "additionalInfo"); //$NON-NLS-1$ - IContextInformation info= createContextInformation(proposalKey); - -// // Move cursor on to the left if the proposal ends with '}' - int relativeOffset= proposal.length(); - // XXX: currently there's no smartness: position the cursor after the proposal -// if (relativeOffset > 0 && proposal.charAt(relativeOffset - 1) == '}') -// relativeOffset--; - - results.add(new CompletionProposal(proposal, documentOffset, 0, Math.max(0, relativeOffset), null, displayString, info, additionalInfo)); - } - - private IContextInformation createContextInformation(String proposalKey) { - return null; - } - - private String getString(String proposalKey, String type) { - return EditorMessages.getString("FindReplace.regExContentAssist." + type + "." + proposalKey); //$NON-NLS-1$//$NON-NLS-2$ - } -} 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 deleted file mode 100644 index 15921423fc5..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ResourceAction.java +++ /dev/null @@ -1,149 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.texteditor; - - - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.resource.ImageDescriptor; - -import org.eclipse.ui.help.WorkbenchHelp; - - -/** - * An action which configures its label, image, tooltip, and description from - * a resource bundle using known keys. - * <p> - * Clients may subclass this abstract class to define new kinds of actions. As - * with <code>Action</code>, subclasses must implement the - * <code>IAction.run</code> method to carry out the action's semantics. - * </p> - */ -public abstract class ResourceAction extends Action { - - /** - * Retrieves and returns the value with the given key from the given resource - * bundle, or returns the given default value if there is no such resource. - * Convenience method for dealing gracefully with missing resources. - * - * @param bundle the resource bundle - * @param key the resource key - * @param defaultValue the default value, or <code>null</code> - * @return the resource value, or the given default value (which may be - * <code>null</code>) - */ - protected static String getString(ResourceBundle bundle, String key, String defaultValue) { - - String value= defaultValue; - try { - value= bundle.getString(key); - } catch (MissingResourceException x) { - } - - return value; - } - - /** - * Creates a new action that configures itself from the given resource - * bundle. - * <p> - * The following keys, prepended by the given option prefix, - * are used for retrieving resources from the given bundle: - * <ul> - * <li><code>"label"</code> - <code>setText</code></li> - * <li><code>"tooltip"</code> - <code>setToolTipText</code></li> - * <li><code>"image"</code> - <code>setImageDescriptor</code></li> - * <li><code>"description"</code> - <code>setDescription</code></li> - * </ul> - * </p> - * - * @param bundle the resource bundle - * @param prefix a prefix to be prepended to the various resource keys, or - * <code>null</code> if none - * @param style one of <code>IAction.AS_PUSH_BUTTON</code>, <code>IAction.AS_CHECK_BOX</code>, - * and <code>IAction.AS_RADIO_BUTTON</code>. - * - * @see ResourceAction#ResourceAction(ResourceBundle, String) - * @see org.eclipse.jface.action.IAction#AS_CHECK_BOX - * @see org.eclipse.jface.action.IAction#AS_DROP_DOWN_MENU - * @see org.eclipse.jface.action.IAction#AS_PUSH_BUTTON - * @see org.eclipse.jface.action.IAction#AS_RADIO_BUTTON - * @since 2.1 - */ - public ResourceAction(ResourceBundle bundle, String prefix, int style) { - super(null, style); - initialize(bundle, prefix); - } - - /** - * Creates a new action that configures itself from the given resource - * bundle. - * <p> - * The following keys, prepended by the given option prefix, - * are used for retrieving resources from the given bundle: - * <ul> - * <li><code>"label"</code> - <code>setText</code></li> - * <li><code>"tooltip"</code> - <code>setToolTipText</code></li> - * <li><code>"image"</code> - <code>setImageDescriptor</code></li> - * <li><code>"description"</code> - <code>setDescription</code></li> - * </ul> - * </p> - * - * @param bundle the resource bundle - * @param prefix a prefix to be prepended to the various resource keys, or - * <code>null</code> if none - */ - public ResourceAction(ResourceBundle bundle, String prefix) { - super(); - initialize(bundle, prefix); - } - - /** - * Sets the action's help context id. - * - * @param contextId the help context id - */ - public final void setHelpContextId(String contextId) { - WorkbenchHelp.setHelp(this, contextId); - } - - /** - * Initializes this action using the given bundle and prefix. - * - * @param bundle the resource bundle - * @param prefix a prefix to be prepended to the various resource keys, or <code>null</code> if none - * @since 2.1 - */ - 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$ - String descriptionKey= "description"; //$NON-NLS-1$ - - if (prefix != null && prefix.length() > 0) { - labelKey= prefix + labelKey; - tooltipKey= prefix + tooltipKey; - imageKey= prefix + imageKey; - descriptionKey= prefix + descriptionKey; - } - - setText(getString(bundle, labelKey, labelKey)); - setToolTipText(getString(bundle, tooltipKey, null)); - setDescription(getString(bundle, descriptionKey, null)); - - String file= getString(bundle, imageKey, null); - if (file != null && file.trim().length() > 0) - setImageDescriptor(ImageDescriptor.createFromFile(getClass(), file)); - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/RetargetTextEditorAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/RetargetTextEditorAction.java deleted file mode 100644 index 994bcaf26fe..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/RetargetTextEditorAction.java +++ /dev/null @@ -1,239 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.ui.texteditor; - - -import java.util.ResourceBundle; - -import org.eclipse.swt.events.HelpEvent; -import org.eclipse.swt.events.HelpListener; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; - - -/** - * Action used by an editor action bar contributor to establish placeholders in - * menus or action bars which can be retargeted to dynamically changing actions, - * for example, those which come from the active editor. This action assumes that - * the "wrapped" action sends out property change events in response to state - * changes. It uses these change notifications to adapt its enabling state and - * its visual presentation. - */ -public final class RetargetTextEditorAction extends ResourceAction { - - /** The target action. */ - private IAction fAction; - /** The default label if there is no target action. */ - private String fDefaultText; - /** - * The local help listener - * @since 2.1 - */ - private HelpListener fLocalHelpListener; - /** The listener to pick up changes of the target action. */ - private IPropertyChangeListener fListener= new IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - update(event); - } - }; - - /** - * Creates a new action. The action configures its initial visual - * representation from the given resource bundle. If this action's - * wrapped action is set to <code>null</code> it also uses the - * information in the resource bundle. - * - * @param bundle the resource bundle - * @param prefix a prefix to be prepended to the various resource keys - * (described in <code>ResourceAction</code> constructor), or - * <code>null</code> if none - * @param style one of <code>IAction.AS_PUSH_BUTTON</code>, <code>IAction.AS_CHECK_BOX</code>, - * and <code>IAction.AS_RADIO_BUTTON</code>. - * - * @see ResourceAction#ResourceAction(ResourceBundle, String, int) - * @see IAction#AS_CHECK_BOX - * @see IAction#AS_DROP_DOWN_MENU - * @see IAction#AS_PUSH_BUTTON - * @see IAction#AS_RADIO_BUTTON - * @since 2.1 - */ - public RetargetTextEditorAction(ResourceBundle bundle, String prefix, int style) { - super(bundle, prefix, style); - fDefaultText= getText(); - installHelpListener(); - } - - /** - * Creates a new action. The action configures its initial visual - * representation from the given resource bundle. If this action's - * wrapped action is set to <code>null</code> it also uses the - * information in the resource bundle. - * - * @param bundle the resource bundle - * @param prefix a prefix to be prepended to the various resource keys - * (described in <code>ResourceAction</code> constructor), or - * <code>null</code> if none - * @see ResourceAction#ResourceAction(ResourceBundle, String) - */ - public RetargetTextEditorAction(ResourceBundle bundle, String prefix) { - super(bundle, prefix); - fDefaultText= getText(); - installHelpListener(); - } - - /** - * Creates a new action. The action configures its initial visual - * representation from the given resource bundle. If this action's - * wrapped action is set to <code>null</code> it also uses the - * information in the resource bundle. The action gets the given - * action id. - * - * @param bundle the resource bundle - * @param prefix a prefix to be prepended to the various resource keys - * (described in <code>ResourceAction</code> constructor), or <code>null</code> if none - * @param actionId the action id - * @param style one of <code>IAction.AS_PUSH_BUTTON</code>, <code>IAction.AS_CHECK_BOX</code>, - * and <code>IAction.AS_RADIO_BUTTON</code>. - * - * @see ResourceAction#ResourceAction(ResourceBundle, String, int) - * @see IAction#AS_CHECK_BOX - * @see IAction#AS_DROP_DOWN_MENU - * @see IAction#AS_PUSH_BUTTON - * @see IAction#AS_RADIO_BUTTON - * @since 2.1 - */ - public RetargetTextEditorAction(ResourceBundle bundle, String prefix, String actionId, int style) { - super(bundle, prefix, style); - fDefaultText= getText(); - setId(actionId); - installHelpListener(); - } - - /** - * Creates a new action. The action configures its initial visual - * representation from the given resource bundle. If this action's - * wrapped action is set to <code>null</code> it also uses the - * information in the resource bundle. The action gets the given - * action id. - * - * @param bundle the resource bundle - * @param prefix a prefix to be prepended to the various resource keys - * (described in <code>ResourceAction</code> constructor), or <code>null</code> if none - * @param actionId the action id - * @see ResourceAction#ResourceAction(ResourceBundle, String) - * @since 2.0 - */ - public RetargetTextEditorAction(ResourceBundle bundle, String prefix, String actionId) { - super(bundle, prefix); - fDefaultText= getText(); - setId(actionId); - installHelpListener(); - } - - /** - * Updates to the changes of the underlying action. - * - * @param event the change event describing the state change - */ - private void update(PropertyChangeEvent event) { - if (ENABLED.equals(event.getProperty())) { - Boolean bool= (Boolean) event.getNewValue(); - setEnabled(bool.booleanValue()); - } else if (TEXT.equals(event.getProperty())) - setText((String) event.getNewValue()); - else if (TOOL_TIP_TEXT.equals(event.getProperty())) - setToolTipText((String) event.getNewValue()); - else if (CHECKED.equals(event.getProperty())) { - Boolean bool= (Boolean) event.getNewValue(); - setChecked(bool.booleanValue()); - } - } - - /** - * Sets the underlying action. - * - * @param action the underlying action - */ - public void setAction(IAction action) { - - if (fAction != null) { - fAction.removePropertyChangeListener(fListener); - fAction= null; - } - - fAction= action; - - if (fAction == null) { - - setEnabled(false); - if (getStyle() == AS_CHECK_BOX || getStyle() == AS_RADIO_BUTTON) - setChecked(false); - setText(fDefaultText); - setToolTipText(""); //$NON-NLS-1$ - - } else { - - setEnabled(fAction.isEnabled()); - if (fAction.getStyle() == AS_CHECK_BOX || fAction.getStyle() == AS_RADIO_BUTTON) - super.setChecked(fAction.isChecked()); - setText(fAction.getText()); - setToolTipText(fAction.getToolTipText()); - fAction.addPropertyChangeListener(fListener); - } - } - - /** - * Installs the help listener. - * - * @since 2.1 - */ - private void installHelpListener() { - super.setHelpListener(new HelpListener() { - public void helpRequested(HelpEvent e) { - HelpListener listener= null; - if (fAction != null) { - // if we have a handler, see if it has a help listener - listener= fAction.getHelpListener(); - if (listener == null) - // use our own help listener - listener= fLocalHelpListener; - } - if (listener != null) - // pass on the event - listener.helpRequested(e); - } - }); - } - - /** - * The <code>RetargetTextEditorAction</code> implementation of this method declared on - * <code>IAction</code> stores the help listener in a local field. The - * supplied listener is only used if there is no handler. - * - * @param listener the help listener - * @since 2.1 - */ - public void setHelpListener(HelpListener listener) { - fLocalHelpListener= listener; - } - - /* - * @see IAction#run() - */ - public void run() { - if (fAction != null) - fAction.run(); - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/RevertToSavedAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/RevertToSavedAction.java deleted file mode 100644 index 7da8f18050a..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/RevertToSavedAction.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.texteditor; - - - -import java.util.ResourceBundle; - - -/** - * Action for abandoning changes made in the text editor since the last save - * operation. The action is initially associated with a text editor via the - * constructor, but that can be subsequently changed using <code>setEditor</code>. - * <p> - * This class may be instantiated; it is not intended to be subclassed. - * </p> - */ -public class RevertToSavedAction extends TextEditorAction { - - /** - * Creates a new action for the given text editor. The action configures its - * visual representation from the given resource bundle. - * - * @param bundle the resource bundle - * @param prefix a prefix to be prepended to the various resource keys - * (described in <code>ResourceAction</code> constructor), or - * <code>null</code> if none - * @param editor the text editor - * @see TextEditorAction#TextEditorAction(ResourceBundle, String, ITextEditor) - */ - public RevertToSavedAction(ResourceBundle bundle, String prefix, ITextEditor editor) { - super(bundle, prefix, editor); - } - - /* - * @see IAction#run() - */ - public void run() { - getTextEditor().doRevertToSaved(); - } - - /* - * @see TextEditorAction#update() - */ - public void update() { - setEnabled(getTextEditor().isDirty()); - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SaveAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SaveAction.java deleted file mode 100644 index 6d60b73788a..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SaveAction.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.texteditor; - - - -import java.util.ResourceBundle; - - -/** - * Action for saving recent changes made in the text editor. The action is - * initially associated with a text editor via the constructor, but that can be - * subsequently changed using <code>setEditor</code>. - * <p> - * This class may be instantiated; it is not intended to be subclassed. - * </p> - */ -public class SaveAction extends TextEditorAction { - - /** - * Creates a new action for the given text editor. The action configures its - * visual representation from the given resource bundle. - * - * @param bundle the resource bundle - * @param prefix a prefix to be prepended to the various resource keys - * (described in <code>ResourceAction</code> constructor), or - * <code>null</code> if none - * @param editor the text editor - * @see TextEditorAction#TextEditorAction(ResourceBundle, String, ITextEditor) - */ - public SaveAction(ResourceBundle bundle, String prefix, ITextEditor editor) { - super(bundle, prefix, editor); - } - - /* - * @see IAction#run() - */ - public void run() { - getTextEditor().getSite().getPage().saveEditor(getTextEditor(), false); - } - - /* - * @see TextEditorAction#update() - */ - public void update() { - setEnabled(getTextEditor().isDirty()); - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SelectAnnotationRulerAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SelectAnnotationRulerAction.java deleted file mode 100644 index 09ec1e08bf3..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SelectAnnotationRulerAction.java +++ /dev/null @@ -1,102 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.ui.texteditor; - - -import java.util.ResourceBundle; - -import org.eclipse.swt.widgets.Menu; - -import org.eclipse.jface.text.Position; -import org.eclipse.jface.text.source.Annotation; -import org.eclipse.jface.text.source.IVerticalRulerListener; -import org.eclipse.jface.text.source.IAnnotationModel; -import org.eclipse.jface.text.source.IVerticalRulerInfo; -import org.eclipse.jface.text.source.IVerticalRulerInfoExtension; -import org.eclipse.jface.text.source.VerticalRulerEvent; - -/** - * A ruler action which can select the textual range of an annotation that has a - * visual representation in a vertical ruler. - * - * @since 3.0 - */ -public class SelectAnnotationRulerAction extends TextEditorAction implements IVerticalRulerListener { - - /** - * Creates a new action for the given ruler and editor. The action configures - * its visual representation from the given resource bundle. - * - * @param bundle the resource bundle - * @param prefix a prefix to be prepended to the various resource keys - * (described in <code>ResourceAction</code> constructor), or <code>null</code> if none - * @param editor the editor - * - * @see ResourceAction#ResourceAction(ResourceBundle, String) - */ - public SelectAnnotationRulerAction(ResourceBundle bundle, String prefix, ITextEditor editor) { - super(bundle, prefix, editor); - } - - /* - * @see org.eclipse.ui.texteditor.TextEditorAction#setEditor(org.eclipse.ui.texteditor.ITextEditor) - */ - public void setEditor(ITextEditor editor) { - if (getTextEditor() != null) { - IVerticalRulerInfo service= (IVerticalRulerInfo) getTextEditor().getAdapter(IVerticalRulerInfo.class); - if (service instanceof IVerticalRulerInfoExtension) - ((IVerticalRulerInfoExtension) service).removeVerticalRulerListener(this); - } - super.setEditor(editor); - if (getTextEditor() != null) { - IVerticalRulerInfo service= (IVerticalRulerInfo) getTextEditor().getAdapter(IVerticalRulerInfo.class); - if (service instanceof IVerticalRulerInfoExtension) - ((IVerticalRulerInfoExtension) service).addVerticalRulerListener(this); - } - } - - /** - * Returns the <code>AbstractMarkerAnnotationModel</code> of the editor's input. - * - * @return the marker annotation model or <code>null</code> if there's none - */ - protected IAnnotationModel getAnnotationModel() { - IDocumentProvider provider= getTextEditor().getDocumentProvider(); - return provider.getAnnotationModel(getTextEditor().getEditorInput()); - } - - /* - * @see org.eclipse.ui.texteditor.IVerticalRulerListener#annotationSelected(org.eclipse.ui.texteditor.VerticalRulerEvent) - */ - public void annotationSelected(VerticalRulerEvent event) { - } - - /* - * @see org.eclipse.ui.texteditor.IVerticalRulerListener#annotationDefaultSelected(org.eclipse.ui.texteditor.VerticalRulerEvent) - */ - public void annotationDefaultSelected(VerticalRulerEvent event) { - Annotation a= event.getSelectedAnnotation(); - IAnnotationModel model= getAnnotationModel(); - Position position= model.getPosition(a); - if (position == null) - return; - - getTextEditor().selectAndReveal(position.offset, position.length); - } - - /* - * @see org.eclipse.ui.texteditor.IVerticalRulerListener#annotationContextMenuAboutToShow(org.eclipse.ui.texteditor.VerticalRulerEvent, org.eclipse.swt.widgets.Menu) - */ - public void annotationContextMenuAboutToShow(VerticalRulerEvent event, Menu menu) { - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ShiftAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ShiftAction.java deleted file mode 100644 index a55458ac1c0..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ShiftAction.java +++ /dev/null @@ -1,161 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.ui.texteditor; - - -import java.util.ResourceBundle; - -import org.eclipse.swt.custom.BusyIndicator; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; - -import org.eclipse.jface.text.ITextOperationTarget; - -import org.eclipse.ui.IWorkbenchPartSite; - - - -/** - * Action for shifting code to the right or left by one indentation level. - * @since 2.0 - */ -public class ShiftAction extends TextEditorAction implements IReadOnlyDependent { - - /** The text operation code */ - private int fOperationCode= -1; - /** The text operation target */ - private ITextOperationTarget fOperationTarget; - - /** - * Creates and initializes the action for the given text editor and operation - * code. The action configures its visual representation from the given resource - * bundle. The action works by asking the text editor at the time for its - * text operation target adapter (using - * <code>getAdapter(ITextOperationTarget.class)</code>. The action runs that - * operation with the given opcode. - * - * @param bundle the resource bundle - * @param prefix a prefix to be prepended to the various resource keys - * (described in <code>ResourceAction</code> constructor), or <code>null</code> if none - * @param editor the text editor - * @param operationCode the operation code - * @see TextEditorAction#TextEditorAction(ResourceBundle, String, ITextEditor) - */ - public ShiftAction(ResourceBundle bundle, String prefix, ITextEditor editor, int operationCode) { - super(bundle, prefix, editor); - fOperationCode= operationCode; - update(); - } - - /** - * The <code>TextOperationAction</code> implementation of this - * <code>IAction</code> method runs the operation with the current - * operation code. - */ - public void run() { - if (fOperationCode == -1 || fOperationTarget == null) - return; - - ITextEditor editor= getTextEditor(); - if (editor == null) - return; - - if (!validateEditorInputState()) - return; - - Display display= null; - - IWorkbenchPartSite site= editor.getSite(); - Shell shell= site.getShell(); - if (shell != null && !shell.isDisposed()) - display= shell.getDisplay(); - - BusyIndicator.showWhile(display, new Runnable() { - public void run() { - fOperationTarget.doOperation(fOperationCode); - } - }); - } - - /* - * @see IUpdate#update() - */ - public void update() { - super.update(); - if (!isEnabled()) - return; - - if (!canModifyEditor()) { - setEnabled(false); - return; - } - - ITextEditor editor= getTextEditor(); - if (fOperationTarget == null && editor != null && fOperationCode != -1) - fOperationTarget= (ITextOperationTarget) editor.getAdapter(ITextOperationTarget.class); - - } - - /** - * Enablement when tab key is pressed - the current selection has to be cover multiple lines. - * - * @since 3.0 - */ - protected void updateForTab() { - super.update(); - - if (isEnabled()) { - if (!canModifyEditor()) { - setEnabled(false); - return; - } - - ITextEditor editor= getTextEditor(); - if (fOperationTarget == null && editor != null && fOperationCode != -1) - fOperationTarget= (ITextOperationTarget) editor.getAdapter(ITextOperationTarget.class); - - boolean isEnabled= (fOperationTarget != null && fOperationTarget.canDoOperation(fOperationCode)); - setEnabled(isEnabled); - } - - } - - /* - * @see TextEditorAction#setEditor(ITextEditor) - */ - public void setEditor(ITextEditor editor) { - super.setEditor(editor); - fOperationTarget= null; - } - - /* - * @see IReadOnlyDependent#isEnabled(boolean) - */ - public boolean isEnabled(boolean isWritable) { - - if (!isWritable) - return false; - - /* - * Note that this implementation still honors the result returned by canDoOperation. - * I.e. if the viewer is set to read-only, this method still returns false. - * It covers the case in which the viewer is also writable. - * - */ - ITextEditor editor= getTextEditor(); - if (fOperationTarget == null && editor!= null && fOperationCode != -1) - fOperationTarget= (ITextOperationTarget) editor.getAdapter(ITextOperationTarget.class); - - return (fOperationTarget != null && fOperationTarget.canDoOperation(fOperationCode)); - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SourceViewerDecorationSupport.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SourceViewerDecorationSupport.java deleted file mode 100644 index 46fdfdd5374..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SourceViewerDecorationSupport.java +++ /dev/null @@ -1,981 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.texteditor; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import org.eclipse.swt.custom.StyledText; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.RGB; - -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.preference.PreferenceConverter; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; - -import org.eclipse.jface.text.CursorLinePainter; -import org.eclipse.jface.text.IPainter; -import org.eclipse.jface.text.ITextViewerExtension2; -import org.eclipse.jface.text.ITextViewerExtension4; -import org.eclipse.jface.text.MarginPainter; -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.ICharacterPairMatcher; -import org.eclipse.jface.text.source.IOverviewRuler; -import org.eclipse.jface.text.source.ISharedTextColors; -import org.eclipse.jface.text.source.ISourceViewer; -import org.eclipse.jface.text.source.MatchingCharacterPainter; -import org.eclipse.jface.text.source.AnnotationPainter.IDrawingStrategy; - -/** - * Support class used by text editors to draw and update decorations on the - * source viewer and its rulers. An instance of this class is independent of a - * certain editor and must be configured with the needed preference keys and - * helper objects before it can be used. - * <p> - * Once configured, an instance may be installed (see - * {@link #install(IPreferenceStore) install}) on a preference store, from then - * on monitoring the configured preference settings and changing the respective - * decorations. Calling {@link #uninstall() uninstall} will unregister the - * listeners with the preferences store and must be called before changing the - * preference store by another call to <code>install</code>.<br> - * {@link #dispose() dispose} will uninstall the support and remove any - * decorations from the viewer. It is okay to reuse a - * <code>SourceViewerDecorationSupport</code> instance after disposing it. - * </p> - * <p> - * <code>SourceViewerDecorationSupport</code> can draw the following - * decorations: - * <ul> - * <li>matching character highlighting,</li> - * <li>current line highlighting,</li> - * <li>print margin, and</li> - * <li>annotations.</li> - * </ul> - * Annotations are managed for the overview ruler and also drawn onto the text - * widget by an - * {@link org.eclipse.jface.text.source.AnnotationPainter AnnotationPainter} - * instance. - * </p> - * <p> - * Subclasses may add decorations but should adhere to the lifecyle described - * above. - * </p> - * - * @see org.eclipse.jface.text.source.AnnotationPainter - * @since 2.1 - */ -public class SourceViewerDecorationSupport { - - - /** - * Underline drawing strategy. - * - * @since 3.0 - */ - private static final class UnderlineDrawingStrategy implements IDrawingStrategy { - - /* - * @see org.eclipse.jface.text.source.AnnotationPainter.IDrawingStrategy#draw(org.eclipse.jface.text.source.Annotation, 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) { - - Point left= textWidget.getLocationAtOffset(offset); - Point right= textWidget.getLocationAtOffset(offset + length); - int y= left.y + textWidget.getLineHeight() - 1; - - gc.setForeground(color); - gc.drawLine(left.x, y, right.x, y); - - } else { - textWidget.redrawRange(offset, length, true); - } - } - } - - /** - * Draws a box around a given range. - * - * @since 3.0 - */ - private static final class BoxDrawingStrategy implements IDrawingStrategy { - /* - * @see org.eclipse.jface.text.source.AnnotationPainter.IDrawingStrategy#draw(org.eclipse.jface.text.source.Annotation, 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 (length == 0) { - fgIBeamStrategy.draw(annotation, gc, textWidget, offset, length, color); - return; - } - - if (gc != null) { - - Point left= textWidget.getLocationAtOffset(offset); - Point right= textWidget.getLocationAtOffset(offset + length); - int x1= left.x; - int x2= right.x - 1; - int y1= left.y; - int y2= y1 + textWidget.getLineHeight() - 1; - - gc.setForeground(color); - gc.drawRectangle(x1, y1, x2 - x1, y2 - y1); - - } else { - textWidget.redrawRange(offset, length, true); - } - } - } - - /** - * Draws an iBeam at the given offset, the length is ignored. - * - * @since 3.0 - */ - private static final class IBeamStrategy implements IDrawingStrategy { - - /* - * @see org.eclipse.jface.text.source.AnnotationPainter.IDrawingStrategy#draw(org.eclipse.jface.text.source.Annotation, 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) { - - Point left= textWidget.getLocationAtOffset(offset); - int x1= left.x; - int y1= left.y; - - gc.setForeground(color); - gc.drawLine(x1, y1, x1, left.y + textWidget.getLineHeight() - 1); - - } else { - textWidget.redrawRange(offset, length, true); - } - } - } - - /** - * The box drawing strategy. - * @since 3.0 - */ - private static IDrawingStrategy fgBoxStrategy= new BoxDrawingStrategy(); - - /** - * The null drawing strategy. - * @since 3.0 - */ - private static IDrawingStrategy fgNullStrategy= new AnnotationPainter.NullStrategy(); - - /** - * The underline drawing strategy. - * @since 3.0 - */ - private static IDrawingStrategy fgUnderlineStrategy= new UnderlineDrawingStrategy(); - - /** - * The iBeam drawing strategy. - * @since 3.0 - */ - private static IDrawingStrategy fgIBeamStrategy= new IBeamStrategy(); - - /** - * The squiggles drawing strategy. - * @since 3.0 - */ - private static IDrawingStrategy fgSquigglesStrategy= new AnnotationPainter.SquigglesStrategy(); - - /* - * @see IPropertyChangeListener - */ - private class FontPropertyChangeListener implements IPropertyChangeListener { - /* - * @see IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) - */ - public void propertyChange(PropertyChangeEvent event) { - if (fMarginPainter != null && fSymbolicFontName != null && fSymbolicFontName.equals(event.getProperty())) - fMarginPainter.initialize(); - } - } - - - /** The viewer */ - private ISourceViewer fSourceViewer; - /** The viewer's overview ruler */ - private IOverviewRuler fOverviewRuler; - /** The annotation access */ - private IAnnotationAccess fAnnotationAccess; - /** The shared color manager */ - private ISharedTextColors fSharedTextColors; - - /** The editor's line painter */ - private CursorLinePainter fCursorLinePainter; - /** The editor's margin ruler painter */ - private MarginPainter fMarginPainter; - /** The editor's annotation painter */ - private AnnotationPainter fAnnotationPainter; - /** The editor's peer character painter */ - private MatchingCharacterPainter fMatchingCharacterPainter; - /** The character painter's pair matcher */ - private ICharacterPairMatcher fCharacterPairMatcher; - - /** Table of annotation type preference infos */ - private Map fAnnotationTypeKeyMap= new HashMap(); - /** Preference key for the cursor line highlighting */ - private String fCursorLinePainterEnableKey; - /** Preference key for the cursor line background color */ - private String fCursorLinePainterColorKey; - /** Preference key for the margin painter */ - private String fMarginPainterEnableKey; - /** Preference key for the margin painter color */ - private String fMarginPainterColorKey; - /** Preference key for the margin painter column */ - private String fMarginPainterColumnKey; - /** Preference key for the matching character painter */ - private String fMatchingCharacterPainterEnableKey; - /** Preference key for the matching character painter color */ - private String fMatchingCharacterPainterColorKey; - /** The property change listener */ - private IPropertyChangeListener fPropertyChangeListener; - /** The preference store */ - private IPreferenceStore fPreferenceStore; - /** The symbolic font name */ - private String fSymbolicFontName; - /** The font change listener */ - private FontPropertyChangeListener fFontPropertyChangeListener; - - - /** - * Creates a new decoration support for the given viewer. - * - * @param sourceViewer the source viewer - * @param overviewRuler the viewer's overview ruler - * @param annotationAccess the annotation access - * @param sharedTextColors the shared text color manager - */ - public SourceViewerDecorationSupport(ISourceViewer sourceViewer, IOverviewRuler overviewRuler, IAnnotationAccess annotationAccess, ISharedTextColors sharedTextColors) { - fSourceViewer= sourceViewer; - fOverviewRuler= overviewRuler; - fAnnotationAccess= annotationAccess; - fSharedTextColors= sharedTextColors; - } - - /** - * Installs this decoration support on the given preference store. It assumes - * that this support has completely been configured. - * - * @param store the preference store - */ - public void install(IPreferenceStore store) { - - fPreferenceStore= store; - if (fPreferenceStore != null) { - fPropertyChangeListener= new IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - handlePreferenceStoreChanged(event); - } - }; - fPreferenceStore.addPropertyChangeListener(fPropertyChangeListener); - } - - updateTextDecorations(); - updateOverviewDecorations(); - } - - /** - * Updates the text decorations for all configured annotation types. - */ - private void updateTextDecorations() { - - StyledText widget= fSourceViewer.getTextWidget(); - if (widget == null || widget.isDisposed()) - return; - - if (areMatchingCharactersShown()) - showMatchingCharacters(); - else - hideMatchingCharacters(); - - if (isCursorLineShown()) - showCursorLine(); - else - hideCursorLine(); - - if (isMarginShown()) - showMargin(); - else - hideMargin(); - - Iterator e= fAnnotationTypeKeyMap.keySet().iterator(); - while (e.hasNext()) { - Object type= e.next(); - Object style= getAnnotationDecorationType(type); - if (style != AnnotationPreference.STYLE_NONE) - showAnnotations(type, false, false); - else - hideAnnotations(type, false, false); - if (areAnnotationsHighlighted(type)) - showAnnotations(type, true, false); - else - hideAnnotations(type, true, false); - - } - updateAnnotationPainter(); - } - - /** - * Returns the annotation decoration style used for the show in text preference for - * a given annotation type. - * - * @param annotationType the annotation type being looked up - * @return the decoration style for <code>type</code> - * @since 3.0 - */ - private Object getAnnotationDecorationType(Object annotationType) { - if (areAnnotationsShown(annotationType) && fPreferenceStore != null) { - AnnotationPreference info= (AnnotationPreference) fAnnotationTypeKeyMap.get(annotationType); - if (info != null) { - String key= info.getTextStylePreferenceKey(); - if (key != null) - return fPreferenceStore.getString(key); - else - // legacy - return AnnotationPreference.STYLE_SQUIGGLES; - } - } - return AnnotationPreference.STYLE_NONE; - } - - /** - * Updates the annotation overview for all configured annotation types. - */ - public void updateOverviewDecorations() { - if (fOverviewRuler != null) { - Iterator e= fAnnotationTypeKeyMap.keySet().iterator(); - while (e.hasNext()) { - Object type= e.next(); - if (isAnnotationOverviewShown(type)) - showAnnotationOverview(type, false); - else - hideAnnotationOverview(type, false); - } - fOverviewRuler.update(); - } - } - - /** - * Uninstalls this support from the preference store it has previously been - * installed on. If there is no such preference store, this call is without - * effect. - */ - public void uninstall() { - - if (fPreferenceStore != null) { - fPreferenceStore.removePropertyChangeListener(fPropertyChangeListener); - fPropertyChangeListener= null; - fPreferenceStore= null; - } - - if (fFontPropertyChangeListener != null) { - JFaceResources.getFontRegistry().removeListener(fFontPropertyChangeListener); - fFontPropertyChangeListener= null; - } - } - - /** - * Disposes this decoration support. Internally calls - * <code>uninstall</code>. - */ - public void dispose() { - uninstall(); - updateTextDecorations(); - updateOverviewDecorations(); - } - - /** - * Sets the character pair matcher for the matching character painter. - * - * @param pairMatcher - */ - public void setCharacterPairMatcher(ICharacterPairMatcher pairMatcher) { - fCharacterPairMatcher= pairMatcher; - } - - /** - * Sets the preference keys for the annotation painter. - * - * @param type the annotation type - * @param colorKey the preference key for the color - * @param editorKey the preference key for the presentation in the text area - * @param overviewRulerKey the preference key for the presentation in the overview ruler - * @param layer the layer - */ - public void setAnnotationPainterPreferenceKeys(Object type, String colorKey, String editorKey, String overviewRulerKey, int layer) { - AnnotationPreference info= new AnnotationPreference(type, colorKey, editorKey, overviewRulerKey, layer); - fAnnotationTypeKeyMap.put(type, info); - } - - /** - * Sets the preference info for the annotation painter. - * @param info the preference info to be set - */ - public void setAnnotationPreference(AnnotationPreference info) { - fAnnotationTypeKeyMap.put(info.getAnnotationType(), info); - } - - /** - * Sets the preference keys for the cursor line painter. - * @param enableKey the preference key for the cursor line painter - * @param colorKey the preference key for the color used by the cursor line - * painter - */ - public void setCursorLinePainterPreferenceKeys(String enableKey, String colorKey) { - fCursorLinePainterEnableKey= enableKey; - fCursorLinePainterColorKey= colorKey; - } - - /** - * Sets the preference keys for the margin painter. - * @param enableKey the preference key for the margin painter - * @param colorKey the preference key for the color used by the margin - * painter - * @param columnKey the preference key for the margin column - */ - public void setMarginPainterPreferenceKeys(String enableKey, String colorKey, String columnKey) { - fMarginPainterEnableKey= enableKey; - fMarginPainterColorKey= colorKey; - fMarginPainterColumnKey= columnKey; - } - - /** - * Sets the preference keys for the matching character painter. - * @param enableKey the preference key for the matching character painter - * @param colorKey the preference key for the color used by the matching - * character painter - */ - public void setMatchingCharacterPainterPreferenceKeys(String enableKey, String colorKey) { - fMatchingCharacterPainterEnableKey= enableKey; - fMatchingCharacterPainterColorKey= colorKey; - } - - /** - * Sets the symbolic font name that is used for computing the margin width. - * @param symbolicFontName - */ - public void setSymbolicFontName(String symbolicFontName) { - fSymbolicFontName= symbolicFontName; - } - - /** - * Returns the annotation preference for the given key. - * - * @param preferenceKey the preference key string - * @return the annotation preference - */ - private AnnotationPreference getAnnotationPreferenceInfo(String preferenceKey) { - Iterator e= fAnnotationTypeKeyMap.values().iterator(); - while (e.hasNext()) { - AnnotationPreference info= (AnnotationPreference) e.next(); - if (info != null && info.isPreferenceKey(preferenceKey)) - return info; - } - return null; - } - - - /* - * @see AbstractTextEditor#handlePreferenceStoreChanged(PropertyChangeEvent) - */ - protected void handlePreferenceStoreChanged(PropertyChangeEvent event) { - - String p= event.getProperty(); - - if (fMatchingCharacterPainterEnableKey != null && fMatchingCharacterPainterEnableKey.equals(p) && fCharacterPairMatcher != null) { - if (areMatchingCharactersShown()) - showMatchingCharacters(); - else - hideMatchingCharacters(); - return; - } - - if (fMatchingCharacterPainterColorKey != null && fMatchingCharacterPainterColorKey.equals(p)) { - if (fMatchingCharacterPainter != null) { - fMatchingCharacterPainter.setColor(getColor(fMatchingCharacterPainterColorKey)); - fMatchingCharacterPainter.paint(IPainter.CONFIGURATION); - } - return; - } - - if (fCursorLinePainterEnableKey != null && fCursorLinePainterEnableKey.equals(p)) { - if (isCursorLineShown()) - showCursorLine(); - else - hideCursorLine(); - return; - } - - if (fCursorLinePainterColorKey != null && fCursorLinePainterColorKey.equals(p)) { - if (fCursorLinePainter != null) { - hideCursorLine(); - showCursorLine(); - } - return; - } - - if (fMarginPainterEnableKey != null && fMarginPainterEnableKey.equals(p)) { - if (isMarginShown()) - showMargin(); - else - hideMargin(); - return; - } - - if (fMarginPainterColorKey != null && fMarginPainterColorKey.equals(p)) { - if (fMarginPainter != null) { - fMarginPainter.setMarginRulerColor(getColor(fMarginPainterColorKey)); - fMarginPainter.paint(IPainter.CONFIGURATION); - } - return; - } - - if (fMarginPainterColumnKey != null && fMarginPainterColumnKey.equals(p)) { - if (fMarginPainter != null && fPreferenceStore != null) { - fMarginPainter.setMarginRulerColumn(fPreferenceStore.getInt(fMarginPainterColumnKey)); - fMarginPainter.paint(IPainter.CONFIGURATION); - } - return; - } - - AnnotationPreference info= getAnnotationPreferenceInfo(p); - if (info != null) { - - if (info.getColorPreferenceKey().equals(p)) { - Color color= getColor(info.getColorPreferenceKey()); - if (fAnnotationPainter != null) { - fAnnotationPainter.setAnnotationTypeColor(info.getAnnotationType(), color); - fAnnotationPainter.paint(IPainter.CONFIGURATION); - } - setAnnotationOverviewColor(info.getAnnotationType(), color); - return; - } - - if (info.getTextPreferenceKey().equals(p) || info.getTextStylePreferenceKey() != null && info.getTextStylePreferenceKey().equals(p)) { - Object style= getAnnotationDecorationType(info.getAnnotationType()); - if (AnnotationPreference.STYLE_NONE != style) - showAnnotations(info.getAnnotationType(), false, true); - else - hideAnnotations(info.getAnnotationType(), false, true); - return; - } - - if (info.getHighlightPreferenceKey() != null && info.getHighlightPreferenceKey().equals(p)) { - if (areAnnotationsHighlighted(info.getAnnotationType())) - showAnnotations(info.getAnnotationType(), true, true); - else - hideAnnotations(info.getAnnotationType(), true, true); - return; - } - - Object style= getAnnotationDecorationType(info.getAnnotationType()); - if (style != AnnotationPreference.STYLE_NONE) - showAnnotations(info.getAnnotationType(), false, false); - else - hideAnnotations(info.getAnnotationType(), false, false); - - if (info.getOverviewRulerPreferenceKey().equals(p)) { - if (isAnnotationOverviewShown(info.getAnnotationType())) - showAnnotationOverview(info.getAnnotationType(), true); - else - hideAnnotationOverview(info.getAnnotationType(), true); - return; - } - } - - } - - /** - * Returns the shared color for the given key. - * - * @param key the color key string - * @return the shared color for the given key - */ - private Color getColor(String key) { - if (fPreferenceStore != null) { - RGB rgb= PreferenceConverter.getColor(fPreferenceStore, key); - return getColor(rgb); - } - return null; - } - - /** - * Returns the shared color for the given RGB. - * - * @param rgb the RGB - * @return the shared color for the given RGB - */ - private Color getColor(RGB rgb) { - return fSharedTextColors.getColor(rgb); - } - - /** - * Returns the color of the given annotation type. - * - * @param annotationType the annotation type - * @return the color of the annotation type - */ - private Color getAnnotationTypeColor(Object annotationType) { - AnnotationPreference info= (AnnotationPreference) fAnnotationTypeKeyMap.get(annotationType); - if (info != null) - return getColor( info.getColorPreferenceKey()); - return null; - } - - - - /** - * Returns the layer of the given annotation type. - * - * @param annotationType the annotation type - * @return the layer - */ - private int getAnnotationTypeLayer(Object annotationType) { - AnnotationPreference info= (AnnotationPreference) fAnnotationTypeKeyMap.get(annotationType); - if (info != null) - return info.getPresentationLayer(); - return 0; - } - - /** - * Enables showing of matching characters. - */ - private void showMatchingCharacters() { - if (fMatchingCharacterPainter == null) { - if (fSourceViewer instanceof ITextViewerExtension2) { - fMatchingCharacterPainter= new MatchingCharacterPainter(fSourceViewer, fCharacterPairMatcher); - fMatchingCharacterPainter.setColor(getColor(fMatchingCharacterPainterColorKey)); - ITextViewerExtension2 extension= (ITextViewerExtension2) fSourceViewer; - extension.addPainter(fMatchingCharacterPainter); - } - } - } - - /** - * Disables showing of matching characters. - */ - private void hideMatchingCharacters() { - if (fMatchingCharacterPainter != null) { - if (fSourceViewer instanceof ITextViewerExtension2) { - ITextViewerExtension2 extension= (ITextViewerExtension2) fSourceViewer; - extension.removePainter(fMatchingCharacterPainter); - fMatchingCharacterPainter.deactivate(true); - fMatchingCharacterPainter.dispose(); - fMatchingCharacterPainter= null; - } - } - } - - /** - * Tells whether matching characters are shown. - * - * @return <code>true</code> if the matching characters are shown - */ - private boolean areMatchingCharactersShown() { - if (fPreferenceStore != null && fMatchingCharacterPainterEnableKey != null) - return fPreferenceStore.getBoolean(fMatchingCharacterPainterEnableKey); - return false; - } - - /** - * Shows the cursor line. - */ - private void showCursorLine() { - if (fCursorLinePainter == null) { - if (fSourceViewer instanceof ITextViewerExtension2) { - fCursorLinePainter= new CursorLinePainter(fSourceViewer); - fCursorLinePainter.setHighlightColor(getColor(fCursorLinePainterColorKey)); - ITextViewerExtension2 extension= (ITextViewerExtension2) fSourceViewer; - extension.addPainter(fCursorLinePainter); - } - } - } - - /** - * Hides the cursor line. - */ - private void hideCursorLine() { - if (fCursorLinePainter != null) { - if (fSourceViewer instanceof ITextViewerExtension2) { - ITextViewerExtension2 extension= (ITextViewerExtension2) fSourceViewer; - extension.removePainter(fCursorLinePainter); - fCursorLinePainter.deactivate(true); - fCursorLinePainter.dispose(); - fCursorLinePainter= null; - } - } - } - - /** - * Tells whether the cursor line is shown. - * - * @return <code>true</code> if the cursor line is shown - */ - private boolean isCursorLineShown() { - if (fPreferenceStore != null && fCursorLinePainterEnableKey != null) - return fPreferenceStore.getBoolean(fCursorLinePainterEnableKey); - return false; - } - - /** - * Shows the margin. - */ - private void showMargin() { - if (fMarginPainter == null) { - if (fSourceViewer instanceof ITextViewerExtension2) { - fMarginPainter= new MarginPainter(fSourceViewer); - fMarginPainter.setMarginRulerColor(getColor(fMarginPainterColorKey)); - if (fPreferenceStore != null) - fMarginPainter.setMarginRulerColumn(fPreferenceStore.getInt(fMarginPainterColumnKey)); - ITextViewerExtension2 extension= (ITextViewerExtension2) fSourceViewer; - extension.addPainter(fMarginPainter); - - fFontPropertyChangeListener= new FontPropertyChangeListener(); - JFaceResources.getFontRegistry().addListener(fFontPropertyChangeListener); - } - } - } - - /** - * Hides the margin. - */ - private void hideMargin() { - if (fMarginPainter != null) { - if (fSourceViewer instanceof ITextViewerExtension2) { - JFaceResources.getFontRegistry().removeListener(fFontPropertyChangeListener); - fFontPropertyChangeListener= null; - - ITextViewerExtension2 extension= (ITextViewerExtension2) fSourceViewer; - extension.removePainter(fMarginPainter); - fMarginPainter.deactivate(true); - fMarginPainter.dispose(); - fMarginPainter= null; - } - } - } - - /** - * Tells whether the margin is shown. - * - * @return <code>true</code> if the margin is shown - */ - private boolean isMarginShown() { - if (fPreferenceStore != null && fMarginPainterEnableKey != null) - return fPreferenceStore.getBoolean(fMarginPainterEnableKey); - return false; - } - - /** - * Enables annotations in the source viewer for the given annotation type. - * - * @param annotationType the annotation type - * @param highlighting <code>true</code> if highlighting <code>false</code> if painting squiggles - * @param updatePainter if <code>true</code> update the annotation painter - * @since 3.0 - */ - private void showAnnotations(Object annotationType, boolean highlighting, boolean updatePainter) { - if (fSourceViewer instanceof ITextViewerExtension2) { - if (fAnnotationPainter == null) { - fAnnotationPainter= createAnnotationPainter(); - if (fSourceViewer instanceof ITextViewerExtension4) - ((ITextViewerExtension4)fSourceViewer).addTextPresentationListener(fAnnotationPainter); - ITextViewerExtension2 extension= (ITextViewerExtension2) fSourceViewer; - extension.addPainter(fAnnotationPainter); - } - fAnnotationPainter.setAnnotationTypeColor(annotationType, getAnnotationTypeColor(annotationType)); - if (highlighting) - fAnnotationPainter.addHighlightAnnotationType(annotationType); - else - fAnnotationPainter.addAnnotationType(annotationType, getAnnotationDecorationType(annotationType)); - - if (updatePainter) - updateAnnotationPainter(); - } - } - - /** - * Creates and configures the annotation painter and configures. - * @return an annotation painter - * @since 3.0 - */ - protected AnnotationPainter createAnnotationPainter() { - AnnotationPainter painter= new AnnotationPainter(fSourceViewer, fAnnotationAccess); - - // TODO add extension point for drawing strategies? - painter.addDrawingStrategy(AnnotationPreference.STYLE_BOX, fgBoxStrategy); - painter.addDrawingStrategy(AnnotationPreference.STYLE_NONE, fgNullStrategy); - painter.addDrawingStrategy(AnnotationPreference.STYLE_SQUIGGLES, fgSquigglesStrategy); - painter.addDrawingStrategy(AnnotationPreference.STYLE_UNDERLINE, fgUnderlineStrategy); - painter.addDrawingStrategy(AnnotationPreference.STYLE_IBEAM, fgIBeamStrategy); - - return painter; - } - - /** - * Updates the annotation painter. - * @since 3.0 - */ - private void updateAnnotationPainter() { - if (fAnnotationPainter == null) - return; - - fAnnotationPainter.paint(IPainter.CONFIGURATION); - if (!fAnnotationPainter.isPaintingAnnotations()) { - if (fSourceViewer instanceof ITextViewerExtension2) { - ITextViewerExtension2 extension= (ITextViewerExtension2) fSourceViewer; - extension.removePainter(fAnnotationPainter); - } - if (fSourceViewer instanceof ITextViewerExtension4) - ((ITextViewerExtension4)fSourceViewer).removeTextPresentationListener(fAnnotationPainter); - - fAnnotationPainter.deactivate(true); - fAnnotationPainter.dispose(); - fAnnotationPainter= null; - } - } - - /** - * Hides annotations in the source viewer for the given annotation type. - * - * @param annotationType the annotation type - * @param highlighting <code>true</code> if highlighting <code>false</code> if painting squiggles - * @param updatePainter if <code>true</code> update the annotation painter - * @since 3.0 - */ - private void hideAnnotations(Object annotationType, boolean highlighting, boolean updatePainter) { - if (fAnnotationPainter != null) { - if (highlighting) - fAnnotationPainter.removeHighlightAnnotationType(annotationType); - else - fAnnotationPainter.removeAnnotationType(annotationType); - - if (updatePainter) { - updateAnnotationPainter(); - } - } - } - - /** - * Tells whether annotations are shown in the source viewer for the given type. - * - * @param annotationType the annotation type - * @return <code>true</code> if the annotations are shown - */ - private boolean areAnnotationsShown(Object annotationType) { - if (fPreferenceStore != null) { - AnnotationPreference info= (AnnotationPreference) fAnnotationTypeKeyMap.get(annotationType); - if (info != null) { - String key= info.getTextPreferenceKey(); - return key != null && fPreferenceStore.getBoolean(key); - } - } - return false; - } - - /** - * Tells whether annotations are highlighted in the source viewer for the given type. - * - * @param annotationType the annotation type - * @return <code>true</code> if the annotations are highlighted - * @since 3.0 - */ - private boolean areAnnotationsHighlighted(Object annotationType) { - if (fPreferenceStore != null) { - AnnotationPreference info= (AnnotationPreference)fAnnotationTypeKeyMap.get(annotationType); - if (info != null) - return info.getHighlightPreferenceKey() != null && fPreferenceStore.getBoolean(info.getHighlightPreferenceKey()); - } - return false; - } - - /** - * Tells whether annotation overview is enabled for the given type. - * - * @param annotationType the annotation type - * @return <code>true</code> if the annotation overview is shown - */ - private boolean isAnnotationOverviewShown(Object annotationType) { - if (fPreferenceStore != null && fOverviewRuler != null) { - AnnotationPreference info= (AnnotationPreference) fAnnotationTypeKeyMap.get(annotationType); - if (info != null) - return fPreferenceStore.getBoolean(info.getOverviewRulerPreferenceKey()); - } - return false; - } - - /** - * Enable annotation overview for the given annotation type. - * - * @param annotationType the annotation type - * @param update <code>true</code> if the overview should be updated - */ - private void showAnnotationOverview(Object annotationType, boolean update) { - if (fOverviewRuler != null) { - fOverviewRuler.setAnnotationTypeColor(annotationType, getAnnotationTypeColor(annotationType)); - fOverviewRuler.setAnnotationTypeLayer(annotationType, getAnnotationTypeLayer(annotationType)); - fOverviewRuler.addAnnotationType(annotationType); - if (update) - fOverviewRuler.update(); - } - } - - /** - * Hides the annotation overview for the given type. - * @param annotationType the annotation type - * @param update <code>true</code> if the overview should be updated - */ - private void hideAnnotationOverview(Object annotationType, boolean update) { - if (fOverviewRuler != null) { - fOverviewRuler.removeAnnotationType(annotationType); - if (update) - fOverviewRuler.update(); - } - } - - /** - * Hides the annotation overview. - */ - public void hideAnnotationOverview() { - if (fOverviewRuler != null) { - Iterator e= fAnnotationTypeKeyMap.keySet().iterator(); - while (e.hasNext()) - fOverviewRuler.removeAnnotationType(e.next()); - fOverviewRuler.update(); - } - } - - /** - * Sets the annotation overview color for the given annotation type. - * - * @param annotationType the annotation type - * @param color the color - */ - private void setAnnotationOverviewColor(Object annotationType, Color color) { - if (fOverviewRuler != null) { - fOverviewRuler.setAnnotationTypeColor(annotationType, color); - fOverviewRuler.update(); - } - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/StatusLineContributionItem.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/StatusLineContributionItem.java deleted file mode 100644 index 15885d446cb..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/StatusLineContributionItem.java +++ /dev/null @@ -1,288 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.texteditor; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CLabel; -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.MouseListener; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; - -import org.eclipse.jface.action.ContributionItem; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.action.StatusLineLayoutData; -import org.eclipse.jface.resource.JFaceColors; - -/** - * Contribution item for the status line. - * @since 2.0 - */ -public class StatusLineContributionItem extends ContributionItem implements IStatusField, IStatusFieldExtension { - - /** - * Internal mouse listener to track double clicking the status line item. - * @since 3.0 - */ - private class Listener extends MouseAdapter { - /* - * @see org.eclipse.swt.events.MouseAdapter#mouseDoubleClick(org.eclipse.swt.events.MouseEvent) - */ - public void mouseDoubleClick(MouseEvent e) { - if (fActionHandler != null && fActionHandler.isEnabled()) - fActionHandler.run(); - } - } - - /** - * Left and right margin used in CLabel. - * @since 2.1 - */ - private static final int INDENT= 3; - /** - * Default number of characters that should fit into the item. - * @since 3.0 - */ - static final int DEFAULT_WIDTH_IN_CHARS= 14; - /** - * Precomputed label width hint. - * @since 2.1 - */ - private int fFixedWidth= -1; - /** - * Precomputed label height hint. - * @since 3.0 - */ - private int fFixedHeight= -1; - /** The text */ - private String fText; - /** The image */ - private Image fImage; - /** - * The error text. - * @since 3.0 - */ - private String fErrorText; - /** - * The error image. - * @since 3.0 - */ - private Image fErrorImage; - /** - * The tool tip text. - * @since 3.0 - */ - private String fToolTipText; - /** - * Number of characters that should fit into the item. - * @since 3.0 - */ - private int fWidthInChars; - /** The status line label widget */ - private CLabel fLabel; - /** - * The action handler. - * @since 3.0 - */ - private IAction fActionHandler; - /** - * The mouse listener - * @since 3.0 - */ - private MouseListener fMouseListener; - - - /** - * Creates a new item with the given id. - * - * @param id the item's id - */ - public StatusLineContributionItem(String id) { - this(id, true, DEFAULT_WIDTH_IN_CHARS); - } - - /** - * Creates a new item with the given attributes. - * - * @param id the item's id - * @param visible the visibility of this item - * @param widthInChars the width in characters - * @since 3.0 - */ - public StatusLineContributionItem(String id, boolean visible, int widthInChars) { - super(id); - setVisible(visible); - fWidthInChars= widthInChars; - } - - /* - * @see IStatusField#setText(String) - */ - public void setText(String text) { - fText= text; - updateMessageLabel(); - } - - /* - * @see IStatusField#setImage(Image) - */ - public void setImage(Image image) { - fImage= image; - updateMessageLabel(); - } - - /* - * @see org.eclipse.ui.texteditor.IStatusFieldExtension#setErrorText(java.lang.String) - * @since 3.0 - */ - public void setErrorText(String text) { - fErrorText= text; - updateMessageLabel(); - } - - /* - * @see org.eclipse.ui.texteditor.IStatusFieldExtension#setErrorImage(org.eclipse.swt.graphics.Image) - * @since 3.0 - */ - public void setErrorImage(Image image) { - fErrorImage= image; - updateMessageLabel(); - } - - /* - * @see org.eclipse.ui.texteditor.IStatusFieldExtension#setToolTipText(java.lang.String) - * @since 3.0 - */ - public void setToolTipText(String string) { - fToolTipText= string; - updateMessageLabel(); - } - - /* - * @see IContributionItem#fill(Composite) - */ - public void fill(Composite parent) { - - Label sep= new Label(parent, SWT.SEPARATOR); - fLabel= new CLabel(parent, SWT.SHADOW_NONE); - - fLabel.addDisposeListener(new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - fMouseListener= null; - } - }); - if (fActionHandler != null) { - fMouseListener= new Listener(); - fLabel.addMouseListener(fMouseListener); - } - - StatusLineLayoutData data= new StatusLineLayoutData(); - data.widthHint= getWidthHint(parent); - fLabel.setLayoutData(data); - - data= new StatusLineLayoutData(); - data.heightHint= getHeightHint(parent); - sep.setLayoutData(data); - - updateMessageLabel(); - } - - public void setActionHandler(IAction actionHandler) { - if (fActionHandler != null && actionHandler == null && fMouseListener != null) { - if (!fLabel.isDisposed()) - fLabel.removeMouseListener(fMouseListener); - fMouseListener= null; - } - - fActionHandler= actionHandler; - - if (fLabel != null && !fLabel.isDisposed() && fMouseListener == null && fActionHandler != null) { - fMouseListener= new Listener(); - fLabel.addMouseListener(fMouseListener); - } - } - - /** - * Returns the width hint for this label. - * - * @param control the root control of this label - * @return the width hint for this label - * @since 2.1 - */ - private int getWidthHint(Composite control) { - if (fFixedWidth < 0) { - GC gc= new GC(control); - gc.setFont(control.getFont()); - fFixedWidth= gc.getFontMetrics().getAverageCharWidth() * fWidthInChars; - fFixedWidth += INDENT * 2; - gc.dispose(); - } - return fFixedWidth; - } - - /** - * Returns the height hint for this label. - * - * @param control the root control of this label - * @return the height hint for this label - * @since 3.0 - */ - private int getHeightHint(Composite control) { - if (fFixedHeight < 0) { - GC gc= new GC(control); - gc.setFont(control.getFont()); - fFixedHeight= gc.getFontMetrics().getHeight(); - gc.dispose(); - } - return fFixedHeight; - } - - /** - * Updates the message label widget. - * - * @since 3.0 - */ - private void updateMessageLabel() { - if (fLabel != null && !fLabel.isDisposed()) { - Display display= fLabel.getDisplay(); - if ((fErrorText != null && fErrorText.length() > 0) || fErrorImage != null) { - fLabel.setForeground(JFaceColors.getErrorText(display)); - fLabel.setText(fErrorText); - fLabel.setImage(fErrorImage); - if (fToolTipText != null) - fLabel.setToolTipText(fToolTipText); - else if (fErrorText.length() > fWidthInChars) - fLabel.setToolTipText(fErrorText); - else - fLabel.setToolTipText(null); - } - else { - fLabel.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_FOREGROUND)); - fLabel.setText(fText); - fLabel.setImage(fImage); - if (fToolTipText != null) - fLabel.setToolTipText(fToolTipText); - else if (fText != null && fText.length() > fWidthInChars) - fLabel.setToolTipText(fText); - else - fLabel.setToolTipText(null); - } - } - } -} - diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/StatusTextEditor.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/StatusTextEditor.java deleted file mode 100644 index b90444774a4..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/StatusTextEditor.java +++ /dev/null @@ -1,197 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.texteditor; - - -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.StackLayout; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; - -import org.eclipse.ui.IEditorInput; - - -/** - * Capable of handling input elements that have an associated status with them. - * @since 2.0 - */ -public class StatusTextEditor extends AbstractTextEditor { - - /** The root composite of this editor */ - private Composite fParent; - /** The layout used to manage the regular and the status page */ - private StackLayout fStackLayout; - /** The root composite for the regular page */ - private Composite fDefaultComposite; - /** The status page */ - private Control fStatusControl; - - /* - * @see IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) - */ - public void createPartControl(Composite parent) { - - fParent= new Composite(parent, SWT.NONE); - fStackLayout= new StackLayout(); - fParent.setLayout(fStackLayout); - - fDefaultComposite= new Composite(fParent, SWT.NONE); - fDefaultComposite.setLayout(new FillLayout()); - super.createPartControl(fDefaultComposite); - - updatePartControl(getEditorInput()); - } - - /** - * Checks if the status of the given input is OK. If not the - * status control is shown rather than the default control. - * - * @param input the input whose status is checked - */ - public void updatePartControl(IEditorInput input) { - - if (fStatusControl != null) { - fStatusControl.dispose(); - fStatusControl= null; - } - - Control front= null; - if (fParent != null && input != null) { - if (getDocumentProvider() instanceof IDocumentProviderExtension) { - IDocumentProviderExtension extension= (IDocumentProviderExtension) getDocumentProvider(); - IStatus status= extension.getStatus(input); - if (!isErrorStatus(status)) { - front= fDefaultComposite; - } else { - fStatusControl= createStatusControl(fParent, status); - front= fStatusControl; - } - } - } - - if (fStackLayout.topControl != front) { - fStackLayout.topControl= front; - fParent.layout(); - updateStatusFields(); - } - } - - /** - * Returns whether the given status indicates an error. Subclasses may override. - * - * @param status the status to be checked - * @return <code>true</code> if the status indicates an error, <code>false</code> otherwise\ - * @since 3.0 - */ - protected boolean isErrorStatus(IStatus status) { - return status != null && !status.isOK(); - } - - /** - * Creates the status control for the given status. - * May be overridden by subclasses. - * - * @param parent the parent control - * @param status the status - * @return the new status control - */ - protected Control createStatusControl(Composite parent, IStatus status) { - InfoForm infoForm= new InfoForm(parent); - infoForm.setHeaderText(getStatusHeader(status)); - infoForm.setBannerText(getStatusBanner(status)); - infoForm.setInfo(getStatusMessage(status)); - return infoForm.getControl(); - } - - /** - * Returns a header for the given status - * - * @param status the status whose message is returned - * @return a header for the given status - */ - protected String getStatusHeader(IStatus status) { - return ""; //$NON-NLS-1$ - } - - /** - * Returns a banner for the given status. - * - * @param status the status whose message is returned - * @return a banner for the given status - */ - protected String getStatusBanner(IStatus status) { - return ""; //$NON-NLS-1$ - } - - /** - * Returns a message for the given status. - * - * @param status the status whose message is returned - * @return a message for the given status - */ - protected String getStatusMessage(IStatus status) { - return status.getMessage(); - } - - /* - * @see AbstractTextEditor#updateStatusField(String) - */ - protected void updateStatusField(String category) { - IDocumentProvider provider= getDocumentProvider(); - if (provider instanceof IDocumentProviderExtension) { - IDocumentProviderExtension extension= (IDocumentProviderExtension) provider; - IStatus status= extension.getStatus(getEditorInput()); - if (isErrorStatus(status)) { - IStatusField field= getStatusField(category); - if (field != null) { - field.setText(fErrorLabel); - return; - } - } - } - - super.updateStatusField(category); - } - - /* - * @see AbstractTextEditor#doSetInput(IEditorInput) - */ - protected void doSetInput(IEditorInput input) throws CoreException { - super.doSetInput(input); - if (fParent != null && !fParent.isDisposed()) - updatePartControl(getEditorInput()); - } - - /* - * @see ITextEditor#doRevertToSaved() - */ - public void doRevertToSaved() { - // http://dev.eclipse.org/bugs/show_bug.cgi?id=19014 - super.doRevertToSaved(); - if (fParent != null && !fParent.isDisposed()) - updatePartControl(getEditorInput()); - } - - /* - * @see AbstractTextEditor#sanityCheckState(IEditorInput) - */ - protected void sanityCheckState(IEditorInput input) { - // http://dev.eclipse.org/bugs/show_bug.cgi?id=19014 - super.sanityCheckState(input); - if (fParent != null && !fParent.isDisposed()) - updatePartControl(getEditorInput()); - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/TextEditorAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/TextEditorAction.java deleted file mode 100644 index 5525f030d7a..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/TextEditorAction.java +++ /dev/null @@ -1,151 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.texteditor; - - -import java.util.ResourceBundle; - -/** - * Skeleton of a standard text editor action. The action is - * initially associated with a text editor via the constructor, - * but can subsequently be changed using <code>setEditor</code>. - * Subclasses must implement the <code>run</code> method and if - * required override the <code>update</code> method. - * <p> - * Subclasses that may modify the editor content should use {@link #canModifyEditor()} - * in their <code>update</code> code to check whether updating the editor is most - * likely possible (even if it is read-only - this may change for editor contents - * that are under version control) and {@link #validateEditorInputState()} before - * actually modifying the editor contents. - * </p> - */ -public abstract class TextEditorAction extends ResourceAction implements IUpdate { - - /** The action's editor */ - private ITextEditor fTextEditor; - - /** - * Creates and initializes the action for the given text editor. The action - * configures its visual representation from the given resource bundle. - * - * @param bundle the resource bundle - * @param prefix a prefix to be prepended to the various resource keys - * (described in <code>ResourceAction</code> constructor), or - * <code>null</code> if none - * @param editor the text editor - * @see ResourceAction#ResourceAction(ResourceBundle, String) - */ - protected TextEditorAction(ResourceBundle bundle, String prefix, ITextEditor editor) { - super(bundle, prefix); - setEditor(editor); - update(); - } - - /** - * Creates and initializes the action for the given text editor. The action - * configures its visual representation from the given resource bundle. - * - * @param bundle the resource bundle - * @param prefix a prefix to be prepended to the various resource keys - * (described in <code>ResourceAction</code> constructor), or - * <code>null</code> if none - * @param editor the text editor - * @param style the style of this action - * @see ResourceAction#ResourceAction(ResourceBundle, String, int) - * @since 3.0 - */ - protected TextEditorAction(ResourceBundle bundle, String prefix, ITextEditor editor, int style) { - super(bundle, prefix, style); - setEditor(editor); - update(); - } - - /** - * Returns the action's text editor. - * - * @return the action's text editor - */ - protected ITextEditor getTextEditor() { - return fTextEditor; - } - - /** - * Retargets this action to the given editor. - * - * @param editor the new editor, or <code>null</code> if none - */ - public void setEditor(ITextEditor editor) { - fTextEditor= editor; - } - - /** - * Always enables this action if it is connected to a text editor. - * If the associated editor is <code>null</code>, the action is disabled. - * Subclasses may override. - */ - public void update() { - setEnabled(getTextEditor() != null); - } - - /** - * Checks the editor's modifiable state. Returns <code>true</code> if the editor can be modified, - * taking in account the possible editor extensions. - * - * <p>If the editor implements <code>ITextEditorExtension2</code>, - * this method returns {@link ITextEditorExtension2#isEditorInputModifiable()};<br> else if the editor - * implements <code>ITextEditorExtension2</code>, it returns {@link ITextEditorExtension#isEditorInputReadOnly()};<br> - * else, {@link ITextEditor#isEditable()} is returned, or <code>false</code> if the editor is <code>null</code>.</p> - * - * <p>There is only a difference to {@link #validateEditorInputState()} if the editor implements - * <code>ITextEditorExtension2</code>.</p> - * - * @return <code>true</code> if a modifying action should be enabled, <code>false</code> otherwise - * @since 3.0 - */ - protected boolean canModifyEditor() { - ITextEditor editor= getTextEditor(); - if (editor instanceof ITextEditorExtension2) - return ((ITextEditorExtension2) editor).isEditorInputModifiable(); - else if (editor instanceof ITextEditorExtension) - return !((ITextEditorExtension) editor).isEditorInputReadOnly(); - else if (editor != null) - return editor.isEditable(); - else - return false; - } - - /** - * Checks and validates the editor's modifiable state. Returns <code>true</code> if an action - * can proceed modifying the editor's input, <code>false</code> if it should not. - * - * <p>If the editor implements <code>ITextEditorExtension2</code>, - * this method returns {@link ITextEditorExtension2#validateEditorInputState()};<br> else if the editor - * implements <code>ITextEditorExtension</code>, it returns {@link ITextEditorExtension#isEditorInputReadOnly()};<br> - * else, {@link ITextEditor#isEditable()} is returned, or <code>false</code> if the editor is <code>null</code>.</p> - * - * <p>There is only a difference to {@link #canModifyEditor()} if the editor implements - * <code>ITextEditorExtension2</code>.</p> - * - * @return <code>true</code> if a modifying action can proceed to modify the underlying document, <code>false</code> otherwise - * @since 3.0 - */ - protected boolean validateEditorInputState() { - ITextEditor editor= getTextEditor(); - if (editor instanceof ITextEditorExtension2) - return ((ITextEditorExtension2) editor).validateEditorInputState(); - else if (editor instanceof ITextEditorExtension) - return !((ITextEditorExtension) editor).isEditorInputReadOnly(); - else if (editor != null) - return editor.isEditable(); - else - return false; - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/TextNavigationAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/TextNavigationAction.java deleted file mode 100644 index 56722328501..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/TextNavigationAction.java +++ /dev/null @@ -1,302 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.ui.texteditor; - - -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.StyledText; -import org.eclipse.swt.events.HelpListener; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.Event; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IMenuCreator; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.util.IPropertyChangeListener; - - -/** - * An <code>Action</code> wrapper for text widget navigational and selection actions. - * @since 2.0 - */ -public class TextNavigationAction extends Action { - - /** The text widget */ - private StyledText fTextWidget; - /** The styled text action id */ - private int fAction; - /** The action's action id */ - private String fActionId; - /** This action's action definition id */ - private String fActionDefinitionId; - - - /** - * Creates a new <code>TextNavigationAction</code>. - * @param textWidget the text widget - * @param action the styled text widget action - */ - public TextNavigationAction(StyledText textWidget, int action) { - fTextWidget= textWidget; - fAction= action; - } - - /** - * Returns the text widget this actions is bound to. - * - * @return returns the text widget this actions is bound to - */ - protected StyledText getTextWidget() { - return fTextWidget; - } - - /* - * @see IAction#run() - */ - public void run() { - Point selection= fTextWidget.getSelection(); - fTextWidget.invokeAction(fAction); - fireSelectionChanged(selection); - } - - private void doFireSelectionChanged(Point selection) { - Event event= new Event(); - event.x= selection.x; - event.y= selection.y; - fTextWidget.notifyListeners(SWT.Selection, event); - } - - /** - * Sends a selection event with the current selection to all - * selection listeners of the action's text widget - * - * @since 3.0 - */ - protected void fireSelectionChanged() { - fireSelectionChanged(null); - } - - /** - * Fires a selection event to all selection listener of the action's - * text widget if the current selection differs from the given selection. - * - * @param oldSelection the old selection - * @since 3.0 - */ - protected void fireSelectionChanged(Point oldSelection) { - Point selection= fTextWidget.getSelection(); - if (oldSelection == null || !selection.equals(oldSelection)) - doFireSelectionChanged(selection); - } - - /* - * @see IAction#runWithEvent(Event) - */ - public void runWithEvent(Event event) { - run(); - } - - /* - * @see IAction#setActionDefinitionId(String) - */ - public void setActionDefinitionId(String id) { - fActionDefinitionId= id; - } - - /* - * @see IAction#getActionDefinitionId() - */ - public String getActionDefinitionId() { - return fActionDefinitionId; - } - - /* - * @see IAction#setId(String) - */ - public void setId(String id) { - fActionId= id; - } - - /* - * @see IAction#getId() - */ - public String getId() { - return fActionId; - } - - -// ---------------------------------------------------------------------------------------------------------------------------------- -// All the subsequent methods are just empty method bodies. - - /* - * @see IAction#addPropertyChangeListener(IPropertyChangeListener) - */ - public void addPropertyChangeListener(IPropertyChangeListener listener) { - } - - /* - * @see IAction#getAccelerator() - */ - public int getAccelerator() { - return 0; - } - - /* - * @see IAction#getDescription() - */ - public String getDescription() { - return null; - } - - /* - * @see IAction#getDisabledImageDescriptor() - */ - public ImageDescriptor getDisabledImageDescriptor() { - return null; - } - - /* - * @see IAction#getHelpListener() - */ - public HelpListener getHelpListener() { - return null; - } - - /* - * @see IAction#getHoverImageDescriptor() - */ - public ImageDescriptor getHoverImageDescriptor() { - return null; - } - - /* - * @see IAction#getImageDescriptor() - */ - public ImageDescriptor getImageDescriptor() { - return null; - } - - /* - * @see IAction#getMenuCreator() - */ - public IMenuCreator getMenuCreator() { - return null; - } - - /* - * @see IAction#getStyle() - */ - public int getStyle() { - return 0; - } - - /* - * @see IAction#getText() - */ - public String getText() { - return null; - } - - /* - * @see IAction#getToolTipText() - */ - public String getToolTipText() { - return null; - } - - /* - * @see IAction#isChecked() - */ - public boolean isChecked() { - return false; - } - - /* - * @see IAction#isEnabled() - */ - public boolean isEnabled() { - return true; - } - - /* - * @see IAction#removePropertyChangeListener(IPropertyChangeListener) - */ - public void removePropertyChangeListener(IPropertyChangeListener listener) { - } - - /** - * @deprecated - */ - public void setAccelerator(int keycode) { - } - - /* - * @see IAction#setChecked(boolean) - */ - public void setChecked(boolean checked) { - } - - /* - * @see IAction#setDescription(String) - */ - public void setDescription(String text) { - } - - /* - * @see IAction#setDisabledImageDescriptor(ImageDescriptor) - */ - public void setDisabledImageDescriptor(ImageDescriptor newImage) { - } - - /* - * @see IAction#setEnabled(boolean) - */ - public void setEnabled(boolean enabled) { - } - - /* - * @see IAction#setHelpListener(HelpListener) - */ - public void setHelpListener(HelpListener listener) { - } - - /* - * @see IAction#setHoverImageDescriptor(ImageDescriptor) - */ - public void setHoverImageDescriptor(ImageDescriptor newImage) { - } - - /* - * @see IAction#setImageDescriptor(ImageDescriptor) - */ - public void setImageDescriptor(ImageDescriptor newImage) { - } - - /* - * @see IAction#setMenuCreator(IMenuCreator) - */ - public void setMenuCreator(IMenuCreator creator) { - } - - /* - * @see IAction#setText(String) - */ - public void setText(String text) { - } - - /* - * @see IAction#setToolTipText(String) - */ - public void setToolTipText(String text) { - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/TextOperationAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/TextOperationAction.java deleted file mode 100644 index 44b2f80e718..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/TextOperationAction.java +++ /dev/null @@ -1,156 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.ui.texteditor; - - -import java.util.ResourceBundle; - -import org.eclipse.swt.custom.BusyIndicator; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; - -import org.eclipse.jface.text.ITextOperationTarget; - -import org.eclipse.ui.IWorkbenchPartSite; - - -/** - * An action which gets a text operation target from its text editor. - * <p> - * The action is initially associated with a text editor via the constructor, - * but can subsequently be changed using <code>setEditor</code>.</p> - * <p> - * If this class is used as is, it works by asking the text editor for its - * text operation target adapter (using <code>getAdapter(ITextOperationTarget.class)</code>. - * The action runs this operation with the pre-configured opcode.</p> - */ -public final class TextOperationAction extends TextEditorAction { - - /** The text operation code */ - private int fOperationCode= -1; - /** The text operation target */ - private ITextOperationTarget fOperationTarget; - /** - * Indicates whether this action can be executed on read only editors - * @since 2.0 - */ - private boolean fRunsOnReadOnly= false; - - /** - * Creates and initializes the action for the given text editor and operation - * code. The action configures its visual representation from the given resource - * bundle. The action works by asking the text editor at the time for its - * text operation target adapter (using - * <code>getAdapter(ITextOperationTarget.class)</code>. The action runs that - * operation with the given opcode. - * - * @param bundle the resource bundle - * @param prefix a prefix to be prepended to the various resource keys - * (described in <code>ResourceAction</code> constructor), or - * <code>null</code> if none - * @param editor the text editor - * @param operationCode the operation code - * @see TextEditorAction#TextEditorAction(ResourceBundle, String, ITextEditor) - */ - public TextOperationAction(ResourceBundle bundle, String prefix, ITextEditor editor, int operationCode) { - super(bundle, prefix, editor); - fOperationCode= operationCode; - update(); - } - - /** - * Creates and initializes the action for the given text editor and operation - * code. The action configures its visual representation from the given resource - * bundle. The action works by asking the text editor at the time for its - * text operation target adapter (using - * <code>getAdapter(ITextOperationTarget.class)</code>. The action runs that - * operation with the given opcode. - * - * @param bundle the resource bundle - * @param prefix a prefix to be prepended to the various resource keys - * (described in <code>ResourceAction</code> constructor), or - * <code>null</code> if none - * @param editor the text editor - * @param operationCode the operation code - * @param runsOnReadOnly <code>true</code> if action can be executed on read-only files - * - * @see TextEditorAction#TextEditorAction(ResourceBundle, String, ITextEditor) - * @since 2.0 - */ - public TextOperationAction(ResourceBundle bundle, String prefix, ITextEditor editor, int operationCode, boolean runsOnReadOnly) { - super(bundle, prefix, editor); - fOperationCode= operationCode; - fRunsOnReadOnly= runsOnReadOnly; - update(); - } - - /** - * The <code>TextOperationAction</code> implementation of this - * <code>IAction</code> method runs the operation with the current - * operation code. - */ - public void run() { - if (fOperationCode == -1 || fOperationTarget == null) - return; - - ITextEditor editor= getTextEditor(); - if (editor == null) - return; - - if (!fRunsOnReadOnly && !validateEditorInputState()) - return; - - Display display= null; - - IWorkbenchPartSite site= editor.getSite(); - Shell shell= site.getShell(); - if (shell != null && !shell.isDisposed()) - display= shell.getDisplay(); - - BusyIndicator.showWhile(display, new Runnable() { - public void run() { - fOperationTarget.doOperation(fOperationCode); - } - }); - } - - /** - * The <code>TextOperationAction</code> implementation of this - * <code>IUpdate</code> method discovers the operation through the current - * editor's <code>ITextOperationTarget</code> adapter, and sets the - * enabled state accordingly. - */ - public void update() { - super.update(); - - if (!fRunsOnReadOnly && !canModifyEditor()) { - setEnabled(false); - return; - } - - ITextEditor editor= getTextEditor(); - if (fOperationTarget == null && editor!= null && fOperationCode != -1) - fOperationTarget= (ITextOperationTarget) editor.getAdapter(ITextOperationTarget.class); - - boolean isEnabled= (fOperationTarget != null && fOperationTarget.canDoOperation(fOperationCode)); - setEnabled(isEnabled); - } - - /* - * @see TextEditorAction#setEditor(ITextEditor) - */ - public void setEditor(ITextEditor editor) { - super.setEditor(editor); - fOperationTarget= null; - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/TextSelectionNavigationLocation.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/TextSelectionNavigationLocation.java deleted file mode 100644 index fcdb74ca959..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/TextSelectionNavigationLocation.java +++ /dev/null @@ -1,343 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.texteditor; - -import org.eclipse.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.ITextSelection; -import org.eclipse.jface.text.Position; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionProvider; - -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IMemento; -import org.eclipse.ui.INavigationLocation; -import org.eclipse.ui.NavigationLocation; - -import org.eclipse.ui.internal.IWorkbenchConstants; - - -/** - * Represents the text selection context marked for the user in the navigation history. - * - * @since 2.1 - */ -public class TextSelectionNavigationLocation extends NavigationLocation { - - - private final static String DELETED= "deleted"; //$NON-NLS-1$ - private final static String NOT_DELETED= "not_deleted"; //$NON-NLS-1$ - - private final static String CATEGORY= "__navigation_" + TextSelectionNavigationLocation.class.hashCode(); //$NON-NLS-1$ - private static IPositionUpdater fgPositionUpdater= new DefaultPositionUpdater(CATEGORY); - - private Position fPosition; - private IDocument fDocument; - private Position fSavedPosition; - - - /** - * Creates a new text selection navigation location. - * - * @param part the text editor part - * @param initialize a boolean indicating whether to initialize the new instance from the current selection - */ - public TextSelectionNavigationLocation(ITextEditor part, boolean initialize) { - super(part); - - if (initialize) { - - ISelection s= part.getSelectionProvider().getSelection(); - if(s == null || s.isEmpty()) - return; - - ITextSelection selection= (ITextSelection) s; - if(selection.getOffset() == 0 && selection.getLength() == 0) - return; - - IDocument document= getDocument(part); - Position position= new Position(selection.getOffset(), selection.getLength()); - if (installOnDocument(document, position)) { - fDocument= document; - fPosition= position; - if (!part.isDirty()) - fSavedPosition= new Position(fPosition.offset, fPosition.length); - } - } - } - - /** - * Returns the text editor's document. - * - * @param part the text editor - * @return the document of the given text editor - */ - private IDocument getDocument(ITextEditor part) { - IDocumentProvider provider= part.getDocumentProvider(); - return provider.getDocument(part.getEditorInput()); - } - - /** - * Installs the given position on the given document. - * - * @param document the document - * @param position the position - * @return <code>true</code> if the position could be installed - */ - private boolean installOnDocument(IDocument document, Position position) { - - if (document != null && position != null) { - - if (!document.containsPositionCategory(CATEGORY)) { - document.addPositionCategory(CATEGORY); - document.addPositionUpdater(fgPositionUpdater); - } - - try { - document.addPosition(CATEGORY, position); - return true; - } catch (BadLocationException e) { - } catch (BadPositionCategoryException e) { - } - } - - return false; - } - - /** - * Uninstalls the given position from the given document. - * - * @param document the document - * @param position the position - * @return <code>true</code> if the position could be uninstalled - */ - private boolean uninstallFromDocument(IDocument document, Position position) { - - if (document != null && position != null) { - try { - - document.removePosition(CATEGORY, position); - - Position[] category= document.getPositions(CATEGORY); - if (category == null || category.length == 0) { - document.removePositionCategory(CATEGORY); - document.removePositionUpdater(fgPositionUpdater); - } - return true; - - } catch (BadPositionCategoryException e) { - } - } - - return false; - } - - /* - * @see Object#toString() - */ - public String toString() { - return "Selection<" + fPosition + ">"; //$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * Tells whether this location is equal to the current - * location in the given text editor. - * - * @param part the text editor - * @return <code>true</code> if the locations are equal - */ - private boolean equalsLocationOf(ITextEditor part) { - - if (fPosition == null) - return true; - - if (fPosition.isDeleted) - return false; - - ISelectionProvider provider= part.getSite().getSelectionProvider(); - ISelection selection= provider.getSelection(); - if (selection instanceof ITextSelection) { - ITextSelection textSelection= (ITextSelection) selection; - if (textSelection.getOffset() == fPosition.offset && textSelection.getLength() == fPosition.length) { - String text= textSelection.getText(); - if (text != null) { - try { - return text.equals(fDocument.get(fPosition.offset, fPosition.length)); - } catch (BadLocationException e) { - } - } - } - } - - return false; - } - - public void dispose() { - uninstallFromDocument(fDocument, fPosition); - fDocument= null; - fPosition= null; - fSavedPosition= null; - super.dispose(); - } - - /** - * Releases the state of this location. - */ - public void releaseState() { - // deactivate - uninstallFromDocument(fDocument, fPosition); - fDocument= null; - fPosition= null; - fSavedPosition= null; - super.releaseState(); - } - - /** - * Merges the given location into this one. - * - * @param location the location to merge into this one - * @return <code>true<code> if merging was successful - */ - public boolean mergeInto(INavigationLocation location) { - - if (location == null) - return false; - - if (getClass() != location.getClass()) - return false; - - if (fPosition == null || fPosition.isDeleted) - return true; - - TextSelectionNavigationLocation s= (TextSelectionNavigationLocation) location; - if (s.fPosition == null || s.fPosition.isDeleted) { - uninstallFromDocument(fDocument, fPosition); - s.fDocument= fDocument; - s. fPosition= fPosition; - s.fSavedPosition= fSavedPosition; - return true; - } - - if (s.fDocument == fDocument) { - if (s.fPosition.overlapsWith(fPosition.offset, fPosition.length) || fPosition.offset + fPosition.length == s.fPosition.offset || s.fPosition.offset + s.fPosition.length == fPosition.offset) { - s.fPosition.offset= fPosition.offset; - s.fPosition.length= fPosition.length; - return true; - } - } - - return false; - } - - /** - * Restores this location. - */ - public void restoreLocation() { - if (fPosition == null || fPosition.isDeleted) - return; - - IEditorPart part= getEditorPart(); - if (part instanceof ITextEditor) { - ITextEditor editor= (ITextEditor) getEditorPart(); - editor.selectAndReveal(fPosition.offset, fPosition.length); - } - } - - /** - * Restores the object state from the given memento. - * - * @param memento the memento - */ - public void restoreState(IMemento memento) { - - IEditorPart part= getEditorPart(); - if (part instanceof ITextEditor) { - - // restore - fDocument= getDocument((ITextEditor) part); - - Integer offset= memento.getInteger(IWorkbenchConstants.TAG_X); - Integer length= memento.getInteger(IWorkbenchConstants.TAG_Y); - String deleted= memento.getString(IWorkbenchConstants.TAG_INFO); - - if (offset != null && length != null) { - Position p= new Position(offset.intValue(), length.intValue()); - if (deleted != null) - p.isDeleted= DELETED.equals(deleted) ? true : false; - - // activate - if (installOnDocument(fDocument, p)) { - fPosition= p; - if (!part.isDirty()) - fSavedPosition= new Position(fPosition.offset, fPosition.length); - } - } - } - } - - /** - * Stores the object state into the given memento. - * - * @param memento the memento - */ - public void saveState(IMemento memento) { - if (fSavedPosition != null) { - memento.putInteger(IWorkbenchConstants.TAG_X, fSavedPosition.offset); - memento.putInteger(IWorkbenchConstants.TAG_Y, fSavedPosition.length); - memento.putString(IWorkbenchConstants.TAG_INFO, (fSavedPosition.isDeleted ? DELETED : NOT_DELETED)); - } - } - - /** - * Hook method which is called when the given editor has been saved. - * - * @param part the editor part - */ - public void partSaved(IEditorPart part) { - // http://dev.eclipse.org/bugs/show_bug.cgi?id=25440 - if (fPosition == null || fPosition.isDeleted()) - fSavedPosition= null; - else - fSavedPosition= new Position(fPosition.offset, fPosition.length); - } - - /** - * Updates the this location. - */ - public void update() { - IEditorPart part= getEditorPart(); - if (part instanceof ITextEditor) { - ITextEditor textEditor= (ITextEditor) getEditorPart(); - - if(equalsLocationOf(textEditor)) - return; - - ISelection s= textEditor.getSelectionProvider().getSelection(); - if(s == null || s.isEmpty()) - return; - - ITextSelection selection= (ITextSelection) s; - if(selection.getOffset() == 0 && selection.getLength() == 0) - return; - - fPosition.offset= selection.getOffset(); - fPosition.length= selection.getLength(); - fPosition.isDeleted= false; - - if (!part.isDirty()) - fSavedPosition= new Position(fPosition.offset, fPosition.length); - } - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ValidateStateException.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ValidateStateException.java deleted file mode 100644 index 85d65440fee..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ValidateStateException.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.ui.texteditor; - - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; - -/** - * Formerly thrown by <code>AbstractDocumentProvider.doValidateState(Object, Object)</code>. - * @deprecated - * @since 2.1 - */ -public class ValidateStateException extends CoreException { - - /* - * @see CoreException#CoreException(org.eclipse.core.runtime.IStatus) - */ - public ValidateStateException(IStatus status) { - super(status); - } - -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/WorkbenchChainedTextFontFieldEditor.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/WorkbenchChainedTextFontFieldEditor.java deleted file mode 100644 index ffd84dc558b..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/WorkbenchChainedTextFontFieldEditor.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.ui.texteditor; - - -import org.eclipse.swt.widgets.Composite; - -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Plugin; - -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.jface.text.PropagatingFontFieldEditor; - -import org.eclipse.ui.plugin.AbstractUIPlugin; - - -/** - * This font field editor implements chaining between the workbench's preference - * store and a given target preference store. Any time the workbench's preference - * for the text font changes, the change is propagated to the target store. - * Propagation means that the actual text font stored in the workbench store is set as - * default text font in the target store. If the target store does not contain a value - * rather than the default text font, the new default text font is immediately effective. - * - * @see org.eclipse.jface.preference.FontFieldEditor - * @deprecated since 3.0 not longer in use, no longer supported - * @since 2.0 - */ -public class WorkbenchChainedTextFontFieldEditor extends PropagatingFontFieldEditor { - - /** - * 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 - */ - public WorkbenchChainedTextFontFieldEditor(String name, String labelText, Composite parent) { - super(name, labelText, parent, EditorMessages.getString("WorkbenchChainedTextFontFieldEditor.defaultWorkbenchTextFont")); //$NON-NLS-1$ - } - - /** - * Starts the propagation of the text font preference set in the workbench - * to given target preference store using the given preference key. - * - * @param target the target preference store - * @param targetKey the key to be used in the target preference store - */ - public static void startPropagate(IPreferenceStore target, String targetKey) { - Plugin plugin= Platform.getPlugin("org.eclipse.ui.workbench"); //$NON-NLS-1$ - if (plugin instanceof AbstractUIPlugin) { - AbstractUIPlugin uiPlugin= (AbstractUIPlugin) plugin; - IPreferenceStore store= uiPlugin.getPreferenceStore(); - if (store != null) - PropagatingFontFieldEditor.startPropagate(store, JFaceResources.TEXT_FONT, target, targetKey); - } - } -} - diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/link/EditorLinkedModeUI.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/link/EditorLinkedModeUI.java deleted file mode 100644 index 2083338eafc..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/link/EditorLinkedModeUI.java +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.texteditor.link; - -import org.eclipse.jface.text.ITextViewer; -import org.eclipse.jface.text.link.LinkedModeModel; -import org.eclipse.jface.text.link.LinkedModeUI; -import org.eclipse.jface.text.link.LinkedPosition; - -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; - -/** - * A <code>LinkedModeUI</code> that takes care of updating the focus editor's - * navigation history. - * - * @since 3.0 - */ -public class EditorLinkedModeUI extends LinkedModeUI { - - /** - * Updates the editor navigation history upon linked focus changes. - * - * @since 3.0 - */ - private static class EditorHistoryUpdater implements ILinkedModeUIFocusListener { - - /* - * @see org.eclipse.jface.text.link.LinkedModeUI.ILinkedModeUIFocusListener#linkedFocusLost(org.eclipse.jface.text.link.LinkedPosition, org.eclipse.jface.text.link.LinkedModeUI.LinkedModeUITarget) - */ - public void linkingFocusLost(LinkedPosition position, LinkedModeUITarget target) { - // mark navigation history - IWorkbenchWindow win= PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (win != null) { - IWorkbenchPage page= win.getActivePage(); - if (page != null) { - IEditorPart part= page.getActiveEditor(); - page.getNavigationHistory().markLocation(part); - } - } - } - - /* - * @see org.eclipse.jface.text.link.LinkedModeUI.ILinkedModeUIFocusListener#linkedFocusGained(org.eclipse.jface.text.link.LinkedPosition, org.eclipse.jface.text.link.LinkedModeUI.LinkedModeUITarget) - */ - public void linkingFocusGained(LinkedPosition position, LinkedModeUITarget target) { - // does nothing - } - } - - - /** - * @param model - * @param viewer - */ - public EditorLinkedModeUI(LinkedModeModel model, ITextViewer viewer) { - super(model, viewer); - setPositionListener(new EditorHistoryUpdater()); - } - - /** - * @param model - * @param viewers - */ - public EditorLinkedModeUI(LinkedModeModel model, ITextViewer[] viewers) { - super(model, viewers); - setPositionListener(new EditorHistoryUpdater()); - } - - /** - * @param model - * @param target - */ - public EditorLinkedModeUI(LinkedModeModel model, LinkedModeUITarget target) { - super(model, target); - setPositionListener(new EditorHistoryUpdater()); - } - - /** - * @param model - * @param targets - */ - public EditorLinkedModeUI(LinkedModeModel model, LinkedModeUITarget[] targets) { - super(model, targets); - setPositionListener(new EditorHistoryUpdater()); - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/package.html b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/package.html deleted file mode 100644 index 0ebf7f2db7f..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/package.html +++ /dev/null @@ -1,30 +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 text editors obeying to the -desktop rules. -<h2> -Package Specification</h2> -<tt>ITextEditor</tt> extends <tt>IEditorPart</tt> with text editor specific -functionality. Text editors use source viewers (<tt>ISourceViewer</tt>) -for displaying and editing the given editor input. In order to translate -the editor input into a document and vice versa (e.g., for saving a change), -a text editor uses document providers (<tt>IDocumentProvider</tt>). A document -provider is responsible not just for providing the document for a given -editor input but for the complete translation between the domain model -and the editor's internal document-based model. Document provider can be -shared between editors. -<br>The package provides a default implementation of <tt>ITextEditor</tt> -(<tt>AbstractTextEditor</tt>). This default implementation also covers -the editor's complete action management and activation. The package contains -a number of configurable and predefined actions. <tt>AbstractMarkerAnnotationModel</tt> -establishs a link between text annotations (<tt>Annotation</tt>) and desktop -markers (<tt>IMarker</tt>). -</body> -</html> diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/IQuickDiffReferenceProvider.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/IQuickDiffReferenceProvider.java deleted file mode 100644 index 1987cf3aa64..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/IQuickDiffReferenceProvider.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.texteditor.quickdiff; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; - -import org.eclipse.jface.text.IDocument; - -import org.eclipse.ui.texteditor.ITextEditor; - - -/** - * The protocol a reference provider for quickdiff has to implement. Quickdiff references provide - * a reference document (an <code>IDocument</code>) that is used as the original against which - * diff information is generated. - * <p>Extensions to the extension point <code>quickdiff.referenceprovider</code> have to implement - * this interface (plus another interface for plugin and UI management.</p> - * - * @since 3.0 - */ -public interface IQuickDiffReferenceProvider { - /** - * Returns the reference document for the quick diff display. - * - * @param monitor a preference monitor to monitor / cancel the process, or <code>null</code> - * @return the reference document for the quick diff display or <code>null</code> if getting the - * document was canceled or there is no reference available. - * @throws CoreException if getting the document fails. - */ - IDocument getReference(IProgressMonitor monitor) throws CoreException; - - /** - * Called when the reference is no longer used and the provider can free resources. - */ - void dispose(); - - /** - * Returns the id of this reference provider. - * - * @return the id of this provider as stated in the extending plugin's manifest. - */ - String getId(); - - /** - * Sets the active editor for the provider implementation. Will usually just be called right after - * creation of the implementation. - * - * @param editor the active editor. - */ - void setActiveEditor(ITextEditor editor); - - /** - * Gives the implementation a hook to publish its enablement. The action corresponding to this - * implementation might be grayed out or not shown at all based on the value presented here. - * - * @return <code>false</code> if the implementation cannot be executed, <code>true</code> if it can, - * or if it cannot be decided yet. - */ - boolean isEnabled(); - - /** - * Sets the id of this implementation. This method will be called right after creation, and - * <code>id</code> will be set to the <code>Id</code> attribute specified in the extension's - * declaration. - * - * @param id the provider's new id. - */ - void setId(String id); -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/QuickDiff.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/QuickDiff.java deleted file mode 100644 index 9f183a7092a..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/QuickDiff.java +++ /dev/null @@ -1,143 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.texteditor.quickdiff; - -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.jface.text.Assert; -import org.eclipse.jface.text.source.IAnnotationModel; - -import org.eclipse.ui.internal.texteditor.TextEditorPlugin; -import org.eclipse.ui.internal.texteditor.quickdiff.DocumentLineDiffer; -import org.eclipse.ui.internal.texteditor.quickdiff.QuickDiffExtensionsRegistry; -import org.eclipse.ui.texteditor.ITextEditor; - -/** - * Access class for the quick diff reference provider extension point. - * <p> - * This class may be instantiated, it is not intended to be subclassed. - * </p> - * @since 3.0 - */ -public class QuickDiff { - - /** - * Creates a new instance. - */ - public QuickDiff() { - } - - /** - * Returns the first descriptor with the <code>default</code> attribute set to <code>true</code>. - * <p> - * Clients should not cache this value because it can change when plug-ins get dynamically added or removed. - * </p> - * - * @return the descriptor of the default reference provider or <code>null</code> if none - */ - public ReferenceProviderDescriptor getDefaultProvider() { - QuickDiffExtensionsRegistry registry= TextEditorPlugin.getDefault().getQuickDiffExtensionRegistry(); - if (registry != null) - return registry.getDefaultProvider(); - - return null; - } - - /** - * Returns a non-modifiable list of <code>ReferenceProviderDescriptor</code> describing all extension - * to the <code>quickDiffReferenceProvider</code> extension point. - * <p> - * Clients should not cache this list because it can change when plug-ins get dynamically added or removed. - * </p> - * - * @return the non-modifiable list of extensions to the <code>quickDiffReferenceProvider</code> extension point. - */ - public List getReferenceProviderDescriptors() { - QuickDiffExtensionsRegistry registry= TextEditorPlugin.getDefault().getQuickDiffExtensionRegistry(); - if (registry != null) - return registry.getReferenceProviderDescriptors(); - - return Collections.EMPTY_LIST; - } - - /** - * Returns the quick diff reference provider registered under <code>id</code>, or the default - * reference provider. The returned provider gets its editor set to <code>editor</code>. If neither - * the requested provider nor the default provider return <code>true</code> from <code>isEnabled</code> after - * having the editor set, <code>null</code> is returned. - * <p> - * Clients should not cache this value because it can change when plug-ins get dynamically added or removed. - * </p> - * - * @param editor the editor to be installed with the returned provider - * @param id the id as specified in the <code>plugin.xml</code> that installs the reference provider - * @return the reference provider registered under <code>id</code>, or the default reference provider, or <code>null</code> - */ - public IQuickDiffReferenceProvider getReferenceProviderOrDefault(ITextEditor editor, String id) { - Assert.isNotNull(editor); - Assert.isNotNull(id); - - List descs= getReferenceProviderDescriptors(); - IQuickDiffReferenceProvider provider= null; - // try to fetch preferred provider; load if needed - for (Iterator iter= descs.iterator(); iter.hasNext();) { - ReferenceProviderDescriptor desc= (ReferenceProviderDescriptor) iter.next(); - if (desc.getId().equals(id)) { - provider= desc.createProvider(); - if (provider != null) { - provider.setActiveEditor(editor); - if (provider.isEnabled()) - break; - provider.dispose(); - provider= null; - } - } - } - - // if not found, get default provider as specified by the extension point - if (provider == null) { - ReferenceProviderDescriptor defaultDescriptor= getDefaultProvider(); - if (defaultDescriptor != null) { - provider= defaultDescriptor.createProvider(); - if (provider != null) { - provider.setActiveEditor(editor); - if (!provider.isEnabled()) { - provider.dispose(); - provider= null; - } - } - } - } - - return provider; - } - - /** - * Creates a new line differ annotation model with its reference provider set to the reference provider - * obtained by calling <code>getReferenceProviderOrDefault(editor, id)</code>. - * - * @param editor the editor to be installed with the returned provider - * @param id the id as specified in the <code>plugin.xml</code> that installs the reference provider - * @return a quick diff annotation model - */ - public IAnnotationModel createQuickDiffAnnotationModel(ITextEditor editor, String id) { - IQuickDiffReferenceProvider provider= getReferenceProviderOrDefault(editor, id); - if (provider != null) { - DocumentLineDiffer differ= new DocumentLineDiffer(); - differ.setReferenceProvider(provider); - return differ; - } else - return null; - } - -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/QuickDiffToggleAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/QuickDiffToggleAction.java deleted file mode 100644 index 92005f04a93..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/QuickDiffToggleAction.java +++ /dev/null @@ -1,211 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.texteditor.quickdiff; - -import java.util.Iterator; -import java.util.List; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.action.IMenuListener; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.viewers.ISelection; - -import org.eclipse.ui.IEditorActionDelegate; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbenchActionConstants; -import org.eclipse.ui.texteditor.ITextEditor; -import org.eclipse.ui.texteditor.ITextEditorExtension; -import org.eclipse.ui.texteditor.ITextEditorExtension3; -import org.eclipse.ui.texteditor.IUpdate; - -import org.eclipse.ui.internal.texteditor.quickdiff.QuickDiffMessages; -import org.eclipse.ui.internal.texteditor.quickdiff.QuickDiffRestoreAction; -import org.eclipse.ui.internal.texteditor.quickdiff.ReferenceSelectionAction; -import org.eclipse.ui.internal.texteditor.quickdiff.RestoreAction; -import org.eclipse.ui.internal.texteditor.quickdiff.RevertBlockAction; -import org.eclipse.ui.internal.texteditor.quickdiff.RevertLineAction; -import org.eclipse.ui.internal.texteditor.quickdiff.RevertSelectionAction; - -/** - * Action to toggle the line number bar's quick diff display. When turned on, quick diff shows - * the changes relative to the saved version of the file. - * - * @since 3.0 - */ -public class QuickDiffToggleAction implements IEditorActionDelegate, IUpdate { - - /** The editor we are working on. */ - ITextEditor fEditor= null; - - /** Our UI proxy action. */ - IAction fProxy; - - /** The restore actions associated with this toggle action. */ - QuickDiffRestoreAction[] fRestoreActions= - new QuickDiffRestoreAction[] { - new RevertSelectionAction(fEditor), - new RevertBlockAction(fEditor), - new RevertLineAction(fEditor), - new RestoreAction(fEditor) - }; - - /** The menu listener that adds the ruler context menu. */ - private IMenuListener fListener= new IMenuListener() { - /** Group name for additions, in CompilationUnitEditor... */ - private static final String GROUP_ADD= "add"; //$NON-NLS-1$ - /** Group name for debug contributions */ - private static final String GROUP_DEBUB= "debug"; //$NON-NLS-1$ - private static final String GROUP_QUICKDIFF= "quickdiff"; //$NON-NLS-1$ - private static final String MENU_LABEL_KEY= "quickdiff.menu.label"; //$NON-NLS-1$ - private static final String MENU_ID= "quickdiff.menu"; //$NON-NLS-1$ - private static final String GROUP_RESTORE= "restore"; //$NON-NLS-1$ - - public void menuAboutToShow(IMenuManager manager) { - // update the toggle action itself - update(); - - IMenuManager menu= (IMenuManager)manager.find(MENU_ID); - // only add menu if it isn't there yet - if (menu == null) { - /* HACK: pre-install menu groups - * This is needed since we get the blank context menu, but want to show up - * in the same position as the extension-added QuickDiffToggleAction. - * The extension is added at the end (naturally), but other menus (debug, add) - * don't add themselves to MB_ADDITIONS or alike, but rather to the end, too. So - * we pre-install their respective menu groups here. - */ - // TODO move these into editor as well - if (manager.find(GROUP_DEBUB) == null) - manager.insertBefore(IWorkbenchActionConstants.MB_ADDITIONS, new Separator(GROUP_DEBUB)); - if (manager.find(GROUP_ADD) == null) - manager.insertAfter(IWorkbenchActionConstants.MB_ADDITIONS, new Separator(GROUP_ADD)); - if (manager.find(GROUP_RESTORE) == null) - manager.insertAfter(GROUP_ADD, new Separator(GROUP_RESTORE)); - if (manager.find(GROUP_QUICKDIFF) == null) - manager.insertAfter(GROUP_RESTORE, new Separator(GROUP_QUICKDIFF)); - - // create quickdiff menu - menu= new MenuManager(QuickDiffMessages.getString(MENU_LABEL_KEY), MENU_ID); - List descriptors= new QuickDiff().getReferenceProviderDescriptors(); - for (Iterator it= descriptors.iterator(); it.hasNext();) { - ReferenceProviderDescriptor desc= (ReferenceProviderDescriptor) it.next(); - ReferenceSelectionAction action= new ReferenceSelectionAction(desc, fEditor); - if (action.isEnabled()) - menu.add(action); - } - manager.appendToGroup(GROUP_QUICKDIFF, menu); - - // create restore menu if this action is enabled - if (isConnected()) { - for (int i= 0; i < fRestoreActions.length; i++) { - fRestoreActions[i].update(); - } - // only add block action if selection action is not enabled - if (fRestoreActions[0].isEnabled()) - manager.appendToGroup(GROUP_RESTORE, fRestoreActions[0]); - else if (fRestoreActions[1].isEnabled()) - manager.appendToGroup(GROUP_RESTORE, fRestoreActions[1]); - if (fRestoreActions[2].isEnabled()) - manager.appendToGroup(GROUP_RESTORE, fRestoreActions[2]); - if (fRestoreActions[3].isEnabled()) - manager.appendToGroup(GROUP_RESTORE, fRestoreActions[3]); - } - } - } - }; - - /* - * @see org.eclipse.ui.IEditorActionDelegate#setActiveEditor(org.eclipse.jface.action.IAction, org.eclipse.ui.IEditorPart) - */ - public void setActiveEditor(IAction action, IEditorPart targetEditor) { - fProxy= action; - removePopupMenu(); - if (targetEditor instanceof ITextEditor) { - fEditor= (ITextEditor)targetEditor; - } else - fEditor= null; - for (int i= 0; i < fRestoreActions.length; i++) { - fRestoreActions[i].setEditor(fEditor); - } - setPopupMenu(); - } - - /** - * Removes the ruler context menu listener from the current editor. - */ - private void removePopupMenu() { - if (!(fEditor instanceof ITextEditorExtension)) - return; - ((ITextEditorExtension)fEditor).removeRulerContextMenuListener(fListener); - } - - /** - * Installs a submenu with <code>fEditor</code>'s ruler context menu that contains the choices - * for the quick diff reference. This allows the toggle action to lazily install the menu once - * quick diff has been enabled. - * - * @see QuickDiffToggleAction - */ - private void setPopupMenu() { - if (!(fEditor instanceof ITextEditorExtension)) - return; - ((ITextEditorExtension)fEditor).addRulerContextMenuListener(fListener); - } - - /** - * States whether this toggle action has been installed and a incremental differ has been - * installed with the line number bar. - * - * @return <code>true</code> if a differ has been installed on <code>fEditor</code>. - */ - boolean isConnected() { - if (!(fEditor instanceof ITextEditorExtension3)) - return false; - return ((ITextEditorExtension3)fEditor).isChangeInformationShowing(); - } - - /* - * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) - */ - public void run(IAction action) { - fProxy= action; - if (fEditor == null) - return; - - if (fEditor instanceof ITextEditorExtension3) { - ITextEditorExtension3 extension= (ITextEditorExtension3)fEditor; - extension.showChangeInformation(!extension.isChangeInformationShowing()); - } - } - - /* - * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) - */ - public void selectionChanged(IAction action, ISelection selection) { - fProxy= action; - } - - /* - * @see org.eclipse.ui.texteditor.IUpdate#update() - */ - public void update() { - if (fProxy == null) - return; - if (isConnected()) - fProxy.setText(QuickDiffMessages.getString("quickdiff.toggle.disable")); //$NON-NLS-1$ - else - fProxy.setText(QuickDiffMessages.getString("quickdiff.toggle.enable")); //$NON-NLS-1$ - } - -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/ReferenceProviderDescriptor.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/ReferenceProviderDescriptor.java deleted file mode 100644 index 6f7bd48c579..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/ReferenceProviderDescriptor.java +++ /dev/null @@ -1,132 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.texteditor.quickdiff; - -import org.osgi.framework.Bundle; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.Platform; - -import org.eclipse.jface.util.Assert; - - - -/** - * Describes an extension to the <code>quickdiff.referenceprovider</code> extension point. - * - * @see org.eclipse.ui.internal.texteditor.quickdiff.ReferenceSelectionAction - * @see QuickDiff - * @since 3.0 - */ -public class ReferenceProviderDescriptor { - - /** Name of the <code>label</code> attribute. */ - private static final String LABEL_ATTRIBUTE= "label"; //$NON-NLS-1$ - /** Name of the <code>class</code> attribute. */ - private static final String CLASS_ATTRIBUTE= "class"; //$NON-NLS-1$ - /** Name of the <code>id</code> attribute. */ - private static final String ID_ATTRIBUTE= "id"; //$NON-NLS-1$ - /** Name of the <code>default</code> attribute. */ - private static final String DEFAULT_ATTRIBUTE= "default"; //$NON-NLS-1$ - - /** The configuration element describing this extension. */ - private IConfigurationElement fConfiguration; - /** The value of the <code>label</code> attribute, if read. */ - private String fLabel; - /** The value of the <code>id</code> attribute, if read. */ - private String fId; - /** The value of the <code>default</code> attribute, if read. */ - private Boolean fDefault; - /** The bundle where this extension was defined. */ - private Bundle fBundle; - - /** - * Creates a new descriptor for <code>element</code>. - * <p> - * This method is for internal use only. - * </p> - * - * @param element the extension point element to be described. - */ - public ReferenceProviderDescriptor(IConfigurationElement element) { - Assert.isLegal(element != null); - fConfiguration= element; - } - - /** - * Reads (if needed) and returns the label of this extension. - * - * @return the label for this extension. - */ - public String getLabel() { - if (fLabel == null) { - fLabel= fConfiguration.getAttribute(LABEL_ATTRIBUTE); - Assert.isNotNull(fLabel); - } - return fLabel; - } - - /** - * Reads (if needed) and returns the id of this extension. - * - * @return the id for this extension. - */ - public String getId() { - if (fId == null) { - fId= fConfiguration.getAttribute(ID_ATTRIBUTE); - Assert.isNotNull(fId); - } - return fId; - } - - /** - * Creates a referenceprovider as described in the extension's xml. Sets the id on the provider. - * @return a new instance of the reference provider described by this descriptor. - */ - public IQuickDiffReferenceProvider createProvider() { - try { - IQuickDiffReferenceProvider impl= (IQuickDiffReferenceProvider)fConfiguration.createExecutableExtension(CLASS_ATTRIBUTE); - impl.setId(getId()); - return impl; - } catch (CoreException e) { - return null; - } - } - - /** - * States whether the plugin declaring this extension has been loaded already. - * - * @return <code>true</code> if the extension point's plugin has been loaded, <code>false</code> otherwise. - */ - public boolean isPluginLoaded() { - if (fBundle == null) - fBundle= Platform.getBundle(fConfiguration.getDeclaringExtension().getNamespace()); - return (fBundle != null && fBundle.getState() == Bundle.ACTIVE); - } - - /** - * Reads (if needed) and returns the default attribute value of this extension. - * - * @return the default attribute value for this extension. - */ - public boolean getDefault() { - if (fDefault == null) { - String def= fConfiguration.getAttribute(DEFAULT_ATTRIBUTE); - if ("true".equalsIgnoreCase(def)) //$NON-NLS-1$ - fDefault= Boolean.TRUE; - else - fDefault= Boolean.FALSE; - } - return fDefault.booleanValue(); - } - -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/package.html b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/package.html deleted file mode 100644 index c85f51bf08a..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/package.html +++ /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"> - <meta name="Author" content="IBM"> - <meta name="GENERATOR" content="Mozilla/4.51 [en] (WinNT; I) [Netscape]"> - <title>QuickDiff API</title> -</head> -<body> -Provides interfaces to for the <code>org.eclipse.ui.editors.quickDiffReferenceProvider</code> -extension point and adds an action to enable quick diff display for an editor. -</body> -</html> diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/EditTemplateDialog.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/EditTemplateDialog.java deleted file mode 100644 index 72e864b5912..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/EditTemplateDialog.java +++ /dev/null @@ -1,547 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.texteditor.templates; - -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.custom.StyledText; -import org.eclipse.swt.custom.VerifyKeyListener; -import org.eclipse.swt.events.FocusEvent; -import org.eclipse.swt.events.FocusListener; -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.events.VerifyEvent; -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.Label; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; -import org.eclipse.swt.widgets.Widget; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.GroupMarker; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.action.IMenuListener; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.text.Document; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.ITextListener; -import org.eclipse.jface.text.ITextOperationTarget; -import org.eclipse.jface.text.ITextViewer; -import org.eclipse.jface.text.TextEvent; -import org.eclipse.jface.text.contentassist.ContentAssistant; -import org.eclipse.jface.text.contentassist.IContentAssistant; -import org.eclipse.jface.text.source.ISourceViewer; -import org.eclipse.jface.text.source.SourceViewer; -import org.eclipse.jface.text.source.SourceViewerConfiguration; -import org.eclipse.jface.text.templates.TemplateContextType; -import org.eclipse.jface.text.templates.ContextTypeRegistry; -import org.eclipse.jface.text.templates.Template; -import org.eclipse.jface.text.templates.TemplateException; - -import org.eclipse.ui.texteditor.ITextEditorActionConstants; -import org.eclipse.ui.texteditor.IUpdate; - -/** - * Dialog to edit a template. Clients will usually instantiate, but may also may - * extend. - * - * @since 3.0 - */ -class EditTemplateDialog extends StatusDialog { - - private static class TextViewerAction extends Action implements IUpdate { - - private int fOperationCode= -1; - private ITextOperationTarget fOperationTarget; - - /** - * Creates a new action. - * - * @param viewer the viewer - * @param operationCode the opcode - */ - public TextViewerAction(ITextViewer viewer, int operationCode) { - fOperationCode= operationCode; - fOperationTarget= viewer.getTextOperationTarget(); - update(); - } - - /** - * Updates the enabled state of the action. - * Fires a property change if the enabled state changes. - * - * @see Action#firePropertyChange(String, Object, Object) - */ - public void update() { - - boolean wasEnabled= isEnabled(); - boolean isEnabled= (fOperationTarget != null && fOperationTarget.canDoOperation(fOperationCode)); - setEnabled(isEnabled); - - if (wasEnabled != isEnabled) { - firePropertyChange(ENABLED, wasEnabled ? Boolean.TRUE : Boolean.FALSE, isEnabled ? Boolean.TRUE : Boolean.FALSE); - } - } - - /** - * @see Action#run() - */ - public void run() { - if (fOperationCode != -1 && fOperationTarget != null) { - fOperationTarget.doOperation(fOperationCode); - } - } - } - - private final Template fTemplate; - - private Text fNameText; - private Text fDescriptionText; - private Combo fContextCombo; - private SourceViewer fPatternEditor; - private Button fInsertVariableButton; - private boolean fIsNameModifiable; - - private StatusInfo fValidationStatus; - private boolean fSuppressError= true; // #4354 - private Map fGlobalActions= new HashMap(10); - private List fSelectionActions = new ArrayList(3); - private String[][] fContextTypes; - - private ContextTypeRegistry fContextTypeRegistry; - - private final TemplateVariableProcessor fTemplateProcessor= new TemplateVariableProcessor(); - - /** - * Creates a new dialog. - * - * @param parent the shell parent of the dialog - * @param template the template to edit - * @param edit whether this is a new template or an existing being edited - * @param isNameModifiable whether the name of the template may be modified - * @param registry the context type registry to use - */ - public EditTemplateDialog(Shell parent, Template template, boolean edit, boolean isNameModifiable, ContextTypeRegistry registry) { - super(parent); - - setShellStyle(getShellStyle() | SWT.MAX | SWT.RESIZE); - - String title= edit - ? TextEditorTemplateMessages.getString("EditTemplateDialog.title.edit") //$NON-NLS-1$ - : TextEditorTemplateMessages.getString("EditTemplateDialog.title.new"); //$NON-NLS-1$ - setTitle(title); - - fTemplate= template; - fIsNameModifiable= isNameModifiable; - - List contexts= new ArrayList(); - for (Iterator it= registry.contextTypes(); it.hasNext();) { - TemplateContextType type= (TemplateContextType) it.next(); - contexts.add(new String[] { type.getId(), type.getName() }); - } - fContextTypes= (String[][]) contexts.toArray(new String[contexts.size()][]); - - fValidationStatus= new StatusInfo(); - - fContextTypeRegistry= registry; - - TemplateContextType type= fContextTypeRegistry.getContextType(template.getContextTypeId()); - fTemplateProcessor.setContextType(type); - } - - /* - * @see org.eclipse.ui.texteditor.templates.StatusDialog#create() - */ - public void create() { - super.create(); - // update initial ok button to be disabled for new templates - boolean valid= fNameText == null || fNameText.getText().trim().length() != 0; - if (!valid) { - StatusInfo status = new StatusInfo(); - status.setError(TextEditorTemplateMessages.getString("EditTemplateDialog.error.noname")); //$NON-NLS-1$ - updateButtonsEnableState(status); - } - } - - /* - * @see Dialog#createDialogArea(Composite) - */ - protected Control createDialogArea(Composite ancestor) { - Composite parent= new Composite(ancestor, SWT.NONE); - GridLayout layout= new GridLayout(); - layout.numColumns= 2; - parent.setLayout(layout); - parent.setLayoutData(new GridData(GridData.FILL_BOTH)); - - ModifyListener listener= new ModifyListener() { - public void modifyText(ModifyEvent e) { - doTextWidgetChanged(e.widget); - } - }; - - if (fIsNameModifiable) { - createLabel(parent, TextEditorTemplateMessages.getString("EditTemplateDialog.name")); //$NON-NLS-1$ - - Composite composite= new Composite(parent, SWT.NONE); - composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - layout= new GridLayout(); - layout.numColumns= 3; - layout.marginWidth= 0; - layout.marginHeight= 0; - composite.setLayout(layout); - - fNameText= createText(composite); - fNameText.addModifyListener(listener); - fNameText.addFocusListener(new FocusListener() { - - public void focusGained(FocusEvent e) { - } - - public void focusLost(FocusEvent e) { - if (fSuppressError) { - fSuppressError= false; - updateButtons(); - } - } - }); - - createLabel(composite, TextEditorTemplateMessages.getString("EditTemplateDialog.context")); //$NON-NLS-1$ - fContextCombo= new Combo(composite, SWT.READ_ONLY); - - for (int i= 0; i < fContextTypes.length; i++) { - fContextCombo.add(fContextTypes[i][1]); - } - - fContextCombo.addModifyListener(listener); - } - - createLabel(parent, TextEditorTemplateMessages.getString("EditTemplateDialog.description")); //$NON-NLS-1$ - - int descFlags= fIsNameModifiable ? SWT.BORDER : SWT.BORDER | SWT.READ_ONLY; - fDescriptionText= new Text(parent, descFlags ); - fDescriptionText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - fDescriptionText.addModifyListener(listener); - - Label patternLabel= createLabel(parent, TextEditorTemplateMessages.getString("EditTemplateDialog.pattern")); //$NON-NLS-1$ - patternLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); - fPatternEditor= createEditor(parent); - - Label filler= new Label(parent, SWT.NONE); - filler.setLayoutData(new GridData()); - - Composite composite= new Composite(parent, SWT.NONE); - layout= new GridLayout(); - layout.marginWidth= 0; - layout.marginHeight= 0; - composite.setLayout(layout); - composite.setLayoutData(new GridData()); - - fInsertVariableButton= new Button(composite, SWT.NONE); - fInsertVariableButton.setLayoutData(getButtonGridData(fInsertVariableButton)); - fInsertVariableButton.setText(TextEditorTemplateMessages.getString("EditTemplateDialog.insert.variable")); //$NON-NLS-1$ - fInsertVariableButton.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent e) { - fPatternEditor.getTextWidget().setFocus(); - fPatternEditor.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS); - } - - public void widgetDefaultSelected(SelectionEvent e) {} - }); - - fDescriptionText.setText(fTemplate.getDescription()); - if (fIsNameModifiable) { - fNameText.setText(fTemplate.getName()); - fNameText.addModifyListener(listener); - fContextCombo.select(getIndex(fTemplate.getContextTypeId())); - } else { - fPatternEditor.getControl().setFocus(); - } - initializeActions(); - - applyDialogFont(parent); - return composite; - } - - private void doTextWidgetChanged(Widget w) { - if (w == fNameText) { - fSuppressError= false; - String name= fNameText.getText(); - fTemplate.setName(name); - updateButtons(); - } else if (w == fContextCombo) { - String name= fContextCombo.getText(); - String contextId= getContextId(name); - fTemplate.setContextTypeId(contextId); - fTemplateProcessor.setContextType(fContextTypeRegistry.getContextType(contextId)); - } else if (w == fDescriptionText) { - String desc= fDescriptionText.getText(); - fTemplate.setDescription(desc); - } - } - - private String getContextId(String name) { - if (name == null) - return name; - - for (int i= 0; i < fContextTypes.length; i++) { - if (name.equals(fContextTypes[i][1])) { - return fContextTypes[i][0]; - } - } - return name; - } - - private void doSourceChanged(IDocument document) { - String text= document.get(); - fTemplate.setPattern(text); - fValidationStatus.setOK(); - TemplateContextType contextType= fContextTypeRegistry.getContextType(fTemplate.getContextTypeId()); - if (contextType != null) { - try { - contextType.validate(text); - } catch (TemplateException e) { - fValidationStatus.setError(e.getLocalizedMessage()); - } - } - - updateUndoAction(); - updateButtons(); - } - - private static GridData getButtonGridData(Button button) { - GridData data= new GridData(GridData.FILL_HORIZONTAL); - // TODO get some button hints. -// data.heightHint= SWTUtil.getButtonHeightHint(button); - - return data; - } - - private static Label createLabel(Composite parent, String name) { - Label label= new Label(parent, SWT.NULL); - label.setText(name); - label.setLayoutData(new GridData()); - - return label; - } - - private static Text createText(Composite parent) { - Text text= new Text(parent, SWT.BORDER); - text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - return text; - } - - private SourceViewer createEditor(Composite parent) { - SourceViewer viewer= createViewer(parent); - - IDocument document= new Document(fTemplate.getPattern()); - viewer.setEditable(true); - viewer.setDocument(document); - - - int nLines= document.getNumberOfLines(); - if (nLines < 5) { - nLines= 5; - } else if (nLines > 12) { - nLines= 12; - } - - Control control= viewer.getControl(); - GridData data= new GridData(GridData.FILL_BOTH); - data.widthHint= convertWidthInCharsToPixels(80); - data.heightHint= convertHeightInCharsToPixels(nLines); - control.setLayoutData(data); - - viewer.addTextListener(new ITextListener() { - public void textChanged(TextEvent event) { - if (event .getDocumentEvent() != null) - doSourceChanged(event.getDocumentEvent().getDocument()); - } - }); - - viewer.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - updateSelectionDependentActions(); - } - }); - - viewer.prependVerifyKeyListener(new VerifyKeyListener() { - public void verifyKey(VerifyEvent event) { - handleVerifyKeyPressed(event); - } - }); - - return viewer; - } - - /** - * Creates the viewer to be used to display the pattern. Subclasses may override. - * - * @param parent the parent composite of the viewer - * @return a configured <code>SourceViewer</code> - */ - protected SourceViewer createViewer(Composite parent) { - SourceViewer viewer= new SourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); - SourceViewerConfiguration configuration= new SourceViewerConfiguration() { - public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) { - - ContentAssistant assistant= new ContentAssistant(); - assistant.enableAutoActivation(true); - assistant.enableAutoInsert(true); - assistant.setContentAssistProcessor(fTemplateProcessor, IDocument.DEFAULT_CONTENT_TYPE); - return assistant; - } - }; - viewer.configure(configuration); - return viewer; - } - - private void handleVerifyKeyPressed(VerifyEvent event) { - if (!event.doit) - return; - - if (event.stateMask != SWT.MOD1) - return; - - switch (event.character) { - case ' ': - fPatternEditor.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS); - event.doit= false; - break; - - // CTRL-Z - case 'z' - 'a' + 1: - fPatternEditor.doOperation(ITextOperationTarget.UNDO); - event.doit= false; - break; - } - } - - private void initializeActions() { - TextViewerAction action= new TextViewerAction(fPatternEditor, ITextOperationTarget.UNDO); - action.setText(TextEditorTemplateMessages.getString("EditTemplateDialog.undo")); //$NON-NLS-1$ - fGlobalActions.put(ITextEditorActionConstants.UNDO, action); - - action= new TextViewerAction(fPatternEditor, ITextOperationTarget.CUT); - action.setText(TextEditorTemplateMessages.getString("EditTemplateDialog.cut")); //$NON-NLS-1$ - fGlobalActions.put(ITextEditorActionConstants.CUT, action); - - action= new TextViewerAction(fPatternEditor, ITextOperationTarget.COPY); - action.setText(TextEditorTemplateMessages.getString("EditTemplateDialog.copy")); //$NON-NLS-1$ - fGlobalActions.put(ITextEditorActionConstants.COPY, action); - - action= new TextViewerAction(fPatternEditor, ITextOperationTarget.PASTE); - action.setText(TextEditorTemplateMessages.getString("EditTemplateDialog.paste")); //$NON-NLS-1$ - fGlobalActions.put(ITextEditorActionConstants.PASTE, action); - - action= new TextViewerAction(fPatternEditor, ITextOperationTarget.SELECT_ALL); - action.setText(TextEditorTemplateMessages.getString("EditTemplateDialog.select.all")); //$NON-NLS-1$ - fGlobalActions.put(ITextEditorActionConstants.SELECT_ALL, action); - - action= new TextViewerAction(fPatternEditor, ISourceViewer.CONTENTASSIST_PROPOSALS); - action.setText(TextEditorTemplateMessages.getString("EditTemplateDialog.content.assist")); //$NON-NLS-1$ - fGlobalActions.put("ContentAssistProposal", action); //$NON-NLS-1$ - - fSelectionActions.add(ITextEditorActionConstants.CUT); - fSelectionActions.add(ITextEditorActionConstants.COPY); - fSelectionActions.add(ITextEditorActionConstants.PASTE); - - // create context menu - MenuManager manager= new MenuManager(null, null); - manager.setRemoveAllWhenShown(true); - manager.addMenuListener(new IMenuListener() { - public void menuAboutToShow(IMenuManager mgr) { - fillContextMenu(mgr); - } - }); - - StyledText text= fPatternEditor.getTextWidget(); - Menu menu= manager.createContextMenu(text); - text.setMenu(menu); - } - - private void fillContextMenu(IMenuManager menu) { - menu.add(new GroupMarker(ITextEditorActionConstants.GROUP_UNDO)); - menu.appendToGroup(ITextEditorActionConstants.GROUP_UNDO, (IAction) fGlobalActions.get(ITextEditorActionConstants.UNDO)); - - menu.add(new Separator(ITextEditorActionConstants.GROUP_EDIT)); - menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, (IAction) fGlobalActions.get(ITextEditorActionConstants.CUT)); - menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, (IAction) fGlobalActions.get(ITextEditorActionConstants.COPY)); - menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, (IAction) fGlobalActions.get(ITextEditorActionConstants.PASTE)); - menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, (IAction) fGlobalActions.get(ITextEditorActionConstants.SELECT_ALL)); - - menu.add(new Separator("templates")); //$NON-NLS-1$ - menu.appendToGroup("templates", (IAction) fGlobalActions.get("ContentAssistProposal")); //$NON-NLS-1$ //$NON-NLS-2$ - } - - private void updateSelectionDependentActions() { - Iterator iterator= fSelectionActions.iterator(); - while (iterator.hasNext()) - updateAction((String)iterator.next()); - } - - private void updateUndoAction() { - IAction action= (IAction) fGlobalActions.get(ITextEditorActionConstants.UNDO); - if (action instanceof IUpdate) - ((IUpdate) action).update(); - } - - private void updateAction(String actionId) { - IAction action= (IAction) fGlobalActions.get(actionId); - if (action instanceof IUpdate) - ((IUpdate) action).update(); - } - - private int getIndex(String contextid) { - - if (contextid == null) - return -1; - - for (int i= 0; i < fContextTypes.length; i++) { - if (contextid.equals(fContextTypes[i][0])) { - return i; - } - } - return -1; - } - - private void updateButtons() { - StatusInfo status; - - boolean valid= fNameText == null || fNameText.getText().trim().length() != 0; - if (!valid) { - status = new StatusInfo(); - if (!fSuppressError) { - status.setError(TextEditorTemplateMessages.getString("EditTemplateDialog.error.noname")); //$NON-NLS-1$ - } - } else { - status= fValidationStatus; - } - updateStatus(status); - } - -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/MessageLine.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/MessageLine.java deleted file mode 100644 index 2025e53962b..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/MessageLine.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.texteditor.templates; - -import org.eclipse.core.runtime.IStatus; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CLabel; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; - -import org.eclipse.jface.resource.JFaceColors; - - -/** - * A message line displaying a status. - * - * @since 3.0 - */ -class MessageLine extends CLabel { - - private Color fNormalMsgAreaBackground; - - /** - * Creates a new message line as a child of the given parent. - * - * @param parent the parent composite - */ - 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. - * - * @param parent the parent composite - * @param style the style - */ - public MessageLine(Composite parent, int style) { - super(parent, style); - fNormalMsgAreaBackground= getBackground(); - } - - - private Image findImage(IStatus status) { - if (status.isOK()) { - return null; - } - return null; - } - - /** - * Sets the message and image to the given status. - * <code>null</code> is a valid argument and will set the empty text and no image - * - * @param status the status - */ - public void setErrorStatus(IStatus status) { - if (status != null && !status.isOK()) { - String message= status.getMessage(); - if (message != null && message.length() > 0) { - setText(message); - setImage(findImage(status)); - setBackground(JFaceColors.getErrorBackground(getDisplay())); - return; - } - } - setText(""); //$NON-NLS-1$ - setImage(null); - setBackground(fNormalMsgAreaBackground); - } -} - diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/StatusDialog.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/StatusDialog.java deleted file mode 100644 index 46e89f839e7..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/StatusDialog.java +++ /dev/null @@ -1,180 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.texteditor.templates; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Image; -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.Shell; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; - -import org.eclipse.core.runtime.IStatus; - -/** - * An abstract base class for dialogs with a status bar and ok/cancel buttons. - * The status message must be passed over as StatusInfo object and can be - * an error, warning or ok. The OK button is enabled or disabled depending - * on the status. - * - * @since 3.0 - */ -abstract class StatusDialog extends Dialog { - - private Button fOkButton; - private MessageLine fStatusLine; - private IStatus fLastStatus; - private String fTitle; - private Image fImage; - private boolean fStatusLineAboveButtons= true; - - /** - * Creates an instane of a status dialog. - * - * @param parent the parent shell - */ - public StatusDialog(Shell parent) { - super(parent); - fLastStatus= new StatusInfo(); - } - - /** - * Specifies whether status line appears to the left of the buttons (default) - * or above them. - * - * @param aboveButtons if <code>true</code> status line is placed above buttons; if - * <code>false</code> to the right - */ - public void setStatusLineAboveButtons(boolean aboveButtons) { - fStatusLineAboveButtons= aboveButtons; - } - - /** - * Update the dialog's status line to reflect the given status. - * It is save to call this method before the dialog has been opened. - * - * @param status the status - */ - protected void updateStatus(IStatus status) { - fLastStatus= status; - if (fStatusLine != null && !fStatusLine.isDisposed()) { - updateButtonsEnableState(status); - fStatusLine.setErrorStatus(status); - } - } - - /** - * Returns the last status. - * - * @return the last status - */ - public IStatus getStatus() { - return fLastStatus; - } - - /** - * Updates the status of the ok button to reflect the given status. - * Subclasses may override this method to update additional buttons. - * @param status the status. - */ - protected void updateButtonsEnableState(IStatus status) { - if (fOkButton != null && !fOkButton.isDisposed()) - fOkButton.setEnabled(!status.matches(IStatus.ERROR)); - } - - /* - * @see Window#create(Shell) - */ - protected void configureShell(Shell shell) { - super.configureShell(shell); - if (fTitle != null) - shell.setText(fTitle); - } - - /* - * @see Window#create() - */ - public void create() { - super.create(); - if (fLastStatus != null) { - // policy: dialogs are not allowed to come up with an error message - if (fLastStatus.matches(IStatus.ERROR)) { - StatusInfo status= new StatusInfo(); - status.setError(""); //$NON-NLS-1$ - fLastStatus= status; - } - updateStatus(fLastStatus); - } - } - - /* - * @see Dialog#createButtonsForButtonBar(Composite) - */ - protected void createButtonsForButtonBar(Composite parent) { - fOkButton= createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); - createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); - } - - /* - * @see Dialog#createButtonBar(Composite) - */ - protected Control createButtonBar(Composite parent) { - Composite composite= new Composite(parent, SWT.NULL); - GridLayout layout= new GridLayout(); - - if (fStatusLineAboveButtons) { - layout.numColumns= 1; - } else { - layout.numColumns= 2; - } - - layout.marginHeight= 0; - layout.marginWidth= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - fStatusLine= new MessageLine(composite); - fStatusLine.setAlignment(SWT.LEFT); - fStatusLine.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - fStatusLine.setErrorStatus(null); - applyDialogFont(composite); - super.createButtonBar(composite); - return composite; - } - - /** - * Sets the title for this dialog. - * @param title the title. - */ - public void setTitle(String title) { - fTitle= title != null ? title : ""; //$NON-NLS-1$ - Shell shell= getShell(); - if ((shell != null) && !shell.isDisposed()) - shell.setText(fTitle); - } - - /** - * Sets the image for this dialog. - * @param image the image. - */ - public void setImage(Image image) { - fImage= image; - Shell shell= getShell(); - if ((shell != null) && !shell.isDisposed()) - shell.setImage(fImage); - } - -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/StatusInfo.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/StatusInfo.java deleted file mode 100644 index e0de57ce22f..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/StatusInfo.java +++ /dev/null @@ -1,184 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.texteditor.templates; - -import org.eclipse.core.runtime.IStatus; - -import org.eclipse.jface.util.Assert; - -/** - * A settable IStatus. - * Can be an error, warning, info or ok. For error, info and warning states, - * a message describes the problem. - * - * @since 3.0 - */ -class StatusInfo implements IStatus { - - private String fStatusMessage; - private int fSeverity; - - /** - * Creates a status set to OK (no message) - */ - public StatusInfo() { - this(OK, null); - } - - /** - * Creates a status . - * @param severity The status severity: ERROR, WARNING, INFO and OK. - * @param message The message of the status. Applies only for ERROR, - * WARNING and INFO. - */ - public StatusInfo(int severity, String message) { - fStatusMessage= message; - fSeverity= severity; - } - - /** - * Returns if the status' severity is OK. - * - * @return <code>true</code> if the status' severity is OK - */ - public boolean isOK() { - return fSeverity == IStatus.OK; - } - - /** - * Returns if the status' severity is WARNING. - * - * @return <code>true</code> if the status' severity is WARNING - */ - public boolean isWarning() { - return fSeverity == IStatus.WARNING; - } - - /** - * Returns if the status' severity is INFO. - * - * @return <code>true</code> if the status' severity is INFO - */ - public boolean isInfo() { - return fSeverity == IStatus.INFO; - } - - /** - * Returns if the status' severity is ERROR. - * - * @return <code>true</code> if the status' severity is ERROR - */ - public boolean isError() { - return fSeverity == IStatus.ERROR; - } - - /** - * Returns the message. - * - * @return the message - * @see IStatus#getMessage() - */ - public String getMessage() { - return fStatusMessage; - } - - /** - * Sets the status to ERROR. - * @param errorMessage the error message (can be empty, but not null) - */ - public void setError(String errorMessage) { - Assert.isNotNull(errorMessage); - fStatusMessage= errorMessage; - fSeverity= IStatus.ERROR; - } - - /** - * Sets the status to WARNING. - * @param warningMessage the warning message (can be empty, but not null) - */ - public void setWarning(String warningMessage) { - Assert.isNotNull(warningMessage); - fStatusMessage= warningMessage; - fSeverity= IStatus.WARNING; - } - - /** - * Sets the status to INFO. - * @param infoMessage the info message (can be empty, but not null) - */ - public void setInfo(String infoMessage) { - Assert.isNotNull(infoMessage); - fStatusMessage= infoMessage; - fSeverity= IStatus.INFO; - } - - /** - * Sets the status to OK. - */ - public void setOK() { - fStatusMessage= null; - fSeverity= IStatus.OK; - } - - /* - * @see IStatus#matches(int) - */ - public boolean matches(int severityMask) { - return (fSeverity & severityMask) != 0; - } - - /** - * Returns always <code>false</code>. - * @see IStatus#isMultiStatus() - */ - public boolean isMultiStatus() { - return false; - } - - /* - * @see IStatus#getSeverity() - */ - public int getSeverity() { - return fSeverity; - } - - /* - * @see IStatus#getPlugin() - */ - public String getPlugin() { - return ""; //$NON-NLS-1$ - } - - /** - * Returns always <code>null</code>. - * @see IStatus#getException() - */ - public Throwable getException() { - return null; - } - - /** - * Returns always the error severity. - * @see IStatus#getCode() - */ - public int getCode() { - return fSeverity; - } - - /** - * Returns always <code>null</code>. - * @see IStatus#getChildren() - */ - public IStatus[] getChildren() { - return new IStatus[0]; - } - -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplateContentProvider.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplateContentProvider.java deleted file mode 100644 index 622fc1595d8..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplateContentProvider.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.texteditor.templates; - -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.Viewer; - -import org.eclipse.jface.text.templates.persistence.TemplateStore; - - -/** - * A content provider for the template preferenc page's table viewer. - * - * @since 3.0 - */ -class TemplateContentProvider implements IStructuredContentProvider { - - /** The template store. */ - private TemplateStore fStore; - - /* - * @see IStructuredContentProvider#getElements(Object) - */ - public Object[] getElements(Object input) { - return fStore.getTemplateData(false); - } - - /* - * @see IContentProvider#inputChanged(Viewer, Object, Object) - */ - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - fStore= (TemplateStore) newInput; - } - - /* - * @see IContentProvider#dispose() - */ - public void dispose() { - fStore= null; - } - -} - diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java deleted file mode 100644 index 73e00ba658e..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java +++ /dev/null @@ -1,820 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.texteditor.templates; - -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -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 org.eclipse.swt.SWT; -import org.eclipse.swt.events.ControlAdapter; -import org.eclipse.swt.events.ControlEvent; -import org.eclipse.swt.graphics.Image; -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.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.FileDialog; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.preference.PreferencePage; -import org.eclipse.jface.viewers.CheckStateChangedEvent; -import org.eclipse.jface.viewers.CheckboxTableViewer; -import org.eclipse.jface.viewers.DoubleClickEvent; -import org.eclipse.jface.viewers.ICheckStateListener; -import org.eclipse.jface.viewers.IDoubleClickListener; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerSorter; -import org.eclipse.jface.window.Window; - -import org.eclipse.jface.text.Document; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.source.SourceViewer; -import org.eclipse.jface.text.source.SourceViewerConfiguration; -import org.eclipse.jface.text.templates.ContextTypeRegistry; -import org.eclipse.jface.text.templates.Template; -import org.eclipse.jface.text.templates.TemplateContextType; -import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; -import org.eclipse.jface.text.templates.persistence.TemplateReaderWriter; -import org.eclipse.jface.text.templates.persistence.TemplateStore; - -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; - -/** - * A template preference page allows configuration of the templates for an - * editor. It provides controls for adding, removing and changing templates as - * well as enablement, default management and an optional formatter preference. - * <p> - * Subclasses need to provide a {@link TemplateStore} and a - * {@link ContextTypeRegistry} and should set the preference store. They may - * optionally override {@link #isShowFormatterSetting()}. - * </p> - * - * @since 3.0 - */ -public abstract class TemplatePreferencePage extends PreferencePage implements IWorkbenchPreferencePage { - - /** - * Label provider for templates. - */ - private class TemplateLabelProvider extends LabelProvider implements ITableLabelProvider { - - /* - * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int) - */ - public Image getColumnImage(Object element, int columnIndex) { - return null; - } - - /* - * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int) - */ - public String getColumnText(Object element, int columnIndex) { - TemplatePersistenceData data = (TemplatePersistenceData) element; - Template template= data.getTemplate(); - - switch (columnIndex) { - case 0: - return template.getName(); - case 1: - TemplateContextType type= fContextTypeRegistry.getContextType(template.getContextTypeId()); - if (type != null) - return type.getName(); - else - return template.getContextTypeId(); - case 2: - return template.getDescription(); - default: - return ""; //$NON-NLS-1$ - } - } - } - - - /** Qualified key for formatter preference. */ - private static final String DEFAULT_FORMATTER_PREFERENCE_KEY= "org.eclipse.ui.texteditor.templates.preferences.format_templates"; //$NON-NLS-1$ - - /** The table presenting the templates. */ - private CheckboxTableViewer fTableViewer; - - /* buttons */ - private Button fAddButton; - private Button fEditButton; - private Button fImportButton; - private Button fExportButton; - private Button fRemoveButton; - private Button fRestoreButton; - private Button fRevertButton; - - /** The viewer displays the pattern of selected template. */ - private SourceViewer fPatternViewer; - /** Format checkbox. This gets conditionally added. */ - private Button fFormatButton; - /** The store for our templates. */ - private TemplateStore fTemplateStore; - /** The context type registry. */ - private ContextTypeRegistry fContextTypeRegistry; - - - /** - * Creates a new template preference page. - */ - protected TemplatePreferencePage() { - super(); - - setDescription(TextEditorTemplateMessages.getString("TemplatePreferencePage.message")); //$NON-NLS-1$ - } - - /** - * Returns the template store. - * - * @return the template store - */ - public TemplateStore getTemplateStore() { - return fTemplateStore; - } - - /** - * Returns the context type registry. - * - * @return the context type registry - */ - public ContextTypeRegistry getContextTypeRegistry() { - return fContextTypeRegistry; - } - - /** - * Sets the template store. - * - * @param store the new template store - */ - public void setTemplateStore(TemplateStore store) { - fTemplateStore= store; - } - - /** - * Sets the context type registry. - * - * @param registry the new context type registry - */ - public void setContextTypeRegistry(ContextTypeRegistry registry) { - fContextTypeRegistry= registry; - } - - /* - * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) - */ - public void init(IWorkbench workbench) { - } - - /* - * @see PreferencePage#createContents(Composite) - */ - protected Control createContents(Composite ancestor) { - Composite parent= new Composite(ancestor, SWT.NONE); - GridLayout layout= new GridLayout(); - layout.numColumns= 2; - layout.marginHeight= 0; - layout.marginWidth= 0; - parent.setLayout(layout); - - Composite innerParent= new Composite(parent, SWT.NONE); - GridLayout innerLayout= new GridLayout(); - innerLayout.numColumns= 2; - innerLayout.marginHeight= 0; - innerLayout.marginWidth= 0; - innerParent.setLayout(innerLayout); - GridData gd= new GridData(GridData.FILL_BOTH); - gd.horizontalSpan= 2; - innerParent.setLayoutData(gd); - - Table table= new Table(innerParent, SWT.CHECK | SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION); - - GridData data= new GridData(GridData.FILL_BOTH); - data.widthHint= convertWidthInCharsToPixels(3); - data.heightHint= convertHeightInCharsToPixels(10); - table.setLayoutData(data); - - table.setHeaderVisible(true); - table.setLinesVisible(true); - - TableLayout tableLayout= new TableLayout(); - table.setLayout(tableLayout); - - TableColumn column1= new TableColumn(table, SWT.NONE); - column1.setText(TextEditorTemplateMessages.getString("TemplatePreferencePage.column.name")); //$NON-NLS-1$ - - TableColumn column2= new TableColumn(table, SWT.NONE); - column2.setText(TextEditorTemplateMessages.getString("TemplatePreferencePage.column.context")); //$NON-NLS-1$ - - TableColumn column3= new TableColumn(table, SWT.NONE); - column3.setText(TextEditorTemplateMessages.getString("TemplatePreferencePage.column.description")); //$NON-NLS-1$ - - fTableViewer= new CheckboxTableViewer(table); - fTableViewer.setLabelProvider(new TemplateLabelProvider()); - fTableViewer.setContentProvider(new TemplateContentProvider()); - - fTableViewer.setSorter(new ViewerSorter() { - public int compare(Viewer viewer, Object object1, Object object2) { - if ((object1 instanceof TemplatePersistenceData) && (object2 instanceof TemplatePersistenceData)) { - Template left= ((TemplatePersistenceData) object1).getTemplate(); - Template right= ((TemplatePersistenceData) object2).getTemplate(); - int result= left.getName().compareToIgnoreCase(right.getName()); - if (result != 0) - return result; - return left.getDescription().compareToIgnoreCase(right.getDescription()); - } - return super.compare(viewer, object1, object2); - } - - public boolean isSorterProperty(Object element, String property) { - return true; - } - }); - - fTableViewer.addDoubleClickListener(new IDoubleClickListener() { - public void doubleClick(DoubleClickEvent e) { - edit(); - } - }); - - fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent e) { - selectionChanged1(); - } - }); - - fTableViewer.addCheckStateListener(new ICheckStateListener() { - public void checkStateChanged(CheckStateChangedEvent event) { - TemplatePersistenceData d= (TemplatePersistenceData) event.getElement(); - d.setEnabled(event.getChecked()); - } - }); - - Composite buttons= new Composite(innerParent, SWT.NONE); - buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); - layout= new GridLayout(); - layout.marginHeight= 0; - layout.marginWidth= 0; - buttons.setLayout(layout); - - fAddButton= new Button(buttons, SWT.PUSH); - fAddButton.setText(TextEditorTemplateMessages.getString("TemplatePreferencePage.new")); //$NON-NLS-1$ - fAddButton.setLayoutData(getButtonGridData(fAddButton)); - fAddButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - add(); - } - }); - - fEditButton= new Button(buttons, SWT.PUSH); - fEditButton.setText(TextEditorTemplateMessages.getString("TemplatePreferencePage.edit")); //$NON-NLS-1$ - fEditButton.setLayoutData(getButtonGridData(fEditButton)); - fEditButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - edit(); - } - }); - - fRemoveButton= new Button(buttons, SWT.PUSH); - fRemoveButton.setText(TextEditorTemplateMessages.getString("TemplatePreferencePage.remove")); //$NON-NLS-1$ - fRemoveButton.setLayoutData(getButtonGridData(fRemoveButton)); - fRemoveButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - remove(); - } - }); - - createSeparator(buttons); - - fRestoreButton= new Button(buttons, SWT.PUSH); - fRestoreButton.setText(TextEditorTemplateMessages.getString("TemplatePreferencePage.restore")); //$NON-NLS-1$ - fRestoreButton.setLayoutData(getButtonGridData(fRestoreButton)); - fRestoreButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - restoreDeleted(); - } - }); - - fRevertButton= new Button(buttons, SWT.PUSH); - fRevertButton.setText(TextEditorTemplateMessages.getString("TemplatePreferencePage.revert")); //$NON-NLS-1$ - fRevertButton.setLayoutData(getButtonGridData(fRevertButton)); - fRevertButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - revert(); - } - }); - - createSeparator(buttons); - - fImportButton= new Button(buttons, SWT.PUSH); - fImportButton.setText(TextEditorTemplateMessages.getString("TemplatePreferencePage.import")); //$NON-NLS-1$ - fImportButton.setLayoutData(getButtonGridData(fImportButton)); - fImportButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - import_(); - } - }); - - fExportButton= new Button(buttons, SWT.PUSH); - fExportButton.setText(TextEditorTemplateMessages.getString("TemplatePreferencePage.export")); //$NON-NLS-1$ - fExportButton.setLayoutData(getButtonGridData(fExportButton)); - fExportButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - export(); - } - }); - - fPatternViewer= doCreateViewer(parent); - - if (isShowFormatterSetting()) { - fFormatButton= new Button(parent, SWT.CHECK); - fFormatButton.setText(TextEditorTemplateMessages.getString("TemplatePreferencePage.use.code.formatter")); //$NON-NLS-1$ - GridData gd1= new GridData(); - gd1.horizontalSpan= 2; - fFormatButton.setLayoutData(gd1); - fFormatButton.setSelection(getPreferenceStore().getBoolean(getFormatterPreferenceKey())); - } - - fTableViewer.setInput(fTemplateStore); - fTableViewer.setAllChecked(false); - fTableViewer.setCheckedElements(getEnabledTemplates()); - - updateButtons(); - configureTableResizing(innerParent, buttons, table, column1, column2, column3); - - Dialog.applyDialogFont(parent); - return parent; - } - - /** - * Creates a separator between buttons - * @param parent - * @return - */ - private Label createSeparator(Composite parent) { - Label separator= new Label(parent, SWT.NONE); - separator.setVisible(false); - GridData gd= new GridData(); - gd.horizontalAlignment= GridData.FILL; - gd.verticalAlignment= GridData.BEGINNING; - gd.heightHint= 4; - separator.setLayoutData(gd); - return separator; - } - - /** - * Returns whether the formatter preference checkbox should be shown. - * - * @return <code>true</code> if the formatter preference checkbox should - * be shown, <code>false</code> otherwise - */ - protected boolean isShowFormatterSetting() { - return true; - } - - /** - * Correctly resizes the table so no phantom columns appear - */ - private static void configureTableResizing(final Composite parent, final Composite buttons, final Table table, final TableColumn column1, final TableColumn column2, final TableColumn column3) { - parent.addControlListener(new ControlAdapter() { - public void controlResized(ControlEvent e) { - Rectangle area= parent.getClientArea(); - Point preferredSize= table.computeSize(SWT.DEFAULT, SWT.DEFAULT); - int width= area.width - 2 * table.getBorderWidth(); - if (preferredSize.y > area.height) { - // Subtract the scrollbar width from the total column width - // if a vertical scrollbar will be required - Point vBarSize = table.getVerticalBar().getSize(); - width -= vBarSize.x; - } - width -= buttons.getSize().x; - Point oldSize= table.getSize(); - if (oldSize.x > width) { - // table is getting smaller so make the columns - // smaller first and then resize the table to - // match the client area width - column1.setWidth(width/4); - column2.setWidth(width/4); - column3.setWidth(width - (column1.getWidth() + column2.getWidth())); - table.setSize(width, area.height); - } else { - // table is getting bigger so make the table - // bigger first and then make the columns wider - // to match the client area width - table.setSize(width, area.height); - column1.setWidth(width / 4); - column2.setWidth(width / 4); - column3.setWidth(width - (column1.getWidth() + column2.getWidth())); - } - } - }); - } - - - private TemplatePersistenceData[] getEnabledTemplates() { - List enabled= new ArrayList(); - TemplatePersistenceData[] datas= fTemplateStore.getTemplateData(false); - for (int i= 0; i < datas.length; i++) { - if (datas[i].isEnabled()) - enabled.add(datas[i]); - } - return (TemplatePersistenceData[]) enabled.toArray(new TemplatePersistenceData[enabled.size()]); - } - - private SourceViewer doCreateViewer(Composite parent) { - Label label= new Label(parent, SWT.NONE); - label.setText(TextEditorTemplateMessages.getString("TemplatePreferencePage.preview")); //$NON-NLS-1$ - GridData data= new GridData(); - data.horizontalSpan= 2; - label.setLayoutData(data); - - SourceViewer viewer= createViewer(parent); - viewer.setEditable(false); - - Control control= viewer.getControl(); - data= new GridData(GridData.FILL_BOTH); - data.horizontalSpan= 2; - data.heightHint= convertHeightInCharsToPixels(5); - control.setLayoutData(data); - - return viewer; - } - - /** - * Creates, configures and returns a source viewer to present the template - * pattern on the preference page. Clients may override to provide a custom - * source viewer featuring e.g. syntax coloring. - * - * @param parent the parent control - * @return a configured source viewer - */ - protected SourceViewer createViewer(Composite parent) { - SourceViewer viewer= new SourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); - SourceViewerConfiguration configuration= new SourceViewerConfiguration(); - viewer.configure(configuration); - IDocument document= new Document(); - viewer.setDocument(document); - return viewer; - } - - private static GridData getButtonGridData(Button button) { - GridData data= new GridData(GridData.FILL_HORIZONTAL); - // TODO replace SWTUtil -// data.widthHint= SWTUtil.getButtonWidthHint(button); -// data.heightHint= SWTUtil.getButtonHeightHint(button); - - return data; - } - - private void selectionChanged1() { - updateViewerInput(); - - updateButtons(); - } - - /** - * Updates the pattern viewer. - */ - protected void updateViewerInput() { - IStructuredSelection selection= (IStructuredSelection) fTableViewer.getSelection(); - - if (selection.size() == 1) { - TemplatePersistenceData data= (TemplatePersistenceData) selection.getFirstElement(); - Template template= data.getTemplate(); - fPatternViewer.getDocument().set(template.getPattern()); - } else { - fPatternViewer.getDocument().set(""); //$NON-NLS-1$ - } - } - - /** - * Updates the buttons. - */ - protected void updateButtons() { - IStructuredSelection selection= (IStructuredSelection) fTableViewer.getSelection(); - int selectionCount= selection.size(); - int itemCount= fTableViewer.getTable().getItemCount(); - boolean canRestore= fTemplateStore.getTemplateData(true).length != fTemplateStore.getTemplateData(false).length; - boolean canRevert= false; - for (Iterator it= selection.iterator(); it.hasNext();) { - TemplatePersistenceData data= (TemplatePersistenceData) it.next(); - if (data.isModified()) { - canRevert= true; - break; - } - } - - fEditButton.setEnabled(selectionCount == 1); - fExportButton.setEnabled(selectionCount > 0); - fRemoveButton.setEnabled(selectionCount > 0 && selectionCount <= itemCount); - fRestoreButton.setEnabled(canRestore); - fRevertButton.setEnabled(canRevert); - } - - private void add() { - - Template template= new Template(); - Iterator it= fContextTypeRegistry.contextTypes(); - if (it.hasNext()) { - template.setContextTypeId(((TemplateContextType) it.next()).getId()); - - Dialog dialog= createTemplateEditDialog(template, false, true); - if (dialog.open() == Window.OK) { - TemplatePersistenceData data= new TemplatePersistenceData(template, true); - fTemplateStore.add(data); - fTableViewer.refresh(); - fTableViewer.setChecked(data, true); - fTableViewer.setSelection(new StructuredSelection(data)); - } - } - } - - /** - * Creates the edit dialog. Subclasses may override this method to provide a - * custom dialog. - * - * @param template the template being edited - * @param edit whether the dialog should be editable - * @param isNameModifiable whether the template name may be modified - * @return an <code>EditTemplateDialog</code> which will be opened. - */ - protected Dialog createTemplateEditDialog(Template template, boolean edit, boolean isNameModifiable) { - return new EditTemplateDialog(getShell(), template, edit, isNameModifiable, fContextTypeRegistry); - } - - private void edit() { - IStructuredSelection selection= (IStructuredSelection) fTableViewer.getSelection(); - - Object[] objects= selection.toArray(); - if ((objects == null) || (objects.length != 1)) - return; - - TemplatePersistenceData data= (TemplatePersistenceData) selection.getFirstElement(); - edit(data); - } - - private void edit(TemplatePersistenceData data) { - Template oldTemplate= data.getTemplate(); - Template newTemplate= new Template(oldTemplate); - Dialog dialog= createTemplateEditDialog(newTemplate, true, true); - if (dialog.open() == Window.OK) { - - if (!newTemplate.getName().equals(oldTemplate.getName()) && - MessageDialog.openQuestion(getShell(), - TextEditorTemplateMessages.getString("TemplatePreferencePage.question.create.new.title"), //$NON-NLS-1$ - TextEditorTemplateMessages.getString("TemplatePreferencePage.question.create.new.message"))) //$NON-NLS-1$ - { - data= new TemplatePersistenceData(newTemplate, true); - fTemplateStore.add(data); - fTableViewer.refresh(); - } else { - data.setTemplate(newTemplate); - fTableViewer.refresh(data); - } - selectionChanged1(); - fTableViewer.setChecked(data, data.isEnabled()); - fTableViewer.setSelection(new StructuredSelection(data)); - } - } - - private void import_() { - FileDialog dialog= new FileDialog(getShell()); - dialog.setText(TextEditorTemplateMessages.getString("TemplatePreferencePage.import.title")); //$NON-NLS-1$ - dialog.setFilterExtensions(new String[] {TextEditorTemplateMessages.getString("TemplatePreferencePage.import.extension")}); //$NON-NLS-1$ - String path= dialog.open(); - - if (path == null) - return; - - try { - TemplateReaderWriter reader= new TemplateReaderWriter(); - File file= new File(path); - if (file.exists()) { - InputStream input= new BufferedInputStream(new FileInputStream(file)); - TemplatePersistenceData[] datas= reader.read(input, null); - for (int i= 0; i < datas.length; i++) { - TemplatePersistenceData data= datas[i]; - fTemplateStore.add(data); - } - } - - fTableViewer.refresh(); - fTableViewer.setAllChecked(false); - fTableViewer.setCheckedElements(getEnabledTemplates()); - - } catch (FileNotFoundException e) { - openReadErrorDialog(e); - } catch (IOException e) { - openReadErrorDialog(e); - } - } - - private void export() { - IStructuredSelection selection= (IStructuredSelection) fTableViewer.getSelection(); - Object[] templates= selection.toArray(); - - TemplatePersistenceData[] datas= new TemplatePersistenceData[templates.length]; - for (int i= 0; i != templates.length; i++) - datas[i]= (TemplatePersistenceData) templates[i]; - - export(datas); - } - - private void export(TemplatePersistenceData[] templates) { - FileDialog dialog= new FileDialog(getShell(), SWT.SAVE); - dialog.setText(TextEditorTemplateMessages.getFormattedString("TemplatePreferencePage.export.title", new Integer(templates.length))); //$NON-NLS-1$ - dialog.setFilterExtensions(new String[] {TextEditorTemplateMessages.getString("TemplatePreferencePage.export.extension")}); //$NON-NLS-1$ - dialog.setFileName(TextEditorTemplateMessages.getString("TemplatePreferencePage.export.filename")); //$NON-NLS-1$ - String path= dialog.open(); - - if (path == null) - return; - - File file= new File(path); - - if (file.isHidden()) { - String title= TextEditorTemplateMessages.getString("TemplatePreferencePage.export.error.title"); //$NON-NLS-1$ - String message= TextEditorTemplateMessages.getFormattedString("TemplatePreferencePage.export.error.hidden", file.getAbsolutePath()); //$NON-NLS-1$ - MessageDialog.openError(getShell(), title, message); - return; - } - - if (file.exists() && !file.canWrite()) { - String title= TextEditorTemplateMessages.getString("TemplatePreferencePage.export.error.title"); //$NON-NLS-1$ - String message= TextEditorTemplateMessages.getFormattedString("TemplatePreferencePage.export.error.canNotWrite", file.getAbsolutePath()); //$NON-NLS-1$ - MessageDialog.openError(getShell(), title, message); - return; - } - - if (!file.exists() || confirmOverwrite(file)) { - try { - OutputStream output= new BufferedOutputStream(new FileOutputStream(file)); - TemplateReaderWriter writer= new TemplateReaderWriter(); - writer.save(templates, output); - } catch (Exception e) { - openWriteErrorDialog(e); - } - } - } - - private boolean confirmOverwrite(File file) { - return MessageDialog.openQuestion(getShell(), - TextEditorTemplateMessages.getString("TemplatePreferencePage.export.exists.title"), //$NON-NLS-1$ - TextEditorTemplateMessages.getFormattedString("TemplatePreferencePage.export.exists.message", file.getAbsolutePath())); //$NON-NLS-1$ - } - - private void remove() { - IStructuredSelection selection= (IStructuredSelection) fTableViewer.getSelection(); - - Iterator elements= selection.iterator(); - while (elements.hasNext()) { - TemplatePersistenceData data= (TemplatePersistenceData) elements.next(); - fTemplateStore.delete(data); - } - - fTableViewer.refresh(); - } - - private void restoreDeleted() { - fTemplateStore.restoreDeleted(); - fTableViewer.refresh(); - fTableViewer.setCheckedElements(getEnabledTemplates()); - updateButtons(); - } - - private void revert() { - IStructuredSelection selection= (IStructuredSelection) fTableViewer.getSelection(); - - Iterator elements= selection.iterator(); - while (elements.hasNext()) { - TemplatePersistenceData data= (TemplatePersistenceData) elements.next(); - data.revert(); - } - - fTableViewer.refresh(); - selectionChanged1(); - fTableViewer.setChecked(getEnabledTemplates(), true); - } - - /* - * @see Control#setVisible(boolean) - */ - public void setVisible(boolean visible) { - super.setVisible(visible); - if (visible) - setTitle(TextEditorTemplateMessages.getString("TemplatePreferencePage.title")); //$NON-NLS-1$ - } - - /* - * @see PreferencePage#performDefaults() - */ - protected void performDefaults() { - if (isShowFormatterSetting()) { - IPreferenceStore prefs= getPreferenceStore(); - fFormatButton.setSelection(prefs.getDefaultBoolean(getFormatterPreferenceKey())); - } - - fTemplateStore.restoreDefaults(); - - // refresh - fTableViewer.refresh(); - fTableViewer.setAllChecked(false); - fTableViewer.setCheckedElements(getEnabledTemplates()); - } - - /* - * @see PreferencePage#performOk() - */ - public boolean performOk() { - if (isShowFormatterSetting()) { - IPreferenceStore prefs= getPreferenceStore(); - prefs.setValue(getFormatterPreferenceKey(), fFormatButton.getSelection()); - } - - try { - fTemplateStore.save(); - } catch (IOException e) { - openWriteErrorDialog(e); - } - - return super.performOk(); - } - - /** - * Returns the key to use for the formatter preference. - * @return - */ - protected String getFormatterPreferenceKey() { - return DEFAULT_FORMATTER_PREFERENCE_KEY; - } - - /* - * @see PreferencePage#performCancel() - */ - public boolean performCancel() { - try { - fTemplateStore.load(); - } catch (IOException e) { - openReadErrorDialog(e); - return false; - } - return super.performCancel(); - } - - private void openReadErrorDialog(Exception e) { - String title= TextEditorTemplateMessages.getString("TemplatePreferencePage.error.read.title"); //$NON-NLS-1$ - String message= TextEditorTemplateMessages.getString("TemplatePreferencePage.error.read.message"); //$NON-NLS-1$ - MessageDialog.openError(getShell(), title, message); - } - - private void openWriteErrorDialog(Exception e) { - String title= TextEditorTemplateMessages.getString("TemplatePreferencePage.error.write.title"); //$NON-NLS-1$ - String message= TextEditorTemplateMessages.getString("TemplatePreferencePage.error.write.message"); //$NON-NLS-1$ - MessageDialog.openError(getShell(), title, message); - } - - protected SourceViewer getViewer() { - return fPatternViewer; - } - - protected TableViewer getTableViewer() { - return fTableViewer; - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplateVariableProcessor.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplateVariableProcessor.java deleted file mode 100644 index d6b3e8ae2fc..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplateVariableProcessor.java +++ /dev/null @@ -1,160 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.texteditor.templates; - -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.ITextViewer; -import org.eclipse.jface.text.contentassist.ICompletionProposal; -import org.eclipse.jface.text.contentassist.IContentAssistProcessor; -import org.eclipse.jface.text.contentassist.IContextInformation; -import org.eclipse.jface.text.contentassist.IContextInformationValidator; -import org.eclipse.jface.text.templates.TemplateContextType; -import org.eclipse.jface.text.templates.TemplateVariableResolver; - - - -/** - * A content assist processor for template variables. - * <p> - * This class should not be used by clients and may become package visible in - * the future. - * </p> - * - * @since 3.0 - */ -public class TemplateVariableProcessor implements IContentAssistProcessor { - - private static Comparator fgTemplateVariableProposalComparator= new Comparator() { - public int compare(Object arg0, Object arg1) { - TemplateVariableProposal proposal0= (TemplateVariableProposal) arg0; - TemplateVariableProposal proposal1= (TemplateVariableProposal) arg1; - - return proposal0.getDisplayString().compareTo(proposal1.getDisplayString()); - } - - public boolean equals(Object arg0) { - return false; - } - }; - - - /** the context type */ - private TemplateContextType fContextType; - - /** - * Sets the context type. - * - * @param contextType the context type for this processor - */ - public void setContextType(TemplateContextType contextType) { - fContextType= contextType; - } - - /** - * Returns the context type. - * - * @return the context type - */ - public TemplateContextType getContextType() { - return fContextType; - } - - /* - * @see IContentAssistProcessor#computeCompletionProposals(ITextViewer, int) - */ - public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) { - - if (fContextType == null) - return null; - - List proposals= new ArrayList(); - - String text= viewer.getDocument().get(); - int start= getStart(text, documentOffset); - int end= documentOffset; - - String string= text.substring(start, end); - String prefix= (string.length() >= 2) - ? string.substring(2) - : null; - - int offset= start; - int length= end - start; - - for (Iterator iterator= fContextType.resolvers(); iterator.hasNext(); ) { - TemplateVariableResolver variable= (TemplateVariableResolver) iterator.next(); - - if (prefix == null || variable.getType().startsWith(prefix)) - proposals.add(new TemplateVariableProposal(variable, offset, length, viewer)); - } - - Collections.sort(proposals, fgTemplateVariableProposalComparator); - return (ICompletionProposal[]) proposals.toArray(new ICompletionProposal[proposals.size()]); - } - - /* Guesses the start position of the completion */ - private int getStart(String string, int end) { - int start= end; - - if (start >= 1 && string.charAt(start - 1) == '$') - return start - 1; - - while ((start != 0) && Character.isUnicodeIdentifierPart(string.charAt(start - 1))) - start--; - - if (start >= 2 && string.charAt(start - 1) == '{' && string.charAt(start - 2) == '$') - return start - 2; - - return end; - } - - /* - * @see IContentAssistProcessor#computeContextInformation(ITextViewer, int) - */ - public IContextInformation[] computeContextInformation(ITextViewer viewer, int documentOffset) { - return null; - } - - /* - * @see IContentAssistProcessor#getCompletionProposalAutoActivationCharacters() - */ - public char[] getCompletionProposalAutoActivationCharacters() { - return new char[] {'$'}; - } - - /* - * @see IContentAssistProcessor#getContextInformationAutoActivationCharacters() - */ - public char[] getContextInformationAutoActivationCharacters() { - return null; - } - - /* - * @see IContentAssistProcessor#getErrorMessage() - */ - public String getErrorMessage() { - return null; - } - - /* - * @see IContentAssistProcessor#getContextInformationValidator() - */ - public IContextInformationValidator getContextInformationValidator() { - return null; - } - -} - diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplateVariableProposal.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplateVariableProposal.java deleted file mode 100644 index d5b2cc31c24..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplateVariableProposal.java +++ /dev/null @@ -1,109 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.texteditor.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.BadLocationException; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.ITextViewer; -import org.eclipse.jface.text.contentassist.ICompletionProposal; -import org.eclipse.jface.text.contentassist.IContextInformation; -import org.eclipse.jface.text.templates.TemplateVariableResolver; - -/** - * A proposal for insertion of template variables. - * <p> - * This class should not be used by clients and may become package visible in - * the future. - * </p> - * - * @since 3.0 - */ -public class TemplateVariableProposal implements ICompletionProposal { - - private TemplateVariableResolver fVariable; - private int fOffset; - private int fLength; - private ITextViewer fViewer; - - private Point fSelection; - - /** - * Creates a template variable proposal. - * - * @param variable the template variable - * @param offset the offset to replace - * @param length the length to replace - * @param viewer the viewer - */ - public TemplateVariableProposal(TemplateVariableResolver variable, int offset, int length, ITextViewer viewer) { - fVariable= variable; - fOffset= offset; - fLength= length; - fViewer= viewer; - } - - /* - * @see ICompletionProposal#apply(IDocument) - */ - public void apply(IDocument document) { - - try { - String variable= fVariable.getType().equals("dollar") ? "$$" : "${" + fVariable.getType() + '}'; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - document.replace(fOffset, fLength, variable); - fSelection= new Point(fOffset + variable.length(), 0); - - } catch (BadLocationException e) { - Shell shell= fViewer.getTextWidget().getShell(); - MessageDialog.openError(shell, TextEditorTemplateMessages.getString("TemplateVariableProposal.error.title"), e.getMessage()); //$NON-NLS-1$ - } - } - - /* - * @see ICompletionProposal#getSelection(IDocument) - */ - public Point getSelection(IDocument document) { - return fSelection; - } - - /* - * @see ICompletionProposal#getAdditionalProposalInfo() - */ - public String getAdditionalProposalInfo() { - return null; - } - - /* - * @see ICompletionProposal#getDisplayString() - */ - public String getDisplayString() { - return fVariable.getType() + " - " + fVariable.getDescription(); //$NON-NLS-1$ - } - - /* - * @see ICompletionProposal#getImage() - */ - public Image getImage() { - return null; - } - - /* - * @see ICompletionProposal#getContextInformation() - */ - public IContextInformation getContextInformation() { - return null; - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TextEditorTemplateMessages.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TextEditorTemplateMessages.java deleted file mode 100644 index b204fc36a71..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TextEditorTemplateMessages.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.texteditor.templates; - -import java.text.MessageFormat; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -/** - * @since 3.0 - */ -class TextEditorTemplateMessages { - - private static final String RESOURCE_BUNDLE= TextEditorTemplateMessages.class.getName(); - private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE); - - private TextEditorTemplateMessages() { - } - - /** - * @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.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TextEditorTemplateMessages.properties b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TextEditorTemplateMessages.properties deleted file mode 100644 index 88a662dfb69..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TextEditorTemplateMessages.properties +++ /dev/null @@ -1,88 +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 -############################################################################### - -# 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.remove=&Remove -TemplatePreferencePage.editor=Template -TemplatePreferencePage.revert=Re&vert to Default -TemplatePreferencePage.restore=Restore Re&moved - -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} cannot 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: - -# 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... - -TemplateVariableProposal.error.title=Error applying template variable proposal -TemplateVariableProcessor.error.title=Error creating template variable proposals - -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 - diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/package.html b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/package.html deleted file mode 100644 index e70145a0f58..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/package.html +++ /dev/null @@ -1,113 +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>Templates</title> - <meta content="Template Infrastructure package description" - name="description"> -</head> -<body> -Application programming interfaces for interaction -with the Eclipse Java User Interface text support. -<h2>Templates<br> -</h2> -<h3>packages</h3> -<ul> - <li style="font-weight: bold;"><big><span - style="font-family: monospace;">org.eclipse.jface.text.templates</span></big></li> - <li style="font-weight: bold;"><big><span - style="font-family: monospace;">org.eclipse.ui.workbench.texteditor.templates</span><br> - <span style="font-family: monospace;"></span></big></li> - <li><big><span style="font-family: monospace; font-weight: bold;">org.eclipse.ui.editors.templates</span></big><br> - <span style="font-family: monospace;"></span></li> -</ul> -<h3><code></code></h3> -Templates are shortcuts for frequently used fragments of text such as -code patterns or complex text entities. They may contain variables -which are only resolved at the time when the template is inserted -within a context. Together with linked mode, inserting a template can -create a on-the-fly edit mask within a text viewer.<br> -<br> -Templates are specified as text, variables are defined using the <span - style="font-family: monospace;">${variable}</span> notation known from -Ant, for example. The following snippet shows an example template for -an instance check in Java:<br> -<pre>if (${name} instanceof ${type}) {<br> ${type} ${new_name} = (${type})${name};<br> ${cursor}<br>}<br></pre> -In this template, the variables (<span style="font-family: monospace;">name, -type, ...</span><span style="font-family: sans-serif;">) are resolved -when inserted into java source and changing one variable instance will -also change the other. When leaving linked mode, the caret is placed at -the </span><span style="font-family: monospace;">cursor</span><span - style="font-family: sans-serif;"> variable.<br> -<br> -Template functionality can be added to a custom text editor by offering -</span><span style="font-family: monospace;">TemplateProposal</span><span - style="font-family: sans-serif;">s as content assist choices, which is -simplified by using a </span><span style="font-family: sans-serif;"><span - style="font-family: sans-serif;">subclass of </span></span><span - style="font-family: monospace;">TemplateCompletionProcessor</span><span - style="font-family: sans-serif;">. User template management can be -offered by including a </span><span style="font-family: monospace;">TemplatePreferencePage</span><span - style="font-family: sans-serif;"> which uses a </span><span - style="font-family: monospace;">TemplateStore</span><span - style="font-family: sans-serif;"> and <span - style="font-family: monospace;">ContextTypeRegistry</span> as the -underlying model to store templates. The <span - style="font-family: monospace;">org.eclipse.ui.editors.templates</span> -extension point can be used to allow other plug-ins to contribute -templates to an editor. This is accomplished by using the <span - style="font-family: monospace;">ContributionTemplateStore</span> and <span - style="font-family: monospace;">ContributionContextTypeRegistry</span> -subclasses of the above types.<br> -<br> -Template variables are resolved by a <span - style="font-family: monospace;">TemplateVariableResolver.</span> <span - style="font-family: monospace;">GlobalTemplateVariables</span> offers -some default variables such as date, user, and selection, but advanced -features such as resolving to language constructs can be performed in -subclasses.<br> -</span> -<h4>Classes</h4> -<ul> - <li><span style="font-family: monospace;">Template</span><span - style="font-family: sans-serif;"> a template consists of name, context -type identifier, and a pattern.</span></li> - <li><span style="font-family: sans-serif;"><span - style="font-family: monospace;">TemplateTranslator</span> and <span - style="font-family: monospace;">TemplateBuffer</span> are used to -parse the template grammar and don't need to be used usually.</span></li> - <li><span style="font-family: sans-serif;">A <span - style="font-family: monospace;">TemplateProposal </span>can be -offered in content assist, possibly created by a subclass of <span - style="font-family: monospace;">TemplateCompletionProcessor.</span></span></li> - <li><span style="font-family: sans-serif;"><span - style="font-family: monospace;">TemplateStore</span> and <span - style="font-family: monospace;">ContextTypeRegistry</span> manage a -set of templates within a plug-in and offer ways to store them in the -preferences or externally in XML streams via a <span - style="font-family: monospace;">TemplateReaderWriter</span>.<br> - </span></li> - <li><span style="font-family: sans-serif;"><span - style="font-family: monospace;">ContributionTemplateStore</span> and <span - style="font-family: monospace;">ContributionContextTypeRegistry</span> -add awareness for the </span><span style="font-family: sans-serif;"><span - style="font-family: sans-serif;"> <span - style="font-family: monospace;">org.eclipse.ui.editors.templates</span> -extension point.</span></span></li> - <li style="font-family: monospace;"><span - style="font-family: sans-serif;"><span style="font-family: sans-serif;"><span - style="font-family: monospace;">TemplatePreferencePage</span> allows -the user to access the templates within a <span - style="font-family: monospace;">TemplateStore</span>.</span></span></li> -</ul> -<ul> -</ul> -<h4>Example</h4> -<pre><span style="font-family: sans-serif;">See the Template Editor Example in the <span - style="font-weight: bold;">org.eclipse.ui.examples.javaeditor</span> project.<br></span></pre> -</body> -</html> |